About this task
Take the following steps to define the backing beans:
- Extend the BTTJSFBaseBean delivered by BTT.
- Implement the two abstract methods in the base bean: setInvokerParameters() and parseInvokerResult().
- Start BTT components in its action method.
Following is a code sample:
public class AccountTransferBean extends BTTJSFBaseBean {
private String[] errorMessages = null;
public String accountTransferOp() {
try {
execute("accountTransferOp", "htmlOpStepAdaptorInvoker");
return "success";
} catch (Exception e) {
e.printStackTrace();
return "failure";
}
}
@Override
public void parseInvokerResult(Object invokerResult) {
try {
parseInvokerResult((Map)invokerResult, getBeanContext());
} catch (DSEInvalidRequestException e) {
e.printStackTrace();
}
}
@Override
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);
}
}