I have a JSP page that is very commonly used all throughout the application
(with minor tweaks).
here is the snippet form struts.xml for it:
<action name="ReportSelectionAction"
class="com.generate.web.action.reports.ReportSelection">
<result>/reports/IncomeReportselection_struts2.jsp</result>
<result name="failure">login.jsp</result>
</action>
The action class ReportSelection has bunch of getters/setters and logic in
it. The jsp that it goes to is IncomeReportselection_struts2.jsp. The JSP
has some labels that are specific to 'IncomeReport' If I want to make this
jsp general, I want to change to labels to something more specific to where
the action came from.
is there a way to retrieve the action name in the action class?? like in the
above example, is there a way to retrieve action name
"ReportSelectionAction" in the "ReportSelection" class?
Why I want to do that is that way I can set labels in the action class.
something like
If (actionName.equals("ReportSelectionAction"))
setLabel1("Income Report");
else if (actionName.equals("SomeOtherReportSelectionAction"))
setLabel1("Some Other Report Selection");
Then my struts.xml will have this.
<action name="ReportSelectionAction"
class="com.generate.web.action.reports.ReportSelection">
<result>/reports/IncomeReportselection_struts2.jsp</result>
<result name="failure">login.jsp</result>
</action>
<action name="SomeOtherReportSelectionAction"
class="com.generate.web.action.reports.ReportSelection">
<result>/reports/IncomeReportselection_struts2.jsp</result>
<result name="failure">login.jsp</result>
</action>
and in JSP IncomeReportSelection.jsp I can do <s:property value="label1"/>
Is this a good approach or is there a better way to achieve this?
Thanks