struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sachin Lale <lalesach...@gmail.com>
Subject chain or redirectAction ResultType
Date Mon, 30 May 2011 21:13:34 GMT
Hi,
I am migrating an application from struts1.1 to struts 2.2.3.  I have 
two action

   1. InstitutuionAction : The purpose is to prepare the data required
      to display and then forward to a Institution.JSP (using tiles)
   2. InstitutionAddEditAction: This action exposed two methods insert,
      update and validate.

The insert and validate method of InstitutionAddEditAction class looks 
like below

public String insert() throws Exception
     {
         log.info("In 
InstitutionStrutsAddEditAction"+institution.getName());
         return Action.SUCCESS;
     }

public void validate()
     {
         if(institution.getName().equals("abc"))
             addActionError("<font color=\"red\"> Invalid Name .</font>");
     }

struts.xml

<action name="Institution" method="execute" 
class="edu.wustl.clinportal.action.struts2.InstitutionStruts2Action">
<result name="success" type="tiles">.clinportal.institutionDef</result>
<result name="failure" type="tiles">.clinportal.institutionDef</result>
<result name="access_denied" >/ManageAdministrativeData.do</result>
</action>
<action name="InstitutionAddEdit_*" method="{1}" 
class="edu.wustl.clinportal.action.struts2.InstitutionStrutsAddEditAction">
<result name="input" type="redirectAction">
<param name="actionName">Institution</param>
<param name="operation">add</param>
<param name="pageOf">pageOfInstitution</param>
<param name="menuSelected">2</param>
</result>
<result name="success" type="redirectAction">
<param name="actionName">Institution</param>
</result>
</action>

After a validation error it is getting redirect to Institution.action 
but not re-populating the data entered by the users obvious reason as 
the request is redirected and not forward. Everything works fine if i 
replace the result type to chain and could populate the Institution name 
(this object is in InstitutionAddEditAction class).

I added a Institution object in InstitutuionAction  class. I tried the 
same scenarion using chain this time. Its worked as well. Is 
ChainInterceptor populating this object?

But is using chain a recommended approach. What is harm in using chain.?

Best regards,
Sachin


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message