Skip to main content

ATG - more about Forms and Form Handlers

An ATG form is defined by the dsp:form tag, which typically encloses DSP tags that specify form elements, such as dsp:input that provide direct access to Nucleus component properties. Find below a sample dsp:form tag.
   <dsp:form action="/testPages/showPersonProperties.jsp" method="post" target="_top">
     <p>Name: <dsp:input bean="/samples/Person.name" type="text"/>
     <p>Age: <dsp:input bean="/samples/Person.age" type="text" value="30"/>
     <p><dsp:input type="submit" bean="/samples/Person.submit"/> value="Click to submit"/>
   </dsp:form>
 
When the user submits the form, the /samples/Person.name property is set to the value entered in the input field.Unlike standard HTML, which requires the name attribute for most input tags; the name attribute is optional for DSP form element tags. If an input tag omits the name attribute, the ATG platform assigns one when it compiles the page. A text input field displays the component property’s current value unless the dsp:input tag also includes the value attribute. The value attribute overrides the property’s current value.

If an outer JSP has a dsp:form then the inner included page(dsp:include) can contain element tags such as dsp:input, dsp:textarea, and dsp:select only if the page is a complete JSP. Form elements cannot be embedded in a JSP fragment (.jspf) file.

ATG provides hundreds of readymade form handlers for performing all sorts of tasks, like updating a customer profile(CommerceProfileFormHandler), managing your shopping cart(CartModifierFormHandler), checking out(ExpressCheckoutFormHandler), or interacting with a repository(RepositoryFormHandler).

Following are the tasks assigned to Form Handlers by ATG :

  • Validate data before it is submitted.
  • Detect missing information and display appropriate messages to the user.
  • Direct users to different pages depending on form submission results.
  • Read and write database or repository data.

A better way to create a new form handler is to subclass a Dynamo class that implements DropletFormHandler interface. Dynamo provides three form handler base classes that implement this interface :

  • atg.droplet.DropletFormHandler --> inteface
  • atg.droplet.EmptyFormHandler --> implements DropletFormHandler
  • atg.droplet.GenericFormHandler --> extends EmptyFormHandler
  • atg.droplet.TransactionalFormHandler --> extends GenericFormHandler --> treats the form processing operation as a transaction.

Find below a sample call to /atg/search/formhandlers/SearchValidateFormHandler from a JSP :

      <dsp:input bean="SearchValidateFormHandler.validate" name="validate" id="validate" type="hidden" value="DAS" style="display:none" priority="-10"/>

A handler method will be specified with the name ‘handlex’ where x represents the name of the submit. The signature of the handle method is:

       public boolean  handlex(DynamoHttpServletRequest request,
DynamoHttpServletResponse response)throws IOException, ServletException{}

The handler method (handlex) returns a boolean value. This value indicates whether Dynamo should continue processing the rest of the page after this handler has finished. In the above example, there is a public boolean handleValidate(DynamoHttpServletRequest pRequest,DynamoHttpServletResponse pResponse) method @ SearchValidateFormHandler.

If there are any setx methods in the FormHandler, it will be called before the handlex method is invoked. Some of the other methods used by the form handler are:

  • beforeSet --> This is called before any setx methods are called.
  • afterSet --> This is called after all setx methods are called.
  • beforeGet  --> This is called before any tags that reference the component is rendered.
  • afterGet --> This is called after the page rendering gets completed.
  • handleFormException --> This is called when any exception occurs while trying to call the setx methods.
Following are the form handler component properties to handle form errors/exceptions:
  • formError --> Boolean that is set to true if any errors occur during form processing.
  • formExceptions  --> A vector of the exceptions that occur during form processing.  If your form handler is session-scoped, clear the formExceptions property after you display errors to the user.
  • propertyExceptions  --> A read-only property that returns a Dictionary of subproperties, one for each property set by the form. For each property that generates an exception, a corresponding subproperty in the propertyExceptions Dictionary contains that exception
Use the checkFormRedirect(String pSuccessURL, String pFailureURL, DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) method of GenericFormHandler to redirect to a url from the formhandler on a success/error cases. A handler that redirects the user to another page should return false.

The atg.droplet.GenericFormHandler class (and any subclass of GenericFormHandler you write) includes a handleCancel method for implementing Cancel buttons in forms. This method redirects to the URL specified in the form handler’s cancelURL property.

When a dsp:setvalue tag is rendered for a form handler property, it invokes the setX and handleX methods of the form handler (if the methods exists).

A form handler component should be either request- scoped or session-scoped.When your form handler spans several pages, such as in a multi-page registration process,  you want the session-scoped form handler.It is especially important to clear error messages to ensure they do not appear in other forms where they are not relevant.



Comments

  1. hi sony,
    Iam really amazed the way you put efforts to write these blogs. Please could you write something about folder structure. how it is created, if you could. God bless you

    ReplyDelete
  2. check it @ http://tips4ufromsony.blogspot.com/2012/02/atg-how-to-create-and-deploy-new-atg.html

    If you want to know anything special, please raise it... :-)

    ReplyDelete
  3. this post is good one tag An ATG form is defined by the dsp:form tag, which typically encloses DSP tags that specify form elements

    ReplyDelete
  4. your efforts are brilliant. please try to increase the examples on form handlers and droplets. as i am a beginner your blog helping me alot!

    ReplyDelete
  5. Thank you for the info. It sounds pretty user friendly. I guess I’ll pick one up for fun. thank u


    Form Processing

    ReplyDelete
  6. Hi sony,

    Great effort!.it's really helpful for beginners like me.could you please explain login validations using form handlers?

    ReplyDelete
  7. hi sony,
    I want to know how to extend the oob(Out Of Box) components and how can i override those methods....

    ReplyDelete
  8. Hi Sony,

    Thanks for your valuable time that you gave here to write this blog.
    It is very very helpful and your effort is really appreciable.
    Wish to see more posts from you in coming future.

    Great job :)

    ReplyDelete
  9. i am new to ATG, Please explain me how ATG is Different From other tools or Frameworks to develop Websites. Thank you Somuch

    ReplyDelete
    Replies
    1. ATG is basically an e-Commerce platform which provide many capabilities. It provides an API for most of the eCommerce stuff... you can also have a detailed look on this blog.. lot of detail:-

      http://learnoracleatg.blogspot.in/p/atg-e-commerce.html

      Delete
  10. nice post.

    For atg related stuff, you can visit www.atg-tips.blogspot.com

    ReplyDelete

Post a Comment

Popular posts from this blog

ATG - basic concepts of ATG

This blog is for the ATG beginners to get some basic overview about ATG. I just given the ATG concepts as a list of numbered points for the ease of understanding. 1. At the framework level, ATG is a               java based application platform for hosting web-based applications, as well as RMI accessible business components,               with an ORM layer,               a component container,               an MVC framework,               and a set of tag libraries for JSP. 2. Art Technology Group(ATG)'s Dynamo Application Server (DAS) is a Java EE compliant application server. DAS is no longer actively developed as ATG recommends using other Java EE applications servers for its products such as BEA WebLogic, JBoss or IBM WebSphere. 3. Prior to ATG 2007, JHTML was used instead of JSP for view purpose. J...

ATG Search - how to configure multiple language search

Here I am going to explain the steps involved in configuring the multi-language ATG Search if your site support multiple language. I have given the different steps in indexing and search flows. Indexing flow : You could configure different search projects for different locales to support parallel search indexing for each locale. You could setup search environment for the search projects so that the indexing host is different for the two projects. Configure the LocaleVariantProducer @ ProductCatalogOutputConfig to specify the locale for the new language. Include the language dictionaries you need in Search Admin on the Search Projects which can be used for indexing and searching in multiple languages. Specify the locales @ \atg\search\config\LanguageDimensionService so that you could configure the search configurations for each language. When you create the search configuration tree, specify the "Contents vary by" as Language, to configure the search configurations li...

Tax Credit Statement ( Form 26AS )

Read more about Tax filing @  http://tips4ufromsony.blogspot.com/2011/07/income-tax-process-and-e-filing.html  . Form 26AS is a consolidated tax statement issued under Rule 31 AB of Income Tax Rules to PAN holders. This statement, with respect to a financial year, will include details of: Tax deducted at source (TDS). Tax collected at source (TCS). Advance tax/self assessment tax/regular assessment tax etc., deposited in the bank by the taxpayers (PAN holders). Paid refund received during the financial year. Form 26AS will be prepared only with respect to Financial Year 05-06 onwards. To view the Form26AS , log-in to https://incometaxindiaefiling.gov.in and click on ‘View Tax Credit Statement (From 26AS)’  in ‘My Account’. Read more about Form 26AS  @ http://www.incometaxindia.gov.in/26ASTaxCreditStatement.asp http://www.tin-nsdl.com/form26as.asp

ATG Search and startRemoteLauncher

If the search engine application is running in a separate box than the ATG CA-BCC deployed server, the search engine is invoked through a remoteLauncher running in these boxes. Means, a remoteLauncher needs to run in the host where SearchEngine is installed remotely to start the search engine. You could find the startRemoteLauncher.sh @ ATG/ATG2007.1/Search2007.1/SearchAdmin/bin/startRemoteLauncher.sh Start remoteLauncher using the command   ./startremotelauncher.sh –p <RMI Launcher service Port > & The Launcher Service Port on the host machine can be found in BCC @ Search Administration>Projects > Search Project: gmri_search_en_CA > Environments > Host Machine: > Advanced Settings. If the startRemoteLanucher reports a BindingException , then you need to find the process that is using the launchServicePort. For that run the netstat command like :   netstat -an |grep 10880 Then inorder to identify the process t...

ATG search installation and search engine log files

Here I would like to explain how your ATG search folder structure looks like after you do the ATG search installation and also about the search engine log files. To get the ATG search, you need to install the ATGSearch<version>Windows.exe after you do the ATG installation. When you install ATG search, the generated folders include an OS dependant folder. In the below screen shot, you could see the "i686-win32-vc71" folder and this is generated since the ATG search ins installed in a windows machine. The ATG search engine is actually an exe file inside this "i686-win32-vc71" folder. Below screen shot give you an idea about the "atgsearch.exe", which is the search engine application. This search engine application (atgsearch.exe) is started by a remote launcher call from the BCC search administration UI.  The log files like "atgsearch_20120106112413_568.log" are the search engine log files where you could see the engine ...