1 Reply Latest reply on Aug 11, 2008 11:32 AM by Brian Gregory

    Dynamically created component IDs

    Peter Treitler Newbie


      In my Application I have a dataTable with a "show details" link for each row, basically like this:

      <t:dataTable id="myTable" value="#{MyBean.data}" var="rowVar" ...>
       <h:commandLink action="showDetail">
       <h:outputText value="#{rowVar.title}" />

      Now I want to click one of these links in a JSFUnit test, which obviously is a problem since I couldn't assign component IDs to my links.
      Is there an easy way to assign IDs all my links or to somehow refer to the components without an ID?

        • 1. Re: Dynamically created component IDs
          Brian Gregory Newbie

          If you assign an id="" to the h:commandLink, you'll notice that richfaces will make that id unique (if you look for the generated html in the "view source"). The tail end of the actual id for the link will be something like <table id>:<row key>:<link id> where the "row key" will be derrived from whatever richfaces thinks is the key for the particular row (and there may be a number of prefix items, but you only need a 'unique' tail end to find the component).

          If you add id="linkid" h:commandLink in your example, the tail end of link id will probably be "myTable:rowkey:linkid".