Hi Sarat,
sarat.pediredla wrote:
So would I use
<s:iterator value="posts" id="post" var="post">
<s:property value="#commentCount(post)"/>
</s:iterator>
I tried it but doesnt seem to make a difference. Even tried <s:property
value="getCommentCount(post)"/>
Not sure how much difference it makes, but when I've done this
(successfully), I've done the following:
- used the full name of the method (in your case, "getCommentCount" )
- put spaces either side of the parameter list to the function, ie:
"getCommentCount( post )"
- made sure the Type of the value that's being passed to the function
is the same as that declared by the function - OGNL doesn't always use
the Type for a value that you might expect it to.
Assuming your getCommentCount( .. ) method is declared in your Action
(and is public of course), I don't believe you have to use a pound (#)
prefix in n <s:property ../> tag, but I may be wrong about that.
mraible wrote:
You'll need to use a Struts Tag (with OGNL) to call a method with
parameters. JSP's EL doesn't support calling methods with arguments.
Matt
On Jan 22, 2008, at 1:34 PM, sarat.pediredla wrote:
Hello,
My action has a method like below
public int getCommentCount(BlogPost post) {
.......
}
In my JSP, I iterate through a list of objects as follows
<s:iterator value="posts" id="post">
..........
</s:iterator>
How do I call the getCommentCount method inside the s:iterator
passing an
instance of the current post?
${commentCount(post)} does not seem to work and I cannot find any
reference
on the net allowing me to call a method in my action from the JSP
using the
current stack object inside an iterator
HTH,
Rob Hills
Waikiki, Western Australia
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]