Class JSFUtils
- java.lang.Object
-
- org.springframework.extensions.webscripts.ui.common.JSFUtils
-
public final class JSFUtils extends java.lang.ObjectClass containing misc helper methods for managing JSF Components. NOTE: Extracted from org.alfresco.web.ui.common.Utils;- Author:
- Kevin Roast
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringbuildImageTag(javax.faces.context.FacesContext context, java.lang.String image, int width, int height, java.lang.String alt)Build a context path safe image tag for the supplied image path.static java.lang.StringbuildImageTag(javax.faces.context.FacesContext context, java.lang.String image, int width, int height, java.lang.String alt, java.lang.String onclick)Build a context path safe image tag for the supplied image path.static java.lang.StringbuildImageTag(javax.faces.context.FacesContext context, java.lang.String image, int width, int height, java.lang.String alt, java.lang.String onclick, java.lang.String verticalAlign)Build a context path safe image tag for the supplied image path.static java.lang.StringbuildImageTag(javax.faces.context.FacesContext context, java.lang.String image, java.lang.String alt)Build a context path safe image tag for the supplied image path.static java.lang.StringbuildImageTag(javax.faces.context.FacesContext context, java.lang.String image, java.lang.String alt, java.lang.String verticalAlign)Build a context path safe image tag for the supplied image path.static voidencodeRecursive(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)Helper to recursively render a component and it's child componentsstatic java.lang.StringgenerateFormSubmit(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)Generate the JavaScript to submit the parent Form.static java.lang.StringgenerateFormSubmit(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String fieldId, java.lang.String fieldValue)Generate the JavaScript to submit set the specified hidden Form field to the supplied value and submit the parent Form.static java.lang.StringgenerateFormSubmit(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String fieldId, java.lang.String fieldValue, boolean valueIsParam, java.util.Map<java.lang.String,java.lang.String> params)Generate the JavaScript to submit set the specified hidden Form field to the supplied value and submit the parent Form.static java.lang.StringgenerateFormSubmit(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String fieldId, java.lang.String fieldValue, java.util.Map<java.lang.String,java.lang.String> params)Generate the JavaScript to submit set the specified hidden Form field to the supplied value and submit the parent Form.static java.lang.StringgetActionHiddenFieldName(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)Get the hidden field name for any action component.static javax.faces.component.UIFormgetParentForm(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)Return the parent UIForm component for the specified UIComponentstatic javax.faces.component.UIComponentgetParentNamingContainer(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)Return the parent UIComponent implementing the NamingContainer interface for the specified UIComponent.static booleanisComponentDisabledOrReadOnly(javax.faces.component.UIComponent component)Determines whether the given component is disabled or readonlystatic voidoutputAttribute(javax.faces.context.ResponseWriter out, java.lang.Object attr, java.lang.String mapping)Helper to output an attribute to the output streamstatic voidprocessActionMethod(javax.faces.context.FacesContext context, javax.faces.el.MethodBinding method, javax.faces.event.ActionEvent event)Invoke the method encapsulated by the supplied MethodBinding
-
-
-
Method Detail
-
outputAttribute
public static void outputAttribute(javax.faces.context.ResponseWriter out, java.lang.Object attr, java.lang.String mapping) throws java.io.IOExceptionHelper to output an attribute to the output stream- Parameters:
out- ResponseWriterattr- attribute value object (cannot be null)mapping- mapping to output as e.g. style="..."- Throws:
java.io.IOException
-
getActionHiddenFieldName
public static java.lang.String getActionHiddenFieldName(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)Get the hidden field name for any action component. All components that wish to simply encode a form value with their client ID can reuse the same hidden field within the parent form. NOTE: components which use this method must only encode their client ID as the value and nothing else! Build a shared field name from the parent form name and the string "act".- Returns:
- hidden field name shared by all action components within the Form.
-
encodeRecursive
public static void encodeRecursive(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component) throws java.io.IOExceptionHelper to recursively render a component and it's child components- Parameters:
context- FacesContextcomponent- UIComponent- Throws:
java.io.IOException
-
generateFormSubmit
public static java.lang.String generateFormSubmit(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String fieldId, java.lang.String fieldValue)Generate the JavaScript to submit set the specified hidden Form field to the supplied value and submit the parent Form. NOTE: the supplied hidden field name is added to the Form Renderer map for output.- Parameters:
context- FacesContextcomponent- UIComponent to generate JavaScript forfieldId- Hidden field id to set value forfieldValue- Hidden field value to set hidden field too on submit- Returns:
- JavaScript event code
-
generateFormSubmit
public static java.lang.String generateFormSubmit(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String fieldId, java.lang.String fieldValue, java.util.Map<java.lang.String,java.lang.String> params)Generate the JavaScript to submit set the specified hidden Form field to the supplied value and submit the parent Form. NOTE: the supplied hidden field name is added to the Form Renderer map for output.- Parameters:
context- FacesContextcomponent- UIComponent to generate JavaScript forfieldId- Hidden field id to set value forfieldValue- Hidden field value to set hidden field too on submitparams- Optional map of param name/values to output- Returns:
- JavaScript event code
-
generateFormSubmit
public static java.lang.String generateFormSubmit(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String fieldId, java.lang.String fieldValue, boolean valueIsParam, java.util.Map<java.lang.String,java.lang.String> params)Generate the JavaScript to submit set the specified hidden Form field to the supplied value and submit the parent Form. NOTE: the supplied hidden field name is added to the Form Renderer map for output.- Parameters:
context- FacesContextcomponent- UIComponent to generate JavaScript forfieldId- Hidden field id to set value forfieldValue- Hidden field value to set hidden field too on submitvalueIsParam- Determines whether the fieldValue parameter should be treated as a parameter in the generated JavaScript, false will treat the value i.e. surround it with single quotesparams- Optional map of param name/values to output- Returns:
- JavaScript event code
-
generateFormSubmit
public static java.lang.String generateFormSubmit(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)Generate the JavaScript to submit the parent Form.- Parameters:
context- FacesContextcomponent- UIComponent to generate JavaScript for- Returns:
- JavaScript event code
-
buildImageTag
public static java.lang.String buildImageTag(javax.faces.context.FacesContext context, java.lang.String image, int width, int height, java.lang.String alt, java.lang.String onclick)Build a context path safe image tag for the supplied image path. Image path should be supplied with a leading slash '/'.- Parameters:
context- FacesContextimage- The local image path from the web folder with leading slash '/'width- Width in pixelsheight- Height in pixelsalt- Optional alt/title textonclick- JavaScript onclick event handler code- Returns:
- Populated
imgtag
-
buildImageTag
public static java.lang.String buildImageTag(javax.faces.context.FacesContext context, java.lang.String image, int width, int height, java.lang.String alt, java.lang.String onclick, java.lang.String verticalAlign)Build a context path safe image tag for the supplied image path. Image path should be supplied with a leading slash '/'.- Parameters:
context- FacesContextimage- The local image path from the web folder with leading slash '/'width- Width in pixelsheight- Height in pixelsalt- Optional alt/title textonclick- JavaScript onclick event handler codeverticalAlign- Optional HTML alignment value- Returns:
- Populated
imgtag
-
buildImageTag
public static java.lang.String buildImageTag(javax.faces.context.FacesContext context, java.lang.String image, int width, int height, java.lang.String alt)Build a context path safe image tag for the supplied image path. Image path should be supplied with a leading slash '/'.- Parameters:
context- FacesContextimage- The local image path from the web folder with leading slash '/'width- Width in pixelsheight- Height in pixelsalt- Optional alt/title text- Returns:
- Populated
imgtag
-
buildImageTag
public static java.lang.String buildImageTag(javax.faces.context.FacesContext context, java.lang.String image, java.lang.String alt)Build a context path safe image tag for the supplied image path. Image path should be supplied with a leading slash '/'.- Parameters:
context- FacesContextimage- The local image path from the web folder with leading slash '/'alt- Optional alt/title text- Returns:
- Populated
imgtag
-
buildImageTag
public static java.lang.String buildImageTag(javax.faces.context.FacesContext context, java.lang.String image, java.lang.String alt, java.lang.String verticalAlign)Build a context path safe image tag for the supplied image path. Image path should be supplied with a leading slash '/'.- Parameters:
context- FacesContextimage- The local image path from the web folder with leading slash '/'alt- Optional alt/title textverticalAlign- Optional HTML alignment value- Returns:
- Populated
imgtag
-
getParentForm
public static javax.faces.component.UIForm getParentForm(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)Return the parent UIForm component for the specified UIComponent- Parameters:
context- FaceContextcomponent- The UIComponent to find parent Form for- Returns:
- UIForm parent or null if none found in hiearachy
-
getParentNamingContainer
public static javax.faces.component.UIComponent getParentNamingContainer(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)Return the parent UIComponent implementing the NamingContainer interface for the specified UIComponent.- Parameters:
context- FaceContextcomponent- The UIComponent to find parent Form for- Returns:
- NamingContainer parent or null if none found in hiearachy
-
isComponentDisabledOrReadOnly
public static boolean isComponentDisabledOrReadOnly(javax.faces.component.UIComponent component)
Determines whether the given component is disabled or readonly- Parameters:
component- The component to test- Returns:
- true if the component is either disabled or set to readonly
-
processActionMethod
public static void processActionMethod(javax.faces.context.FacesContext context, javax.faces.el.MethodBinding method, javax.faces.event.ActionEvent event)Invoke the method encapsulated by the supplied MethodBinding- Parameters:
context- FacesContextmethod- MethodBinding to invokeevent- ActionEvent to pass to the method of signature: public void myMethodName(ActionEvent event)
-
-