tags:

views:

37

answers:

2

I am working on a Struts application.Now I have a strange situation.The current application has a config file something like this

<action path="/validate" type="test1Action" scope="request" validate="false"> 
        <forward name="cat1" path="path1/value1"/>
        <forward name="cat2" path="path1/value2"/>
        <forward name="cat3" path="path1/value3"/>
        <forward name="failure" path="path1"/>
        <forward name="failed" path="emptysession"/>
        </action>

Now the issue is if I add a new Action class test2Action and I have to change the type to test2Action and in test2Action I have only three return variables namely

cat1,failure,failed. Now cat1 should call test1Action. What I am trying to do is insert an action class inbetween a JSP and Action class.Anyone can help me out?

+1  A: 

I believe you need to updated the struts-config with:

<action path="/validate" type="test1Action" scope="request" validate="false"> 
  <forward name="cat1" path="validateTest2Action.do"/>
  <forward name="cat2" path="path1/value2"/>
  <forward name="cat3" path="path1/value3"/>
  <forward name="failure" path="path1"/>
  <forward name="failed" path="emptysession"/>
</action>

<action path="/validateTest2Action" type="test2Action" scope="request" validate="false"> 
  <forward name="cat1" path="path1/value1"/>
  <forward name="failure" path="path1"/>
  <forward name="failed" path="emptysession"/>
</action>
OMG Ponies
+1  A: 

I'll get down voted for this, but, oh well.

IF you are just starting out, then I'd simply abandon Struts 1 completely. Head on over to either Struts 2 or Stripes. Struts 1 has no redeeming qualities whatsoever today, save legacy code.

If you're on a legacy code set, then there's not much you can do.

If you have the option bailing on it now, I'd run, quickly, right now, away from Struts 1 and pick something else. Life's too short.

Will Hartung
Can't waste 1 year in a second
Harish
@Will: If you're worried, post this as a comment.
OMG Ponies
I'm not going to downvote you because I agree with "abandon Struts1" line of thought but OP did say "current application has ..." so he clearly is working on an existing project. Also, both Struts2 and Stripes are not **that** much better than Struts1 :-)
ChssPly76
@ChssPly76 - I agree he said existing application, but it may well have been an existing application that he is just starting, so now is the time to flee. Stripes and S2 are vastly better than S1 if you are looking for a Java action framework. There are certainly other frameworks offering other idioms both in Java and other languages, but S2 and Stripes are the Modern Man to the Neanderthal S1 version of Java action frameworks.
Will Hartung