You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (JIRA)" <ji...@apache.org> on 2012/05/29 14:43:23 UTC

[jira] [Created] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Lukasz Lenart created WW-3828:
---------------------------------

             Summary: FreeMarker dynamic attributes cannot be boolean
                 Key: WW-3828
                 URL: https://issues.apache.org/jira/browse/WW-3828
             Project: Struts 2
          Issue Type: Improvement
          Components: Core Actions
    Affects Versions: 2.3.4
            Reporter: Lukasz Lenart
            Assignee: Lukasz Lenart
            Priority: Trivial
             Fix For: 2.3.5


The code below will produce an exception

{code:html}
<@s.text type="email" key="user.email" required=true autofocus=true />
{code}

{code}
Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
The problematic instruction:
----------
==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
 in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
 in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
----------
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart resolved WW-3828.
-------------------------------

    Resolution: Not A Problem

In my opinion there is no problem with that. Please re-open if you disagree.
                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "zhouyanming (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13285489#comment-13285489 ] 

zhouyanming commented on WW-3828:
---------------------------------

it works in my test if I add code text.ftl
<#if parameters.autofocus?default(false)>
autofocus="autofocus"<#rt/>
</#if>

<@s.textfield theme="simple" name="username" autofocus=true/>
will render
<input type="text" name="username" value=""autofocus="autofocus" id="username" autofocus="true"/>

the side effects is there is a needless autofocus="true" generated by dynamicAttributes 
if you want fixed this problem,you should make autofocus as stardard attribute of org.apache.struts2.components.UIBean,like required.
                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Roland McIntosh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13284854#comment-13284854 ] 

Roland McIntosh commented on WW-3828:
-------------------------------------

Build #481 does NOT fix this issue as I'm experiencing it, but it DOES allow booleans in dynamic attributes when used as a "pass-through" attribute (sorry for my inexact terminology).  However, the type of the dynamic attribute still appears to be string in the tag's parameters map (whereas in 2.3.1.2 it was not).

For posterity, in the above example, the tag should have read:
<@s.textfield type="email" key="user.email" autofocus=true required=true />

(note @s.textfiled instead of @s.text)

The reasoning for supporting dynamic attributes of type boolean or Integer is so that custom themes (like an "html5" theme) can better match the existing API for the "textfield" tag.  A theme developer might expect to be able to provide a dynamic attribute "autofocus" boolean to match the existing "required" attribute boolean.  This allows themes that rely on dynamic attributes to be "first-class" citizens in the API, and not to be restricted to Strings.  Furthermore, allowing booleans (and Integers) in dynamic attributes matches Struts 2.3.1.2 behavior.

I have a theme "mytheme" with the following "text.ftl" contents:
<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
<#include "/${parameters.templateDir}/html5/text.ftl" />
<#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

Note that it includes "html5/text.ftl".    This file contains (partially):

<#if parameters.autofocus?default(false)>
 autofocus="autofocus"<#rt/>
</#if>

I copy/pasted the existing implementation of the (documented, supported) "required" attribute.  The intention is that if a boolean parameter named "autofocus" exists and has value true, that an attribute/value 'autofocus="autofocus"' will be added to inputs.  The actual value of the attribute doesn't matter so much, but is set as "autofocus" for backwards compatibility and conformance to older HTML specifications.

Because my "html5/text.ftl" file checks the parameters map for a boolean "autofocus" attribute, I get the following exception with Build #481 / Struts 2.3.5 SNAPSHOT (same as with 2.3.4):

2012-05-29 09:19:11,568 ERROR [freemarker.runtime] (http-0.0.0.0-8443-6) Template processing error: "Error on line 49, column 6 in themes/html5/text.ftl
Expecting a boolean (true/false) expression here
Expression parameters.autofocus?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel"
Error on line 49, column 6 in themes/html5/text.ftl
Expecting a boolean (true/false) expression here
Expression parameters.autofocus?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel
The problematic instruction:
----------
==> if parameters.autofocus?default(false) [on line 49, column 1 in themes/html5/text.ftl]
 in include "/${parameters.templateDir}/html5/text.ftl" [on line 25, column 1 in themes/mytheme/text.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.NonBooleanException: Error on line 49, column 6 in themes/html5/text.ftl
Expecting a boolean (true/false) expression here
Expression parameters.autofocus?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel
	at freemarker.core.Expression.isTrue(Expression.java:150)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77)
	at freemarker.core.Environment.visit(Environment.java:221)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)


If I remove my check for the "autofocus" parameter from text.ftl, then the value is passed through as a dynamic attribute autofocus="true".  This actually works, but isn't what I intended originally when creating my "html5/text.ftl" template, since I had hoped to query the parameters map directly.
                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13419827#comment-13419827 ] 

Lukasz Lenart commented on WW-3828:
-----------------------------------

I've added additional test case and autofocus=true works in custom theme and I don't see the side effect as autofocus="true" in the result.
                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13285457#comment-13285457 ] 

Lukasz Lenart commented on WW-3828:
-----------------------------------

But he wants to use the with a custom theme where you can define autofocus=true which will be translated to html as autofocus="autofocus". The problem is, that the current support for dynamic attributes wasn't designed in that way (and at least 2.3.3 broke that ;-) )
                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Comment Edited] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13285457#comment-13285457 ] 

Lukasz Lenart edited comment on WW-3828 at 5/30/12 7:21 AM:
------------------------------------------------------------

But he wants to use them with a custom theme where you can define autofocus=true which will be translated to html as autofocus="autofocus". The problem is, that the current support for dynamic attributes wasn't designed in that way (and at least 2.3.3 broke that ;-) )
                
      was (Author: lukaszlenart):
    But he wants to use the with a custom theme where you can define autofocus=true which will be translated to html as autofocus="autofocus". The problem is, that the current support for dynamic attributes wasn't designed in that way (and at least 2.3.3 broke that ;-) )
                  
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Comment Edited] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Roland McIntosh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13284854#comment-13284854 ] 

Roland McIntosh edited comment on WW-3828 at 5/29/12 2:48 PM:
--------------------------------------------------------------

Build #481 does NOT fix this issue as I'm experiencing it, but it DOES allow booleans in dynamic attributes when used as a "pass-through" attribute (sorry for my inexact terminology).  However, the type of the dynamic attribute still appears to be string in the tag's parameters map (whereas in 2.3.1.2 it was not).

For posterity, in the above example, the tag should have read:
{code}
<@s.textfield type="email" key="user.email" autofocus=true required=true />
{code}
(note @s.textfiled instead of @s.text)

The reasoning for supporting dynamic attributes of type boolean or Integer is so that custom themes (like an "html5" theme) can better match the existing API for the "textfield" tag.  A theme developer might expect to be able to provide a dynamic attribute "autofocus" boolean to match the existing "required" attribute boolean.  This allows themes that rely on dynamic attributes to be "first-class" citizens in the API, and not to be restricted to Strings.  Furthermore, allowing booleans (and Integers) in dynamic attributes matches Struts 2.3.1.2 behavior.

I have a theme "mytheme" with the following "text.ftl" contents:
{code:title=mytheme/text.ftl}
<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
<#include "/${parameters.templateDir}/html5/text.ftl" />
<#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />
{code}
Note that it includes "html5/text.ftl".    This file contains (partially):

<#if parameters.autofocus?default(false)>
 autofocus="autofocus"<#rt/>
</#if>

I copy/pasted the existing implementation of the (documented, supported) "required" attribute.  The intention is that if a boolean parameter named "autofocus" exists and has value true, that an attribute/value 'autofocus="autofocus"' will be added to inputs.  The actual value of the attribute doesn't matter so much, but is set as "autofocus" for backwards compatibility and conformance to older HTML specifications.

Because my "html5/text.ftl" file checks the parameters map for a boolean "autofocus" attribute, I get the following exception with Build #481 / Struts 2.3.5 SNAPSHOT (same as with 2.3.4):
{noformat}
2012-05-29 09:19:11,568 ERROR [freemarker.runtime] (http-0.0.0.0-8443-6) Template processing error: "Error on line 49, column 6 in themes/html5/text.ftl
Expecting a boolean (true/false) expression here
Expression parameters.autofocus?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel"
Error on line 49, column 6 in themes/html5/text.ftl
Expecting a boolean (true/false) expression here
Expression parameters.autofocus?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel
The problematic instruction:
----------
==> if parameters.autofocus?default(false) [on line 49, column 1 in themes/html5/text.ftl]
 in include "/${parameters.templateDir}/html5/text.ftl" [on line 25, column 1 in themes/mytheme/text.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.NonBooleanException: Error on line 49, column 6 in themes/html5/text.ftl
Expecting a boolean (true/false) expression here
Expression parameters.autofocus?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel
	at freemarker.core.Expression.isTrue(Expression.java:150)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77)
	at freemarker.core.Environment.visit(Environment.java:221)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)
{noformat}

If I remove my check for the "autofocus" parameter from text.ftl, then the value is passed through as a dynamic attribute autofocus="true".  This actually works, but isn't what I intended originally when creating my "html5/text.ftl" template, since I had hoped to query the parameters map directly.
                
      was (Author: rgm):
    Build #481 does NOT fix this issue as I'm experiencing it, but it DOES allow booleans in dynamic attributes when used as a "pass-through" attribute (sorry for my inexact terminology).  However, the type of the dynamic attribute still appears to be string in the tag's parameters map (whereas in 2.3.1.2 it was not).

For posterity, in the above example, the tag should have read:
<@s.textfield type="email" key="user.email" autofocus=true required=true />

(note @s.textfiled instead of @s.text)

The reasoning for supporting dynamic attributes of type boolean or Integer is so that custom themes (like an "html5" theme) can better match the existing API for the "textfield" tag.  A theme developer might expect to be able to provide a dynamic attribute "autofocus" boolean to match the existing "required" attribute boolean.  This allows themes that rely on dynamic attributes to be "first-class" citizens in the API, and not to be restricted to Strings.  Furthermore, allowing booleans (and Integers) in dynamic attributes matches Struts 2.3.1.2 behavior.

I have a theme "mytheme" with the following "text.ftl" contents:
<#include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" />
<#include "/${parameters.templateDir}/html5/text.ftl" />
<#include "/${parameters.templateDir}/css_xhtml/controlfooter.ftl" />

Note that it includes "html5/text.ftl".    This file contains (partially):

<#if parameters.autofocus?default(false)>
 autofocus="autofocus"<#rt/>
</#if>

I copy/pasted the existing implementation of the (documented, supported) "required" attribute.  The intention is that if a boolean parameter named "autofocus" exists and has value true, that an attribute/value 'autofocus="autofocus"' will be added to inputs.  The actual value of the attribute doesn't matter so much, but is set as "autofocus" for backwards compatibility and conformance to older HTML specifications.

Because my "html5/text.ftl" file checks the parameters map for a boolean "autofocus" attribute, I get the following exception with Build #481 / Struts 2.3.5 SNAPSHOT (same as with 2.3.4):

2012-05-29 09:19:11,568 ERROR [freemarker.runtime] (http-0.0.0.0-8443-6) Template processing error: "Error on line 49, column 6 in themes/html5/text.ftl
Expecting a boolean (true/false) expression here
Expression parameters.autofocus?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel"
Error on line 49, column 6 in themes/html5/text.ftl
Expecting a boolean (true/false) expression here
Expression parameters.autofocus?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel
The problematic instruction:
----------
==> if parameters.autofocus?default(false) [on line 49, column 1 in themes/html5/text.ftl]
 in include "/${parameters.templateDir}/html5/text.ftl" [on line 25, column 1 in themes/mytheme/text.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.NonBooleanException: Error on line 49, column 6 in themes/html5/text.ftl
Expecting a boolean (true/false) expression here
Expression parameters.autofocus?default(false) does not evaluate to true/false 
it is an instance of freemarker.ext.beans.StringModel
	at freemarker.core.Expression.isTrue(Expression.java:150)
	at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77)
	at freemarker.core.Environment.visit(Environment.java:221)
	at freemarker.core.MixedContent.accept(MixedContent.java:92)


If I remove my check for the "autofocus" parameter from text.ftl, then the value is passed through as a dynamic attribute autofocus="true".  This actually works, but isn't what I intended originally when creating my "html5/text.ftl" template, since I had hoped to query the parameters map directly.
                  
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "zhouyanming (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13285500#comment-13285500 ] 

zhouyanming commented on WW-3828:
---------------------------------

html5 add a lots of attributes:
hidden autofocus autocomplete placeholder multiple dirName 
control form formAction formEnctype formMethod formNoValidate formTarget labels 
oninput onchange oninvalid
novalidate
draggable dropzone
ondrag ondragstart ondragenter ondragover ondragleave ondragend ondrop 
spellcheck
and so on...

it's not acceptable of adding all those attributes as stardard attributes of UIBean,I submit dynamicAttributes patch in order to embrace html5,autofocus="autofocus" instead of autofocus=true is totally reasonable
                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13284793#comment-13284793 ] 

Hudson commented on WW-3828:
----------------------------

Integrated in Struts2 #481 (See [https://builds.apache.org/job/Struts2/481/])
    WW-3828 adds support for dynamic attributes not only for String literals but for other objects (Revision 1343701)

     Result = SUCCESS
lukaszlenart : 
Files : 
* /struts/struts2/trunk/core/src/main/resources/template/simple/dynamic-attributes.ftl
* /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/dynaAttributes.ftl

                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Reopened] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart reopened WW-3828:
-------------------------------

    
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13419833#comment-13419833 ] 

Hudson commented on WW-3828:
----------------------------

Integrated in Struts2 #502 (See [https://builds.apache.org/job/Struts2/502/])
    WW-3828 adds additional test to check if dynamic attributes work with custom theme (Revision 1364077)

     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/customTextField.ftl
* /struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/freemarker/dynaAttributes.ftl
* /struts/struts2/trunk/core/src/test/resources/struts.xml
* /struts/struts2/trunk/core/src/test/resources/template/test/text.ftl

                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13285419#comment-13285419 ] 

Lukasz Lenart commented on WW-3828:
-----------------------------------

Two things, the change to dynamicAttributes can be related to this WW-3174 and the second, could you contribute your html5 theme to Struts 2?


                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart resolved WW-3828.
-------------------------------

    Resolution: Fixed

Please test the latest snapshot
                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (WW-3828) FreeMarker dynamic attributes cannot be boolean

Posted by "zhouyanming (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13285445#comment-13285445 ] 

zhouyanming commented on WW-3828:
---------------------------------

@Roland McIntosh 
dynamicAttributes was designed for html5,you should use autofocus="autofocus" instead of autofocus=true
                
> FreeMarker dynamic attributes cannot be boolean
> -----------------------------------------------
>
>                 Key: WW-3828
>                 URL: https://issues.apache.org/jira/browse/WW-3828
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Actions
>    Affects Versions: 2.3.4
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Trivial
>             Fix For: 2.3.5
>
>
> The code below will produce an exception
> {code:html}
> <@s.text type="email" key="user.email" required=true autofocus=true />
> {code}
> {code}
> Method public java.lang.String org.apache.struts2.util.StrutsUtil.translateVariables(java.lang.String) threw an exception when invoked on org.apache.struts2.util.StrutsUtil@540948a7
> The problematic instruction:
> ----------
> ==> assignment: value=struts.translateVariables(keyValue)!keyValue [on line 27, column 3 in /themes/simple/dynamic-attributes.ftl]
>  in include "/${parameters.templateDir}/simple/dynamic-attributes.ftl" [on line 52, column 1 in /themes/simple/text.ftl]
>  in include "/${parameters.templateDir}/simple/text.ftl" [on line 25, column 1 in /themes/my-custom-theme/text.ftl]
> ----------
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira