|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.faces.component.UIComponent
javax.faces.component.UIComponentBase
org.jboss.seam.faces.component.UIInputContainer
public class UIInputContainer
UIInputContainer is a supplemental component for a JSF 2.0 composite component encapsulating one or more input components (EditableValueHolder), their corresponding message components (UIMessage) and a label (HtmlOutputLabel). This component takes care of wiring the label to the first input and the messages to each input in sequence. It also assigns two implicit attribute values, "required" and "invalid" to indicate that a required input field is present and whether there are any validation errors, respectively. To determine if a input field is required, both the required attribute is consulted. Finally, if the "label" attribute is not provided on the composite component, the label value will be derived from the id of the composite component, for convenience.
Composite component definition example (minus layout):
<cc:interface componentType="org.jboss.seam.faces.InputContainer"/> <cc:implementation> <h:outputLabel id="label" value="#{cc.attrs.label}:" styleClass="#{cc.attrs.invalid ? 'invalid' : ''}"> <h:ouputText styleClass="required" rendered="#{cc.attrs.required}" value="*"/> </h:outputLabel> <cc:insertChildren/> <h:message id="message" errorClass="invalid message" rendered="#{cc.attrs.invalid}"/> </cc:implementation>
Composite component usage example:
<example:inputContainer id="name"> <h:inputText id="input" value="#{person.name}"/> </example:inputContainer>
Possible enhancements:
NOTE: Firefox does not properly associate a label with the target input if the input id contains a colon (:), the default separator character in JSF. JSF 2 allows developers to set the value via an initialization parameter (context-param in web.xml) keyed to javax.faces.SEPARATOR_CHAR. We recommend that you override this setting to make the separator an underscore (_).
Nested Class Summary | |
---|---|
static class |
UIInputContainer.InputContainerElements
|
Field Summary | |
---|---|
static String |
COMPONENT_TYPE
The standard component type for this component. |
protected static String |
HTML_CLASS_ATTR_NAME
|
protected static String |
HTML_ID_ATTR_NAME
|
protected static String |
HTML_STYLE_ATTR_NAME
|
Fields inherited from class javax.faces.component.UIComponent |
---|
BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY |
Fields inherited from interface javax.faces.component.NamingContainer |
---|
SEPARATOR_CHAR |
Constructor Summary | |
---|---|
UIInputContainer()
|
Method Summary | |
---|---|
void |
assignIds(UIInputContainer.InputContainerElements elements,
FacesContext context)
|
void |
encodeBegin(FacesContext context)
|
void |
encodeEnd(FacesContext context)
|
protected void |
endContainerElement(FacesContext context)
|
protected String |
generateLabel(UIInputContainer.InputContainerElements elements,
FacesContext context)
|
String |
getContainerElementName()
|
String |
getDefaultInputId()
|
String |
getDefaultLabelId()
|
String |
getDefaultMessageId()
|
String |
getElementsAttributeName()
The name of the auto-generated composite component attribute that holds the elements in this input container. |
String |
getEncloseAttributeName()
The name of the composite component attribute that holds a boolean indicating whether the component template should be enclosed in an HTML element, so that it be referenced from JavaScript. |
String |
getFamily()
|
String |
getInvalidAttributeName()
The name of the auto-generated composite component attribute that holds a boolean indicating whether the the template contains an invalid input. |
String |
getLabelAttributeName()
The name of the composite component attribute that holds the string label for this set of inputs. |
String |
getRequiredAttributeName()
The name of the auto-generated composite component attribute that holds a boolean indicating whether the template contains a required input. |
protected UIInputContainer.InputContainerElements |
scan(UIComponent component,
UIInputContainer.InputContainerElements elements,
FacesContext context)
Walk the component tree branch built by the composite component and locate the input container elements. |
protected void |
startContainerElement(FacesContext context)
|
protected void |
wire(UIInputContainer.InputContainerElements elements,
FacesContext context)
Wire the label and messages to the input(s) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String COMPONENT_TYPE
protected static final String HTML_ID_ATTR_NAME
protected static final String HTML_CLASS_ATTR_NAME
protected static final String HTML_STYLE_ATTR_NAME
Constructor Detail |
---|
public UIInputContainer()
Method Detail |
---|
public String getFamily()
getFamily
in class UIComponent
public String getInvalidAttributeName()
public String getRequiredAttributeName()
public String getLabelAttributeName()
public String getElementsAttributeName()
public String getEncloseAttributeName()
public String getContainerElementName()
public String getDefaultLabelId()
public String getDefaultInputId()
public String getDefaultMessageId()
public void encodeBegin(FacesContext context) throws IOException
encodeBegin
in class UIComponentBase
IOException
public void encodeEnd(FacesContext context) throws IOException
encodeEnd
in class UIComponentBase
IOException
protected void startContainerElement(FacesContext context) throws IOException
IOException
protected void endContainerElement(FacesContext context) throws IOException
IOException
protected String generateLabel(UIInputContainer.InputContainerElements elements, FacesContext context)
protected UIInputContainer.InputContainerElements scan(UIComponent component, UIInputContainer.InputContainerElements elements, FacesContext context)
public void assignIds(UIInputContainer.InputContainerElements elements, FacesContext context)
protected void wire(UIInputContainer.InputContainerElements elements, FacesContext context)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |