Tapestry 5
  1. Tapestry 5
  2. TAP5-194

Handler method of Submit component should accept a context


    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.0.15
    • Fix Version/s:
    • Component/s: None
    • Labels:


      The Submit component has two major deficiencies:
      1) You cannot use an image submit ( <input type="image" /> )
      2) You cannot pass any context into the button's "selected" event handler.

      Issue 1 currently requires you to create your own submit button type, though this is simple if you don't mind copy/pasting the current Submit class and changing one line.

      Issue 2 is a much bigger problem. If you have a submit button in a loop and need to know (for example) which item was current in the loop when it was rendered, you have to set "defer" to false, then record the context information in your onSelected handler. You often can't perform a useful action directly in your deferred onSelected handler because you shouldn't change the structure of your bound data in the middle of a form submit, or because you should not perform your action until you're assured the form has validated.
      So, you now have to record the context that you need to perform the action, PLUS the action that needs to be performed, and then perform it all inside of your onSuccess handler! Frankly, this seems so inelegant as to have been an oversight.

      On the Tapestry Wiki, at http://wiki.apache.org/tapestry/Tapestry5SubmitContextComponent there is a basic implementation, though it has several weaknesses:
      1) It was written for 5.0.4 and doesn't compile without changing a few minor things, nor does it support RenderDisabled.
      2) It only supports a single context parameter and it makes no effort to properly encode it when rendered to the client.

      So, based on the concept used on the wiki code (namely, using a <hidden> field to store the context) I made a few small modifications to the Tapestry 5.0.11 Submit.java class that I will attach to this issue.

      I grant ownership of the attached code to the Apache Software Foundation.

      1. SubmitContext.java
        4 kB
        Cherry Development

        Issue Links


          Cherry Development created issue -
          Cherry Development made changes -
          Field Original Value New Value
          Attachment SubmitContext.java [ 12383073 ]
          Howard M. Lewis Ship made changes -
          Project Tapestry [ 10573 ] Tapestry 5 [ 12310833 ]
          Key TAPESTRY-2434 TAP5-194
          Component/s tapestry-core [ 12311285 ]
          Affects Version/s 5.0 [ 12312018 ]
          Howard M. Lewis Ship made changes -
          Affects Version/s 5.0.15 [ 12313429 ]
          Al Wold added a comment -

          If this does get implemented, it would make sense to add the context support to LinkSubmit as well.

          Al Wold added a comment - If this does get implemented, it would make sense to add the context support to LinkSubmit as well.
          Igor Drobiazko made changes -
          Assignee Igor Drobiazko [ igor.drobiazko ]
          Igor Drobiazko made changes -
          Link This issue is cloned as TAP5-523 [ TAP5-523 ]
          Igor Drobiazko made changes -
          Summary Submit Button missing context and image support Handler method of Submit component should accept a context
          Igor Drobiazko made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Fix Version/s [ 12313428 ]
          Resolution Fixed [ 1 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Closed Closed
          264d 16h 57m 1 Igor Drobiazko 18/Feb/09 19:46


            • Assignee:
              Igor Drobiazko
              Cherry Development
            • Votes:
              4 Vote for this issue
              6 Start watching this issue


              • Created: