简体   繁体   中英

Assign a unique client ID to each <rich:dataTable /> row?

I'm relatively new to working with the UI in Seam, so I'm hoping there is something simple I can replace the three instances of UNIQUE_ID with in the following example.

The goal is to have a <rich:dataTable /> wherein each row has the ability to show/hide a <rich:modalPanel /> with more details about the particular object instance.

<rich:dataTable var="object" value="#{bean.myObject}">
  <rich:column>
    <h:outputText value="#{object.summary}" />
  </rich:column>

  <rich:column>
    <a onclick="Richfaces.showModalPanel('UNIQUE_ID');" href="#">Show Details in ModalPanel</a>
    <a4j:form>
      <rich:modalPanel id="UNIQUE_ID" >
        <a onclick="Richfaces.hideModalPanel('UNIQUE_ID');" href="#">Hide This ModalPanel</a>
        <h:outputText value="#{object.details}" />
      </rich:modalPanel>
    </a4j:form>
  </rich:column>
</rich:dataTable>

If I only had one link/modalPanel pair, this would obviously be trivial, but I don't know what to do within the scope of the <rich:dataTable /> 's iteration. Also, in case it complicates things further, the page will also contain many <rich:dataTable /> 's, each implementing this behavior.

Take a look at the <rich:componentControl /> tag.

Use attachTo to "bind" the event to display the modalPanel you wish to popup using the for attribute.

Ex:

<h:outputLink id="modalPanelLink" value="#">Show Details
    <rich:componentControl attachTo="modalPanelLink" for="modalPanelId" event="onclick" operation="show" />
</h:outputLink>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM