Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.platform.ui.web.util
Class ComponentUtils

java.lang.Object
  extended by org.nuxeo.ecm.platform.ui.web.util.ComponentUtils

public final class ComponentUtils
extends Object

Generic component helper methods.

Author:
Anahide Tchertchian

Field Summary
static String WHITE_SPACE_CHARACTER
           
 
Method Summary
static void addErrorMessage(FacesContext context, UIComponent component, String message)
           
static void addErrorMessage(FacesContext context, UIComponent component, String message, Object[] params)
           
static void copyLinkValues(UIComponent parent, UIComponent child)
           
static void copyValues(UIComponent parent, UIComponent child, String[] valueNames)
          Copies attributes and value expressions with given name from parent component to child component.
static String download(FacesContext faces, Blob blob, String filename)
           
static String downloadFile(FacesContext faces, String filename, File file)
           
static void encodeComponent(FacesContext context, UIComponent component)
          Calls a component encodeBegin/encodeChildren/encodeEnd methods.
static Object getAttributeOrExpressionValue(FacesContext context, UIComponent component, String attributeName, Object defaultValue)
           
static Object getAttributeValue(UIComponent component, String attributeName, Object defaultValue)
           
static UIComponent getBase(UIComponent anchor)
          Gets the base naming container from anchor.
static
<T> T
getComponent(UIComponent base, String componentId, Class<T> expectedComponentClass)
          Returns the component specified by the componentId parameter from the base component.
static UIComponent hookSubComponent(FacesContext context, UIComponent parent, UIComponent child, String defaultChildId)
          Add a sub component to a UI component, marking is as rendered.
static void initiateSubComponent(UIComponent parent, String facetName, UIComponent child)
          Helper method meant to be called in the component constructor.
static void moveAllItems(UISelectItems sourceItems, UISelectItems targetItems, UIEditableList hiddenTargetList, boolean setTargetIds)
          Move items from components to others.
static void moveItems(UISelectMany sourceSelect, UISelectItems sourceItems, UISelectItems targetItems, UIEditableList hiddenTargetList, boolean setTargetIds)
          Move items from components to others.
static void shiftItemsDown(UISelectMany targetSelect, UISelectItems targetItems, UIEditableList hiddenTargetList)
           
static void shiftItemsFirst(UISelectMany targetSelect, UISelectItems targetItems, UIEditableList hiddenTargetList)
           
static void shiftItemsLast(UISelectMany targetSelect, UISelectItems targetItems, UIEditableList hiddenTargetList)
           
static void shiftItemsUp(UISelectMany targetSelect, UISelectItems targetItems, UIEditableList hiddenTargetList)
          Move items up inside the target select
static String translate(FacesContext context, String messageId)
           
static String translate(FacesContext context, String messageId, Object... params)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WHITE_SPACE_CHARACTER

public static final String WHITE_SPACE_CHARACTER
See Also:
Constant Field Values
Method Detail

encodeComponent

public static void encodeComponent(FacesContext context,
                                   UIComponent component)
                            throws IOException
Calls a component encodeBegin/encodeChildren/encodeEnd methods.

Throws:
IOException

initiateSubComponent

public static void initiateSubComponent(UIComponent parent,
                                        String facetName,
                                        UIComponent child)
Helper method meant to be called in the component constructor.

When adding sub components dynamically, the tree fetching could be a problem so all possible sub components must be added.

By default initiated component are marked as not rendered.

Parameters:
parent -
child -
facetName - facet name to put the child in.

hookSubComponent

public static UIComponent hookSubComponent(FacesContext context,
                                           UIComponent parent,
                                           UIComponent child,
                                           String defaultChildId)
Add a sub component to a UI component, marking is as rendered.

Parameters:
context -
parent -
child -
defaultChildId -
Returns:
child comp

copyValues

public static void copyValues(UIComponent parent,
                              UIComponent child,
                              String[] valueNames)
Copies attributes and value expressions with given name from parent component to child component.


copyLinkValues

public static void copyLinkValues(UIComponent parent,
                                  UIComponent child)

getAttributeValue

public static Object getAttributeValue(UIComponent component,
                                       String attributeName,
                                       Object defaultValue)

getAttributeOrExpressionValue

public static Object getAttributeOrExpressionValue(FacesContext context,
                                                   UIComponent component,
                                                   String attributeName,
                                                   Object defaultValue)

download

public static String download(FacesContext faces,
                              Blob blob,
                              String filename)

downloadFile

public static String downloadFile(FacesContext faces,
                                  String filename,
                                  File file)

translate

public static String translate(FacesContext context,
                               String messageId)

translate

public static String translate(FacesContext context,
                               String messageId,
                               Object... params)

addErrorMessage

public static void addErrorMessage(FacesContext context,
                                   UIComponent component,
                                   String message)

addErrorMessage

public static void addErrorMessage(FacesContext context,
                                   UIComponent component,
                                   String message,
                                   Object[] params)

getBase

public static UIComponent getBase(UIComponent anchor)
Gets the base naming container from anchor.

Gets out of suggestion box as it's a naming container and we can't get components out of it with a relative path => take above first found container.

Since:
5.3.1

getComponent

public static <T> T getComponent(UIComponent base,
                                 String componentId,
                                 Class<T> expectedComponentClass)
Returns the component specified by the componentId parameter from the base component.

Does not throw any exception if the component is not found, returns null instead.

Since:
5.4

shiftItemsUp

public static void shiftItemsUp(UISelectMany targetSelect,
                                UISelectItems targetItems,
                                UIEditableList hiddenTargetList)
Move items up inside the target select


shiftItemsDown

public static void shiftItemsDown(UISelectMany targetSelect,
                                  UISelectItems targetItems,
                                  UIEditableList hiddenTargetList)

shiftItemsFirst

public static void shiftItemsFirst(UISelectMany targetSelect,
                                   UISelectItems targetItems,
                                   UIEditableList hiddenTargetList)

shiftItemsLast

public static void shiftItemsLast(UISelectMany targetSelect,
                                  UISelectItems targetItems,
                                  UIEditableList hiddenTargetList)

moveItems

public static void moveItems(UISelectMany sourceSelect,
                             UISelectItems sourceItems,
                             UISelectItems targetItems,
                             UIEditableList hiddenTargetList,
                             boolean setTargetIds)
Move items from components to others.


moveAllItems

public static void moveAllItems(UISelectItems sourceItems,
                                UISelectItems targetItems,
                                UIEditableList hiddenTargetList,
                                boolean setTargetIds)
Move items from components to others.


Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.