1 Reply Latest reply on Jan 26, 2010 6:50 AM by vineet_tripathi

    Long client id's for rich faces components in portlets

    mschwietzke

      When using JSF components in Portlets, very long client id's are automatically generated inlcuding the path of the current page.

       

      E. g. jbpns_2fdefault_2fKunde_20und_20Kontakte_2fKontaktesnpbj:_viewRoot:cf:forenameSearchterm


      Is there any possibilty to get them shorter?
      For example to define a very short id for each page in JBoss Portal?
      Then the id's could be much shorter and many traffic could be avoid. In my opinion
      it is horror that each component has got such so long id's in the source code.

      Regards
      Martin

        • 1. Re: Long client id's for rich faces components in portlets

          Namespacing

          The bridge handles the namespacing combinations of JSF in the portal environment. In situations where you need to use the id of an element in your JSF/xhtml markup, you would normally see something like 'form1:myBtn' in the rendered markup. But now with the bridge namespacing you will see something similar to:
          jbpns_2fdefault_2fNews_2fStories_2fStoryTemplateWindow12snpbj:_viewRoot:form1:myBtn

          To overcome this, you can use the following expression in your Facelets page to prepend the namespace to your javascript code:
          document.getElementById('#{facesContext.externalContext.response.namespace}the_rest_of_JSF_ID');

          Please note that since this uses the portletResponse, once you try to view this page on the servlet application side you will get an exception. To avoid this, you need to check for the type of response in your backing bean and assign a new "safe" namespace variable for the UI.

           

          Refer to: http://www.infoq.com/articles/jsf-ajax-seam-portlets-pt-1