Spring Framework
  1. Spring Framework
  2. SPR-5931

Allow non-standard attributes in <form> tags

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0 RC1
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      The dojo framework creates form widgets using a syntax like this

      <select dojoType="dijit.form.FilteringSelect"
      id="setvaluetest2"
      name="state1"
      autoComplete="false"
      invalidMessage="Invalid state name"
      onChange="dojo.byId('oc1').value=arguments[0]"

      As far as I can tell, it's impossible to do stuff like this with the Spring <form> tags because there is no way to specify non-standard HTML attributes. An approach I've used for my own custom tags is to add a catch-all attribute called "attributes" so the syntax would look something like

      <form:select id="setvaluetest2" attributes='dojoType="dijit.form.FilteringSelect" invalidMessage="Invalid state name" ... etc

        Issue Links

          Activity

          Show
          Matthew Sgarlata added a comment - I just found out JSP 2 allows you to specify dynamic attirbutes in the API. Here is a link explaining this feature. http://books.google.com/books?id=A3FuJXgx0RAC&pg=PA305&lpg=PA305&dq=jsp+tag+file+dynamic-attributes+case&source=bl&ots=hpOTrEz1iF&sig=NePyJCSGH2JtZ01CHKo9vx1wXIM&hl=en&ei=qSJfSpyKFd_ktgfdnqDgAw&sa=X&oi=book_result&ct=result&resnum=1
          Hide
          Tim added a comment -

          Attaching a proposed patch. If someone is inclined to look at this. A few notes on the patch:

          1) Of course, a comitter needs to review and agree on where/how/what the patch implements.

          Summary: It adds a lazily instantiated map to AbstractFormTag as well as default implementation of setDynamicAttribute from the DynamicAttribute interface. It does not declare AbstractFormTag as an implementor of DynamicAttribute (just gives a default impl of the method for convenience.) Next, AbstractHtmlElementTag added call writeDynamicAttributes akin to writeOptionalAttributes. Finally, declare AbstractHtmlInputElementTag to implement DynamicAttributes (marker interface for containers to accept/support DynamicAttributes and the assumption is that this is the base class we want to support dynamic attributes on?)

          2) I'm not familiar with Ivy or the build process. I know maven so... mvn clean compile executes successfully (after a few pom tweaks on my end like changing javax.activation dependency to geronimo-spec version of it etc..Just my preference to get the build running) but...

          3) mvn clean install fails with a couple of test compilation failures unrelated to the patch it seems. Not sure if these are supposed to work or if maven is really used, etc. But without being able to compile the test suite I've tried to emphasize "draft". So hopefully someone finds this a useful start.

          Show
          Tim added a comment - Attaching a proposed patch. If someone is inclined to look at this. A few notes on the patch: 1) Of course, a comitter needs to review and agree on where/how/what the patch implements. Summary: It adds a lazily instantiated map to AbstractFormTag as well as default implementation of setDynamicAttribute from the DynamicAttribute interface. It does not declare AbstractFormTag as an implementor of DynamicAttribute (just gives a default impl of the method for convenience.) Next, AbstractHtmlElementTag added call writeDynamicAttributes akin to writeOptionalAttributes. Finally, declare AbstractHtmlInputElementTag to implement DynamicAttributes (marker interface for containers to accept/support DynamicAttributes and the assumption is that this is the base class we want to support dynamic attributes on?) 2) I'm not familiar with Ivy or the build process. I know maven so... mvn clean compile executes successfully (after a few pom tweaks on my end like changing javax.activation dependency to geronimo-spec version of it etc..Just my preference to get the build running) but... 3) mvn clean install fails with a couple of test compilation failures unrelated to the patch it seems. Not sure if these are supposed to work or if maven is really used, etc. But without being able to compile the test suite I've tried to emphasize "draft". So hopefully someone finds this a useful start.
          Hide
          Keith Donald added a comment -

          Assigned to Jeremy for completion for upcoming 3.0.0.RC1.

          Show
          Keith Donald added a comment - Assigned to Jeremy for completion for upcoming 3.0.0.RC1.
          Hide
          Jeremy Grelle added a comment -

          Taking advantage of the dynamic attributes feature will require upgrading the tag library to JSP 2.0.

          Show
          Jeremy Grelle added a comment - Taking advantage of the dynamic attributes feature will require upgrading the tag library to JSP 2.0.

            People

            • Assignee:
              Jeremy Grelle
              Reporter:
              Matthew Sgarlata
              Last updater:
              Trevor Marshall
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                4 years, 32 weeks, 1 day ago