|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts.action.Action
jp.terasoluna.fw.web.struts.actions.ActionEx
jp.terasoluna.fw.web.struts.actions.AbstractBLogicAction<P>
P
- Specify the JavaBean which is input value to the business logic.public abstract class AbstractBLogicAction<P>
Abstract class to invoke the business logic.
This is the abstract class in which the functionalities common for the action class, are consolidated. This action class invokes the business logic. All the action classes which invoke the business logic are implemented by inheriting this class. BLogicAction also inherits this class. Following is the list of provided functionalities.
After setting the business logic in the Bean definition file, action class which invokes the business logic, is executed. In the following example, the settings to invoke business logic, SampleBLogic from SampleAction are shown. Configuration example of struts-config.xml is also shown below.
Settings of Bean definition file
<bean name="/SampleAction" scope="prototype"
class="jp.terasoluna.sample1.actions.SampleAction">
<property name="sampleBLogic">
<ref bean="SampleBLogic"></ref>
</property>
</bean>
<bean id="SampleBLogic"
class="jp.terasoluna.sample1.blogic.SampleBLogic">
</bean>
Settings of struts-config.xml
<action path="/SampleAction"
name="_sampleForm"
validate="true"
scope="session"
input="/sample.jsp">
<forward name="success" path="/sampleSCR.do"/>
<forward name="failure" path="/errorSCR.do"/>
</action>
When the business logic execution fails and message needs to be set, store the message in the BLogicResult as shown below.
public BLogicResult doExecuteBLogic(ParamsBean params) {
// Generates BLogicResult.
BLogicResult result = new BLogicResult();
...
//Business logic
...
//Error condition
if (// Error processing ) {
// Sets the information which needs to be mapped in Web tier.
...
return result;
} else {
// Error occurs in the business logic
// BLogicMessages are generated
BLogicMessages messages = new BLogicMessages();
// Store BLogicMessage as the message of GROUP_ERROR group
messages.add("GROUP_ERROR", new BLogicMessage("message.error.sample", "sample"));
// Set BLogicMessages in the BLogicResult
result.setErrors(messages);
// Specify "failure" in the execution result
result.setResultString("failure");
return result;
}
}
As shown in the following example, "request" or the "session" can be
specified in the "saveMessageScope" of <property> element as
the storage location of BLogicMessages.
If the property definition is omitted, the BLogicMessages are stored in "request".
<bean name="/SampleAction" scope="prototype"
class="jp.terasoluna.sample1.actions.SampleAction">
<property name="sampleBLogic">
<ref bean="SampleBLogic"></ref>
</property>
<property name="saveMessageScope" value="session"/>
</bean>
BLogicAction
,
BLogicIOPlugIn
,
BLogicResult
,
AbstractBLogicMapper
,
BLogicMapper
,
BLogicMessage
,
BLogicMessages
Field Summary | |
---|---|
protected static java.lang.String |
BLOGIC_FORM_ILLEGAL_ERROR
Error code when the error occurs in the settings of extended action form. |
protected static java.lang.String |
BLOGIC_MAPPING_ILLEGAL_ERROR
Error code when the error ocurs in the settings of the extended action mapping. |
protected static java.lang.String |
BLOGIC_RESOURCES_ILLEGAL_ERROR
Error code when the error occursin the settings of the extended action resource. |
protected static java.lang.String |
BLOGIC_RESULT_NULL_ERROR
Error code when BLogicResult is returned as null. |
private static org.apache.commons.logging.Log |
log
Log class. |
protected static java.lang.String |
NULL_MAPPER_KEY
Error code when AbstractBLogicMapper is null. |
private java.lang.String |
saveMessageScope
Message storage scope. Specify "request" or "session" as the storage location of the BLogicMessages generated in the busness logic. |
Fields inherited from class jp.terasoluna.fw.web.struts.actions.ActionEx |
---|
FORWARD_TXTOKEN_ERROR |
Fields inherited from class org.apache.struts.action.Action |
---|
defaultLocale, servlet |
Constructor Summary | |
---|---|
AbstractBLogicAction()
|
Method Summary | |
---|---|
protected org.apache.struts.action.ActionMessages |
convertMessages(BLogicMessages blogicMessages)
Store the contents of BLogicMessages again in the ActionMessages. |
org.apache.struts.action.ActionForward |
doExecute(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
executes the business logic. |
abstract BLogicResult |
doExecuteBLogic(P param)
Abstract method to execute business logic. To be implemented in the subclass. |
protected void |
evaluateBLogicResult(BLogicResult result,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ActionMappingEx mappingEx)
Evaluates BLogicResult and reflect the result of Web tier object. |
protected BLogicIO |
getBLogicIO(org.apache.struts.action.ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)
Fetches BLogicIO. |
protected AbstractBLogicMapper |
getBLogicMapper(javax.servlet.http.HttpServletRequest req)
Fetches BLogicMapper instance. |
protected P |
getBLogicParams(ActionMappingEx mapping,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Generates and returns params. |
protected boolean |
isErrorsEmpty(BLogicResult result)
Returns true when the error information stored in the BLogicResult is null or empty. |
protected void |
postDoExecuteBLogic(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
P params,
BLogicResult result)
Processing after executing the business logic. |
protected void |
preDoExecuteBLogic(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
P params)
Processing before executing business logic. |
protected void |
processBLogicResult(BLogicResult result,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
ActionMappingEx mappingEx)
Reflects the result to the Web tier object from BLogicResult. |
void |
setSaveMessageScope(java.lang.String saveMessageScope)
Sets message storage scope. |
Methods inherited from class jp.terasoluna.fw.web.struts.actions.ActionEx |
---|
addErrors, addMessages, execute, isSaveToken, isTokenCheck, processTokenCheck, setSaveToken, setTokenCheck |
Methods inherited from class org.apache.struts.action.Action |
---|
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static org.apache.commons.logging.Log log
protected static final java.lang.String BLOGIC_FORM_ILLEGAL_ERROR
protected static final java.lang.String BLOGIC_MAPPING_ILLEGAL_ERROR
protected static final java.lang.String BLOGIC_RESOURCES_ILLEGAL_ERROR
protected static final java.lang.String BLOGIC_RESULT_NULL_ERROR
protected static final java.lang.String NULL_MAPPER_KEY
private java.lang.String saveMessageScope
Constructor Detail |
---|
public AbstractBLogicAction()
Method Detail |
---|
public void setSaveMessageScope(java.lang.String saveMessageScope)
saveMessageScope
- Message storage scopepublic org.apache.struts.action.ActionForward doExecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
Perform the following processes which are commonly required to execute the business logic.
doExecute
in class ActionEx
mapping
- Action mappingform
- Formrequest
- Requestresponse
- Response
java.lang.Exception
- Unexepected exception thrown from the subclassprotected void preDoExecuteBLogic(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, P params) throws java.lang.Exception
request
- Requestresponse
- Responseparams
- Parameter(JavaBean)
java.lang.Exception
- Unexpected exceptionprotected void postDoExecuteBLogic(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, P params, BLogicResult result) throws java.lang.Exception
This process is executed only when exception has not occurred in the business logic.
request
- Requestresponse
- Responseparams
- Parameter(JavaBean)result
- Business logic executon result
java.lang.Exception
- Unexpected exceptionprotected void evaluateBLogicResult(BLogicResult result, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionMappingEx mappingEx)
result
- BLogicResult instancerequest
- HTTP requestresponse
- HTTP responsemappingEx
- Extended action mappingprotected void processBLogicResult(BLogicResult result, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionMappingEx mappingEx)
result
- BLogicResult instancerequest
- HTTP requestresponse
- HTTP responsemappingEx
- Extended action mappingprotected org.apache.struts.action.ActionMessages convertMessages(BLogicMessages blogicMessages)
blogicMessages
- BLogicMessages instance
public abstract BLogicResult doExecuteBLogic(P param) throws java.lang.Exception
param
- Business logic input information
java.lang.Exception
- Unexpected exceptionprotected boolean isErrorsEmpty(BLogicResult result)
result
- Business logic execution result
protected AbstractBLogicMapper getBLogicMapper(javax.servlet.http.HttpServletRequest req)
req
- HTTP request
protected P getBLogicParams(ActionMappingEx mapping, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
mapping
- Action mappingrequest
- HTTP requestresponse
- HTTP response
java.lang.Exception
- Unexpected exceptionprotected BLogicIO getBLogicIO(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
mapping
- Action mappingrequest
- HTTP request
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |