com.gwtext.client.widgets.form
Class FormPanel

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.gwtext.client.widgets.Component
              extended by com.gwtext.client.widgets.BoxComponent
                  extended by com.gwtext.client.widgets.Container
                      extended by com.gwtext.client.widgets.Panel
                          extended by com.gwtext.client.widgets.form.FormPanel
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasWidgets, Observable

public class FormPanel
extends Panel

FormPanel uses a FormLayout internally, and that is required for fields and labels to work correctly within the FormPanel's layout. To nest additional layout styles within a FormPanel, you should nest additional Panels or other containers that can provide additional layout functionality. You should not override FormPanel's layout.


Field Summary
 
Fields inherited from class com.gwtext.client.widgets.Component
config, id
 
Constructor Summary
FormPanel()
          Create a new FormPanel.
FormPanel(com.google.gwt.core.client.JavaScriptObject jsObj)
           
FormPanel(Position labelAlign)
          Create a new FormPanel.
 
Method Summary
 void addFormListener(FormListener listener)
          Add a Form listener.
 void addListener(FormPanelListener listener)
          Add a Form Panel Listener.
protected  com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
           
protected  com.google.gwt.core.client.JavaScriptObject getConfigPrototype()
           
 Field[] getFields()
          Return all fields added to the FormPanel.
 Form getForm()
          Provides access to the Form which this Panel contains.
 java.lang.String getXType()
          Gets the xtype for this component as registered with ComponentMgr.
protected  void initComponent()
          This template method is called after the Component has been instantiated but before it's rendered.
 void setBaseParams(UrlParam[] params)
          Parameters to pass with all requests.
 void setButtonAlign(Position buttonAlign)
          Valid values are "left," "center" and "right" (defaults to "center").
 void setErrorReader(Reader errorReader)
          A Reader (e.g.
 void setFileUpload(boolean fileUpload)
          Set true if this form is a file upload.
 void setHideLabels(boolean hideLabels)
          Set to true to hide all field labels.
 void setItemCls(java.lang.String itemCls)
          A CSS class to apply to the x-form-item of fields.
 void setLabelAlign(Position labelAlign)
          Valid values are "left," "top" and "right" (defaults to "left").
 void setLabelWidth(int labelWidth)
          The width of labels.
 void setMethod(Connection.Method method)
          The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
 void setMinButtonWidth(int minButtonWidth)
          Minimum width of all buttons in pixels (defaults to 75).
 void setMonitorPoll(int monitorPoll)
          The milliseconds to poll valid state, ignored if monitorValid is not true (defaults to 200).
 void setMonitorValid(boolean monitorValid)
          If true the form monitors its valid state client-side and fires a looping event with that state.
 void setReader(Reader reader)
          A Reader (e.g.
 void setTimeout(int timeout)
          Timeout for form actions in seconds (default is 30 seconds).
 void setTrackResetOnLoad(boolean trackResetOnLoad)
          If set to true, form.reset() resets to the last loaded or setValues() data instead of when the form was first created.
 void setUrl(java.lang.String url)
          The URL to use for form actions if one isn't supplied in the action options.
 void setWaitMsgTarget(boolean waitMsgTarget)
          By default wait messages are displayed with Object.wait(long).
 void setWaitMsgTarget(java.lang.String waitMsgTarget)
          By default wait messages are displayed with Object.wait(long).
 void startMonitoring()
          Starts monitoring of the valid state of this form.
 void stopMonitoring()
          Stops monitoring of the valid state of this form.
 
Methods inherited from class com.gwtext.client.widgets.Panel
addButton, addListener, addTool, collapse, collapse, expand, expand, getBaseCls, getBody, getBodyStyle, getBodyWrap, getBottomToolbar, getCollapsedCls, getCollapseFirst, getFloating, getFooter, getFrameHeight, getFrameWidth, getHeader, getHtml, getIconCls, getInnerHeight, getInnerWidth, getMinButtonWidth, getShadowOffset, getTabCls, getTitle, getTopToolbar, getUpdateManager, isAnimCollapse, isAutoScroll, isBodyBorder, isBorder, isClosable, isCollapsed, isCollapsible, isFrame, isHeader, isHeaderAsText, isHideCollapseTool, isMaskDisabled, isShadow, isShim, isTitleCollapse, load, load, setAnimCollapse, setAutoLoad, setAutoLoad, setAutoScroll, setBaseCls, setBodyBorder, setBodyStyle, setBorder, setBottomToolbar, setBottomToolbar, setBottomToolbar, setButtons, setClosable, setCollapsed, setCollapsedCls, setCollapseFirst, setCollapsible, setContentEl, setDraggable, setFloating, setFooter, setFrame, setHeader, setHeaderAsText, setHideCollapseTool, setHtml, setIconCls, setMargins, setMargins, setMaskDisabled, setPaddings, setPaddings, setShadow, setShadow, setShadowOffset, setShim, setTabCls, setTitle, setTitle, setTitleCollapse, setTools, setTopToolbar, setTopToolbar, setTopToolbar, toggleCollapse, toggleCollapse
 
Methods inherited from class com.gwtext.client.widgets.Container
add, add, add, add, addListener, bubble, cascade, clear, doLayout, doLayout, findBy, findByID, findByType, getActiveItem, getActiveItemID, getAutoDestroy, getBufferResize, getComponent, getComponent, getComponents, getHideBorders, getItems, getLayout, getMonitorResize, insert, iterator, remove, remove, remove, remove, removeAll, removeAll, setActiveItem, setActiveItemID, setAutoDestroy, setBufferResize, setDefaults, setHideBorders, setLayout, setMonitorResize
 
Methods inherited from class com.gwtext.client.widgets.BoxComponent
addListener, doOnRender, doOnRender, getAutoHeight, getAutoWidth, getBox, getBox, getHeight, getPosition, getPosition, getSize, getWidth, setAutoHeight, setAutoWidth, setHeight, setHeight, setPagePosition, setPosition, setSize, setSize, setWidth, setWidth, syncSize, updateBox
 
Methods inherited from class com.gwtext.client.widgets.Component
addClass, addClassCreated, addEvent, addEvents, addListener, addListener, addListener, addPlugin, addStyleDependentName, addStyleName, afterRender, beforeDestroy, check, checkExtVer, cloneComponent, cloneComponent, cloneConfig, destroy, disable, enable, equals, error, findParentBy, findParentByType, fireEvent, focus, focus, focus, getApplyTo, getAttribute, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAutoShow, getCls, getComponentJS, getConfig, getConfigAsString, getCtCls, getDisabledClass, getEl, getElement, getElement, getElement, getHideMode, getHideParent, getId, getItemId, getJsObj, getOffsetHeight, getOffsetWidth, getOrCreateJsObj, getOwnerContainer, getRenderTo, getStateEvents, getStateId, getXTypes, hashCode, hide, isCreated, isDisabled, isHidden, isRendered, isVisible, isXType, isXType, onDestroy, purgeListeners, removeClass, removeStyleDependentName, removeStyleName, render, render, render, render, render, render, resumeEvents, setApplyTo, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoEl, setAutoEl, setAutoShow, setCls, setCtCls, setDisabled, setDisabledClass, setEl, setEl, setElement, setHideMode, setHideParent, setId, setRenderTo, setRenderToID, setStateEvents, setStateId, setStyle, setStyle, setStyleName, setStylePrimaryName, setVisible, show, suspendEvents, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
doAttachChildren, doDetachChildren, getParent, isAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
getAbsoluteLeft, getAbsoluteTop, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, setPixelSize, setStyleName, setStyleName, setStylePrimaryName, setVisible, sinkEvents, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormPanel

public FormPanel()
Create a new FormPanel.


FormPanel

public FormPanel(Position labelAlign)
Create a new FormPanel.

Parameters:
labelAlign - the label alignment

FormPanel

public FormPanel(com.google.gwt.core.client.JavaScriptObject jsObj)
Method Detail

getConfigPrototype

protected com.google.gwt.core.client.JavaScriptObject getConfigPrototype()
Overrides:
getConfigPrototype in class Panel

getXType

public java.lang.String getXType()
Description copied from class: Component
Gets the xtype for this component as registered with ComponentMgr. For a list of all available xtypes, see the Component javadocs.

 
 

TextField field = new TextField(); field.getXType() returns "textfield"

Overrides:
getXType in class Panel
Returns:
the xtype

initComponent

protected void initComponent()
Description copied from class: Component
This template method is called after the Component has been instantiated but before it's rendered. Subclasses can override it to provide any "constructor" type logic thats desired/

Overrides:
initComponent in class Component

create

protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
Overrides:
create in class Panel

startMonitoring

public void startMonitoring()
Starts monitoring of the valid state of this form. Usually this is done by passing the config option "monitorValid"


stopMonitoring

public void stopMonitoring()
Stops monitoring of the valid state of this form.


getForm

public Form getForm()
Provides access to the Form which this Panel contains. Note that this method must be called only after the FormPanel has been rendered. Returns null if called before the FormPanel has been rendered.. If you need to add a listener to he form prior to the FormPanel being rendered, call addFormListener(com.gwtext.client.widgets.form.event.FormListener) instead.

Returns:
the underlying Form, or null if FormPanel not rendered

getFields

public Field[] getFields()
Return all fields added to the FormPanel.

Returns:
the fields

addFormListener

public void addFormListener(FormListener listener)
Add a Form listener. Although you can add this listener on the Form directly, this method is useful to call when you would like to add a FormListener prior to the FormPaanel being rendered.

Parameters:
listener - the form listener

addListener

public void addListener(FormPanelListener listener)
Add a Form Panel Listener.

Parameters:
listener - the listener

setBaseParams

public void setBaseParams(UrlParam[] params)
                   throws java.lang.IllegalStateException
Parameters to pass with all requests. This effectively acts like Form hidden fields.

Parameters:
params - the base params
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setButtonAlign

public void setButtonAlign(Position buttonAlign)
                    throws java.lang.IllegalStateException
Valid values are "left," "center" and "right" (defaults to "center").

Overrides:
setButtonAlign in class Panel
Parameters:
buttonAlign - form button position
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setErrorReader

public void setErrorReader(Reader errorReader)
                    throws java.lang.IllegalStateException
A Reader (e.g. XmlReader) to be used to read data when reading validation errors on "submit" actions. This is completely optional as there is built-in support for processing JSON. The default JSON error reader expects the return value to be in the format
 
 {"success":false,"errors":[{"id":"email","msg":"Already exists"}, {"id":"username","msg":"Already taken"}]}
 
If the response is in XML format, one can set an XMLReader.

 //setup error reader to process from submit response from server
 RecordDef errorRecordDef = new RecordDef(new FieldDef[]{
     new StringFieldDef("id"),
     new StringFieldDef("msg")
 });

 XmlReader errorReader = new XmlReader("field", errorRecordDef);
 errorReader.setSuccess("@success");
 
and the corresponding XML return value must be in the format :

 <response success="false">
     <errors>
         <field>
             <id>email</id>
             <msg><![CDATA[
             Invalid email. <br /><i>Already exists </i>
          ]]></msg>
         </field>
         <field>
             <id>username</id>
             <msg><![CDATA[
             Invalid Username. <br /><i>Already taken </i>
          ]]></msg>
         </field>
     </errors>
 </response>
 

Parameters:
errorReader - the error reader
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setFileUpload

public void setFileUpload(boolean fileUpload)
                   throws java.lang.IllegalStateException
Set true if this form is a file upload.

Parameters:
fileUpload - true if file upload
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setHideLabels

public void setHideLabels(boolean hideLabels)
                   throws java.lang.IllegalStateException
Set to true to hide all field labels.

Parameters:
hideLabels - true to hide field labels
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setItemCls

public void setItemCls(java.lang.String itemCls)
                throws java.lang.IllegalStateException
A CSS class to apply to the x-form-item of fields. This property cascades to child containers.

Parameters:
itemCls - CSS class
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setLabelAlign

public void setLabelAlign(Position labelAlign)
                   throws java.lang.IllegalStateException
Valid values are "left," "top" and "right" (defaults to "left"). This property cascades to child containers if not set.

Parameters:
labelAlign - label alignment
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setLabelWidth

public void setLabelWidth(int labelWidth)
                   throws java.lang.IllegalStateException
The width of labels. This property cascades to child containers.

Parameters:
labelWidth - the label width
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setMethod

public void setMethod(Connection.Method method)
               throws java.lang.IllegalStateException
The request method to use (GET or POST) for form actions if one isn't supplied in the action options.

Parameters:
method - the request method
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setMinButtonWidth

public void setMinButtonWidth(int minButtonWidth)
                       throws java.lang.IllegalStateException
Minimum width of all buttons in pixels (defaults to 75).

Overrides:
setMinButtonWidth in class Panel
Parameters:
minButtonWidth - min button width
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setMonitorPoll

public void setMonitorPoll(int monitorPoll)
                    throws java.lang.IllegalStateException
The milliseconds to poll valid state, ignored if monitorValid is not true (defaults to 200).

Parameters:
monitorPoll - the monitor poll in milliseconds
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setMonitorValid

public void setMonitorValid(boolean monitorValid)
                     throws java.lang.IllegalStateException
If true the form monitors its valid state client-side and fires a looping event with that state. This is required to bind buttons to the valid state using the config value formBind:true on the button.

Parameters:
monitorValid - true to enable monitoring
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setReader

public void setReader(Reader reader)
               throws java.lang.IllegalStateException
A Reader (e.g. XmlReader) to be used to read data when executing "load" actions. This is optional as there is built-in support for processing JSON.

Parameters:
reader - the load Reader
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setTimeout

public void setTimeout(int timeout)
                throws java.lang.IllegalStateException
Timeout for form actions in seconds (default is 30 seconds).

Parameters:
timeout - timeout in seconds
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setTrackResetOnLoad

public void setTrackResetOnLoad(boolean trackResetOnLoad)
                         throws java.lang.IllegalStateException
If set to true, form.reset() resets to the last loaded or setValues() data instead of when the form was first created.

Parameters:
trackResetOnLoad - true to track reset on load
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setUrl

public void setUrl(java.lang.String url)
            throws java.lang.IllegalStateException
The URL to use for form actions if one isn't supplied in the action options.

Parameters:
url - the url
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setWaitMsgTarget

public void setWaitMsgTarget(java.lang.String waitMsgTarget)
                      throws java.lang.IllegalStateException
By default wait messages are displayed with Object.wait(long). You can target a specific element by passing its id.

Parameters:
waitMsgTarget - ID of the Element to mask
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setWaitMsgTarget

public void setWaitMsgTarget(boolean waitMsgTarget)
                      throws java.lang.IllegalStateException
By default wait messages are displayed with Object.wait(long). You can mask the form itself by passing in true.

Parameters:
waitMsgTarget - true to mask the form
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered