Seam Faces InputContainer
captainvoid Oct 24, 2011 11:55 AMHi,
has anybody successfully used the InputContainer component that Seam Faces provides?
I just can't get it to work. The validation message never shows up and the automatic wiring of the label and the input text component does not seem to work (JSF warning).
Here is my component named fieldRow
:
<?xml version="1.0" encoding="UTF-8" ?> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:composite="http://java.sun.com/jsf/composite" xmlns:h="http://java.sun.com/jsf/html" xmlns:s="http://jboss.org/seam/faces" xmlns:ui="http://java.sun.com/jsf/facelets"> <composite:interface componentType="org.jboss.seam.faces.InputContainer"> <composite:attribute name="label" required="true" /> </composite:interface> <composite:implementation> <h:panelGroup layout="block" styleClass="fieldRow"> <h:outputLabel id="label" value="#{cc.attrs.label}" styleClass="fieldRowLabel #{cc.attrs.invalid ? 'invalid-field' : ''} #{cc.attrs.required ? 'required' : ''}"> </h:outputLabel> <h:panelGroup layout="block" styleClass="fieldRowValue #{cc.attrs.invalid ? 'invalidField' : ''}"> <composite:insertChildren /> </h:panelGroup> <h:panelGroup layout="block" styleClass="errorBox"> <h:message id="message" /> </h:panelGroup> </h:panelGroup> </composite:implementation> </ui:composition>
And that's how I use it:
<txe:fieldRow label="#{messages['login.username']}"> <h:inputText id="name" required="true" value="#{credentials.username}" /> </txe:fieldRow>
The rendered html after a postback leaving the text field empty (validation error):
<div class="fieldRow"> <label class="fieldRowLabel invalid-field required" for="login_j_idt35_login_j_idt35_name" id="login_j_idt35_label">Username</label> <div class="fieldRowValue invalidField"> <input type="text" name="login_j_idt35_name" id="login_j_idt35_name"> </div> <div class="errorBox"> <span id="login_j_idt35_message"></span> </div> </div>
and in the server log:
24-oct-2011 17:41:18 com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent ADVERTENCIA: No se encuentra el componente con ID login_j_idt35_name en la vista.
So it seems like that the invalid
attribute of the component is correctly set, but the message is not rendered. I don't know how to interpret the server warning...
I'm using Seam 3.0.0 Final and JSF 2.0.
Any ideas?
Thanks a lot for help!!