org.zkoss.jsf.zul.impl
Class BranchInput

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by org.zkoss.jsf.zul.impl.AbstractComponent
              extended by org.zkoss.jsf.zul.impl.LeafComponent
                  extended by org.zkoss.jsf.zul.impl.BranchComponent
                      extended by org.zkoss.jsf.zul.impl.BranchOutput
                          extended by org.zkoss.jsf.zul.impl.BranchInput
All Implemented Interfaces:
javax.faces.component.EditableValueHolder, javax.faces.component.StateHolder, javax.faces.component.ValueHolder, ClientInputSupport, ValueHolderSupport
Direct Known Subclasses:
Bandbox, BaseCalendar, BaseCheckbox, BaseDatebox, BaseDecimalbox, BaseDoublebox, BaseIntbox, BaseListbox, BaseRadiogroup, BaseSlider, BaseTimebox, BaseTree, Combobox, Textbox

public abstract class BranchInput
extends BranchOutput
implements javax.faces.component.EditableValueHolder, ClientInputSupport

The skeletal class used to implement the ZULJSF components which needs to support EditableValueHolder.
Components should be declared nested under Page. see Javadoc of JSF Specification

Author:
Dennis.Chen

Field Summary
 
Fields inherited from class org.zkoss.jsf.zul.impl.LeafComponent
_compAttrMap, _composer
 
Fields inherited from class javax.faces.component.UIComponent
bindings
 
Constructor Summary
BranchInput()
           
 
Method Summary
protected  void addErrorMessage(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String messageId, java.lang.Object[] parms)
           
 void addValidator(javax.faces.validator.Validator validator)
           
 void addValueChangeListener(javax.faces.event.ValueChangeListener listener)
           
protected  void afterZULComponentComposed(org.zkoss.zk.ui.Component zulcomp)
          Override Method, if instance implements ClientInputSupport (for now, it is always ), then i will try to set the name/value which get from ClientInputSupport into zulcomp.
 void broadcast(javax.faces.event.FacesEvent event)
           
protected  void clientInputDecode(javax.faces.context.FacesContext context)
          Decode value in request's parameter. call by decode(javax.faces.context.FacesContext)
protected  boolean compareValues(java.lang.Object previous, java.lang.Object value)
           
 void decode(javax.faces.context.FacesContext context)
           
protected  java.lang.Object getConvertedValue(javax.faces.context.FacesContext context, java.lang.Object submittedValue)
          Convert the provided object to the desired value.
 java.lang.String getInputAttributeName()
          Return ZUL Component attribute name which can handler the submition of input.
 java.lang.String getInputAttributeValue()
          Return ZUL Component attribute value which can handler the submition of input.
 java.lang.Object getSubmittedValue()
           
 javax.faces.el.MethodBinding getValidator()
           
 javax.faces.validator.Validator[] getValidators()
           
 javax.faces.el.MethodBinding getValueChangeListener()
           
 javax.faces.event.ValueChangeListener[] getValueChangeListeners()
           
 boolean isImmediate()
           
 boolean isRequired()
           
 boolean isValid()
           
 void processDecodes(javax.faces.context.FacesContext context)
          Set the "submitted value" of this component from the relevant data in the current servlet request object.
 void processUpdates(javax.faces.context.FacesContext context)
           
 void processValidators(javax.faces.context.FacesContext context)
           In addition to the standard processValidators behavior inherited from UIComponentBase, calls validate() if the immediate property is false (which is the default); if the component is invalid afterwards, calls FacesContext.renderResponse().
 void removeValidator(javax.faces.validator.Validator validator)
           
 void removeValueChangeListener(javax.faces.event.ValueChangeListener listener)
           
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
          Override Method, restore the state of this component.
 java.lang.Object saveState(javax.faces.context.FacesContext context)
          Override Method, save the state of this component.
 void setImmediate(boolean immediate)
           
 void setRequired(boolean required)
           
 void setSubmittedValue(java.lang.Object submittedValue)
           
 void setValid(boolean valid)
           
 void setValidator(javax.faces.el.MethodBinding validatorBinding)
           
 void setValueChangeListener(javax.faces.el.MethodBinding valueChangeMethod)
           
 void updateModel(javax.faces.context.FacesContext context)
           
 void validate(javax.faces.context.FacesContext context)
          Determine whether the new value is valid, and queue a ValueChangeEvent if necessary.
protected  void validateValue(javax.faces.context.FacesContext context, java.lang.Object convertedValue)
           
 
Methods inherited from class org.zkoss.jsf.zul.impl.BranchOutput
getConverter, getLocalValue, getMappedAttributeName, getValue, isLocalValueSet, setConverter, setLocalValueSet, setValue, transferValueForAttribute
 
Methods inherited from class org.zkoss.jsf.zul.impl.BranchComponent
loadZULTree
 
Methods inherited from class org.zkoss.jsf.zul.impl.LeafComponent
addZULDynamicAttribute, encodeBegin, encodeChildren, encodeEnd, evaluateDynaAttributes, getAttributeValue, getComponentDefName, getComponentInfo, getForward, getRendersChildren, getUse, getZULComponent, setAttributeValue, setForward, setId, setUse, setZULDynamicAttribute
 
Methods inherited from class org.zkoss.jsf.zul.impl.AbstractComponent
findAncestorWithClass, getBodyContent, getFacesContext, getFamily, getIf, getUnless, isEffective, isSuppressed, restoreAttachedMapState, saveAttachedMapState, setBodyContent, setIf, setSuppressed, setUnless
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId, getValueExpression, setValueExpression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.EditableValueHolder
isLocalValueSet, setLocalValueSet
 
Methods inherited from interface javax.faces.component.ValueHolder
getConverter, getLocalValue, getValue, setConverter, setValue
 

Constructor Detail

BranchInput

public BranchInput()
Method Detail

getSubmittedValue

public java.lang.Object getSubmittedValue()
Specified by:
getSubmittedValue in interface javax.faces.component.EditableValueHolder

setSubmittedValue

public void setSubmittedValue(java.lang.Object submittedValue)
Specified by:
setSubmittedValue in interface javax.faces.component.EditableValueHolder

isRequired

public boolean isRequired()
Specified by:
isRequired in interface javax.faces.component.EditableValueHolder

isValid

public boolean isValid()
Specified by:
isValid in interface javax.faces.component.EditableValueHolder

setValid

public void setValid(boolean valid)
Specified by:
setValid in interface javax.faces.component.EditableValueHolder

setRequired

public void setRequired(boolean required)
Specified by:
setRequired in interface javax.faces.component.EditableValueHolder

isImmediate

public boolean isImmediate()
Specified by:
isImmediate in interface javax.faces.component.EditableValueHolder

setImmediate

public void setImmediate(boolean immediate)
Specified by:
setImmediate in interface javax.faces.component.EditableValueHolder

getValidator

public javax.faces.el.MethodBinding getValidator()
Specified by:
getValidator in interface javax.faces.component.EditableValueHolder

setValidator

public void setValidator(javax.faces.el.MethodBinding validatorBinding)
Specified by:
setValidator in interface javax.faces.component.EditableValueHolder

getValueChangeListener

public javax.faces.el.MethodBinding getValueChangeListener()
Specified by:
getValueChangeListener in interface javax.faces.component.EditableValueHolder

setValueChangeListener

public void setValueChangeListener(javax.faces.el.MethodBinding valueChangeMethod)
Specified by:
setValueChangeListener in interface javax.faces.component.EditableValueHolder

processDecodes

public void processDecodes(javax.faces.context.FacesContext context)
Set the "submitted value" of this component from the relevant data in the current servlet request object.

If this component is not rendered, then do nothing; no output would have been sent to the client so no input is expected.

Invoke the inherited functionality, which typically invokes the renderer associated with this component to extract and set this component's "submitted value".

If this component is marked "immediate", then immediately apply validation to the submitted value found. On error, call context method "renderResponse" which will force processing to leap to the "render response" phase as soon as the "decode" step has completed for all other components.

Overrides:
processDecodes in class javax.faces.component.UIComponentBase

processValidators

public void processValidators(javax.faces.context.FacesContext context)

In addition to the standard processValidators behavior inherited from UIComponentBase, calls validate() if the immediate property is false (which is the default); if the component is invalid afterwards, calls FacesContext.renderResponse(). If a RuntimeException is thrown during validation processing, calls FacesContext.renderResponse() and re-throw the exception.

Overrides:
processValidators in class javax.faces.component.UIComponentBase
Throws:
java.lang.NullPointerException

processUpdates

public void processUpdates(javax.faces.context.FacesContext context)
Overrides:
processUpdates in class javax.faces.component.UIComponentBase

