Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts action ognl setters and getters

 
E Robb
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 182
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the getter method. It cant have parameters.
 
E Robb
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 182
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DOH!!! Thank you so much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic