1 Reply Latest reply on Jun 17, 2008 2:49 PM by mkiel

    Problem with Seam components in dynamic forms

    blumenro

      All,


      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}"/>
      
                              &#160;
      
                              <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




        • 1. Re: Problem with Seam components in dynamic forms
          mkiel

          I'm not sure whether it could make any sense to have a <ui:repeat> which contains value bindings that do not depend on the iteration variable. If there is more than one iteration, you would have more than one text input field with its value bound to formEmail.emailAddress. But if the user enters different values, what value should formEmail.emailAddress have? I would say that if you have n contentHome.contentTree.children, you also need n formEmail.emailAddress(es).