decode

public void decode(javax.faces.context.FacesContext context)
Overrides:
decode in class javax.faces.component.UIComponentBase
Throws:
java.lang.NullPointerException

broadcast

public void broadcast(javax.faces.event.FacesEvent event)
               throws javax.faces.event.AbortProcessingException
Overrides:
broadcast in class javax.faces.component.UIComponentBase
Throws:
javax.faces.event.AbortProcessingException

updateModel

public void updateModel(javax.faces.context.FacesContext context)

validateValue

protected void validateValue(javax.faces.context.FacesContext context,
                             java.lang.Object convertedValue)

validate

public void validate(javax.faces.context.FacesContext context)
Determine whether the new value is valid, and queue a ValueChangeEvent if necessary.

The "submitted value" is converted to the necessary type; conversion failure is reported as an error and validation processing terminates for this component. See documentation for method getConvertedValue for details on the conversion process.

Any validators attached to this component are then run, passing the converted value.

The old value of this component is then fetched (possibly involving the evaluation of a value-binding expression, ie invoking a method on a user object). The old value is compared to the new validated value, and if they are different then a ValueChangeEvent is queued for later processing.

On successful completion of this method:


getConvertedValue

protected java.lang.Object getConvertedValue(javax.faces.context.FacesContext context,
                                             java.lang.Object submittedValue)
Convert the provided object to the desired value.

If there is a renderer for this component, then call the renderer's getConvertedValue method. While this can of course be implemented in any way the renderer desires, it typically performs exactly the same processing that this method would have done anyway (ie that described below for the no-renderer case).

Otherwise:


compareValues

protected boolean compareValues(java.lang.Object previous,
                                java.lang.Object value)

addValidator

public void addValidator(javax.faces.validator.Validator validator)
Specified by:
addValidator in interface javax.faces.component.EditableValueHolder

getValidators

public javax.faces.validator.Validator[] getValidators()
Specified by:
getValidators in interface javax.faces.component.EditableValueHolder

removeValidator

public void removeValidator(javax.faces.validator.Validator validator)
Specified by:
removeValidator in interface javax.faces.component.EditableValueHolder

addValueChangeListener

public void addValueChangeListener(javax.faces.event.ValueChangeListener listener)
Specified by:
addValueChangeListener in interface javax.faces.component.EditableValueHolder

getValueChangeListeners

public javax.faces.event.ValueChangeListener[] getValueChangeListeners()
Specified by:
getValueChangeListeners in interface javax.faces.component.EditableValueHolder

removeValueChangeListener

public void removeValueChangeListener(javax.faces.event.ValueChangeListener listener)
Specified by:
removeValueChangeListener in interface javax.faces.component.EditableValueHolder

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
Override Method, save the state of this component.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class BranchOutput

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
Override Method, restore the state of this component.

Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class BranchOutput

afterZULComponentComposed

protected void afterZULComponentComposed(org.zkoss.zk.ui.Component zulcomp)
Override Method, if instance implements ClientInputSupport (for now, it is always ), then i will try to set the name/value which get from ClientInputSupport into zulcomp. For Example of TextboxComponent, a name=form:compid will set to zulcomp and the result in HTML will likes (<input id="z_fm_2c" type="text" name="helloForm:txt1" value="0" z.type="zul.widget.Txbox"/> ). And then , after form submit, I can decode the submitted value from request by name "helloForm:txt1".

Overrides:
afterZULComponentComposed in class BranchOutput

getInputAttributeName

public java.lang.String getInputAttributeName()
Return ZUL Component attribute name which can handler the submition of input. Note : Default is "name"

Specified by:
getInputAttributeName in interface ClientInputSupport
Returns:
name of attribute
See Also:
ClientInputSupport

getInputAttributeValue

public java.lang.String getInputAttributeValue()
Return ZUL Component attribute value which can handler the submition of input.

Specified by:
getInputAttributeValue in interface ClientInputSupport
Returns:
value of attribute
See Also:
ClientInputSupport, UIComponent.getClientId(FacesContext)

clientInputDecode

protected void clientInputDecode(javax.faces.context.FacesContext context)
Decode value in request's parameter. call by decode(javax.faces.context.FacesContext)


addErrorMessage

protected void addErrorMessage(javax.faces.context.FacesContext context,
                               javax.faces.component.UIComponent component,
                               java.lang.String messageId,
                               java.lang.Object[] parms)


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.