Implementing the client applications for JSF channel

To implement the client applications for JSF channel, do the following:

  1. Create the JSPs for JSF channel:

    To create JSF channel’s JSPs, experience in standard JSF is required. Refer to http://java.sun.com/javaee/javaserverfaces/ for detailed information and take <toolkit_root>/samples/BTTMultiChannleSample/BTTSampleWeb/WebContent/btt/jsf/signin.jsp as an example.

  2. Configure JSFInvoker in invoker.xml
    BTT JSF channel provides a JSFInvokerAdaptor for BackIngBean to call BTT invoker. It is a generic action. In JSF channel you can configure a generic invoker for each transaction. Following is an example code:
    <POJO id="htmlOpStepAdaptorInvoker" beanName="com.ibm.btt.sample.util.JSFOperationAdaptor" method="execute">
      <parameters>
        <parameter id="operationName" type="java.lang.String" />
        <parameter id="ctx" type="com.ibm.btt.base.Context" />
        <parameter id="message" type="java.lang.String" />
      </parameters>
    </POJO>
  3. Develop the Backing Beans
    1. Extend the BTTJSFBaseBean delivered by BTT.
    2. Implement the two abstract methods in the base bean: setInvokerParameters() and parseInvokerResult()
    3. Start BTT components in its action method.
    Following is an example:
    public class AccountTransferBean extends ExtendingBaseBean {	
        public String accountTransferOp() {
            try {
                execute("accountTransferOp", "htmlOpStepAdaptorInvoker");
                return "success";	
            } catch (Exception e) {
                e.printStackTrace();
                return "failure";
                }
        }
    }
    
    public class ExtendingBaseBean extends BTTJSFBaseBean {
        private String[] errorMessages = null;
        public void parseInvokerResult(Object invokerResult) {
            try {
                parseInvokerResult((Map)invokerResult, getBeanContext());	
            } catch (DSEInvalidRequestException e) {
                e.printStackTrace();
            }
        }
    	 	public Object[] setInvokerParameters() {
    		Object[] params = {getActionName(), getBeanContext(), ""};
    		return params;
    	  }
    	
    public void parseInvokerResult(Map invokerResult, Context flowCtx) throws DSEInvalidRequestException {
    	 //update the flow Context
        Boolean passContextFlag = (Boolean) invokerResult.get("passContextFlag");
        if(passContextFlag.booleanValue()) {
            Context cxt = (Context) invokerResult.get("flowContext");
            updateContext(cxt);	
        }
        setOutcome((String) invokerResult.get("outcome"));
        errorMessages = (String[]) invokerResult.get("errorMessages");
        handleErrorMessages(errorMessages);
    }
    	
    	
    public void handleErrorMessages(String[] errorMessages) {
        handleErrorMessages(null, errorMessages);
    }
    	
    public void handleErrorMessages(String clientId, String[] errorMessages) {
        FacesMessage message = null;
        for(int i = 0 ; i < errorMessages.length ; i++) {
            message = new FacesMessage(FacesMessage.SEVERITY_ERROR, errorMessages[i], errorMessages[i]);
            FacesContext.getCurrentInstance().addMessage(clientId, message);
        }
    }