I've been trying to understand how parameterized results should work under the SmartURLs plugin for
Struts 2. In my specific case, I'm trying to redirect on success to a new URL that includes a paramter. I've tried modelling it after the standard XML=based example in the WebWork in Action book on page 191:
<result name="success"
type="redirect">order-confirmation.jsp?confirmationNumber=${confirmationNumber}</result>
So I tried
@Results({
@Result(name="success",location="/competitions/admin?id=${getCompId}",
type="redirect")})
However nothing gets injected into the variable, but the expression is gone. Ie the browser redirects to "/competitions/admin?id=", so it looks like the expression is getting "evaluated" at some point in time and not just passed through verbatim. I've tried several different formulations of the variable: getCompId, getCompId(), compId, etc. Currently
I have a simple method on the action:
public
String getCompId() {return (comp!=null ? comp.getId().toString() :
"0";}
(In reality "0" should never be returned, but I wanted an explicit value to be able to tell if I've hooked up the paramter correctly, versus having access to the Id in the first place.)
When I try to follow along directly with the XML based approach the
action/results from struts.xml seem to interact poorly with the other
annotation based configurations and I can't seem to chase down what would make a valid hybrid configuration.
Can anyone give me some pointers on how to either make paramterized locations work with SmartURLs or, how to configure these results in struts.xml without interfering too much with the other convention/annotations based approaches?
Thank you.