2 Replies Latest reply on Apr 8, 2011 7:28 AM by Jakob D

    New values are not binding with form backing object when posting in seam

    Jakob D Newbie
      Hello experts! I have multiple forms that are populated by ThingPageBean. Each of these forms are submitted with a
      <h:commandButton> where the action is set to call #{thingPageBean.doAmazingThing(oneStuff)} All fields are
      static except for contactEmail and contactPhone where I want to use
      <h:inputText> instead of <h:outputText> so that the user can set a new value if they wish.
      The problem is that the new values are not bound to object that is received in
      doAmazingThing(OneStuff oneStuff) in the ThingPageBean.
      The old ones remain. What am I doing wrong? Have I missed some crucial part?

      My Bean:

      @SuppressWarnings({"unchecked"})
      @AutoCreate
      @Name("thingPageBean")
      @Scope(ScopeType.EVENT)
      @Restrict("#{s:hasRole('admin')}")
      public class ThingPageBean implements Serializable {

          @In
          StuffService stuffService;

          @In
          private StatusMessages statusMessages;


          public String doAmazingThing(OneStuff oneStuff) {
              return this.stuffService.doAmazingStuffToThing(oneStuff);   
          }

          @Factory(value = "notHandledStuff")
          public List<Stuff> notHandledStuff() {
              return this.stuffService.searchNotHandledStuff();
          }
      }
      `
      My xhtml file:

      <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:c="http://java.sun.com/jstl/core"
                      template="/layout/SiteTemplate.xhtml">


          <ui:param name="robots" value="noindex"/>

          <!-- hide blocks -->
          <ui:param name="preContentHide" value="true"/>

          <ui:define name="mainContent">

                  <c:set var="stuff" value="#{notHandledStuff}"/>
                  <s:div styleClass="section"
                         rendered="#{stuff == null or stuff.size==0}">
                      <h:outputText value="#{messages['stuff.no']}"/>
                  </s:div>
                  <s:div styleClass="section"
                         rendered="#{stuff != null and stuff.size>0}">
                      <br/>
                      <ui:repeat var="oneStuff" value="#{stuff}">
                          <h:form id="stuffForm">
                              <hr style="margin-top:8px;margin-bottom:4px;"/>
                              <table border="1">
                                  <tr>
                                      <td><b>Company name:</b></td>
                                      <td width="780px"><h:outputText value="#{oneStuff.companyName}"/></td>
                                  </tr>
                                  <tr>
                                      <td><b>street:</b></td>
                                      <td><h:outputText value="#{oneStuff.street}"/></td>
                                      <td/>
                                  </tr>
                                  <tr>
                                      <td><b>zip:</b></td>
                                      <td><h:outputText value="#{oneStuff.zip}"/></td>
                                      <td/>
                                  </tr>
                                  <tr>
                                      <td><b>city:</b></td>
                                      <td><h:outputText value="#{oneStuff.city}"/></td>
                                      <td/>
                                  </tr>
                                  <tr>
                                      <td style="padding-top:10px"><b>contactPerson:</b></td>
                                      <td><h:outputText value="#{oneStuff.contactPersonName}"/></td>
                                      <td/>
                                  </tr>
                                  <tr>
                                      <td><b>contactEmail:</b></td>
                                      <td><h:inputText value="#{oneStuff.contactEmail}"/></td>
                                      <td/>
                                  </tr>
                                  <tr>
                                      <td><b>contactPhone:</b></td>
                                      <td><h:inputText id="contactPhone" value="#{oneStuff.contactPhone}"/></td>
                                      <td/>
                                  </tr>

                                          <h:commandButton id="submit"  value="couple"
                                                           action="#{thingPageBean.doAmazingThing(oneStuff)}"/>
                                      </td>
                                  </tr>
                              </table>
                            </s:div>
                          </h:form>
                      </ui:repeat>

                      <hr style="margin-top:8px;margin-bottom:4px;"/>
                  </s:div>
                  <br/>
              </div>
          </ui:define>
      </ui:composition>

      Thank you

      Jakob