| java.lang.Object com.sun.rave.web.ui.component.util.Util
Util | public class Util (Code) | | Utility class that contains helper methods for components.
author: Ken Paulsen |
Method Summary | |
public static void | addPhaseListener(PhaseListener phaseListener) Add a PhaseListener. | public static UIComponent | createChildComponent(FacesContext context, LayoutComponent descriptor, UIComponent parent) This method creates a child UIComponent by using the
provided
LayoutComponent (descriptor ). | public static UIComponent | findChild(UIComponent parent, String id, String facetName) Return a child with the specified component id (or facetName) from
the specified component. | public static String | getActionURL(FacesContext context, String url) | public static String | getBase(FacesContext context) | public static UIComponent | getChild(UIComponent parent, String id) Return a child with the specified component id from the specified
component. | public static UIComponent | getChild(UIComponent parent, String id, String factoryClass) This method finds or creates a child UIComponent
identified by the given id. | public static UIComponent | getChild(UIComponent parent, String id, String factoryClass, String facetName) Same as
Util.getChild(UIComponent,String,String) except that
it allows you to specify a facetName different than the id. | public static UIComponent | getChild(UIComponent parent, String id, String factoryClass, Properties properties) This method finds or creates a child UIComponent
identified by the given id. | public static UIComponent | getChild(UIComponent parent, String id, String factoryClass, Properties properties, String facetName) Same as
Util.getChild(UIComponent,String,String,Properties) except that it allows you to specify a facetName different than the
id. | public static UIComponent | getChild(UIComponent parent, LayoutComponent descriptor) This method finds or creates a child UIComponent
identified by the given id. | public static String | getContext(FacesContext context) | public static UIComponent | getForm(FacesContext context, UIComponent component) | public static String | getFormName(FacesContext context, UIComponent component) Gets the form id from the containing UIForm .
Parameters: context - FacesContext for the request we are processing. Parameters: component - UIComponent to find form from. | public static boolean | isVisible(UIComponent component) Return whether the given UIComponent is "visible".
If the property is null, it will return true. | public static void | removePhaseListener(PhaseListener phaseListener) Remove a PhaseListener. | public static Object | resolveValue(FacesContext context, LayoutElement elt, UIComponent parent, String value) This method will attempt to resolve EL strings in the given
value.
Parameters: context - The FacesContext Parameters: elt - The LayoutElement associated w/ the expression Parameters: parent - The parent UIComponent . | public static Object | setOption(FacesContext context, String key, Object value, LayoutElement desc, UIComponent component) This util method will set the given key/value on the
UIComponent . |
addPhaseListener | public static void addPhaseListener(PhaseListener phaseListener)(Code) | | Add a PhaseListener.
Parameters: phaseListener - PhaseListener instance. |
findChild | public static UIComponent findChild(UIComponent parent, String id, String facetName)(Code) | | Return a child with the specified component id (or facetName) from
the specified component. If not found, return null .
facetName or id may be null to avoid
searching the facet Map or the parent 's children.
This method will NOT create a new UIComponent .
Parameters: parent - UIComponent to be searched Parameters: id - id to search for Parameters: facetName - Facet name to search for The child UIComponent if it exists, null otherwise. |
getBase | public static String getBase(FacesContext context)(Code) | | Return the base URI for the view identifier of the current view.
Parameters: context - FacesContext for the current request |
getChild | public static UIComponent getChild(UIComponent parent, String id)(Code) | | Return a child with the specified component id from the specified
component. If not found, return null .
This method will NOT create a new UIComponent .
Parameters: parent - UIComponent to be searched Parameters: id - Component id (or facet name) to search for The child UIComponent if it exists, null otherwise. |
getChild | public static UIComponent getChild(UIComponent parent, String id, String factoryClass)(Code) | | This method finds or creates a child UIComponent
identified by the given id. If the child is not found, it will
attempt to create it using the provided
com.sun.rave.web.ui.component.util.factories.ComponentFactory (factoryClass ).
If there are Properties to be set on the UIComponent,
this method should generally be avoided. It is preferable to use
the
Util.getChild(UIComponent,String,String,Properties) form of getChild .
// Example (no properties):
UIComponent child = Util.getChild(component, "jklLabel", "
com.sun.rave.web.ui.component.util.factories.LabelFactory com.sun.rave.web.ui.component.util.factories.LabelFactory ");
((Label)child).setText("JKL Label:");
((Label)child).setFor("jkl");
LayoutComponent.encodeChild(FacesContextUIComponent) LayoutComponent.encodeChild (context, child);
Parameters: parent - Parent UIComponent Parameters: id - Identifier for the child UIComponent Parameters: factoryClass - Full com.sun.rave.web.ui.component.util.factories.ComponentFactory class name The child UIComponent that was found or created. See Also: Util.getChild(UIComponent,String,String,Properties) |
getChild | public static UIComponent getChild(UIComponent parent, String id, String factoryClass, Properties properties)(Code) | | This method finds or creates a child UIComponent
identified by the given id. If the child is not found, it will
attempt to create it using the provided
com.sun.rave.web.ui.component.util.factories.ComponentFactory (factoryClass ). It will also initialize the
UIComponent using the provided set of
Properties .
// Example (with properties):
Properties props = new Properties();
props.setProperty("text", "ABC Label:");
props.setProperty("for", "abc");
UIComponent child = Util.getChild(component, "abcLabel", "
com.sun.rave.web.ui.component.util.factories.LabelFactory com.sun.rave.web.ui.component.util.factories.LabelFactory ", props);
LayoutComponent.encodeChild(FacesContextUIComponent) LayoutComponent.encodeChild (context, child);
Parameters: parent - Parent UIComponent Parameters: id - Identifier for the child UIComponent Parameters: factoryClass - Full com.sun.rave.web.ui.component.util.factories.ComponentFactory class name Parameters: properties - java.util.Properties needed tocreate and/or initialize theUIComponent The child UIComponent that was found or created. |
getChild | public static UIComponent getChild(UIComponent parent, String id, String factoryClass, Properties properties, String facetName)(Code) | | Same as
Util.getChild(UIComponent,String,String,Properties) except that it allows you to specify a facetName different than the
id. If null is supplied, it won't save the component as a
facet.
Parameters: parent - Parent UIComponent Parameters: id - Identifier for the child UIComponent Parameters: factoryClass - Full com.sun.rave.web.ui.component.util.factories.ComponentFactory class name Parameters: properties - java.util.Properties needed tocreate and/or initialize theUIComponent Parameters: facetName - The facet name (null means don't store it) The child UIComponent that was found or created. |
getChild | public static UIComponent getChild(UIComponent parent, LayoutComponent descriptor)(Code) | | This method finds or creates a child UIComponent
identified by the given id. If the child is not found, it will
attempt to create it using the provided
LayoutComponent (descriptor ). It will also initialize the
UIComponent using the options set on the
LayoutComponent .
If parent implements
ChildManager , then the
responsibility of finding and creating the child will be delegated
to the
ChildManager UIComponent .
If you are constructing and populating a LayoutComponent before
calling this method, there are a few features that should be noted.
Besides id and type which can be set in
the LayoutComponent constructor, you can also set
options , and
com.sun.rave.web.ui.component.util.event.Handler 's.
Options may be set via
LayoutComponent.setOptions(Map) . These options will be
applied to the UIComponent and may also be used by the
com.sun.rave.web.ui.component.util.factories.ComponentFactory while instantiating the
UIComponent .
com.sun.rave.web.ui.component.util.event.Handler 's can be
supplied by calling
LayoutComponent.setHandlers(StringList) . The
type must match the event name which invokes the
List of handlers you provide. The
Renderer for this UIComponent is
responsible for declaring and dispatching events.
com.sun.rave.web.ui.renderer.template.TemplateRenderer will
invoke beforeCreate and afterCreate
events for each child it creates (such as the one being requested
here).
// Example (with LayoutComponent):
ComponentType type = new
ComponentType.ComponentType(StringString) ComponentType ("LabelFactory", "
com.sun.rave.web.ui.component.util.factories.LabelFactory com.sun.rave.web.ui.component.util.factories.LabelFactory ");
LayoutComponent descriptor = new
LayoutComponent.LayoutComponent(LayoutElementStringComponentType) LayoutComponent (null, "abcLabel", type);
LayoutComponent.addOption(StringObject) descriptor.addOption ("text", "ABC Label:");
LayoutComponent.addOption(StringObject) descriptor.addOption ("for", "abc");
UIComponent child = Util.getChild(component, descriptor);
LayoutComponent.encodeChild(FacesContextUIComponent) LayoutComponent.encodeChild (context, child);
Parameters: parent - Parent UIComponent Parameters: descriptor - The LayoutComponent describing theUIComponent The child UIComponent that was found or created. |
getContext | public static String getContext(FacesContext context)(Code) | | Return an absolute URL to our server and context path.
Parameters: context - FacesContext for the current request |
getForm | public static UIComponent getForm(FacesContext context, UIComponent component)(Code) | | Helper method to obtain containing UIForm .
Parameters: context - FacesContext for the request we areprocessing. Parameters: component - UIComponent to find form from. Returns the UIForm component that contains this element |
getFormName | public static String getFormName(FacesContext context, UIComponent component)(Code) | | Gets the form id from the containing UIForm .
Parameters: context - FacesContext for the request we are processing. Parameters: component - UIComponent to find form from. Returns the id of the UIForm that contains thiselement. |
isVisible | public static boolean isVisible(UIComponent component)(Code) | | Return whether the given UIComponent is "visible".
If the property is null, it will return true. Otherwise the value
of the property is returned.
Parameters: component - The UIComponent to check True if the property is null or true, false otherwise. |
removePhaseListener | public static void removePhaseListener(PhaseListener phaseListener)(Code) | | Remove a PhaseListener.
Parameters: phaseListener - PhaseListener instance. |
resolveValue | public static Object resolveValue(FacesContext context, LayoutElement elt, UIComponent parent, String value)(Code) | | This method will attempt to resolve EL strings in the given
value.
Parameters: context - The FacesContext Parameters: elt - The LayoutElement associated w/ the expression Parameters: parent - The parent UIComponent . This is usedbecause the current UIComponent is typicallyunknown (or not even created yet). Parameters: value - The String to resolve The evaluated value (may be null). |
setOption | public static Object setOption(FacesContext context, String key, Object value, LayoutElement desc, UIComponent component)(Code) | | This util method will set the given key/value on the
UIComponent . It will resolve all $...{...}
expressions, and convert the String into a
ValueBinding if a ValueBinding is
detected. The return value will be a ValueBinding or
the value.
Parameters: context - FacesContext Parameters: key - The Property name to set Parameters: value - The Property value to set Parameters: desc - The LayoutElement associated with theUIComponent Parameters: component - The UIComponent A ValueBinding, or the evaulated value (if no value binding ispresent). |
|
|