org.apache.shale.validator.faces
Class ValidatorScript

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by org.apache.shale.validator.faces.ValidatorScript
All Implemented Interfaces:
javax.faces.component.StateHolder

public class ValidatorScript
extends javax.faces.component.UIComponentBase

A JSF component that encodes JavaScript for all client-side validations specified in the same JSP page (with s:commonsValidator. $Id: ValidatorScript.java 464373 2006-10-16 04:21:54Z rahul $


Constructor Summary
ValidatorScript()
           
 
Method Summary
 void encodeBegin(javax.faces.context.FacesContext context)
          Begin encoding for this component.
 String findForm(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Traverses up the tree looking for the owning form.
 String getFamily()
          Returns the component's family.
 String getFunctionName()
          Return the value of the functionName property.
 String getRendererType()
          The component renders itself; therefore, this method returns null.
 void restoreState(javax.faces.context.FacesContext context, Object state)
          Restore the state of this component.
 Object saveState(javax.faces.context.FacesContext context)
          Save the state of this component.
 void setFunctionName(String functionName)
          Set the value of the functionName property.
 void writeJavaScriptParams(javax.faces.context.ResponseWriter writer, javax.faces.context.FacesContext context, String id, CommonsValidator v)
          Writes the JavaScript parameters for the client-side validation code.
 
Methods inherited from class javax.faces.component.UIComponentBase
addFacesListener, broadcast, decode, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendersChildren, getValueBinding, isRendered, isTransient, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatorScript

public ValidatorScript()
Method Detail

getRendererType

public String getRendererType()

The component renders itself; therefore, this method returns null.

Overrides:
getRendererType in class javax.faces.component.UIComponentBase
Returns:
null component handles renderering

getFamily

public String getFamily()

Returns the component's family. In this case, the component is not associated with a family, so this method returns null.

Specified by:
getFamily in class javax.faces.component.UIComponent
Returns:
component's family

getFunctionName

public String getFunctionName()

Return the value of the functionName property.

Returns:
callback function from the form's onsubmit.

setFunctionName

public void setFunctionName(String functionName)

Set the value of the functionName property.

Parameters:
functionName - The new function name

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         Object state)

Restore the state of this component.

Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class javax.faces.component.UIComponentBase
Parameters:
context - FacesContext for the current request
state - State to be restored

saveState

public Object saveState(javax.faces.context.FacesContext context)

Save the state of this component.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class javax.faces.component.UIComponentBase
Parameters:
context - FacesContext for the current request
Returns:
component's state

writeJavaScriptParams

public void writeJavaScriptParams(javax.faces.context.ResponseWriter writer,
                                  javax.faces.context.FacesContext context,
                                  String id,
                                  CommonsValidator v)
                           throws IOException

Writes the JavaScript parameters for the client-side validation code.

Parameters:
writer - A response writer
context - The FacesContext for this request
id - The clientId of the owning component
v - The Commons validator
Throws:
IOException - if an input/output error occurs

findForm

public String findForm(javax.faces.context.FacesContext context,
                       javax.faces.component.UIComponent component)

Traverses up the tree looking for the owning form. Returns the parent UIForm or empty string if one is not found.

Parameters:
context - FacesContext for the current request
component - UIForm parent of the component.
Returns:
client id of the parent form component

encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context)
                 throws IOException

Begin encoding for this component. This method finds all Commons validators attached to components in the current component hierarchy and writes out JavaScript code to invoke those validators, in turn.

Overrides:
encodeBegin in class javax.faces.component.UIComponentBase
Parameters:
context - The FacesContext for this request
Throws:
IOException - if an input/output error occurs


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.