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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void add​(int row, int col, java.lang.Object x)
      This method inserts an object's html presentation into the specified location.
      void addHiddenField​(java.lang.String name, java.lang.String value)
      Inserts a hidden field into the specified location.
      void addInput​(int row, int column, java.lang.String type, java.lang.String name, java.lang.String value)
      Inserts an input field into the specified location.
      void addLink​(int row, int col, java.lang.String text, java.lang.String url)
      This method inserts a hyperlink into the specified location.
      void addPasswordField​(int row, int col, java.lang.String name)
      This method inserts a password field into the specified location.
      AQFormSelector addSelectorField​(int row, int col, java.lang.String name)
      This method inserts a selector field into the specified location.
      void addSubmitButton​(int row, int col, java.lang.String name, java.lang.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, java.lang.String name, java.lang.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.
      java.lang.String getStyle()
      Returns the form style.
      void setAction​(java.lang.String action, java.lang.String method, java.lang.String name)
      Sets form action parameters.
      void setCellStyle​(int row, int col, java.lang.String style)
      Sets individual cell style.
      void setFooter​(java.lang.String footer, java.lang.String style)
      Sets the form footer.
      void setHeader​(java.lang.String header, java.lang.String style)
      Sets the form header.
      void setStyle​(java.lang.String style)
      Sets the form style.
      java.lang.String toHtml()
      Generates html code.
    • Method Detail

      • setAction

        void setAction​(java.lang.String action,
                       java.lang.String method,
                       java.lang.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,
                 java.lang.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,
                     java.lang.String text,
                     java.lang.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,
                          java.lang.String name,
                          java.lang.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,
                              java.lang.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,
                             java.lang.String name,
                             java.lang.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,
                      java.lang.String type,
                      java.lang.String name,
                      java.lang.String value)
        Inserts an input field into the specified location.
        Parameters:
        row - Row index, 0-based.
        column - Column index, 0-based.
        type - The input type.
        name - Field name.
        value - Initial field value.
      • addHiddenField

        void addHiddenField​(java.lang.String name,
                            java.lang.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​(java.lang.String style)
        Sets the form style.
        Parameters:
        style - Valid HTML style specification. Example: "background:#E0E0E0; width:100%;"
      • getStyle

        java.lang.String getStyle()
        Returns the form style.
        Returns:
        the form style
      • setCellStyle

        void setCellStyle​(int row,
                          int col,
                          java.lang.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,
                                        java.lang.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.
        Returns:
        the AQFormSelector
      • 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.
        Returns:
        the AQTextArea
      • setHeader

        void setHeader​(java.lang.String header,
                       java.lang.String style)
        Sets the form header.
        Parameters:
        header - Header text.
        style - Valid HTML style specification. Example: "background:#E0E0E0; width:100%;"
      • setFooter

        void setFooter​(java.lang.String footer,
                       java.lang.String style)
        Sets the form footer.
        Parameters:
        footer - Footer text.
        style - Valid HTML style specification. Example: "background:#E0E0E0; width:100%;"
      • toHtml

        java.lang.String toHtml()
        Generates html code.
        Returns:
        the html code.