org.jscience.sociology.forms
Class Form

java.lang.Object
  extended by org.jscience.sociology.forms.Form
All Implemented Interfaces:
java.io.Serializable

public class Form
extends java.lang.Object
implements java.io.Serializable

This class represents a set of data input elements that are represented by FormElement objects. The instantiation and initialization of one Form object is done only once when parsing the forms.xml file. The Form object is then serialized for later use in producing instances of class Form (for each new client request).

See Also:
FormElement, FieldValidator, GroupValidator, FormHandler, SimpleContentGenerator, Serialized Form

Constructor Summary
Form()
           
 
Method Summary
 java.io.StringReader generateXML()
          Returns a StringReader object that contains this form presentation data in XML format.
 java.lang.String generateXmlAsString()
          Returns a String that contains this form presentation data in an XML format.
 java.lang.String getFormActionPath()
          This method returns the form's "action" path that was entered through the form tag's action attribute (in forms.xml).
 FormElement[] getFormElements()
          This method returns an array of all FormElement-s of this form.
 java.lang.String getFormPagePath()
          This method returns the URL path to the presentation page of this form.
 java.lang.String getName()
          Gets the name of this Form object.
 boolean isFirstime()
          This method returns a flag that shows whether this is the first time the form is shown to the current user, or otherwise.
 boolean isUnboundBeforeActionPage()
          This method returns a flag that defines one of the two following behaviors : true - once the form validation goes well, the user session must be cleared of the Form object and of any other object related with it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Form

public Form()
Method Detail

getName

public java.lang.String getName()
Gets the name of this Form object. In forms.xml, the user sets the name of the form via the name attribute of the form tag.

Returns:
the name that identifies this Form object.

isUnboundBeforeActionPage

public boolean isUnboundBeforeActionPage()
This method returns a flag that defines one of the two following behaviors :

true - once the form validation goes well, the user session must be cleared of the Form object and of any other object related with it. This work has to be done in the forwardToFormAction() method of the ContentGenerator.

false - the user session must not get cleared of the Form object or of any other object related with it, even after the successful form validation. This is specifically useful in the case you use a confirmation page as the "action" of your form. In this case, not clearing the session means that if the user wants to go back from the confirmation page to the form, the last entries will still be preserved.

In forms.xml, the user sets the value of this flag via the unbound attribute of the form tag.

Returns:
the flag.

isFirstime

public boolean isFirstime()
This method returns a flag that shows whether this is the first time the form is shown to the current user, or otherwise.

This method can be used by sendFormContent() method of the ContentGenerator. See the source code of SimpleContentGenerator as an example.

Returns:
the flag.

getFormElements

public FormElement[] getFormElements()
This method returns an array of all FormElement-s of this form.

This method can be used by a ContentGenerator class. See the source code of SimpleContentGenerator for such an example.

Returns:
an array of FormElement-s.

getFormPagePath

public java.lang.String getFormPagePath()
This method returns the URL path to the presentation page of this form. In forms.xml, the user sets this path through the attribute page of form tag. This path should be relative to application root.

This method has to be used by ContentGenerator classes. See the source code of SimpleContentGenerator as an example.

Returns:
a string representing the path to this form presentation page.

getFormActionPath

public java.lang.String getFormActionPath()
This method returns the form's "action" path that was entered through the form tag's action attribute (in forms.xml). This path should be relative to application root.

This method has to be used by ContentGenerator classes. See the source code of SimpleContentGenerator as an example.

Returns:
a string representing the URL to the processing Servlet or JSP.

generateXML

public java.io.StringReader generateXML()
Returns a StringReader object that contains this form presentation data in XML format. This method can be used by ContentGenerator classes for generating the presentation of this form in any desired format, HTML included.

Returns:
a StringReader containing this form presentation data in XML format.

generateXmlAsString

public java.lang.String generateXmlAsString()
Returns a String that contains this form presentation data in an XML format.

Returns:
a String containing this form presentation data in XML format.