3 Replies Latest reply on Dec 13, 2006 12:54 PM by supert24 supert24

    variable resolver not working?

    supert24 supert24 Newbie

      When my action method of my Seam component is triggered, I try to find an enclosed UIComponent, for which I defined id="datMod", by executing

      UIComponent uiDat = javax.faces.context.FacesContext.getCurrentInstance().getViewRoot().findComponent("datMod");
      

      Unfortunatelly it returns null.

      Another approach was to resolve a variable "item" bound by this UIComponent, unfortunately returning null, too:
      Object o = javax.faces.context.FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(javax.faces.context.FacesContext.getCurrentInstance(), "item");
      


      Ok, here is the code of my enclosing UIComponent:
      <h:dataTable var="item" value="#{buy_ActionShowMenu_menu_WEB_OUT.menuItems}" id="datMod">
      
      ..
      <h:column>
      <s:button value="ADD" action="#{mySeamComponent.myActionMethod()}" />
      </h:column>
      </h:dataTable>


      Any idea?




        • 1. Re: variable resolver not working?
          Norman Richards Master

          A component is not a variable, so the variable resolver won't work. You are on the right track with findComponent, but your component id is actually not "datMod". If there is a surrounding naming component (like h:form) your name will be prefixed with that. So, if your form is "id="myform" then you need to look up "myform:datMod". If you have any other naming components, you can take those into consideration too.

          • 2. Re: variable resolver not working?
            Norman Richards Master

            Oh, I should add that if you aren't sure of the name, a quick solution is to take a look at the generated HTML. Search for "datMod" and see how it is being used.

            • 3. Re: variable resolver not working?
              supert24 supert24 Newbie

               

              "norman.richards@jboss.com" wrote:
              Oh, I should add that if you aren't sure of the name, a quick solution is to take a look at the generated HTML. Search for "datMod" and see how it is being used.


              Well ok I see my "formId:datMod" and the "formId" itself.
              My general problem now is, that findComponent() always return null.

              Is it really normal, that
              javax.faces.context.FacesContext
               .getCurrentInstance().getViewRoot().getChildCount()



              returns 0 ?

              By the way, javax.faces.context.FacesContext is not found by using standard Seam libs, so I added lib/myfaces-api-1.1.4.jar from the Seam install dir to my class path, hope this not caused the ill functioning.

              Thanks