1

In the struts-config.xml file,action element has a input attribute which used when the actionForm's validate method return some errors.

<action
  path="/somepath"
  attribute="someForm"
  input="/some.jsp"
  name="someForm"
  parameter="status"
  scope="request"
  type="cn.mycompany.struts.action.SomeAction"/>

But I want to change this input attribute when errors occur in the validate method,because I have more than one page submit to this action and I want it forward to the current submit page.

How can I do this,please help me. I am using Struts 1.2 version.

Chinni
  • 137
  • 3
  • 8

1 Answers1

0

All you need to do is map the action again. One mapping for every input you need.

<action
path="/somepath"
attribute="someForm"
input="/some.jsp"
name="someForm"
parameter="status"
scope="request"
type="cn.mycompany.struts.action.SomeAction"/>

<action
path="/somepath2"
attribute="someForm"
input="/some2.jsp"
name="someForm"
parameter="status"
scope="request"
type="cn.mycompany.struts.action.SomeAction"/>
Th0rndike
  • 3,406
  • 3
  • 22
  • 42
  • In My case path, attribute, name, parameter, etc are common. except the "input" value. Cannot compromise on using different action for each and every different input path values. Please let me know if I can set the value by using some expressions or in actions during validation.. Regards – Chinni Nov 09 '12 at 10:58
  • Why can't you use a different path? you don't have to rewrite the controller, all you need to do is map the same controller to 2 different paths, each with it's own input, and call the action depending on which page you want to return on validation failure. Instead of changing the input, you call a different path, it's the same. – Th0rndike Nov 09 '12 at 11:05
  • Ok!!! Let me explain you my problem. We are in the process of converting our Application to New look and Feel Here ever thing is same except the JSP's. We will be working based on Module by module at the same time, Old code should work as well as new code should work. So we cannot compromise on changing the action paths. Regards. – Chinni Nov 09 '12 at 11:11
  • @PurushothamReddyP once you are done with the answer please post it, I am also facing the same situation. – Java Questions Nov 21 '12 at 09:33
  • @Anto: Sorry I finally found that it is not something that Struts will allow us to change. The only alternative I had is to create a New Struts-configNew.xml and have my definitions for New JSP's in that XML file. We are almost done with the changes. Any inputs are appreciated – Chinni Apr 08 '13 at 14:57