• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

S2: Parametized results

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic