2 Replies Latest reply on Feb 23, 2009 4:57 AM by nbelaevski

    assigning ids to components

    aish

      Hi,

      At times, I encounter duplicate id issue and hence I started assigning "ids" to the components.

      I have certain pages where there are numerous components - about 200 outputText component for a datatable.It becomes difficult to assign ids to all of them. Could you please let me know if there is any efficient way to handle this id assignment.

      Thanks
      Aish

        • 1. Re: assigning ids to components

          I had that problem before and it was because I used session-scoped JSF components, for example <rich:tabPanel> is bound to a session-scoped bean (the JSF spec advises that components should be bound to request-scoped objects only).

          I have a facelets custom component which will render a <h:panelGroup>. The id of the panelGroup is the one of the facelets component (let's call it _id) or an auto-generated one. So

          <h:panelGroup id="#{empty _id ? someBean.id : _id}"
          where
          public class SomeBean {
           public String getId() {
           return FacesContext.getCurrrentInstance().getViewRoot().createUniqueId();
           }
          }

          Not sure if I understand your situation correctly.

          • 2. Re: assigning ids to components
            nbelaevski

            Hi Aish,

            You can develop XSLT template and auto-generate ids: http://www.w3schools.com/XSL/func_generateid.asp.