Saturday, October 7, 2017

ATG 11.3 JAX-RS API – FormHandlerExecutor

ATG 11.3 JAX-RS API – FormHandlerExecutor FormHandlerExecutor class invokes the form handler based on handle method provided in con... thumbnail 1 summary
ATG 11.3 JAX-RS API – FormHandlerExecutor


FormHandlerExecutor class invokes the form handler based on handle method provided in constructor. Forwards are disabled and the request and response are wrapped to capture any redirect response in the result instead.

Executor object can be created using the constructor as below,

FormHandlerExecutor executor = new FormHandlerExecutor(pFormHandlerPath,pHandleMethod);

Adding inputs to the executor.

executor.addInput(pParamName,pParamValue);

Execute the formhandler using

executor.execute();

As well in ootb have a method to process the results.

executor.processFormHandlerResult(executor.execute());

This processFormHandlerResult method process the results and if it has any form exception(s) it will create a DropletException and add it to the error stack.

Example code for formHandlerExecutor from CurrentUserRestResource class

@POST
    @Path("/login")
    ...
    public Map<String, String> login(...) throws RestException ... {
       ...
       try {
          ...
          FormHandlerExecutor executor = new FormHandlerExecutor(this.getProfileFormHandlerPath(), this.getLoginHandleMethod());
          this.addInputsForLogin(executor, pLogin, pPassword);
          executor.processFormHandlerResult(e.execute());
          ...

          HashMap statusCode1 = new HashMap();
          ...
          ...
          return statusCode;
       } catch (...) {
          ...
       }
    }
       protected void addInputsForLogin(FormHandlerExecutor pExecutor, String pLogin, String pPassword)
                     throws ServletException {

              pExecutor.addInput("value.login", pLogin);
              pExecutor.addInput("value.password", pPassword);
         }




Thanks.


1 comment