• 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

action-mapping input

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi folks,
I have an action that might be called from many jsps. If i understand correctly the input specified for action tag will dictate where to go in case there's an error in validation.. How would I be able to specify the input as a variable.. My Actions allow user to pass in a URL and ERL indicating where to go in the normal and error case. Can I integrate this with the action input tag?
thanks!!
this is my action mapping

[ March 16, 2005: Message edited by: jonathan Greens ]
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi greens

As the struts-config.xml is static there is no way that u can make ur input attribute variable (u cant even say actionmapping.setInput as the configuration will be frozen by the actionservlet)

Instead 2 ways

1. Make multiple entries in config file with varying path,input attributes except that everything same

2. Have one entry in config file for all these and move ur validations to action class so that from there u will have the control of deciding where to go after validation fails

is that making sense for u ??
 
jonathan Greens
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Reddy,
thanks for the help!. But I am not clear on the 1st approach. Are you saying making multiple action-mappings like this?

<action path="/deleteUnitA" name="deleteUnitForm"
type="com.xxx.DeleteUnitFormAction"
input="inputA">
<forward name="success" path=""/>
<forward name="failure" path=""/>
</action>

<action path="/deleteUnitB" name="deleteUnitForm"
type="com.xxx.DeleteUnitFormAction"
input="inputB">
<forward name="success" path=""/>
<forward name="failure" path=""/>
</action>

this seem a bit weird. is this what you mean?


2. for the 2nd approach. So I can't use struts validation if am using the action in more than one jsps?

Are there any other way? I guess I prefer the first one if I understood it correctly. Are there any other way?
thanks!!
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yah green

U got it perfectly ?? its up to u decide which method is better ..........because u dont have control on the validate method

r else i will advice u one thing .if u can do that its well and good .Give ur own implementation for RequestProcessor .in that override processValidate() method in such a way that on failure of validation ,instead of saying mapping.getInput() say mapping.findForward(forwardname) and use different forward names for different validations
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jonathan Greens:
2. for the 2nd approach. So I can't use struts validation if am using the action in more than one jsps?



You can call the ActionForm's validate method from your Action class. Your Action can send you to whatever forward you desire.

If you declaratively set validation to true in the ActionMapping, you are giving Struts control of how and when to call it. You could always extend RequestProcessor, but I prefer to not jump at that solution until all other options have been exhausted.
 
jonathan Greens
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You can call the ActionForm's validate method from your Action class. Your Action can send you to whatever forward you desire.



So what you are suggesting is that I can disable struts validation and just call formBean.validate() in my action class manually?


thanks all for the help!!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic