• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Newbie Question

 
Ranch Hand
Posts: 597
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am new to struts and I have come accross a problem.

I have one action class which extends DispatchAction and it used to display list of Emps or Depts depending on actionType parameter.

Now I have one more class DispatchAction Class which I use to either edit or add new Emp depending on value of actionType parameter.

After adding an employee, I want to forward it to ShowList action.


<global-forwards>
<!-- Default forward to "Welcome" action -->
<!-- Demonstrates using index.jsp to forward -->
<forward name="welcome" path="/Welcome.do"/>
<forward name="ShowList" path="/ShowList.do"/>
</global-forwards>


<action path="/ShowList"
type="com.test.action.ShowListAction"
parameter="actionType">

<forward name="ShowEmpList" path="/pages/EmpList.jsp"/>
<forward name="ShowDeptList" path="/pages/DeptList.jsp"/>

</action>

<action path="/EmpEdit"
type="com.test.action.EditEmpAction"
parameter="actionType"
input="/pages/EmpDet.jsp"
name="EmpBean"
scope="session">

<forward name="success" path="/ShowList"/>
</action>



Obviously this will not work because after adding emp, actionType parameter will have value either addEmp or editEmp and showList action expects showEmpList or showDeptList.

Is there a way to set parameter actionType to some value(e.g. showEmpList in this case) in Action class,before I forward action to ShowList


Thanks alot in advance
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this in your action:

forward = mapping.findForward("ShowList");
forward.setPath(forward.getPath()+"?actionType=showEmpList");
reply
    Bookmark Topic Watch Topic
  • New Topic