Re: How to call a method passing a parameter inside jsp with struts 2

2007-12-12 Thread Matthew (IRQ)

Apparently, you can only retrieve properties with the property tag (so it
only allows you to call getName Methods with no parameters).

However, I'm using the following workaround:
s:push value=myMethod(myParameter)
s:property value=top
/s:push

The push tag pushes a new object (the return value in this case) onto the
value stack. It is this object I am refering to with top in my nested
property tag. In my case, the object was a string, so I can directly use it.



TonyD wrote:
 
 In a jsp page, I'am trying to call a method of my class passing a
 parameter and the method will return a string value.
 
 s:property value=#myClass.myMethod(myParameter) /
 
 or
 
 s:action name=myClass!myMethod executeResult=true
 s:param name=myParam value=%{myParam}/
 /s:action
 
 but doesn't work.
 Could someone please help me! Thanks.
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-call-a-method-passing-a-parameter-inside-jsp-with-struts-2-tp11779219p14301807.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to call a method passing a parameter inside jsp with struts 2

2007-12-12 Thread Dave Newton
--- Matthew (IRQ) [EMAIL PROTECTED] wrote:
 Apparently, you can only retrieve properties with the property tag (so it
 only allows you to call getName Methods with no parameters).

s:property.../ can call arbitrary methods with parameters.

Given an action method:

public String foo(final String s_) {
return s_ + s_;
}

the following:

s:property value=foo('huh? ')/

will return:

huh? huh?

d.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to call a method passing a parameter inside jsp with struts 2

2007-07-25 Thread TonyD

s:property value=#myClass_myMethod(myParameter) / 

A made a syntax error, the underscore character and not the dot character
between the class and the method name


TonyD wrote:
 
 In a jsp page, I'am trying to call a method of my class passing a
 parameter and the method will return a string value.
 
 s:property value=#myClass.myMethod(myParameter) /
 
 or
 
 s:action name=myClass!myMethod executeResult=true
 s:param name=myParam value=%{myParam}/
 /s:action
 
 but doesn't work.
 Could someone please help me! Thanks.
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-call-a-method-passing-a-parameter-inside-jsp-with-struts-2-tf4141022.html#a11779422
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]