6 Replies Latest reply on Dec 10, 2007 6:23 PM by David Radunz

    s:decorate looses form values on validation error

    David Radunz Newbie

      Hey All,

      I have been trying to get this to work for the last two days, a little disconcerting. I am sure its something I have done wrong but im not sure what it is. When I use the s:decorate component to display an inline error message, upon displaying the inline error message correctly the forms value is suddenly cleared. Standard input components not wrapped inside a s:decorate do not exhibit this problem so I don't believe its related to page flow or scope, but im not certain what the issue is.

      The xhtml page is as follows:

      (NB: This isn't the desired form layout, this is an example to prove that s:decorate was the issue and that standard inputText / outputText in a panel worked fine)

       <h:form id="registerAgentForm">
      
       <rich:panel>
       <f:facet name="header">Register Agent</f:facet>
      
       <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value">
      
       <h:column>
       <h:outputText value="Agent Reference:"/>
       </h:column>
       <h:column>
       <h:inputText id="agentref" value="#{agent.agentReference}" required="true"/>
       <s:decorate for="agentref" template="/WEB-INF/templates/layout/edit.xhtml"/>
       </h:column>
      
       <h:column>
       <h:outputText value="Name:"/>
       </h:column>
       <h:column>
       <h:inputText id="agentname" value="#{agent.name}" required="true"/>
       <s:decorate for="agentname" template="/WEB-INF/templates/layout/edit.xhtml"/>
       </h:column>
      
       </h:panelGrid>
      
       <s:decorate id="nicDecoration" template="/WEB-INF/templates/fragment/edit.xhtml">
       <ui:define name="label">NIC:</ui:define>
       <h:inputText id="nic" value="#{agent.nic}" required="true"/>
       </s:decorate>
      
       <div style="clear:both"/>
       </rich:panel>
      
       <h:commandButton type="submit" value="Register" action="#{manageAgentAction.register}"/>
      
       </h:form>
      


      The contents of edit.xhtml (pretty standard implementation) are as follows:

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:s="http://jboss.com/products/seam/taglib">
      
       <div class="prop">
      
       <s:label styleClass="name #{invalid?'errors':''}">
       <ui:insert name="label"/>
       <s:span styleClass="required" rendered="#{required}">*</s:span>
       </s:label>
      
       <span class="value #{invalid?'errors':''}">
       <s:validateAll>
       <ui:insert/>
       </s:validateAll>
       </span>
      
       <s:message styleClass="error errors"/>
      
       </div>
      
      </ui:composition>
      


      Thanks in advance!

      David

        • 1. Re: s:decorate looses form values on validation error
          David Radunz Newbie

          I should mention this is based around Seam 2.0.0.GA and JBoss 4.2.2.GA

          Thanks,

          David

          • 2. Re: s:decorate looses form values on validation error
            David Radunz Newbie

            I hope someone can help otherwise im going to have to stop using this. Is the seam source code available? I am happy to look at the source code to try and work out the issue myself.

            David

            • 3. Re: s:decorate looses form values on validation error
              David Radunz Newbie

              I am starting to loose faith in this community. This is the 3rd time I have posted to the forum - as a last resort - and had no response. If it's something I have not said then please let me know, not responding at all tells me nothing.

              David

              • 4. Re: s:decorate looses form values on validation error
                David Radunz Newbie

                Could the issue be because the bean I am binding the form to is neither a Stateful session bean or an entity bean? We are not using a database back end and do not need the complexity of an entity bean.

                The bean annotations are as follows:

                @Name("agent")
                @Install(precedence=Install.DEPLOYMENT)
                @Scope(ScopeType.CONVERSATION)


                This works fine when using anything other than s:decorate. So I guess s:decorate does something special expecting @Stateful or @Entity beans? I say this because all the examples in the seam-gen app that use s:decorate use those.

                Again, is the source code for Seam available? It's open source isn't it?

                Cheers,

                David

                • 5. Re: s:decorate looses form values on validation error
                  Pete Muir Master

                  Yes, its in your download of Seam in the src directory, or cvs as linked off the wiki.

                  I've never seen this as a problem before - should be no problem binding to any Seam component, not just entity beans or SFSBs.

                  • 6. Re: s:decorate looses form values on validation error
                    David Radunz Newbie

                    Hey,

                    I figured out what it was and it ties in with another issue I have been having. I have created a custom resource resolver that loads resources from JAR files.. Well, actually I have created a deployer that registers resources that are dropped into the deploy directory and the custom resource resolver looks to that service for resources. The issue here is that the template being included is loaded in such a way, and suffers from this fate:

                    INFO: Facelet[/file:/usr/local/jboss/jboss-4.2.2.GA/server/default/tmp/deploy/tmp35770wt_umarket_mobilink-dev.ear-contents/wt_umarket_common_mobilink-dev.uiar!/WEB-INF/templates/fragment/edit.xhtml] was modified @ 10:14:38, flushing component applied @ 10:14:27


                    I feel that this 'flush' is what is causing the loss of information - my question is how do I prevent it flushing a component that has not been modified?

                    p.s. Sorry to be a bit heavy footed earlier, its quite frustrating not having other people on hand to ask questions of and having to wait around on a forum response.

                    Cheers,

                    David