I have a requirement of expanding/collapsing the row contents of a table using trinidad tags. Have tried with the following approach
Approach :
- Added RowDisclosureEvent to the tr:table tag of my jspx
- Defined facet:detailStamp for the inside table to be displayed
- Handled RowDisclosureEvent in my MgdBean
- I am using myfaces api and impl 2.1.17 , trinidad api/impl 2.1.0
Below are the code snippets for jspx and MgdBeans.
Snippet of jspx
<tr:table id="offers" var="offer"
rendered="#{oMgdBean.offerList != null}"
value="#{oMgdBean.filteredOList}" varStatus="stat"
binding="#{cpMgdBean.oTable}"
rowDisclosureListener="#{cpMgdBean.handleDisclosureEvent}"
width="100%">
<tr:column align="start" styleClass="oLink">
<tr:panelHorizontalLayout rendered="#{offer.id != 'no_offer' and !empty offer.id}">
<tr:commandLink id="oLink" text="#{offer.name}" >
<tr:setActionListener from="#{offer.name}"
to="#{pageFlowScope.propName}" />
<tr:setActionListener from="#{offer.id}"
to="#{pageFlowScope.propId}" />
</tr:commandLink>
</tr:panelHorizontalLayout>
</tr:column>
<f:facet name="detailStamp" rendered="#{offer.id != 'no_offer' and !empty offer.id}">
<tr:panelHorizontalLayout halign="center">
<tr:table styleClass="priorities" var="customerPriority" value="#{pageFlowScope.customerPriorityMap[offer.id]}" >
<!-- Display the data here -->
</tr:table>
</tr:panelHorizontalLayout>
</f:facet>
</tr:table>
Snippet of MgdBean
public void handleDisclosureEvent(org.apache.myfaces.trinidad.event.RowDisclosureEvent event) throws ServiceException{
//get prop id from row
RowKeySet AddedRowKeys = event.getAddedSet();
List newList;
Iterator rowKeysIter = AddedRowKeys.iterator();
Product currentProp = null;
while(rowKeysIter.hasNext()){
//offerTable is instance of CoreTable
offerTable.getComponent().getRowCount().setRowKey(rowKeysIter.next());
currentProp = (Product)offerTable.getComponent().getRowData();
if(null != currentProp){
//check map for entry
if(pageFlowMap.containsKey(currentProp.getId())){
return;
}
newList = getData(currentProp);
pageFlowMap.put(currentProp.getId(), newList);
}
}
}
Issues facing with current approach:
- When I try to access the getRowData() of my table, selected RowData is coming as null. The getAddedSet does not seem to have the selected RowKeySet. (I think)
- If I have 3 rows in my main table and I select first one to expand, all three rows are being expanded.
Any help would be appreciated.