org.javalid.external.jsf
Interface JsfFacade

All Known Implementing Classes:
JsfFacadeImpl_11, JsfFacadeImpl_12

public interface JsfFacade

This interface is implemented by two classes, each for a different JSF version (1.1 and 1.2). The implementing classes are responsible for creating / getting / setting ValueBinding (1.1) or ValueExpression's. This way the version of JSF is abstracted away, which allows us to use JaValid in both environments.

The first time JsfSupport is loaded, it attempts to determine the proper version and initializes the appropriate class. If that fails, it does it the first time this class is needed.

Since:
1.0.1
Version:
1.0
Author:
M.Reuvers

Field Summary
static java.lang.String JSF_FACADE_CLASS_11
          The class implementing the facade for JSF 1.1
static java.lang.String JSF_FACADE_CLASS_12
          The class implementing the facade for JSF 1.2
 
Method Summary
 java.lang.String getExpressionStringForComponentProperty(javax.faces.component.UIComponent component, java.lang.String propertyName)
          Returns the expression string from either the ValueBinding/ValueExpression that is resolved from the component using given property.
 java.lang.Object getValueForComponentProperty(javax.faces.context.FacesContext ctx, javax.faces.component.UIComponent component, java.lang.String propertyName)
          Gets the value of a property from a component.
 java.lang.Object getValueForExpression(javax.faces.context.FacesContext ctx, java.lang.String expression)
          For given expression, lookups ValueBinding / ValueExpression and retrieves the value from it.
 void setValueForComponentProperty(javax.faces.context.FacesContext ctx, javax.faces.component.UIComponent component, java.lang.String propertyName, java.lang.Object newValue)
          Sets a new value for given property from a component.
 void setValueForComponentPropertyWithExpression(javax.faces.context.FacesContext ctx, javax.faces.component.UIComponent component, java.lang.String propertyName, java.lang.String expressionValue)
          Sets a new value for given property from a component.
 void setValueForExpression(javax.faces.context.FacesContext ctx, java.lang.String expression, java.lang.Object newValue)
          For given expression, lookups ValueBinding / ValueExpression and sets the newValue on it.
 

Field Detail

JSF_FACADE_CLASS_11

static final java.lang.String JSF_FACADE_CLASS_11
The class implementing the facade for JSF 1.1

See Also:
Constant Field Values

JSF_FACADE_CLASS_12

static final java.lang.String JSF_FACADE_CLASS_12
The class implementing the facade for JSF 1.2

See Also:
Constant Field Values
Method Detail

getValueForExpression

java.lang.Object getValueForExpression(javax.faces.context.FacesContext ctx,
                                       java.lang.String expression)
For given expression, lookups ValueBinding / ValueExpression and retrieves the value from it. If no binding / expression is found (null), so no value can be retrieved from it, a JavalidException is raised. Note that null can be returned, but that would mean we found a ValueBinding / ValueExpression except the value from it was null. If an exception occurs for any other reason a JavalidException is raised.

Parameters:
ctx - The current facescontext
expression - The expression to resolve
Returns:
Object from ValueBinding / ValueExpression

setValueForExpression

void setValueForExpression(javax.faces.context.FacesContext ctx,
                           java.lang.String expression,
                           java.lang.Object newValue)
For given expression, lookups ValueBinding / ValueExpression and sets the newValue on it. If no binding/expression is found (null), thus no value can be set on it, a JavalidException is raised. If an exception occurs for any other reason a JavalidException is raised.

Parameters:
ctx - The current facescontext
expression - The expression to resolve
newValue - The new value to set on the valuebinding / valueexpression.

getValueForComponentProperty

java.lang.Object getValueForComponentProperty(javax.faces.context.FacesContext ctx,
                                              javax.faces.component.UIComponent component,
                                              java.lang.String propertyName)
Gets the value of a property from a component. For instance on a JSF input component, you can retrieve the value by setting the property to 'value'. Raises JavalidException if an error occurs.

Parameters:
ctx - The context
component - The actual component to get it from
propertyName - The property name
Returns:
The actual value

setValueForComponentProperty

void setValueForComponentProperty(javax.faces.context.FacesContext ctx,
                                  javax.faces.component.UIComponent component,
                                  java.lang.String propertyName,
                                  java.lang.Object newValue)
Sets a new value for given property from a component. For instance on a JSF input component, you can set the value by setting the property to 'value' and give the newValue for it.

Parameters:
ctx - The context
component - The actual component to get the property and set the value on
propertyName - Property name
newValue - The new value

setValueForComponentPropertyWithExpression

void setValueForComponentPropertyWithExpression(javax.faces.context.FacesContext ctx,
                                                javax.faces.component.UIComponent component,
                                                java.lang.String propertyName,
                                                java.lang.String expressionValue)
Sets a new value for given property from a component. For instance on a JSF input component, you can set the value by setting the property to 'value' and give an expression for it, which will be resolved.

Parameters:
ctx - The context
component - The actual component to get the property and set the value on
propertyName - Property name
expressionValue - The expression value

getExpressionStringForComponentProperty

java.lang.String getExpressionStringForComponentProperty(javax.faces.component.UIComponent component,
                                                         java.lang.String propertyName)
Returns the expression string from either the ValueBinding/ValueExpression that is resolved from the component using given property. E.g. <h:inputText value=#{bean.name}"" /> would return #{bean.name} if the property value was asked for.

Parameters:
component - The component
propertyName - The property
Returns:
Expression String