Search code examples
jsfrichfacesjsf-1.2richfaces-modal

How to know in JSF 1.2 and richfaches the id from h:column in a h:datatable


I have a datatable from which I open with a click on an image the <rich:modalPanel>. But the <rich:componentControl for="panel" attachTo="showPreview" must have the exact id, in my case below: showPreview, but as my link is inside a dataTable, it will be generated like 1:showPreview 2:showPreview.....n:showPreview

Is there any way to know in which line of the table i am, to get a dynamic binding?

My XHTML in JSF 1.2 looks something like this:

<h:dataTable  styleClass="tb_tabletag" id="dtContentPosts" value="#{listOfObjects}" var="object">
    <h:column id="columnnumber" >
        <h:outputLink id="showPreview" value="#">
        <h:graphicImage value="preview.png" />      
        <rich:componentControl for="panel" attachTo="showPreview" operation="show"
            event="onclick"/>
        </h:outputLink>
    </h:column>
</h:dataTable>
...
...
...
<rich:modalPanel id="panel" autosized="true">
  some stuff 
</rich:modalPanel>

Thank you for any help!


Solution

  • Thanks Luiggi for your link, with the given source code,this helped me to find my simple trick: i get now the number with: #{listOfObjects.indexOf(object)}

    the only important thing is, that the modalPanel is in a <h:column></h:column> to receive the correct number works perfect