Hi
I am using Struts 1.3.8. I have written a command to replace the
processPreProcess method of a custom RequestProcessor from an older
verison of Struts. Basically, I want to perform a check for an object
in the session, but only for Actions that have a specific property
set. I hope that makes sense? i.e. check for a user in the session,
but only if the action requires it. i.e. SecureAction requires a valid
session, with a user in the session. HomeAction requires no such
check.
Relevant ActionServlet config in web.xml:
<init-param>
<param-name>chainConfig</param-name>
<param-value>
/WEB-INF/config/struts/chain-config.xml,
/WEB-INF/config/struts/chain-config-custom.xml
</param-value>
</init-param>
Content of /WEB-INF/config/struts/chain-config-custom.xml:
<?xml version="1.0" ?>
<catalog name="struts">
<chain name="servlet-standard-preprocess">
<command className="CustomCommand"/>
</chain>
</catalog>
Struts config:
<action-mappings>
<action path="/test"
type="TestAction">
<set-property key="RunLogic" value="true" />
<forward name="success"
path="success.jsp" />
</action>
</action-mappings>
CustomCommand.java:
public boolean execute(Context ctx) throws Exception {
ActionContext context = (ActionContext) ctx;
Map actionContextParams = context.getParameterMap();
String runLogic = (String) actionContextParams.get("RunLogic");
if (runLogic != null
&& runLogic.equalsIgnoreCase("true")) {
//check for user in session. If no user throw exception.
}
return CONTINUE_PROCESSING;
}
How do I access the "RunLogic" property in the CustomCommand class?
Prior to Struts 1.3.8 I would use a custom ActionMapping class and I
had access to the ActionMapping in the RequestProcessor. I see no way
to access my properties in the Context object.
Any help will be greatly appreciated.
Greg
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]