Thursday, April 19, 2018

Form Handlers

ATG Form Handler is a java class which extends class atg.droplet.GenericFormHandlerFormHandler needs to define at least one handleXXX() method e.g. handleAddCustomer(), handleUpdateCustomer(). Along with this, component with $class=<yourclass_withpackage> needs to be defined. On frontend part, this handle method is triggered when corresponding handler submit button is clicked or form is submitted.

To get value from input boxes or anyother input option, we can define members with same name given in <dsp:input> tag in the formhandler having getters and setters.

Our handler method handleXXX() will contain the logic for validating data and processing. If any validation errors are present, same can be added to formExceptions vector which gets inherited from GenericFormHandler Based on result of processing, we can redirect to appropriate success URL or error URL.

Below is example of form handler class:

class TestFormHandler extends atg.droplet.GenericFormHandler{
    private String name;
    public void setName(String name){ this.name=name; }
    public String getName(){ return this.name; }

    public boolean handleAddData(DynamoHttpServletRequest request, DynamoHttpServletResponse response)
    {
        /*Logic for validation and processing*/
        response.sendLocalRedirect(“successURL”, pRequest);
        return true;
    }
}






No comments:

Post a Comment