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

    Problem with Seam components in dynamic forms

    Christian Blumenroehr Newbie


      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"
              <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">
                      <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 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'}">
                                      <h:inputText id="email"  value="#{formEmail.emailAddress}" required="#{_element.attributes['Required']}"></h:inputText>
                      <div class="buttonBox">
                              <h:commandButton id="send" value="Send" action="#{formEmail.send}"/>
                              <s:button id="cancel" value="Cancel" view="/home.xhtml"/>

      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.


        • 1. Re: Problem with Seam components in dynamic forms
          Marcel Kiel Newbie

          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).