Sample for implementing a request-response-enabled interface
You might implement a request-response-enabled interface when you need both an HTTP request and a response.
Implementing a request-response-enabled interface
Here
is the sample code for when you need both the http request and response.
public interface RequestResponseEnabled {
public void setRequest(HttpServletRequest request);
public void setResponse(HttpServletResponse response);
}
Here is the code to implement the sample class:
public class HomePageCommand implements RequestResponseEnabled {
HttpServletRequest request;
HttpServletResponse response;
public void setRequest(HttpServletRequest request) {
// TODO Auto-generated method stub
this.request=request;
}
public void setResponse(HttpServletResponse response) {
// TODO Auto-generated method stub
this.response=response;
}
public String getHomePage(){
//get the austin context and switch the screen
AustinContext ctx = (AustinContext)request.getSession().getAttribute("ctx");
AustinContext.setCurrentContext(ctx);
String start_page_url = StringUtils.checkString(ctx.getSecurityContext().getUserSettingValue(UserSettingEnum.TRIGO_APPLICATIONS_AS_START_PAGE_ENUM.db,
Const.USER_SETTING_DEFAULT_INSTANCE+ ""), "");
if(Const.HOME_PAGE_CLASSIC.equalsIgnoreCase(start_page_url) || "".equalsIgnoreCase(start_page_url))
return "classic";
else if(Const.HOME_PAGE_NEW.equalsIgnoreCase(start_page_url))
return "newhomepage";
///utils/custom_page.jsp?script_id=802
String script_id = start_page_url.substring(start_page_url.lastIndexOf("=")+1);
//setting the script ID so that i can be routed to the correct custom script
request.setAttribute("script_id",script_id);
return "customhomepage";
}
}
Here is the sample configuration in the flow-config.xml
file:
<flow path="homepage" command="com.ibm.pim.uitest.HomePageCommand" method="getHomePage">
<flow-dispatch name="classic" location="/ccd_workflow/collaboration_console.jsp"
dispatchType="forward" />
<flow-dispatch name="newhomepage" location="/utils/homepage.jsp"
dispatchType="forward"/>
<flow-dispatch name="customhomepage" location="/utils/custom_page.jsp"
dispatchType="forward"/>
</flow>