David Cheng-Hk

Greenhorn
+ Follow
since Dec 02, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David Cheng-Hk

Define your own data table like this:

DataColumn : class represents a single column in a rowset
DataRow: ArrayList<DataColumn> will represent a rowset
DataTable: ArrayList<DataRow> will represent a list of rowset, i.e. a data table

in each class, have those getter/setter ready to provide access to each column/row

assuming you have MyFaces Tomahawk:
then bind the <t:dataTable> to the datatable implementation in your backing bean
<t:dataTable id="mydataTable" border="1" cellspacing="5"
binding="#{myBean.myDataTable}" var="myDT"
rowIndexVar="rowIndex"
rowStyleClass="#{(rowIndex % 2 == 1 ? 'odd' : 'even')}">
<!-- first column -->
<t:column>
<!-- header of first column -->
<f:facet name="header">
<t:selectBooleanCheckbox id="cbxSelectAll"
binding="#{myBean.cbxSelectAll}"
onclick="selectAll(this, 'cbxChecked')" />
</f:facet>
<!-- value of first column -->
<t:selectBooleanCheckbox id="cbxChecked"
value="#{myBean.selectedIds[myDT.myColumnName]}" />
</t:column>
<!-- 2nd column -->
<t:column>
<!-- header of 2nd column -->
<f:facet name="header">
<h:outputText value="2nd Column Header" />
</f:facet>
<!-- value of 2nd column -->
<h:outputText value="#{myDT.myColumnName}" />
</t:column>
...
</t:dataTable>

in the backing bean:
HtmlSelectBooleanCheckbox cbxSelectAll; to keep track if the "select all" checkbox has been checked
Map<Integer, Boolean> selectedIds; Map to keep track which item has been selected
HtmlDataTable myDataTable = new HtmlDataTable();
12 years ago
JSF
For Tree View, have a look at Apache MyFaces Tomahawk - http://myfaces.apache.org/tomahawk
They have Tree, Tree2, play with the examples and see if it's what you need.


http://myfaces.apache.org/tomahawk/download.html
download and setup tomahawk, the deploy the .war examples

12 years ago
JSF