We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

A question about struts-config.xml in Struts

ggyao2003
ggyao2003 asked
on
Medium Priority
1,118 Views
Last Modified: 2012-06-27
in the action-mappings of struts-config.xml, can I create two actions with the same "path" new but different attributes, e.g. "validate", "name"?

For example: WorkflowDispatch is a subclass of DispatchAction, fileUpload is a typcial Action class. I want to use path "/Wf.do?method={valueofmethod}" for both actions. The upload.jsp need to be validated before forwarding to fileUpload action. The WorkflowDispatch doesn't need to do validation.

            <action path="/Wf"
                  type="fileUpload"
                  parameter="method">
                  input="/jsp/upload.jsp"
                  name = "UploadForm"
                  scope="request"
                  validate="true">
                  <forward name="success" path="/workflow.jsp" />
            </action>

            <action path="/Wf"
                  type="WorkflowDispatch"
                  parameter="method">
                  <forward name="success" path="/workflow.jsp" />
            </action>      
Comment
Watch Question

no! you cannot!
but you can forward form one action to another.

Author

Commented:
kennethxu,
I think your answer is right, but it does not help me much. what abot switch the problem to my essential concern:
the WorkflowDispatch.java contains quite a few methods, one of them is, for example, "fileupload". I need to do validation using an ActionForm for the "fileupload" action, but not the others. How can I achieve this goal?
Or even more broad, can I validate a specific Action (e.g. fileupload) using a specific ActionForm (e.g. UploadForm) while ignoring other Actions in the same subclass of DispatchAction (e.g. WorkflowDispatch)?
Thanks a lot!!!
but I still don't see the reason that you have to use same path? you cannot map 2 different actions to same path, period. there is no way around it. you should use different path for different action.
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
you got the point.
I have read the struts source code for requestprocessor and trying to call validation (and even setting the actionform) in the action class instead of setting them in struts-config.xml, but I still encountered exceptions. I will work on this issue tomorrow morning. I will ask more detailed questions shortly.
Or do you have some quick guide for me to do validation in action class?

Author

Commented:
btw, do you know how to set my screen name instead of ggyao2003? This is my email address, not my nick name in my profile.
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
>> do you know how to set my screen name instead of ggyao2003?
post a 0 point question in support:
https://www.experts-exchange.com/Community_Support/
glad to know it works for you. BTW, is there anything wrong leads to a B grade?
for you future reference:
https://www.experts-exchange.com/Web/Web_Languages/JSP/help.jsp#hi73

Author

Commented:
because I also have those ideas in mind, only that I was not sure about it and wanted to get some kind of confirmation.
the most important factor is that I have abandoned this approach, which causes several other problems.
For you future reference, grading measures reliability of an expert, doesn't have to do with the decision of implementation. As an EE rule, NO is a valid answer.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.