3 Replies Latest reply on Dec 29, 2008 2:05 PM by nbelaevski

    rich:component returns the component with the same id in ano

    liuliu

      hi,

      I have a page with a tooltip included(ui:include) in 2 places in two forms different. the method rich:component('idToolTip') returns always the same component(I think it returns the first one it found in the component tree) when i call this method in the two forms different.

      I remember some richfaces's guy(sorry for his name) talked about if we add ":" before the id on rerender, richfaces search it only on the same level(or in the same form?) Is it true? it will work with the rich:component too?

      thanks in advance

      liu

        • 1. Re: rich:component returns the component with the same id in
          nbelaevski

          Hello Liu,

          Functions (rich:component(), rich:element(), rich:clientId()) are contextless in JSF, there's no way to know from what component they're called, so searching is done starting from view root and the first matching component is always used. Absolute path: :formName:componentName should solve the problem.

          • 2. Re: rich:component returns the component with the same id in
            liuliu

            thanks

            for absolute path, you want to write "formName:componentName" not ":formName:componentName"

            • 3. Re: rich:component returns the component with the same id in
              nbelaevski

              Both variants will work. 'formName:componentName' is relative path though, consider the following example:

              <f:subview id="subview1">
               <a4j:form id="form">
              
               <rich:panel id="panel">
               Panel
               </rich:panel>
              
               <rich:panel id="panel2">
               Panel 2
               </rich:panel>
              
               </a4j:form>
               </f:subview>
              
               <f:subview id="subview">
               <a4j:form id="form">
              
               <rich:panel id="panel">
               Panel
               </rich:panel>
              
               <rich:panel id="panel2">
               Panel 2
               </rich:panel>
              
               </a4j:form>
               </f:subview>
              
               <h:outputText value="#{rich:clientId('form:panel')}" /><br />
               <h:outputText value="#{rich:clientId(':subview:form:panel')}" />