Solved

A question about struts-config.xml in Struts

Posted on 2004-03-29
12
1,088 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
session bean client machine 9 63
Getting NoSuchMethodError on accessing a spring mvc project 3 169
struts hibernate integration example 28 144
iterator/ListIterator approach 17 41
Ransomware is a malware that is again in the list of security  concerns. Not only for companies, but also for Government security and  even at personal use. IT departments should be aware and have the right  knowledge to how to fight it.
Ransomware continues to grow in reach and sophistication, putting data everywhere at risk. Learn how to avoid being caught in its sinister clutches with these 11 key tips.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 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