Solved

A question about struts-config.xml in Struts

Posted on 2004-03-29
12
1,084 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now