You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by RogerV <ro...@googlemail.com> on 2011/02/01 14:03:31 UTC
Struts 2 obtaining a property value with no corresponding getXX()
method
Hi
I'm trying to iterate over a collection of Enums of type Authority using
<s:iterator value="userDTO.authorities" status="authstatus">
<s:property value="name"/>
<s:if test="!#authstatus.last">,</s:if>
</s:iterator>
but I'm not getting any values displayed. Debugging shows that the call
getUserDTO().getAuthorities() is being made on my underlying action and a
correctly populated List<Authority> is being returned.
I was wondering if the problem is with the <s:property value="name"/> as
there is no Enum.getName() method, it's Enum.name(). How do I deal with
method names that don't follow the "bean convention"?
Regards
--
View this message in context: http://old.nabble.com/Struts-2-obtaining-a-property-value-with-no-corresponding-getXX%28%29-method-tp30815951p30815951.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 2 obtaining a property value with no corresponding getXX() method
Posted by Dave Newton <da...@gmail.com>.
The first thing I'd try is calling the method on the object of iteration.
Dave
On Tue, Feb 1, 2011 at 8:03 AM, RogerV <ro...@googlemail.com> wrote:
>
> Hi
>
> I'm trying to iterate over a collection of Enums of type Authority using
>
> <s:iterator value="userDTO.authorities" status="authstatus">
> <s:property value="name"/>
> <s:if
> test="!#authstatus.last">,</s:if>
> </s:iterator>
>
> but I'm not getting any values displayed. Debugging shows that the call
> getUserDTO().getAuthorities() is being made on my underlying action and a
> correctly populated List<Authority> is being returned.
>
> I was wondering if the problem is with the <s:property value="name"/> as
> there is no Enum.getName() method, it's Enum.name(). How do I deal with
> method names that don't follow the "bean convention"?
>
> Regards
> --
> View this message in context:
> http://old.nabble.com/Struts-2-obtaining-a-property-value-with-no-corresponding-getXX%28%29-method-tp30815951p30815951.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Struts 2 obtaining a property value with no corresponding
getXX() method
Posted by RogerV <ro...@googlemail.com>.
Chris Pratt wrote:
>
> You might try <s:property value="name()"/>. I'm not sure if it will work,
> but OGNL has the ability to call methods by their full name.
>
>
Thanks Chris, <s:property value="name()"/> works a treat.
Regards
--
View this message in context: http://old.nabble.com/Struts-2-obtaining-a-property-value-with-no-corresponding-getXX%28%29-method-tp30815951p30823909.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 2 obtaining a property value with no corresponding getXX() method
Posted by Chris Pratt <th...@gmail.com>.
You might try <s:property value="name()"/>. I'm not sure if it will work,
but OGNL has the ability to call methods by their full name. Also, if you
haven't overridden toString() you can just use <s:property/> which will
automatically call Authority.toString() which by default returns .name().
(*Chris*)
On Tue, Feb 1, 2011 at 5:03 AM, RogerV <ro...@googlemail.com> wrote:
>
> Hi
>
> I'm trying to iterate over a collection of Enums of type Authority using
>
> <s:iterator value="userDTO.authorities" status="authstatus">
> <s:property value="name"/>
> <s:if
> test="!#authstatus.last">,</s:if>
> </s:iterator>
>
> but I'm not getting any values displayed. Debugging shows that the call
> getUserDTO().getAuthorities() is being made on my underlying action and a
> correctly populated List<Authority> is being returned.
>
> I was wondering if the problem is with the <s:property value="name"/> as
> there is no Enum.getName() method, it's Enum.name(). How do I deal with
> method names that don't follow the "bean convention"?
>
> Regards
> --
> View this message in context:
> http://old.nabble.com/Struts-2-obtaining-a-property-value-with-no-corresponding-getXX%28%29-method-tp30815951p30815951.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>