You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bas Schulte <ba...@connectedcreations.nl> on 2009/05/28 00:28:16 UTC

[S2] getting property value / OGNL calling a method of my model object with an argument

Hi,

more confusion. I'm trying to call a method in a model object with a  
Long (type doesn't really matter though) argument:

         <s:iterator value="categories">
             <s:property value="description.title"/><br />
             Activity id: <s:property value="activityId"/><br />
             String: <s:property value="boomerang(activityId)"/><br />
             No arg: <s:property value="boomerang"/><br /><br />
         </s:iterator>

According to the OGNL docs, adding an argument needs parenthesis, as  
I'm doing in 'boomering(activityId'.

This isn't working :( 'boomerang' without argument does work, it's  
returning a string like it should. getBoomerang(Long l) nor  
getBoomerang(String s) works. They're never called by Struts/ognl.

What am I missing? Is this supposed to work or not?

Thanks.

bas.




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


Re: [S2] getting property value / OGNL calling a method of my model object with an argument

Posted by Bas Schulte <ba...@connectedcreations.nl>.
On 28 mei 2009, at 01:01, Dave Newton wrote:

> Bas Schulte wrote:
>>        <s:iterator value="categories">
>>            <s:property value="description.title"/><br />
>>            Activity id: <s:property value="activityId"/><br />
>>            String: <s:property value="boomerang(activityId)"/><br />
>>            No arg: <s:property value="boomerang"/><br /><br />
>>        </s:iterator>
>> According to the OGNL docs, adding an argument needs parenthesis,  
>> as I'm doing in 'boomering(activityId'. [sic]
>> This isn't working :( 'boomerang' without argument does work, it's  
>> returning a string like it should. getBoomerang(Long l) nor  
>> getBoomerang(String s) works. They're never called by Struts/ognl.
>> What am I missing? Is this supposed to work or not?
>
> Passing in an argument means it's no longer a simple getter, so you  
> have to actually call the method. Only real JavaBean getters work  
> without the "get" prefix.
>
> <s:property value="%{getBoomerang(activityId)}" />

Ok, that does indeed work!

Thanks.




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


Re: [S2] getting property value / OGNL calling a method of my model object with an argument

Posted by Dave Newton <ne...@yahoo.com>.
Bas Schulte wrote:
>         <s:iterator value="categories">
>             <s:property value="description.title"/><br />
>             Activity id: <s:property value="activityId"/><br />
>             String: <s:property value="boomerang(activityId)"/><br />
>             No arg: <s:property value="boomerang"/><br /><br />
>         </s:iterator>
> 
> According to the OGNL docs, adding an argument needs parenthesis, as I'm 
> doing in 'boomering(activityId'. [sic]
> 
> This isn't working :( 'boomerang' without argument does work, it's 
> returning a string like it should. getBoomerang(Long l) nor 
> getBoomerang(String s) works. They're never called by Struts/ognl.
> 
> What am I missing? Is this supposed to work or not?

Passing in an argument means it's no longer a simple getter, so you have 
to actually call the method. Only real JavaBean getters work without the 
"get" prefix.

<s:property value="%{getBoomerang(activityId)}" />

Dave

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