permaculture playing cards*
The moose likes Struts and the fly likes Struts action ognl setters and getters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts action ognl setters and getters" Watch "Struts action ognl setters and getters" New topic
Author

Struts action ognl setters and getters

E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
I have a struts action & when it fails I want to return a value and collect the value with OGNL.

The JSP page contains:
<s:property value="%{#parameters.result}"/>

In my struts xml I have:


The action contains:


All the system.out.prints in the action appear to be correct but I cant collect the variable with OGNL it always returns blank.

What am I missing that I cant collect the result value with OGNL?

Thanks,
Earl

Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

Check the getter method. It cant have parameters.


A.A.Anbarasu
E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
Maybe Im asking the wrong question. The variable "result" will be dependent on which failure happens in execute(). So "result" could be 1, 2 or 3 depending on which type of failure is found. If I shouldnt dynamically change within execute() how do I put a key,value on the default stack so that it can be collected and evaluated on failure by <s:property value="%{#result}"/>

Thanks
Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

E Robb wrote:Maybe Im asking the wrong question. The variable "result" will be dependent on which failure happens in execute(). So "result" could be 1, 2 or 3 depending on which type of failure is found. If I shouldnt dynamically change within execute() how do I put a key,value on the default stack so that it can be collected and evaluated on failure by <s:property value="%{#result}"/>

Thanks
Everything's are fine in your code. But ONGL expects a getter method without any parameter.
If the variable name is result, then
Setter method must beand the getter method must beIn your case there is no public String getResult() method; because it has overloaded version.
E Robb
Ranch Hand

Joined: Aug 27, 2010
Posts: 111
DOH!!! Thank you so much
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts action ognl setters and getters
 
Similar Threads
Struts 2.1 javascript field validate
Struts 2.1 Need two different success results
How to access beans from OGNL
submitting correct username and password, it again come in login.jsp
Can getters/setters be seperated from the ActionSupport class with a bean?