4 Replies Latest reply on Dec 17, 2010 7:36 AM by Leonardo Mahler

    New class attribute into Home

    Leonardo Mahler Newbie


      Hello!
      
      I´m a Seam beginner developer.
      I´m trying to add a new attribute in a Home (generated by seam-gen) to be used as an auxiliar (without persistence) field in my .xhtml. 
      
      I have 2 EJBs: Selecao and PalavraChave
      
      This is part of my SelecaoHome.java:
      @Name("selecaoHome")
      public class SelecaoHome extends EntityHome<Selecao> {
              private Palavrachave palavrachave;
              public Palavrachave getPalavrachave() {
                      return this.palavrachave;
              }
              public void setPalavrachave(Palavrachave palavrachave) {
                      this.palavrachave = palavrachave;
              }
      
      And this is part of my SelecaoEdit.xmtl
      <s:decorate id="pvField" template="layout/edit.xhtml"> 
            <ui:define name="label">Palavras Chaves</ui:define>
            <h:inputText id="texto" required="false" 
                value="#{selecaoHome.palavrachave.texto}">
            <a:support event="onblur" reRender="pvField" 
              action="#{selecaoHome.addNewPalavrachave}"                ajaxSingle="true"/>
            </h:inputText>
            <h:dataTable value="#{selecaoHome.palavrachaves}" var="_palavrachave" id="ds">
                <h:column>
                   <h:outputText value="#{_palavrachave.texto}" />
                </h:column>
                <h:column>
                <a:commandLink value="Delete" reRender="pvField" action="#{selecaoHome.delPalavrachave(_palavrachave)}" ajaxSingle="true"/>
                </h:column>
           </h:dataTable>
           </s:decorate>
      
      I´m filling the List palavraschaves (datatable) using object Palavrachave (inputText). And it´s working!
      But when I click the Done (persist) button, I receive the following error message:
      
      16:53:27,073 WARNING [lifecycle] /SelecaoEdit.xhtml @158,90 value="#{selecaoHome.palavrachave.texto}": Target Unreachable, 'palavrachave' returned null on 'br.gov.rfb.webprog1.session.SelecaoHome_$$_javassist_seam_6'
      javax.el.PropertyNotFoundException: /SelecaoEdit.xhtml @158,90 value="#{selecaoHome.palavrachave.texto}": Target Unreachable, 'palavrachave' returned null on 'br.gov.rfb.webprog1.session.SelecaoHome_$$_javassist_seam_6'
              at com.sun.facelets.el.TagValueExpression.getType(TagValueExpression.java:62)
              at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:92)
              at javax.faces.component.UIInput.getConvertedValue(UIInput.java:942)
              at javax.faces.component.UIInput.validate(UIInput.java:868)
              at javax.faces.component.UIInput.executeValidate(UIInput.java:1072)
              at javax.faces.component.UIInput.processValidators(UIInput.java:672)
              at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
              at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
              at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1058)
              at javax.faces.component.UIForm.processValidators(UIForm.java:235)
              at org.ajax4jsf.component.AjaxViewRoot$3.invokeContextCallback(AjaxViewRoot.java:439)
              at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
              at org.ajax4jsf.component.AjaxViewRoot.processValidators(AjaxViewRoot.java:455)
              at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
              at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              at java.lang.Thread.run(Unknown Source)
      16:53:27,073 SEVERE [lifecycle] JSF1054: (Phase ID: PROCESS_VALIDATIONS 3, View ID: /SelecaoEdit.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1081d04]
      
      I don´t know what´s happening! 
      I suppose it´s trying to persist the palavrachave auxiliar attribute.
      How can I avoid it?
      
      Tks and regards! Leo.



        • 1. Re: New class attribute into Home
          omid pourhadi Apprentice

          let seam creates components for you add this line to your components.xml



          <component name="palavrachave" class="yourpackage.palavrachave"></component>
           <component name="Selcao" class="yourpackage.Selcao">
                     <property name="palavrachave">#{palavrachave}</property>
            </component>


          then you can access to property as below



          #{Selcao.palavrachave}


          this is based on your entities but u can use it in EntityHome and EntityQuery




          • 2. Re: New class attribute into Home
            Leonardo Mahler Newbie

            Tks for help omid!
            But, doing like this is not the same of declaring the property direclty into EntityHome?
            Tks!

            • 3. Re: New class attribute into Home
              omid pourhadi Apprentice

              as i said, you can have this component in EntityHome just inject it



              @In(required = false)
              private Palavrachave palavrachave;
                      public Palavrachave getPalavrachave() {
                              return this.palavrachave;
                      }
                      public void setPalavrachave(Palavrachave palavrachave) {
                              this.palavrachave = palavrachave;
                      }
              



              • 4. Re: New class attribute into Home
                Leonardo Mahler Newbie

                Hello omid!
                I´ve done it as you suggested:
                        @In(required = false)
                        private Palavrachave palavrachave;
                        public Palavrachave getPalavrachave() {
                                return this.palavrachave;
                        }
                        public void setPalavrachave(Palavrachave palavrachave) {
                                this.palavrachave = palavrachave;
                        }

                And my .xhtml has this:
                <h:inputText id="texto" required="false" value="#{selecaoHome.palavrachave.texto}">

                But, when I click Save, I receive this error message:
                javax.el.PropertyNotFoundException: /SelecaoEdit.xhtml @158,90 value="#{selecaoHome.palavrachave.texto}": Target Unreachable, 'palavrachave' returned null on 'br.gov.rfb.webprog1.session.SelecaoHome_$$_javassist_seam_6'

                It looks like the (required = false) is being ignored!