aspose file tools*
The moose likes Struts and the fly likes action-mapping input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "action-mapping input " Watch "action-mapping input " New topic
Author

action-mapping input

jonathan Greens
Ranch Hand

Joined: Apr 07, 2004
Posts: 139
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 ]
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
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

Joined: Apr 07, 2004
Posts: 139
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

Joined: Sep 21, 2003
Posts: 415
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
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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.


A good workman is known by his tools.
jonathan Greens
Ranch Hand

Joined: Apr 07, 2004
Posts: 139
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!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: action-mapping input