• 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

Return types from execute() method in struts2 action

 
Ranch Hand
Posts: 96
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have been trying to learn Struts 2 through materials available on the net. One thing I just picked up is that there are 5 different return values from the action's execute() method, that are pre-defined in the framework, namely SUCCESS, ERROR, INPUT, LOGIN, NONE.
What I have a doubt about is...we can always set our own return value in the struts.xml file, in the action element. I can obviously do something like the following

and then make the execute() method return "reallycoolresult".

Can't I?
If I can't, then please tell me where my understanding went wrong. If I can, then what's the point of having pre-defined return values?

Please help me clear this confusion.
 
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, you can do that.
 
Souvvik Basu
Ranch Hand
Posts: 96
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I can, then what's the point/advantage of having pre-defined return types?
 
Ranch Hand
Posts: 122
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sure those are predefined because the majority of people use things like success, error, input, none, login.

The fact that you can return any other doesnt matter, the point is the method still returns a string ... you map that string to some result name ...
 
Greenhorn
Posts: 15
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I tried returning custom values from my execute method, but it was always returning error and the custom value was ignored.The page corresponding to "error" return value was called.
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Above Cause your method returning error somewhere you are getting exception fix the problem.
 
Ranch Hand
Posts: 300
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I tried returning custom values from my execute method, but it was always returning error and the custom value was ignored




What you mean by custome value?? Please post some code and stack trace so we can have better idea about the problem.

Regards
jatan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic