Solved

A question about struts-config.xml in Struts

Posted on 2004-03-29
12
1,087 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>      
0
Comment
Question by:ggyao2003
  • 7
  • 4
12 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 10710731
no! you cannot!
but you can forward form one action to another.
0
 

Author Comment

by:ggyao2003
ID: 10719101
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!!!
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10720148
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.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 14

Assisted Solution

by:kennethxu
kennethxu earned 125 total points
ID: 10720285
BTW, you can always call the validation method manually in the action.
0
 

Author Comment

by:ggyao2003
ID: 10720610
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?

0
 

Author Comment

by:ggyao2003
ID: 10720627
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.
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 125 total points
ID: 10720673
>> even setting the actionform
that is more difficult because you'll have to manually populate the form bean although you can use beanutil and etc.

>> but I still encountered exceptions
exception detail? stacktrace?

>> quick guide for me to do validation in action class
simply call the validation class and get the ActionErrors, then do whatever you do with normal action validation.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10720678
>> do you know how to set my screen name instead of ggyao2003?
post a 0 point question in support:
http://www.experts-exchange.com/Community_Support/
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10726867
glad to know it works for you. BTW, is there anything wrong leads to a B grade?
for you future reference:
http://www.experts-exchange.com/Web/Web_Languages/JSP/help.jsp#hi73
0
 

Author Comment

by:ggyao2003
ID: 10727825
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.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 10727883
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.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ajax auto save 15 102
some methods private some are not 8 212
HTML5 vs JSP - REST based application development 4 1,081
Market Place not working in Eclipse Luna 2 113
Google always has something new and amazing up its sleeve, and the most current thing that they have been working on is another step in the evolution of Google Search, from machine learning to its brilliant successor, deep learning.
This problem is more common than not and I will show you some things to check to solve this problem.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question