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

社会主义新天地 提交于 2019-12-24 19:22:22

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/2866757/assign-a-unique-client-id-to-each-richdatatable-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!