Java Reference
In-Depth Information
<input type=" button" value="Update"
onClick=" eventValidateAndSubmit ('UWR002','SCR001')"/>
</form>
The controller used this combination of event code and screen code to uniquely
identify a block of code to be executed for each user action and subsequent selection of
the next view to be rendered. This controller was another JSP and was cluttered with sev-
eral long-running if-else blocks, as shown in Listing 3-2.
Listing 3-2. UnderwritingController.jsp
<%
String eventCode = request.getParameter("eventCode");
String screenCode = request.getParameter("screenCode");
String inputPage = request.getParameter("referrer");
Sting userCd = request.getParameter("userCode");
String nextView = "";
try{
SecurityChecker.getInstance().check(userCd, eventCode);
if(screenCode.equals("SCR001") && eventCode.equals("UWR002")){
//Look up session bean
//Create policy by invoking session bean method
nextView = "Policy.jsp";
}
else if(screenCode.equals("UWR002") && eventCode.equals("SCR001")){
//similar to above
nextView = "Policy.jsp";
}
else{
request.setAttribute("ERROR_MESSAGE",
"You have attempted an unsupported function");
nextView = "error.jsp";
}
}
catch(AppException appExp){
request.setAttribute("ERROR_MESSAGE",exp.getMessage());
nextView = inputPage;
}
catch(Throwable exp){
Search WWH ::




Custom Search