5 Replies Latest reply on Apr 13, 2011 5:42 AM by Leo van den berg

    var attribute must be set

    dhanaraja rajendiran Newbie
      Hi all,

      I am getting

      javax.faces.FacesException: var attribute must be set
              at org.jboss.seam.ui.component.UISelectItems$ContextualSelectItem.<init>(UISelectItems.java:58)
              at org.jboss.seam.ui.component.UISelectItems$1.<init>(UISelectItems.java:219)
              at org.jboss.seam.ui.component.UISelectItems.asSelectItems(UISelectItems.java:195)
              at org.jboss.seam.ui.component.UISelectItems.getValue(UISelectItems.java:166)
              at com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:296)
              at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:801)
              at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:280)
              at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
              at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
              at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
              at org.jboss.seam.ui.renderkit.FragmentRendererBase.doEncodeChildren(FragmentRendererBase.java:29)
              at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
              at org.ajax4jsf.renderkit.html.RepeatRenderer$1.process(RepeatRenderer.java:53)
              at org.ajax4jsf.model.SequenceDataModel.walk(SequenceDataModel.java:101)
              at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1133)
              at org.ajax4jsf.renderkit.html.RepeatRenderer.encodeChildren(RepeatRenderer.java:59)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
              at org.ajax4jsf.renderkit.html.RepeatRenderer$1.process(RepeatRenderer.java:53)
              at org.ajax4jsf.model.SequenceDataModel.walk(SequenceDataModel.java:101)
              at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1133)
              at org.ajax4jsf.renderkit.html.RepeatRenderer.encodeChildren(RepeatRenderer.java:59)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
              at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:106)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
              at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:106)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:166)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:83)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:157)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:83)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:157)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:83)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:157)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:83)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:157)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:83)
              at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:157)
              at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
              at org.ajax4jsf.component.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:677)
              at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:548)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
              at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
              at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
              at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
              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.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
              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:58)
              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:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              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:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Unknown Source)
      11:09:26,500 ERROR [lifecycle] JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /reservationforms/newBooking.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1c0ece2]
      11:09:26,500 WARN  [ExceptionFilter] handling uncaught exception
      javax.servlet.ServletException: var attribute must be set
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)





      This is my selectOneMenu->>>>>>>>>

      <h:selectOneMenu id="AttributeId" value="#{allocateBookables.attributes}"  style="font-size: 10px; color: #880000; width: 100px;float:left;" >
      <s:selectItems value="#{allocateBookables.retrieveAttributes()}" var="attribute" label="#{attribute.name}" noSelectionLabel="Please-Select" />
      <s:convertEntity />  <a:support event="onchange" action="#{allocateBookables.updateAttributes()}" reRender="bookableAllocationPanel"/>
                             
                              </h:selectOneMenu>


      Can any one help me out from this pbm !!!!!!!!!!!!!!!!!!!!!













        • 1. Re: var attribute must be set
          Leo van den berg Master

          Hi,


          have you tried to give another var-value to see if there is a naming conflict. The word attriute is very often used on our business.


          Leo

          • 2. Re: var attribute must be set
            dhanaraja rajendiran Newbie
            ya I tried that also by giving different var name etc........
            but not working.....

            and it is working for some condition (previous time also) and getting this error only in some situation only.....

            cant guess wthr it is a jsp problem or it is an java class problem.........

            this is my drop down retrieve method---------->>>>>>>

            public List<IcFacilityAmenityAttributes> updateAttributes(IcBusiness selectedInstance){

            return em.createQuery("from IcFacilityAmenityAttributes icAttributes where 1=1 and icAttributes.icInstance = :instance")

            .setParameter("instance", selectedInstance.getIcInstance())
            .getResultList();
                 }


            -------------------------------------------------------------

            <h:selectOneMenu id="AttributeId" value="#{allocateBookables.attributes}" style="font-size: 10px; color: #880000; width: 100px;float:left;" >

            I declared "allocateBookables.attributes" in my action class like this--------->>>


            private IcFacilityAmenityAttributes attributes;
                 public IcFacilityAmenityAttributes getAttributes() {
                      return attributes;
                 }

                 public void setAttributes(IcFacilityAmenityAttributes attributes) {
                      this.attributes = attributes;
                 }

            -----------------------------------------------------------------






                 
            • 3. Re: var attribute must be set
              Leo van den berg Master

              Hi,





              and it is working for some condition (previous time also) and getting this error only in some situation only.....


              So you say it works sometimes, but not always? Are you sure the query returns something ?


              Leo

              • 4. Re: var attribute must be set
                dhanaraja rajendiran Newbie

                ya its because  my query problem only ............


                Now i solved that problem.....


                now everything is working fine for me...................


                THANK YOU VERY MUCH FOR YOUR GUIDANCE !!!!!!!!!!!!!

                • 5. Re: var attribute must be set
                  Leo van den berg Master

                  Hi,


                  although it saves a lot of keystrokes, optmizing (shortening) code makes testing difficult.


                  Try something like:




                  public List<IcFacilityAmenityAttributes> updateAttributes(IcBusiness selectedInstance){
                  
                  List<IcFacilityAmenityAttributes> result;
                  
                  Query q = em.createQuery("from IcFacilityAmenityAttributes icAttributes where 1=1 and icAttributes.icInstance = :instance");
                  log.debug(<<LOG SOMETHING TO CHECK>>);
                  q.setParameter("instance", selectedInstance.getIcInstance())
                  result = q.getResultList();
                  log.debug(<<LOG SOMETHING TO CHECK>>);
                  
                  return result;
                  
                   }
                  



                  As soon as it works correctly you can optimize, (remove the logs and make it shorter), but there is really no need to do that.



                  Leo