org.apache.struts2.interceptor.CheckboxInterceptor is in the defaultStack. It checks each form parameter submitted to the action and if it finds one with a prefix of _checkbox it inserts a value for a parameter whose name is derived from the suffix to _checkbox if it does not exist. The default value inserted is false but this can be changed by setting the uncheckedValue parameter on the interceptor.

This means that a checkbox can be accompanied by a hidden input with the same name but a prefix of _checkbox so that if the checkbox is not checked on the form the action will still receive a value rather than the default HTML action of not providing a value for unchecked checkboxes.

Parameters

Error formatting macro: snippet: java.lang.NullPointerException

Extending the Interceptor

Error formatting macro: snippet: java.lang.NullPointerException
  • No labels

3 Comments

  1. Rod

    org.apache.struts2.interceptor.CheckboxInterceptor is in the defaultStack. It checks each form parameter submitted to the action and if it finds one with a prefix of "_checkbox" it inserts a value for a parameter whose name is derived from the suffix to "_checkbox" if it does not exist. The default value inserted is "false" but this can be changed by setting the "uncheckedValue" parameter on the interceptor.

    This means that a checkbox can be accompanied by a hidden input with the same name but a prefix of "_checkbox" so that if the checkbox is not checked on the form the action will still receive a value rather than the default HTML action of not providing a value for unchecked checkboxes.

    1. Rod

      sorry, bad wiki markup, the prefix is actually "_checkbox"

      1. Rod

        and again:

        __checkbox_