Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-1372

Provide transparent support for session-scope checkboxes

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • 2.0.0
    • None
    • None

    Description

      HTML checkboxes have a quirk in that if the checkbox is clear (false), browsers are not required to submit the control. If the control is set, the control is submitted as "control_name=control_name", but in the case of a clear checkbox, nothing is expected to be submitted.

      Accordingly, it is impoort to set the property backing the checkbox to false when a form is rendered. If the checkbox submits back clear, it will remain false, if the form submits back, the field can be set to true to reflect the change.

      However, if the form is being held in session scope, prematurely setting the value to false can be dangerous. If the form is never submitted back, the value will remain false. If the form is later committed to persistent store, an inadvertent change in state will occur. This can be a real problem when using POJOs backed by a persistence system like Hibernate.

      One workaround is to create action-properties for session-scope checkboxes and update the POJO in the action.

      Another solution is to use a naming convention in conjection with an interceptor to set missing checkboxes to true.

      For additional background, see http://forums.opensymphony.com/thread.jspa?forumID=1&threadID=23601.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              husted Ted Husted
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: