12 Replies Latest reply: Mar 28, 2013 12:36 AM by Vignesh RSS

    How to avoid Component's client ID becoming null?

    Vignesh
      Hi All,

      I am using Jdev 11.1.2.2.

      I have a jspx page fragment named "someFragment.jsff".

      I have a jspx page named "somePage.jspx".

      In the somePage.jspx I am using a switcher and I am getting the value for the facetName inside the switcher from a bean.

      Depending on the facetName I am rendering different jspx page fragments and the code is as follows:
      <af:switcher id="s1" facetName="#{controller.selectedBOMTreeItem.type}">
        <f:facet name="node1">
          <f:subview id="node1">
            <jsp:include page="/someFragment.jsff"/>
          </f:subview>                                                 
        </f:facet>
        <f:facet name="node2">
          <f:subview id="node2">
            <jsp:include page="someFragmentDifferent.jsff"/> // Different page fragment
          </f:subview>
        </f:facet>
        <f:facet name="node3">
          <f:subview id="node3">
            <jsp:include page="someFragment.jsff"/>
          </f:subview>
        </f:facet>
      </af:switcher>
      The value of the facetName depends on a tree selection.

      The parent container for the switcher region is panelStretchLayout and the somePage.jspx is based on a template and the someFragment.jsff is based on a different template.

      Now the problem is that I am using a table inside the someFragment.jsff and the Id of that table is someTable.

      I am using the following code:
              RichTable someTable = (RichTable)JSFUtils.findComponentInRoot("someTable");
      and it returns the client Id of the component for the first time it is called in the switcher (node1).

      But when it is called for node3 it is returning null for the client Id of the component.

      Is there any solution for this problem and let me know if you need some more information regarding the use case.

      Note : This issue also occurs when the component Id is same in two different jspx page fragments used inside the switcher in a jspx page.

      Thanks,
      Vignesh.
        • 1. Re: How to avoid Component's client ID becoming null?
          Abhijit Dutta
          Hi,

          you create component references (using binding property of the component) and use it for referring the component. or else,check the way for getting the component reference for component inside an ADF region:
          http://biemond.blogspot.com/2009/11/find-uicomponent-in-adf-task-flow.html

          ~Abhijit
          • 2. Re: How to avoid Component's client ID becoming null?
            Vignesh
            Hi Abhijit,

            Thanks for your response.

            We followed the same method in the blog you mentioned and the method "findComponentInRoot(String id)" we used is the same as "getUIComponent(String name)" in the blog.

            It's because of this method it is getting the client Id of the component in the first place.

            The problem is with the component Id being called twice/more in the same region.

            Any help on this issue?

            Thanks,
            Vignesh.
            • 3. Re: How to avoid Component's client ID becoming null?
              Abhijit Dutta
              Hi,

              according to the blog
              When you want to find an UIComponent (like a Tree) inside an ADF Region you can not use findComponent on the ViewRoot because this will only search for the component in the JSF page and not in the JSF page >fragments ( Task Flows).
              my question is why don't you use table binding in the managed bean instead of using findComponentInRoot..

              ~Abhijit
              • 4. Re: How to avoid Component's client ID becoming null?
                Abhijit Dutta
                Hi,

                according to the blog
                When you want to find an UIComponent (like a Tree) inside an ADF Region you can not use findComponent on the ViewRoot because this will only search for the component in the JSF page and not in the JSF page >fragments ( Task Flows).
                my question is why don't you use table binding in your managed bean instead of findComponentInRoot..

                ~Abhijit
                • 5. Re: How to avoid Component's client ID becoming null?
                  Vignesh
                  Hi,

                  Regarding the method, it is retrieving the client Id when the component is called for the first time so the method is not an issue.

                  Regarding the binding of the component, I tried it and it is throwing null pointer exception while rendering the table.

                  FYI, the bean is in session scope. Is the exception due to session scope?

                  Any idea regarding the null pointer exception?

                  Do you want me to post the stack trace?

                  Thanks,
                  Vignesh.
                  • 6. Re: How to avoid Component's client ID becoming null?
                    Abhijit Dutta
                    Hi,

                    why you need a session scope? paste the stack stress also. you can delete the table binding and again re-generate it in managed bean and check whether the NPE still there.


                    ~Abhijit
                    • 7. Re: How to avoid Component's client ID becoming null?
                      Vignesh
                      Hi Abhijit,

                      Let me try the same with a managed bean and let you know.

                      Is there any way to avoid client Id becoming null without binding the table to the bean?

                      I studied in a blog that composite component/ declarative component will help when using the same component multiple times.

                      Do you have any idea regarding this?

                      Thanks,
                      Vignesh.
                      • 8. Re: How to avoid Component's client ID becoming null?
                        Abhijit Dutta
                        Hi,
                        as you are using aTF region can you have a look at "Find an UIComponent in an ADF Task Flow Region". see if this help.
                        http://biemond.blogspot.in/2009/11/find-uicomponent-in-adf-task-flow.html

                        ~Abhijit
                        • 9. Re: How to avoid Component's client ID becoming null?
                          Vignesh
                          Hi Abhijit,

                          You have already posted this blog and we are not using taskflows.

                          The jsff page fragment is included in the jspx page using af:switcher.

                          Thanks,
                          Vignesh.
                          • 10. Re: How to avoid Component's client ID becoming null?
                            Frank Nimphius-Oracle
                            Hi,

                            I think this thread is going nowhere as there is too many missing information:

                            1. a switcher just hides components which means that if a component has its clientComponent="true" property set, a client ID is rendered as well --> missing information #1: does the component have the clientComponent="true" property set assuming you want to access it from JS?
                            2. RichTable someTable = (RichTable)JSFUtils.findComponentInRoot("someTable"); does search the root view and not the subview. The subview is a naming container and as such the table ID becomes subviewId:tableId --> missing information #2: do you reflect the subview Id in the table ID search?
                            3. What do you need the client Id for? This ID is usually only required for component JavaScript access --> missing information #3: Usecase

                            Frank
                            • 11. Re: How to avoid Component's client ID becoming null?
                              Vignesh
                              Hi Frank,

                              I think I should start with my use case.

                              #3. Our use is that to get the selected row keys in the table and the code is as follows:
                                  public boolean isTableDeleteButtonEnabled() {
                                      RichTable someTable= (RichTable)JSFUtils.findComponentInRoot("someTable");
                                      RowKeySet set = someTable.getSelectedRowKeys();  // set is returning null
                                      if (set == null || set.isEmpty())
                                          return false;
                                      Object key = set.iterator().next();
                                      someTable.setRowKey(key);
                                      // Get selected table row
                                      BaseTreeItem selectedValue = (BaseTreeItem)someTable.getRowData();
                                  }
                              The issue is that the table has a selected row but the set is returning null and I thought the reason is client Id returning null.

                              Note : This happens only when the switcher calls the same jsff second time.

                              #2. If you are asking about the client ID, ya it is reflecting the subviewId too.

                              If I understood the question wrongly please explain me a bit more.

                              #1. No, the clientComponent property is not set to true and I am not using JavaScript.

                              I am asking about client ID not to use anywhere but when I debug the code I saw that the client ID is becoming null and I thought this is the reason why the selected row key set is becoming null.

                              Please let me know for more information.

                              Thanks,
                              Vignesh.
                              • 12. Re: How to avoid Component's client ID becoming null?
                                Vignesh
                                Hi Frank,

                                Does Client ID has anything to do with the retrieving of the selected row key from the table?

                                Thanks,
                                Vignesh.