The Action classes and ActionForm classes generated by the iSeries Web Interaction wizard are based on code contained within templates. There are four templates, which contain both static content and dynamic content. The static content can be changed and customized. The dynamic content is used by the Web Interaction wizard to generate code based on the settings made in the wizard. Keywords in this section start with a # character. The keywords are reserved for the Web Interaction wizard. The dynamic section can be customized, but the reserved keywords need to remain in the order in which they occur. User comments can be added to this section by preceding the comments with ## characters. The user comments are not generated in the final code.
Each template affects the code generated in all of the Web projects in the workspace. That is, the scope of the templates is workspace-global.
workspace_location\.metadata\.plugins\com.ibm.etools.iseries.webtools\
#PACKAGE ## e.g. package com.ibm.userwebapp.actions; ##============================================================ ## Template file for the generation of user Action classes ## that invokes iSeries host program. ## #{keyword} are for the internal dynamic code-generation ## based on the Web Interaction Wizard ## Template Comment will be ignored by the code-generation. ##============================================================ /** * Description - Use PCML to call iSeries ILE program */ import java.util.*; import java.io.*; import java.math.*; import java.text.*; import javax.servlet.http.*; import javax.servlet.ServletContext; import org.apache.struts.action.*; import com.ibm.as400.access.*; import com.ibm.iseries.webint.*; import com.ibm.connector2.iseries.pgmcall.*; #IMPORT ## e.g. import com.ibm.userwebapp.beans.*; public class #CLASSNAME ## e.g. UserWebAppAction extends Action { #DEFINE_CONSTRUCTOR ## e.g. public UserWebAppAction() { #CONSTRUCTOR } public ActionForward #EXECUTE_METHOD_NAME ## Struts 1.0 -> perform, Struts 1.1 -> execute ( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) { try { if(!request.isRequestedSessionIdValid()) { return mapping.findForward("session_error"); } else { preprocessing(request, response, form); HttpSession session = request.getSession(); #INPUT ##========================================================= ## e.g ## UserWebAppInputForm inputForm = (UserWebAppInputForm) form; ## String[] strCustNo = (String[]) inputForm.getValues("custNo"); ##========================================================= #OUTPUT1 ##========================================================= ## e.g ## UserWebAppResultForm resultsForm = new UserWebAppResultForm(); ##========================================================= invokeHostProgram(request, dataBean, form, resultsForm); #OUTPUT2 ##========================================================= ## e.g ## String[] strOut = null; ## strOut = new String[1]; ## strOut[0] = dataBean.getBalance(); ## resultsForm.setValues("balance", strOut); ##========================================================= postprocessing(request, form, resultsForm); #POSTPROCESSING ##========================================================= ## e.g ## session.invalidate(); ##========================================================= #RETURN_FORWARD ## e.g. return getForward(mapping, session); } } catch(Exception ex) { handleError(request, response, ex); return mapping.findForward("wdt_error"); } } // Trigger methods Section // These methods represent key processing phases of // the generated Action execute(). // User can potentially extend the classes and override the methods // to specialize their needs. // In general, it is recommended that the derived methods to invoke the // corresponding method in the super class, e.g. super.preprocessing() etc. //----------------------------------------------------------------------------------------- protected void preprocessing(HttpServletRequest request, HttpServletResponse response, ActionForm inputForm ) throws Exception { } protected void invokeHostProgram( HttpServletRequest request, ProgramCallRecord dataBean, ActionForm inputForm, ISeriesActionFormInterface resultsForm ) throws WebIntRuntimeException { } protected void postprocessing( HttpServletRequest request, ActionForm inputForm, ISeriesActionFormInterface resultsForm ) { } // Helper methods Section //-----------------------------------------------------------------------------
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.