Problem with Seam components in dynamic forms
blumenro Jun 12, 2008 8:34 PMAll,
I'm about to create a facelet for dynamic forms. I have the form elements in a list of one Seam component and loop through it to render the form. On the other side I want to store the users' input in another Seam component that is then also used to send out an email.
This is a draft of the code:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.ajax4jsf.org/rich" template="layout/template.xhtml"> <ui:define name="body"> <!-- <h:outputText value="#{contentHome.content.path}"></h:outputText> --> <div id="hd_working_area"> <div id="hd_content_area"> <div id="hd_main_column"> <h:form> <ui:repeat value="#{contentHome.contentTree.children}" var="_element"> <s:div rendered="#{_element.name eq 'FormHeading'}"> <h1><h:outputText style="#{(_element.attributes['Bold'] eq 'true') ? 'font-weight: bold' : ''}" value="#{_element.attributes['HeadingParagraph']}"></h:outputText></h1><br/> </s:div> <s:div rendered="#{_element.name eq 'UserEmail'}"> <h:outputText style="#{(_element.attributes['Bold'] eq 'true') ? 'font-weight: bold' : ''}" value="#{_element.attributes['FieldLabel']}" escape="false"></h:outputText> <s:span style="#{(_element.attributes['Bold'] eq 'true') ? 'font-weight: bold' : ''}" rendered="#{_element.attributes['Required'] eq 'true'}"> * </s:span> <h:inputText id="email" value="#{formEmail.emailAddress}" required="#{_element.attributes['Required']}"></h:inputText> </s:div> </ui:repeat> <div class="buttonBox"> <h:commandButton id="send" value="Send" action="#{formEmail.send}"/>   <s:button id="cancel" value="Cancel" view="/home.xhtml"/> </div> </h:form> </div> </div> </div> </ui:define> </ui:composition>
The problem is that the property formEmail.emailAddress is not filled when I submit the form. However, when I hardcode the form (without rendering it dynamically based on the other Seam component), it works. So my question is whether there is a basic issue with having 2 Seam components in a facelet, one for rendering and one for storing the input.
Regards,
Christian