You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by gd...@jslss.com on 2009/06/25 22:56:20 UTC

Dynamic value supplied s:text name in struts 2

With Struts1 the following would work:

JSP:
<%
String productType = [get the productType from the form]
String productTypeI18nKey = "product.type.list." + productType;
%>
<html:text property="<%=productTypeI18nKey%>"/>

With the Struts2, how would I do the same.  I've tried:

JSP:
<%
String productTypeI18nKey = "product.type.list." + productType;
%>
<s:text name="<%=productTypeI18nKey%>"/>

When I execute the above JSP, I get the following error
"According to TLD or attribute directive in tag file, attribute name does
not accept any expressions"

How do I supply a dynamic value as a key for the s:text tag?

Thanks in advance,
Graham




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Dynamic value supplied s:text name in struts 2

Posted by Graham Down <gd...@jslss.com>.
Well I got it resolved.  The <rtexprvalue> was set to false in the TLD file. 
Once set to true the following worked:

JSP:
<%
String productTypeI18nKey = "product.type.list." + productType;
%>
<s:text name="<%=productTypeI18nKey%>"/>

Graham
----- Original Message ----- 
From: <gd...@jslss.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, June 25, 2009 6:02 PM
Subject: Re: Dynamic value supplied s:text name in struts 2


> Correction on this question.
>
> With Struts1 the following would work:
>
>
> JSP:
> <%
> String productType = [get the productType from the form]
> String productTypeI18nKey = "product.type.list." + productType;
> %>
> <bean:message key="<%=productTypeI18nKey%>"/>
>
>
> With the Struts2, how would I do the same.  I've tried:
>
>
> JSP:
> <%
> String productTypeI18nKey = "product.type.list." + productType;
> %>
> <s:text name="<%=productTypeI18nKey%>"/>
>
>
> When I execute the above JSP, I get the following error
> "According to TLD or attribute directive in tag file, attribute name does
> not accept any expressions"
>
> How do I supply a dynamic value as a key for the s:text tag?
>
>
> Thanks in advance,
> Graham
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Dynamic value supplied s:text name in struts 2

Posted by gd...@jslss.com.
Correction on this question.

With Struts1 the following would work:


JSP:
<%
String productType = [get the productType from the form]
String productTypeI18nKey = "product.type.list." + productType;
%>
<bean:message key="<%=productTypeI18nKey%>"/>


With the Struts2, how would I do the same.  I've tried:


JSP:
<%
String productTypeI18nKey = "product.type.list." + productType;
%>
<s:text name="<%=productTypeI18nKey%>"/>


When I execute the above JSP, I get the following error
"According to TLD or attribute directive in tag file, attribute name does
not accept any expressions"

How do I supply a dynamic value as a key for the s:text tag?


Thanks in advance,
Graham





 ---------------------------------------------------------------------
 To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
 For additional commands, e-mail: user-help@struts.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org