Control API for Form (form)

Is the outer shell of the document and encapsulates normal content, markup, controls and labels of those controls. Forms are essential for the event handling.

 

  • action
    Defines the form processing agent. For example, the value might be a HTTP URI to submit the form to a program or a mailto URI to email the form.

  • defaultButton
    Defines the default button for this document. This button will fire an event if the user presses the RETURN / ENTER key in the web agent. Usually the button should have the 'design' "EMPHASIZED" to graphically show that this button is the default button.
    If you write an application for different web clients you should be aware of the fact that every web client has its own way to handle keyboard input. To achieve the right results on all web clients you should use the default button always together with an inputField and the inputField must have the focus (usually the inputField gets the focus because the user clicked on this field to do some input). In this case the onClick event of the default button will be fired when the user presses RETURN / ENTER in the inputField.

  • encodingType
    Defines the content type (MIME type) used to submit the form to the web server. Examples of content types can be found at http://www.w3.org/TR/1998/REC-html40-19980424/interact/forms.html#h-17.3

    Important note:
    If you use a fileUpload control in the JSP you must set the encondingType attribute to "multipart/form-data".

    Example: <hbj:form encodingType="multipart/form-data" >

  • id
    Identification name of the form.

  • language
    Defines the language code for this document. The attribute defines the primary language and can define a series of sub languages. The language code is according to ISO 639. The language code and the description can be found at http://www.w3.org/TR/1998/REC-HTML40-19980424/references.html#ref-RFC1766
  • method
    Defines the HTTP method that will be used to submit the form data set. The form data set is a sequence of control name/current value pairs constructed from successful controls. A successful control is "valid" for submission. Every control has its control name paired with its current value as part of the submitted form data set. A successful control must be defined within a form and must have a control name.

    Important:
    The control name is generated by the HTML-Business for Java renderer. So you have no way to address the control via e.g. JavaScript.
    • GET
      The form data set is appended to the URI specified by the action attribute (with a question-mark (?) as separator) and this new URI is sent to the processing web agent.
    • POST
      The form data set is included in the body of the form and sent to the processing web agent.

The default method is POST and should not be altered (Limits of GET requests can cause problems).

  • scrollingToLastPosition
    A boolean value that controls the position in a form. By default the position in a form is always reset to "top of form" when the form is submitted (e.g. in case of an event). If the 'scrollingToLastPosition' attribute is set to true the last position in the form is saved and restored on a submit.
  • target
    Specifies the name of the frame where the document is to be opened. The following values refer to w3c HTML-standard.
    • _blank
      The web client should load the designated document in a new, unnamed window.
    • _self
      The web client should load the document in the same frame as the element that refers to the target.
    • _parent
      The web client should load the document into the immediate FRAMESET parent of the current frame. This value is equivalent to _self if the current frame has no parent.
    • _top
      The web client should load the document into the full, original window (thus canceling all other frames). This value is equivalent to _self if the current frame has no parent.
Attribute Req. Values Default Case sens. JSP Taglib Classlib
action no String none yes action="/servlet/com.test.JspTest" setAction("/servlet/com.test.JspTest")
defaultButton no String none yes   setDefaultButton(OKButton)
encodingType no String none no encodingType="multipart/mime" setEncodingType("multipart/mime")
id yes String none yes id="SAPForm"  
language no String none no language="de" setLanguage("de")
method no GET
POST
POST no method="POST" setMethod("POST")
scrollingToLastPosition yes FALSE
TRUE
FALSE no   setScrollingToLastPosition(true)
target no _blank
_self
_parent
_top
_self no target="_blank" setTarget("_blank")

 

Example

This example also shows the definition of a default button. We define the OKbutton as default.
The assignment is made by scripting (<% %>) and has to be done where the button is defined.

<hbj:form
          id="myFormId"
          method="post"
target="_blank"
encodingType="multipart/form-data"
action="/htmlb/servlet/com.sapportals.htmlb.test.MyTestJsp1Test" >
 This form submits to a new web client window <br>
 because of 'target=_blank'.<br><br>
           
      <hbj:inputField
               id="myInputField1"
               type="String"
               invalid="false"
               width="310"
               value="After editing press <Enter> to submit"
               visible="true"
               disabled="false"
               required="true"
               maxlength="30"
               size="50"
               >
       </hbj:inputField>

       <br><br>
       <hbj:button id="oKbutton"
               text="OK"
               onClick="onOKClick"
               design="EMPHASIZED"
               width="100"
               >

               <% myFormId.setDefaultButton(oKbutton); %>
       </hbj:button>

       <hbj:button
               id="Infobutton"
               text="Info"
               onClick="onInfoClick"
               width="100"
       />

       <hbj:button
                id="Cancelbutton"
                text="Cancel"
                onClick="onCanClick"
                width="100"
       />


</hbj:form>

Result