Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.platform.forms.layout.facelets
Class FaceletHandlerHelper

java.lang.Object
  extended by org.nuxeo.ecm.platform.forms.layout.facelets.FaceletHandlerHelper

public final class FaceletHandlerHelper
extends java.lang.Object

Helpers for layout/widget handlers.

Helps generating custom tag handlers and custom tag attributes.

Author:
Anahide Tchertchian

Field Summary
static java.lang.String LAYOUT_ID_PREFIX
           
static java.lang.String MESSAGE_ID_SUFFIX
           
static java.lang.String WIDGET_ID_PREFIX
           
 
Constructor Summary
FaceletHandlerHelper(com.sun.facelets.FaceletContext context, com.sun.facelets.tag.TagConfig tagConfig)
           
 
Method Summary
static com.sun.facelets.tag.TagAttributes addTagAttribute(com.sun.facelets.tag.TagAttributes orig, com.sun.facelets.tag.TagAttribute newAttr)
           
 com.sun.facelets.tag.TagAttributes copyTagAttributes(java.lang.String id, java.lang.String... names)
          Copies tag attributes with given names from the tag config, using given id as base for the id attribute.
 com.sun.facelets.tag.TagAttribute createAttribute(java.lang.String name, java.lang.String value)
          Creates an attribute with given name and value.
 com.sun.facelets.tag.TagAttribute createIdAttribute(java.lang.String base)
          Creates a unique id and returns corresponding attribute, using given string id as base.
 java.lang.String generateLayoutId(java.lang.String layoutName)
           
 java.lang.String generateMessageId(java.lang.String widgetName)
           
 java.lang.String generateUniqueId()
          Returns a id unique within the facelet context.
 java.lang.String generateUniqueId(java.lang.String base)
          Returns a id unique within the facelet context using given id as base.
 java.lang.String generateValidIdString(java.lang.String base)
           
 java.lang.String generateWidgetId(java.lang.String widgetName)
           
 com.sun.facelets.FaceletHandler getAliasTagHandler(java.util.Map<java.lang.String,javax.el.ValueExpression> variables, com.sun.facelets.FaceletHandler nextHandler)
           
 com.sun.facelets.tag.jsf.ConvertHandler getConvertHandler(com.sun.facelets.tag.TagAttributes attributes, com.sun.facelets.FaceletHandler nextHandler, java.lang.String converterId)
          Returns a convert handler for this configuration.
 com.sun.facelets.tag.jsf.ComponentHandler getErrorComponentHandler(java.lang.String errorMessage)
          Component handler that displays an error on interface
 com.sun.facelets.tag.jsf.ComponentHandler getHtmlComponentHandler(com.sun.facelets.tag.TagAttributes attributes, com.sun.facelets.FaceletHandler nextHandler, java.lang.String componentType, java.lang.String rendererType)
          Returns an html component handler for this configuration.
 com.sun.facelets.tag.jsf.ComponentHandler getMessageComponentHandler(java.lang.String id, java.lang.String forId, java.lang.String styleClass)
          Returns a message component handler with given attributes.
static com.sun.facelets.tag.TagAttributes getTagAttributes(java.util.List<com.sun.facelets.tag.TagAttribute> attributes)
           
 com.sun.facelets.tag.TagAttributes getTagAttributes(java.lang.String id, Widget widget)
          Creates tag attributes using given widget properties and field definitions.
static com.sun.facelets.tag.TagAttributes getTagAttributes(com.sun.facelets.tag.TagAttribute... attributes)
           
 com.sun.facelets.tag.jsf.ValidateHandler getValidateHandler(com.sun.facelets.tag.TagAttributes attributes, com.sun.facelets.FaceletHandler nextHandler, java.lang.String validatorId)
          Returns a validate handler for this configuration.
 boolean shouldCreateReferenceAttribute(java.lang.String key, java.io.Serializable value)
          Returns true if a reference tag attribute should be created for given property value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYOUT_ID_PREFIX

public static final java.lang.String LAYOUT_ID_PREFIX
See Also:
Constant Field Values

WIDGET_ID_PREFIX

public static final java.lang.String WIDGET_ID_PREFIX
See Also:
Constant Field Values

MESSAGE_ID_SUFFIX

public static final java.lang.String MESSAGE_ID_SUFFIX
See Also:
Constant Field Values
Constructor Detail

FaceletHandlerHelper

public FaceletHandlerHelper(com.sun.facelets.FaceletContext context,
                            com.sun.facelets.tag.TagConfig tagConfig)
Method Detail

generateUniqueId

public java.lang.String generateUniqueId()
Returns a id unique within the facelet context.


generateUniqueId

public java.lang.String generateUniqueId(java.lang.String base)
Returns a id unique within the facelet context using given id as base.


generateValidIdString

public java.lang.String generateValidIdString(java.lang.String base)

generateWidgetId

public java.lang.String generateWidgetId(java.lang.String widgetName)

generateLayoutId

public java.lang.String generateLayoutId(java.lang.String layoutName)

generateMessageId

public java.lang.String generateMessageId(java.lang.String widgetName)

createIdAttribute

public com.sun.facelets.tag.TagAttribute createIdAttribute(java.lang.String base)
Creates a unique id and returns corresponding attribute, using given string id as base.


createAttribute

public com.sun.facelets.tag.TagAttribute createAttribute(java.lang.String name,
                                                         java.lang.String value)
Creates an attribute with given name and value.

The attribute namespace is assumed to be empty.


shouldCreateReferenceAttribute

public boolean shouldCreateReferenceAttribute(java.lang.String key,
                                              java.io.Serializable value)
Returns true if a reference tag attribute should be created for given property value.

Reference tag attributes are using a non-literal EL expression so that this property value is not kept (cached) in the component on ajax refresh.

Off course property values already representing an expression cannot be mapped as is because they would need to be resolved twice.

Converters and validators cannot be referenced either because components expect corresponding value expressions to resolve to a Converter or Validator instance (instead of the converter of validator id).


getTagAttributes

public static com.sun.facelets.tag.TagAttributes getTagAttributes(com.sun.facelets.tag.TagAttribute... attributes)

getTagAttributes

public static com.sun.facelets.tag.TagAttributes getTagAttributes(java.util.List<com.sun.facelets.tag.TagAttribute> attributes)

addTagAttribute

public static com.sun.facelets.tag.TagAttributes addTagAttribute(com.sun.facelets.tag.TagAttributes orig,
                                                                 com.sun.facelets.tag.TagAttribute newAttr)

copyTagAttributes

public com.sun.facelets.tag.TagAttributes copyTagAttributes(java.lang.String id,
                                                            java.lang.String... names)
Copies tag attributes with given names from the tag config, using given id as base for the id attribute.


getTagAttributes

public com.sun.facelets.tag.TagAttributes getTagAttributes(java.lang.String id,
                                                           Widget widget)
Creates tag attributes using given widget properties and field definitions.

Assumes the "value" attribute has to be computed from the first field definition, using the "value" expression (see widget type tag handler exposed values).


getHtmlComponentHandler

public com.sun.facelets.tag.jsf.ComponentHandler getHtmlComponentHandler(com.sun.facelets.tag.TagAttributes attributes,
                                                                         com.sun.facelets.FaceletHandler nextHandler,
                                                                         java.lang.String componentType,
                                                                         java.lang.String rendererType)
Returns an html component handler for this configuration.

Next handler cannot be null, use LeafFaceletHandler if no next handler is needed.


getErrorComponentHandler

public com.sun.facelets.tag.jsf.ComponentHandler getErrorComponentHandler(java.lang.String errorMessage)
Component handler that displays an error on interface


getConvertHandler

public com.sun.facelets.tag.jsf.ConvertHandler getConvertHandler(com.sun.facelets.tag.TagAttributes attributes,
                                                                 com.sun.facelets.FaceletHandler nextHandler,
                                                                 java.lang.String converterId)
Returns a convert handler for this configuration.

Next handler cannot be null, use LeafFaceletHandler if no next handler is needed.


getValidateHandler

public com.sun.facelets.tag.jsf.ValidateHandler getValidateHandler(com.sun.facelets.tag.TagAttributes attributes,
                                                                   com.sun.facelets.FaceletHandler nextHandler,
                                                                   java.lang.String validatorId)
Returns a validate handler for this configuration.

Next handler cannot be null, use LeafFaceletHandler if no next handler is needed.


getMessageComponentHandler

public com.sun.facelets.tag.jsf.ComponentHandler getMessageComponentHandler(java.lang.String id,
                                                                            java.lang.String forId,
                                                                            java.lang.String styleClass)
Returns a message component handler with given attributes.

Uses component type "javax.faces.HtmlMessage" and renderer type "javax.faces.Message".


getAliasTagHandler

public com.sun.facelets.FaceletHandler getAliasTagHandler(java.util.Map<java.lang.String,javax.el.ValueExpression> variables,
                                                          com.sun.facelets.FaceletHandler nextHandler)

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.