Hi All
I am having a need to sort data displayed using <t:dataTable>.
I am using the tomahawk.jar and have placed it into the WEB-INF/lib folder.
I am using the following jsp to display the results.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%-- jsf:pagecode language="java" location="/JavaSource/com/intuit/ims/oasis/ui/jsp/component/search/TablesTest1.java" --%><%-- /jsf:pagecode --%>
<HTML>
<HEAD>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<TITLE>TablesTest1.jsp</TITLE>
</HEAD>
<f:view>
<BODY>
<t:dataTable var="results" value="#{pc_TableTest.names}" sortColumn="#{pc_TableTest.columnName}">
<t:column id="column1">
<f:facet name="header">
<h:outputText id="text1" value="#{pc_TableTest.columnName}"></h:outputText>
</f:facet>
</t:column>
</t:dataTable>
</BODY>
</f:view>
</HTML>
And my backing bean is as below:
public class TablesTest1 extends PageCodeBase {
private final Name[] names = {
new Name("Mariko", "Keeney"),
new Name("John", "Wilson"),
new Name("Charles", "Randor"),
new Name("Anna", "Dupont")
};
private String columnName = "Name";
protected HtmlSimpleColumn column1;
protected HtmlSimpleColumn getColumn1() {
if (column1 == null) {
column1 = (HtmlSimpleColumn) findComponentInRoot("column1");
}
return column1;
}
/**
* @return Returns the names.
*/
public Name[] getNames() {
return names;
}
/**
* @return Returns the columnName.
*/
public String getColumnName() {
return columnName;
}
/**
* @param columnName The columnName to set.
*/
public void setColumnName(String columnName) {
this.columnName = columnName;
}
}
The Name class is a standard java class having just 2 variables .i.e. firstName and lastName as below
public class Name {
private String firstName;
private String lastName;
public Name(String fName, String lName){
firstName = fName;
lastName = lName;
}
/**
* @return Returns the firstName.
*/
public String getFirstName() {
return firstName;
}
/**
* @param firstName The firstName to set.
*/
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
* @return Returns the lastName.
*/
public String getLastName() {
return lastName;
}
/**
* @param lastName The lastName to set.
*/
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
When I run the jsp, the results are displayed, but t:dataTable does not provide any mechanism which will allow sorting the firstname.
Should <t:datatable> display an href on the column header to allow sorting?
Any help is highly appreciated.
Thanks
Amol