OpenAPI 1.0

com.aquafold.openapi.form
Interface AQForm


public interface AQForm

This interface facilitates creation of simple HTML forms.

The logical representation of the form is a table, where each cell may contain zero, one, or more components added via this class addXX() methods. This object produces HTML code by calling its toHtml() method.

This class can be used to generate straightforward HTML table (without a <form> tag). Simply skip setAction(String, String, String) call.

Example:

 if(aqua.request.getParameter("login") != null)
 {
 // handling the form output
 aqua.response.write("Welcome, " + aqua.request.getParameter("name") + "<br>");
 aqua.response.writeLink("Logout", aqua.request.getRequestURI());
 }
 else
 {
 // present the form
 var f = aqua.form.newForm(3,2);
 

f.setAction("", "get", ""); f.setStyle("width:100%; background:#dddddd;"); f.add(0,0,"Name:"); f.addTextField(0,1, "name", ""); f.add(1,0,"Password:"); f.addPasswordField(1,1, "password"); f.addSubmitButton(2,1,"login","Login"); f.addHiddenField("hidden", "a secret");

aqua.response.write(f); }


Method Summary
 void add(int row, int col, Object x)
          This method inserts an object's html presentation into the specified location.
 void addHiddenField(String name, String value)
          Inserts a hidden field into the specified location.
 void addInput(int row, int column, String type, String name, String value)
          Inserts an input field into the specified location.
 void addLink(int row, int col, String text, String url)
          This method inserts a hyperlink into the specified location.
 void addPasswordField(int row, int col, String name)
          This method inserts a password field into the specified location.
 AQFormSelector addSelectorField(int row, int col, String name)
          This method inserts a selector field into the specified location.
 void addSubmitButton(int row, int col, String name, String text)
          This method inserts a Submit button into the specified location.
 AQTextArea addTextArea(int row, int column, int textRows, int textColumns)
          This method iseerts a TEXTAREA field into a form location specified by (row,col).
 void addTextField(int row, int col, String name, String text)
          This method inserts a text field into the specified location.
 void clear()
          Clear the form.
 void clearCell(int row, int column)
          Remove cell content.
 String getStyle()
          Returns the form style.
 void setAction(String action, String method, String name)
          Sets form action parameters.
 void setCellStyle(int row, int col, String style)
          Sets individual cell style.
 void setFooter(String footer, String style)
          Sets the form footer.
 void setHeader(String header, String style)
          Sets the form header.
 void setStyle(String style)
          Sets the form style.
 String toHtml()
          Generates html code.
 

Method Detail

setAction

void setAction(String action,
               String method,
               String name)
Sets form action parameters. If no parameters are set, the object will generate a simple html table without a <form> tag.

Parameters:
action - The URL of to send the form output to.
method - HTTP request method. Example: GET.
name - The form name.

add

void add(int row,
         int col,
         Object x)
This method inserts an object's html presentation into the specified location. This method may be called repeatedly on the same cell, adding new content to that cell.

Parameters:
row - Row index, 0-based.
col - Column index, 0-based.
x - Object to be added to the cell.

addLink

void addLink(int row,
             int col,
             String text,
             String url)
This method inserts a hyperlink into the specified location.

Parameters:
row - Row index, 0-based.
col - Column index, 0-based.
text - The text which will be presented to the user.
url - Link's URL.

addTextField

void addTextField(int row,
                  int col,
                  String name,
                  String text)
This method inserts a text field into the specified location.

Parameters:
row - Row index, 0-based.
col - Column index, 0-based.
name - Field name.
text - Initial field value.

addPasswordField

void addPasswordField(int row,
                      int col,
                      String name)
This method inserts a password field into the specified location.

Parameters:
row - Row index, 0-based.
col - Column index, 0-based.
name - Field name.

addSubmitButton

void addSubmitButton(int row,
                     int col,
                     String name,
                     String text)
This method inserts a Submit button into the specified location.

Parameters:
row - Row index, 0-based.
col - Column index, 0-based.
name - Field name.
text - Initial field value.

addInput

void addInput(int row,
              int column,
              String type,
              String name,
              String value)
Inserts an input field into the specified location.

Parameters:
row - Row index, 0-based.
column - Column index, 0-based.
name - Field name.
value - Initial field value.

addHiddenField

void addHiddenField(String name,
                    String value)
Inserts a hidden field into the specified location.

Parameters:
name - Field name.
value - Initial field value.

clearCell

void clearCell(int row,
               int column)
Remove cell content.

Parameters:
row - Row index, 0-based.
column - Column index, 0-based.

clear

void clear()
Clear the form.


setStyle

void setStyle(String style)
Sets the form style.

Parameters:
style - Valid HTML style specification. Example: "background:#E0E0E0; width:100%;"

getStyle

String getStyle()
Returns the form style.


setCellStyle

void setCellStyle(int row,
                  int col,
                  String style)
Sets individual cell style.

Parameters:
row - Cell row index.
col - Cell column index.
style - HTML style of the cell TD element.

addSelectorField

AQFormSelector addSelectorField(int row,
                                int col,
                                String name)
This method inserts a selector field into the specified location.

Parameters:
row - Row index, 0-based.
col - Column index, 0-based.
name - Field name.

addTextArea

AQTextArea addTextArea(int row,
                       int column,
                       int textRows,
                       int textColumns)
This method iseerts a TEXTAREA field into a form location specified by (row,col). The text area dimensions are determined by textRows and textColumns.

Parameters:
row - Form row index, 0-based.
column - Form column index, 0-based.
textRows - Number of rows in the text area.
textColumns - Number of columns in the text area.

setHeader

void setHeader(String header,
               String style)
Sets the form header.

Parameters:
header - Header text.
style - Valid HTML style specification. Example: "background:#E0E0E0; width:100%;"

setFooter

void setFooter(String footer,
               String style)
Sets the form footer.

Parameters:
footer - Footer text.
style - Valid HTML style specification. Example: "background:#E0E0E0; width:100%;"

toHtml

String toHtml()
Generates html code.


OpenAPI 1.0


Copyright © 2010 AquaFold, Inc. All Rights Reserved. Use is subject to license terms.