java - How to get request parameter from actionB on execution of actionA -


i have requirement need request parameter actionb on execution of actiona. can see below there complex logic behind working out strb in actionb. want value of strb in actionb without having repeat complex logic. what's best way that?

<action name="actiona"     class="com.mycompany.action.actiona"     method="input">              <result name="input" type="tiles">page.actiona</result> </action>  <action name="actionb"     class="com.mycompany.action.actionb"     method="readfromcache">              <result name="input" type="tiles">page.actionb</result> </action> 
public class actiona extends actionsupport     private string stra = new string();     private string strb = new string();     public string input() throws exception {         stra = "hello";         // here strb actionb         strb = ...need here...         return input;     }        public string setstra(string stra) throws exception {         stra = stra;     }     public string getstra() throws exception {         return stra;     }    } 
public class actionb extends actionsupport     private string strb = new string();     public string readfromcache() throws exception {         strb = ...complex logic here...;         return input;     }        public string setstrb(string strb) throws exception {         strb = strb;     }     public string getstrb() throws exception {         return strb;     }    } 

the best way opinion based. avoid asking questions way;

one way solve it, if have 2 actions common logic , want achieve dry, create parent action, , make actiona , actionb extend parentaction (that extends actionsupport) instead of actionsupport directly.

put in parent action common logic. (the common logic does not belong business side... should not stay in any action)


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -