Struts 2
  1. Struts 2
  2. WW-3173

list={ 'foo': 'bar' } unusable with struts-tags such as <@s.radio /> on freemarker results.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Not a Problem
    • Affects Version/s: 2.1.8
    • Fix Version/s: 2.3.3
    • Component/s: None
    • Labels:
      None

      Description

      Trying to render something like this:

      <@s.radio name="x" list=

      {'foo': 'bar'}

      />

      results in stringifications of freemarker.ext.beans.HashAdapter instead of the desired keys and values. Support for converting this to something that the radiomap.ftl could handle properly would be great.

      Manual workaround available with hiding the forcibly generated label and appending another manually:

      <style type="text/css"> .brokenMapBehaviourWorkaround label

      { display: none; }

      </style>
      <div class="brokenMapBehaviourWorkaround"><@s.radio name="x" list=['foo'] /> bar</div>

        Activity

        Hide
        Hudson added a comment -

        Integrated in Struts2 #485 (See https://builds.apache.org/job/Struts2/485/)
        WW-3173 adds missing closing tag (Revision 1344620)

        Result = SUCCESS
        lukaszlenart :
        Files :

        • /struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Radio.java
        Show
        Hudson added a comment - Integrated in Struts2 #485 (See https://builds.apache.org/job/Struts2/485/ ) WW-3173 adds missing closing tag (Revision 1344620) Result = SUCCESS lukaszlenart : Files : /struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Radio.java
        Lukasz Lenart committed 1344620 (1 file)
        Hide
        Lukasz Lenart added a comment -

        Maybe

        Show
        Lukasz Lenart added a comment - Maybe
        Hide
        Roland McIntosh added a comment -

        You're right, inline maps work fine in the latest snapshot. I'm not sure what or when this changed, it could simply be because of the Freemarker version bump.

        Show
        Roland McIntosh added a comment - You're right, inline maps work fine in the latest snapshot. I'm not sure what or when this changed, it could simply be because of the Freemarker version bump.
        Hide
        Hudson added a comment -

        Integrated in Struts2 #480 (See https://builds.apache.org/job/Struts2/480/)
        WW-3173 adds additional test case to prove usage of inline map (Revision 1343639)

        Result = SUCCESS
        lukaszlenart :
        Files :

        • /struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Radio.java
        • /struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
        • /struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl
        Show
        Hudson added a comment - Integrated in Struts2 #480 (See https://builds.apache.org/job/Struts2/480/ ) WW-3173 adds additional test case to prove usage of inline map (Revision 1343639) Result = SUCCESS lukaszlenart : Files : /struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Radio.java /struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java /struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl
        Hide
        Lukasz Lenart added a comment -

        or

        <@s.radio name="car" list={"ford": "Ford Motor Co", "toyota": "Toyota"} listKey="key" listValue="value" />
        
        Show
        Lukasz Lenart added a comment - or <@s.radio name= "car" list={ "ford" : "Ford Motor Co" , "toyota" : "Toyota" } listKey= "key" listValue= "value" />
        Hide
        Lukasz Lenart added a comment -

        @Roland are you sure ? I've just tried to use your example but without a variable (as below) and it works.

        <@s.radio name="car" list={"ford": "Ford Motor Co", "toyota": "Toyota"} listKey="key" listValue="%{getText(value)}" />
        
        Show
        Lukasz Lenart added a comment - @Roland are you sure ? I've just tried to use your example but without a variable (as below) and it works. <@s.radio name= "car" list={ "ford" : "Ford Motor Co" , "toyota" : "Toyota" } listKey= "key" listValue= "%{getText(value)}" />
        Hide
        Lukasz Lenart added a comment -

        Or please register a new issue for that.

        Show
        Lukasz Lenart added a comment - Or please register a new issue for that.
        Hide
        Lukasz Lenart added a comment -

        It would be nice if you could fill iCLA and add your two cents to the docs

        Show
        Lukasz Lenart added a comment - It would be nice if you could fill iCLA and add your two cents to the docs
        Hide
        Roland McIntosh added a comment -

        You can do this too:
        <#assign carCompanies =

        { "ford" : "Ford Motor Co", "toyota" : "Toyota", "chevrolet" : "Chevy" }

        />
        <@s.radio name="car" list=carCompanies listKey="key" listValue="%

        { getText( value ) }

        " />

        Note that the map MUST be assigned to a variable – it doesn't work inline with the radio tag. This behavior is frustrating. The following pages could benefit greatly from explanation and documentation of this tag's behavior with respect to list/hash literals:

        http://struts.apache.org/2.3.3/docs/freemarker-tags.html
        http://struts.apache.org/2.3.3/docs/radio.html

        I posted to struts-user on 13 Oct 2011 about this.

        Show
        Roland McIntosh added a comment - You can do this too: <#assign carCompanies = { "ford" : "Ford Motor Co", "toyota" : "Toyota", "chevrolet" : "Chevy" } /> <@s.radio name="car" list=carCompanies listKey="key" listValue="% { getText( value ) } " /> Note that the map MUST be assigned to a variable – it doesn't work inline with the radio tag. This behavior is frustrating. The following pages could benefit greatly from explanation and documentation of this tag's behavior with respect to list/hash literals: http://struts.apache.org/2.3.3/docs/freemarker-tags.html http://struts.apache.org/2.3.3/docs/radio.html I posted to struts-user on 13 Oct 2011 about this.
        Lukasz Lenart made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        Hudson added a comment -

        Integrated in Struts2 #451 (See https://builds.apache.org/job/Struts2/451/)
        WW-3173 adds additional test case to proof that there is no error (Revision 1311902)

        Result = SUCCESS
        lukaszlenart :
        Files :

        • /struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java
        • /struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl
        • /struts/struts2/trunk/core/src/test/resources/struts.xml
        Show
        Hudson added a comment - Integrated in Struts2 #451 (See https://builds.apache.org/job/Struts2/451/ ) WW-3173 adds additional test case to proof that there is no error (Revision 1311902) Result = SUCCESS lukaszlenart : Files : /struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/freemarker/FreeMarkerResultTest.java /struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/manual-list.ftl /struts/struts2/trunk/core/src/test/resources/struts.xml
        Lukasz Lenart made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Not A Problem [ 8 ]
        Hide
        Lukasz Lenart added a comment -

        Please re-open if you have other mind.

        Show
        Lukasz Lenart added a comment - Please re-open if you have other mind.
        Lukasz Lenart made changes -
        Assignee Lukasz Lenart [ lukaszlenart ]
        Hide
        Lukasz Lenart added a comment -

        The above syntax is invalid, it must be:

        <@s.radio name="x" list={'foo', 'bar'} />
        

        to work correctly, so what's the problem ?

        Show
        Lukasz Lenart added a comment - The above syntax is invalid, it must be: <@s.radio name= "x" list={'foo', 'bar'} /> to work correctly, so what's the problem ?
        Lukasz Lenart made changes -
        Fix Version/s 2.3.3 [ 12320642 ]
        Fix Version/s 2.3.x [ 12319176 ]
        Lukasz Lenart made changes -
        Fix Version/s 2.3.x [ 12319176 ]
        Jeff Turner made changes -
        Project Import Mon Feb 01 01:17:42 UTC 2010 [ 1264987062082 ]
        Hide
        Christopher Maloof added a comment -

        This is a significant annoyance with Struts + FreeMarker, and I'd love to see it fixed, especially since the docs at http://struts.apache.org/2.x/docs/freemarker-tags.html#FreeMarkerTags-AttributeTypes are pretty clear that it ought to work.

        Show
        Christopher Maloof added a comment - This is a significant annoyance with Struts + FreeMarker, and I'd love to see it fixed, especially since the docs at http://struts.apache.org/2.x/docs/freemarker-tags.html#FreeMarkerTags-AttributeTypes are pretty clear that it ought to work.
        Wes Wannemacher made changes -
        Field Original Value New Value
        Affects Version/s 2.1.8 [ 21920 ]
        Affects Version/s 2.1.7 [ 21907 ]
        Antti Lankila created issue -

          People

          • Assignee:
            Lukasz Lenart
            Reporter:
            Antti Lankila
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development