| Author |
Message |
|
|
Hi,
I wrote those codes long back,somehow I managed to get the deployable and source.Both are attached.But Ice faces jars related to the war are also out dated.I don't remember the exact version probably they are 1.5.1. Paginator component for showing no of items,doesn't work.
But the concept works and I have implemented that in my project through the following way:
1. Create a dummy DataTable and Two data paginator components.Initially u may kept them without data or set their rendering to false.
2. Put a row selector on the first column of the datatable.
3.In a action grab the table and old row selector and dynamically assign it to the new table as I did in my code.Also reset the pagination counter.
4. I think making a sortable column is not a problem.It works.
It worked for me.I hope it will work for others.I have not tried these with the new 1.6 release.If you really wish to see things working as I have mentioned,I will have to make an example in my free time and post it.Please let me know if you wish to have the same.Thanks for showing your interest in solution I posted earlier.
Thanks
Satyajit.
|
 |
|
|
Hi,
I haven’t realized it before. Would you please tell me where people are trying to use a Action Event for a row selection. In fact it almost burned my weekend to figure out a solution.I am happy it is useful to you.
Thanks
Satyajit
|
 |
|
|
Hi,
Thanks for your explanation.It helped me a lot.
Thanks,
Satyajit
|
 |
|
|
Hi,
Thanks for attaching the war.I have tried it in my environment,it is working perfectly.
Don't know why it is not working when I am tring to build my war.I have included ice 1.5.2 jars.My environment is Tomcat 5.5.20,jdk version 1.5.Would it be possible for you to deploy it.Possibly I am missing something.But not able to figure out the mismatch.
Thanks again,
Satyajit
|
 |
|
|
Hi,
With the below code when I am trying to refresh the page,I am getting the following error.I find it is the dtatatable binding after adding which I am getting the error.Would somebody please help me to solve the problem.
- Failed to execute JSP lifecycle.
java.lang.IllegalStateException: Duplicate component ID : myForm:itemID:_id8
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:176)
Code:
<f:view xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<ice:outputDeclaration doctypeRoot="HTML"
doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN"
doctypeSystem="http://www.w3.org/TR/html4/loose.dtd" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
<link href="css/showcase_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<ice:form id="myForm">
<ice:dataTable value="#{testBean.tableData}" id="itemID" rows="5"
var="pnt" binding="#{testBean.myDataTable}">
<ice:column>
<f:facet name="header">
<ice:outputText value="name" />
</f:facet>
<ice:outputText value="#{pnt.name}" />
</ice:column>
</ice:dataTable>
</ice:form>
</body>
</html>
</f:view>
Code:
package com.test;
import com.icesoft.faces.component.ext.HtmlDataTable;
public class TestBean {
HtmlDataTable myDataTable = null;
public Parent[] getTableData() {
return dataList;
}
private Parent[] dataList = new Parent[] { new Parent("XXX"),
new Parent("YYY"), new Parent("ZZZ") };
public class Parent {
String name;
public Parent(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public HtmlDataTable getMyDataTable() {
return myDataTable;
}
public void setMyDataTable(HtmlDataTable myDataTable) {
this.myDataTable = myDataTable;
}
}
Code:
<managed-bean>
<description>
Backing bean that controls panel layout
</description>
<managed-bean-name>testBean</managed-bean-name>
<managed-bean-class>
com.test.TestBean
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
Any help will be highly appreciated.
Thanks
Satyajit
|
 |
|
|
Hi,
I found out a solution for creating a dynamic,sortable,row selectable datatable.
In the current realese of ICEFaces, the following doesn't work related to datatable.
1.You will not be able to bind a method to selectionListener dynamically.
The below commented portion won't work.
Code:
RowSelector rs=new RowSelector();
rs.setId("rs_" + columnName);
ValueBinding binding = app.createValueBinding("#{vartableData.selected}");
rs.setValueBinding("value", binding);
ValueBinding bindingMS = app.createValueBinding("#{dataTableCreator.multipleSelection}");
rs.setValueBinding("multiple", bindingMS);
/*
ValueBinding bindingRS = app.createValueBinding("#{dataTableCreator.rowSelection}");
rs.setValueBinding("selectionListener", bindingRS);
*/
/*Class ca[] = {com.icesoft.faces.component.ext.RowSelectorEvent.class};
javax.faces.el.MethodBinding mb = app.createMethodBinding("#{dataTableCreator.rowSelection}", ca);
rs.setSelectionListener(mb);*/
2.Although you will be able to dynamically create a DataPaginator component for
go next,go previous buttons etc but if you try to dynamically create a DataPaginator component
for displayed record status it is not working.
Method createDataPaginatorComponent() works but createDataPaginatorDisplayInfo() doesn't.
Code:
private DataPaginator createDataPaginatorComponent()
{
DataPaginator dataPaginator=new DataPaginator();
dataPaginator.setFor("inventoryTableID");
dataPaginator.setPaginator(true);
dataPaginator.setId("dataScroll_3");
dataPaginator.setFastStep(3);
dataPaginator.setPaginatorMaxPages(10);
HtmlGraphicImage first=new HtmlGraphicImage();
first.setUrl("./xmlhttp/css/xp/css-images/arrow-first.gif");
first.setStyle("border:none;");
first.setTitle("First Page");
first.setId("id_first");
dataPaginator.setFirst(first);
HtmlGraphicImage last=new HtmlGraphicImage();
last.setUrl("./xmlhttp/css/xp/css-images/arrow-last.gif");
last.setStyle("border:none;");
last.setTitle("Last Page");
last.setId("id_last");
dataPaginator.setLast(last);
HtmlGraphicImage previous=new HtmlGraphicImage();
previous.setUrl("./xmlhttp/css/xp/css-images/arrow-previous.gif");
previous.setStyle("border:none;");
previous.setTitle("Previous Page");
previous.setId("id_previous");
dataPaginator.setPrevious(previous);
HtmlGraphicImage next=new HtmlGraphicImage();
next.setUrl("./xmlhttp/css/xp/css-images/arrow-next.gif");
next.setStyle("border:none;");
next.setTitle("Next Page");
next.setId("id_next");
dataPaginator.setNext(next);
HtmlGraphicImage fastforward=new HtmlGraphicImage();
fastforward.setUrl("./xmlhttp/css/xp/css-images/arrow-ff.gif");
fastforward.setStyle("border:none;");
fastforward.setTitle("Fast Forward");
fastforward.setId("id_fastforward");
dataPaginator.setFastForward(fastforward);
HtmlGraphicImage fastrewind=new HtmlGraphicImage();
fastrewind.setUrl("./xmlhttp/css/xp/css-images/arrow-fr.gif");
fastrewind.setStyle("border:none;");
fastrewind.setTitle("Fast Backwards");
fastrewind.setId("id_fastrewind");
dataPaginator.setFastRewind(fastrewind);
return dataPaginator;
}
private DataPaginator createDataPaginatorDisplayInfo()
{
DataPaginator dataPaginator=new DataPaginator();
dataPaginator.setFor("inventoryTableID");
dataPaginator.setId("dataScroll_2");
dataPaginator.setRowsCountVar("rowsCount");
dataPaginator.setDisplayedRowsCountVar("displayedRowsCount");
dataPaginator.setFirstRowIndexVar("firstRowIndex");
dataPaginator.setLastRowIndexVar("lastRowIndex");
dataPaginator.setPageCountVar("pageCount");
dataPaginator.setPageIndexVar("pageIndex");
HtmlOutputFormat of=new HtmlOutputFormat();
of.setStyleClass("standard");
of.setValue("{0} items found, displaying {1} item(s), from {2} to {3}. Page {4} / {5}.");
UIParameter paramrowsCount=new UIParameter();
paramrowsCount.setValue("#{rowsCount}");
of.getChildren().add(paramrowsCount);
UIParameter paramdisplayedRowsCount=new UIParameter();
paramdisplayedRowsCount.setValue("#{displayedRowsCount}");
of.getChildren().add(paramdisplayedRowsCount);
UIParameter paramfirstRowIndex=new UIParameter();
paramfirstRowIndex.setValue("#{firstRowIndex}");
of.getChildren().add(paramfirstRowIndex);
UIParameter paramlastRowIndex=new UIParameter();
paramlastRowIndex.setValue("#{lastRowIndex}");
of.getChildren().add(paramlastRowIndex);
UIParameter parampageCount=new UIParameter();
parampageCount.setValue("#{pageCount}");
of.getChildren().add(parampageCount);
UIParameter parampageIndex=new UIParameter();
parampageIndex.setValue("#{pageIndex}");
of.getChildren().add(parampageIndex);
dataPaginator.getChildren().add(of);
return dataPaginator;
}
If the reader finds any mistake with method createDataPaginatorDisplayInfo() please send comments.
I think the parameter values can only accessable from client side after it is rendered fully.
So inorder to solve the problem I have taken the below approach:
1.Create a dummy datatable and two datapaginator components(for buttons and status)
2.Add a row selector to the first column of the datatable.
3.I am assuming here that all the new dynamically created tables should have the row selector
attached to the first column.
4.When a new datatable is created extract out the old row selector reference and use it in the new.
Here you can assign the new binding for the row selector and ICEFaces happily accepts that.
Please find the related codes as below:
Code:
**********************************Test.jspx********************************************
<f:view xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<ice:outputDeclaration doctypeRoot="HTML"
doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN"
doctypeSystem="http://www.w3.org/TR/html4/loose.dtd"/>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1"></meta>
<title>Tree Component Tutorial</title>
<link href="css/showcase_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<ice:form id="myForm">
<ice:panelGrid columns="1"
columnClasses="contentLayoutGridColumn"
cellpadding="5" style="width: 100%;border: 1px solid gray;">
<ice:commandButton image="./xmlhttp/css/xp/css-images/clickme.gif"
actionListener="#{employeeTableBean.constructComponent}"
styleClass=""/>
<ice:panelGroup style="border: 1px solid gray; height: 250px;" binding="#{employeeTableBean.myPanelGroup}" >
<ice:dataTable
value="#{employeeTableBean.employeeList}"
binding="#{employeeTableBean.employeeDataTable}"
id="employeeTableID"
rows="5"
var="empl">
<ice:column>
<ice:rowSelector value="#{empl.selected}"
multiple="#{employeeTableBean.multipleSelection}"
selectionListener="#{employeeTableBean.rowSelection}"/>
<f:facet name="header">
<ice:outputText value="Name"/>
</f:facet>
<ice:outputText value="#{empl.name}"/>
</ice:column>
<ice:column>
<f:facet name="header">
<ice:outputText value="Address"/>
</f:facet>
<ice:outputText value="#{empl.address}"/>
</ice:column>
<ice:column>
<f:facet name="header">
<ice:outputText value="Gender"/>
</f:facet>
<ice:outputText value="#{empl.gender}"/>
</ice:column>
</ice:dataTable>
<!-- Paginator with page controls -->
<ice:dataPaginator id="dataScroll_3"
for="employeeTableID"
paginator="true"
fastStep="3"
binding="#{employeeTableBean.employeeDataPaginator}"
paginatorMaxPages="4">
<f:facet name="first">
<ice:graphicImage
url="./xmlhttp/css/xp/css-images/arrow-first.gif"
style="border:none;"
title="First Page"/>
</f:facet>
<f:facet name="last">
<ice:graphicImage
url="./xmlhttp/css/xp/css-images/arrow-last.gif"
style="border:none;"
title="Last Page"/>
</f:facet>
<f:facet name="previous">
<ice:graphicImage
url="./xmlhttp/css/xp/css-images/arrow-previous.gif"
style="border:none;"
title="Previous Page"/>
</f:facet>
<f:facet name="next">
<ice:graphicImage
url="./xmlhttp/css/xp/css-images/arrow-next.gif"
style="border:none;"
title="Next Page"/>
</f:facet>
<f:facet name="fastforward">
<ice:graphicImage url="./xmlhttp/css/xp/css-images/arrow-ff.gif"
style="border:none;"
title="Fast Forward"/>
</f:facet>
<f:facet name="fastrewind">
<ice:graphicImage url="./xmlhttp/css/xp/css-images/arrow-fr.gif"
style="border:none;"
title="Fast Backwards"/>
</f:facet>
</ice:dataPaginator>
<!-- Display counts about the table and the currently displayed page -->
<ice:dataPaginator id="dataScroll_2" for="employeeTableID"
binding="#{employeeTableBean.employeeDisplayedDataPaginator}"
rowsCountVar="rowsCount"
displayedRowsCountVar="displayedRowsCount"
firstRowIndexVar="firstRowIndex"
lastRowIndexVar="lastRowIndex"
pageCountVar="pageCount"
pageIndexVar="pageIndex">
<ice:outputFormat
value="{0} cars found, displaying {1} car(s), from {2} to {3}. Page {4} / {5}."
styleClass="standard">
<f:param value="#{rowsCount}"/>
<f:param value="#{displayedRowsCount}"/>
<f:param value="#{firstRowIndex}"/>
<f:param value="#{lastRowIndex}"/>
<f:param value="#{pageIndex}"/>
<f:param value="#{pageCount}"/>
</ice:outputFormat>
</ice:dataPaginator>
</ice:panelGroup>
</ice:panelGrid>
</ice:form>
</body>
</html>
</f:view>
********************************faces-config.xml*************************************************
<managed-bean>
<managed-bean-name>inventoryList</managed-bean-name>
<managed-bean-class>
com.workflowmanager.TableBean
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>employeeTableBean</managed-bean-name>
<managed-bean-class>
com.workflowmanager.EmployeeTableBean
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
*********************************EmployeeTableBean.java********************************************
package com.workflowmanager;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.component.UIParameter;
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;
import javax.faces.event.ActionEvent;
import com.icesoft.faces.component.commandsortheader.CommandSortHeader;
import com.icesoft.faces.component.datapaginator.DataPaginator;
import com.icesoft.faces.component.ext.HtmlDataTable;
import com.icesoft.faces.component.ext.HtmlGraphicImage;
import com.icesoft.faces.component.ext.HtmlOutputFormat;
import com.icesoft.faces.component.ext.HtmlOutputText;
import com.icesoft.faces.component.ext.HtmlPanelGroup;
import com.icesoft.faces.component.ext.RowSelector;
import com.icesoft.faces.component.ext.RowSelectorEvent;
import com.icesoft.faces.component.ext.UIColumn;
public class EmployeeTableBean {
private HtmlDataTable employeeDataTable = null;
private DataPaginator employeeDataPaginator=null;
private DataPaginator employeeDisplayedDataPaginator=null;
private Application app = FacesContext.getCurrentInstance().getApplication();
private boolean multipleSelection = false;
private ArrayList columnNames = new ArrayList();
private HtmlPanelGroup myPanelGroup;
public void constructComponent(ActionEvent e) {
List lst = employeeDataTable.getChildren();
RowSelector rsel=null;
for(int i=0;i<lst.size();i++)
{
Object obj=lst.get(i);
if(obj instanceof com.icesoft.faces.component.ext.UIColumn)
{
UIColumn col=(UIColumn)obj;
List lstColChilds=col.getChildren();
UIComponent facet=col.getFacet("header");
for(int j=0;j<lstColChilds.size();j++)
{
Object objColCh=lstColChilds.get(j);
if(objColCh instanceof com.icesoft.faces.component.ext.RowSelector)
{
System.out.println("ITS A RS");
rsel=(RowSelector)objColCh;
break;
}
}
}
}
System.out.println(" START SWITCH..............");
List list = employeeDataTable.getChildren();
list.clear();
ValueBinding tblBinding = app.createValueBinding("#{inventoryList.carInventory}");
employeeDataTable.setValueBinding("value", tblBinding);
employeeDataTable.setVar("item");
employeeDataTable.setId("inventoryTableID");
employeeDataTable.setRows(5);
// initialize column names
columnNames.add("stock");
columnNames.add("model");
columnNames.add("odometer");
columnNames.add("price");
int columnCount = columnNames.size();
for(int index = 0; index < columnCount; index++)
{
String columnName = (String)columnNames.get(index);
String columnBinding = "#{item."+columnName+"}";
UIColumn column = new UIColumn();
column.setId("col_" + columnName);
if(index==0)
{
System.out.println("Before transforming RS");
RowSelector rs=rsel;
rs.setId("rs_" + columnName);
ValueBinding binding = app.createValueBinding("#{item.selected}");
rs.setValueBinding("value", binding);
ValueBinding bindingMS = app.createValueBinding("#{inventoryList.multipleSelection}");
rs.setValueBinding("multiple", bindingMS);
ValueBinding bindingTBRS = app.createValueBinding("#{inventoryList.newTableBeanRowSelection}");
rs.setValueBinding("selectionListener", bindingTBRS);
column.getChildren().add(rs);
System.out.println("After transforming RS");
}
HtmlPanelGroup headerpg=new HtmlPanelGroup();
headerpg.setId("pnl_" + columnName+"_"+index);
CommandSortHeader cmdsh=new CommandSortHeader();
cmdsh.setId("cmdsh_" + columnName+"_"+index);
cmdsh.setColumnName(columnName);
cmdsh.setArrow(true);
Class[] params=new Class[]{ActionEvent.class};
MethodBinding mbRS = app.createMethodBinding("#{inventoryList.cmdSortHeaderAction}", params);
cmdsh.setActionListener(mbRS);
HtmlOutputText header = new HtmlOutputText();
header.setId("hdr_" + columnName);
header.setValue(columnName);
cmdsh.getChildren().add(header);
headerpg.getChildren().add(cmdsh);
column.setHeader(headerpg);
HtmlOutputText text = new HtmlOutputText();
text.setId("txt_" + columnName);
ValueBinding vb = app.createValueBinding(columnBinding);
text.setValueBinding("value", vb);
HtmlPanelGroup htmlpg=new HtmlPanelGroup();
htmlpg.setId("pnl_" + columnName);
htmlpg.setStyle("text-align: center; white-space: nowrap;");
htmlpg.getChildren().add(text);
column.getChildren().add(htmlpg);
list.add(column);
}
/*
//Unfortunately createDataPaginatorDisplayInfo() doesn't work
myPanelGroup.getChildren().add(createDataPaginatorComponent());
myPanelGroup.getChildren().add(createDataPaginatorDisplayInfo());
*/
employeeDataPaginator.setFor("inventoryTableID");
employeeDisplayedDataPaginator.setFor("inventoryTableID");
}
private DataPaginator createDataPaginatorComponent()
{
DataPaginator dataPaginator=new DataPaginator();
dataPaginator.setFor("inventoryTableID");
dataPaginator.setPaginator(true);
dataPaginator.setId("dataScroll_3");
dataPaginator.setFastStep(3);
dataPaginator.setPaginatorMaxPages(10);
HtmlGraphicImage first=new HtmlGraphicImage();
first.setUrl("./xmlhttp/css/xp/css-images/arrow-first.gif");
first.setStyle("border:none;");
first.setTitle("First Page");
first.setId("id_first");
dataPaginator.setFirst(first);
HtmlGraphicImage last=new HtmlGraphicImage();
last.setUrl("./xmlhttp/css/xp/css-images/arrow-last.gif");
last.setStyle("border:none;");
last.setTitle("Last Page");
last.setId("id_last");
dataPaginator.setLast(last);
HtmlGraphicImage previous=new HtmlGraphicImage();
previous.setUrl("./xmlhttp/css/xp/css-images/arrow-previous.gif");
previous.setStyle("border:none;");
previous.setTitle("Previous Page");
previous.setId("id_previous");
dataPaginator.setPrevious(previous);
HtmlGraphicImage next=new HtmlGraphicImage();
next.setUrl("./xmlhttp/css/xp/css-images/arrow-next.gif");
next.setStyle("border:none;");
next.setTitle("Next Page");
next.setId("id_next");
dataPaginator.setNext(next);
HtmlGraphicImage fastforward=new HtmlGraphicImage();
fastforward.setUrl("./xmlhttp/css/xp/css-images/arrow-ff.gif");
fastforward.setStyle("border:none;");
fastforward.setTitle("Fast Forward");
fastforward.setId("id_fastforward");
dataPaginator.setFastForward(fastforward);
HtmlGraphicImage fastrewind=new HtmlGraphicImage();
fastrewind.setUrl("./xmlhttp/css/xp/css-images/arrow-fr.gif");
fastrewind.setStyle("border:none;");
fastrewind.setTitle("Fast Backwards");
fastrewind.setId("id_fastrewind");
dataPaginator.setFastRewind(fastrewind);
return dataPaginator;
}
private DataPaginator createDataPaginatorDisplayInfo()
{
DataPaginator dataPaginator=new DataPaginator();
dataPaginator.setFor("inventoryTableID");
dataPaginator.setId("dataScroll_2");
dataPaginator.setRowsCountVar("rowsCount");
dataPaginator.setDisplayedRowsCountVar("displayedRowsCount");
dataPaginator.setFirstRowIndexVar("firstRowIndex");
dataPaginator.setLastRowIndexVar("lastRowIndex");
dataPaginator.setPageCountVar("pageCount");
dataPaginator.setPageIndexVar("pageIndex");
HtmlOutputFormat of=new HtmlOutputFormat();
of.setStyleClass("standard");
of.setValue("{0} items found, displaying {1} item(s), from {2} to {3}. Page {4} / {5}.");
UIParameter paramrowsCount=new UIParameter();
paramrowsCount.setValue("#{rowsCount}");
of.getChildren().add(paramrowsCount);
UIParameter paramdisplayedRowsCount=new UIParameter();
paramdisplayedRowsCount.setValue("#{displayedRowsCount}");
of.getChildren().add(paramdisplayedRowsCount);
UIParameter paramfirstRowIndex=new UIParameter();
paramfirstRowIndex.setValue("#{firstRowIndex}");
of.getChildren().add(paramfirstRowIndex);
UIParameter paramlastRowIndex=new UIParameter();
paramlastRowIndex.setValue("#{lastRowIndex}");
of.getChildren().add(paramlastRowIndex);
UIParameter parampageCount=new UIParameter();
parampageCount.setValue("#{pageCount}");
of.getChildren().add(parampageCount);
UIParameter parampageIndex=new UIParameter();
parampageIndex.setValue("#{pageIndex}");
of.getChildren().add(parampageIndex);
dataPaginator.getChildren().add(of);
return dataPaginator;
}
public void rowSelection(com.icesoft.faces.component.ext.RowSelectorEvent e) {
System.out.println("RowSelectorEvent EVENT FIRED!!!!!!!!!!!!!!!!!!!");
}
private Employee[] employeeList = new Employee[] {
new Employee("AAA", "IND", "M"),
new Employee("BBB", "IND", "F"),
new Employee("XXX", "IND", "M"),
new Employee("YYY", "IND", "F") };
public Employee[] getEmployeeList() {
return employeeList;
}
public class Employee {
String name;
String address;
String gender;
Boolean selected = Boolean.FALSE;
public Employee(String name, String address, String gender) {
this.name = name;
this.address = address;
this.gender = gender;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Boolean getSelected() {
return selected;
}
public void setSelected(Boolean selected) {
this.selected = selected;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
}
public HtmlDataTable getEmployeeDataTable() {
return employeeDataTable;
}
public void setEmployeeDataTable(HtmlDataTable employeeDataTable) {
this.employeeDataTable = employeeDataTable;
}
public boolean isMultipleSelection() {
return multipleSelection;
}
public void setMultipleSelection(boolean multipleSelection) {
this.multipleSelection = multipleSelection;
}
public HtmlPanelGroup getMyPanelGroup() {
return myPanelGroup;
}
public void setMyPanelGroup(HtmlPanelGroup myPanelGroup) {
this.myPanelGroup = myPanelGroup;
}
public DataPaginator getEmployeeDataPaginator() {
return employeeDataPaginator;
}
public void setEmployeeDataPaginator(DataPaginator employeeDataPaginator) {
this.employeeDataPaginator = employeeDataPaginator;
}
public DataPaginator getEmployeeDisplayedDataPaginator() {
return employeeDisplayedDataPaginator;
}
public void setEmployeeDisplayedDataPaginator(
DataPaginator employeeDisplayedDataPaginator) {
this.employeeDisplayedDataPaginator = employeeDisplayedDataPaginator;
}
}
*********************************TableBean.java********************************************
package com.workflowmanager;
import javax.faces.component.UIComponent;
import javax.faces.event.ActionEvent;
import com.icesoft.faces.component.commandsortheader.CommandSortHeader;
public class TableBean extends SortableList {
public TableBean()
{
super("");
}
protected boolean isDefaultAscending(String sortColumn) {
// TODO Auto-generated method stub
return true;
}
protected void sort() {
System.out.println("SORT METHOD CALLED");
}
public void cmdSortHeaderAction(ActionEvent event) {
UIComponent comp=event.getComponent();
if(comp instanceof com.icesoft.faces.component.commandsortheader.CommandSortHeader)
{
CommandSortHeader csh=(CommandSortHeader)comp;
System.out.println("Column "+csh.getColumnName()+" Clicked...sort it");
}
}
private boolean multipleSelection = false;
public void newTableBeanRowSelection(com.icesoft.faces.component.ext.RowSelectorEvent e)
{
System.out.println("newTableBeanRowSelection EVENT FIRED!!!!!!!!!!!!!!!!!!!");
}
// List of sample inventory data.
private InventoryItem[] carInventory = new InventoryItem[]{
new InventoryItem(58285, "Dodge Grand Caravan", " Sto&Go/Keyless", 43500, 21695),
new InventoryItem(57605, "Dodge SX 2.0", "Loaded/Keyless", 28000 ,14495),
new InventoryItem(57805, "Chrysler Sebring Touring", "Keyless/Trac Cont", 31500, 15995),
new InventoryItem(57965, "Chrysler PT Cruiser Convertible", "Touring/Loaded", 7000 , 22195),
new InventoryItem(58095, "Chrysler Pacifica AWD", "Heated Lthr/19' Alloy", 43500, 31995),
new InventoryItem(58165, "Jeep Liberty Sport", "Loaded/Keyless", 31000, 26995),
new InventoryItem(58205, "Dodge SX 2.0", "Loaded/Keyless", 19500, 15495),
new InventoryItem(58245, "Chrysler Pacifica AWD", "Moonroof/DVD", 15500, 35695),
new InventoryItem(58295, "Pontiac Montana SV6 Ext", "Loaded/Quads", 40000, 22695),
new InventoryItem(58355, "Jeep Grand Cherokee", "Laredo/Trailer", 26500, 27495),
new InventoryItem(58365, "Jeep Grand Cherokee", "Laredo/Trailer", 27000, 28595),
new InventoryItem(58375, "Chrysler PT Cruiser", "Cruise/KeylessD", 29500, 17795),
new InventoryItem(58425, "Dodge Durango SLT", "Leather/3rd row", 32500, 26695),
new InventoryItem(58475, "Dodge Grand Caravan", "Quads/Rear AC", 52000, 19895),
new InventoryItem(58455, "Chrysler Sebring Touring", "Keyless/Trac Cont", 34000, 16695),
new InventoryItem(58465, "Chrysler Sebring Touring", "Keyless/Trac Cont", 32500, 15995),
new InventoryItem(58495, "Chrysler Sebring Touring", "Keyless/Trac Cont", 22500, 16695),
new InventoryItem(58155, "GM G2500 Cargo Van", "Extended/Auto/Air", 34000, 27795),
new InventoryItem(58275, "Dodge Dakota Q.C. SLT", "4x4/Loaded/Alloys", 22500, 27995),
new InventoryItem(58265, "Chrysler 300 Touring", "Heated Leather", 40500, 26495)
};
/**
* Gets the inventoryItem array of car data.
* @return array of car inventory data.
*/
public InventoryItem[] getCarInventory() {
if (!oldSort.equals(sortColumnName) ||
oldAscending != ascending){
sort();
oldSort = sortColumnName;
oldAscending = ascending;
}
return carInventory;
}
/**
* Inventory Item subclass stores data about a cars inventory data. Properties
* such a stock, model, description, odometer and price are stored.
*/
public class InventoryItem {
// slock number
int stock;
// model or type of inventory
String model;
// description of item
String description;
// number of miles on odometer
int odometer;
// price of car in Canadian dollars
int price;
Boolean selected = Boolean.FALSE;
public Boolean getSelected() {
return selected;
}
public void setSelected(Boolean selected) {
this.selected = selected;
}
/**
* Creates a new instance of InventoryItem.
* @param stock stock number.
* @param model model or type of inventory.
* @param description description of item.
* @param odometer number of miles on odometer.
* @param price price of care in Canadian dollars.
*/
public InventoryItem(int stock, String model, String description, int odometer, int price) {
this.stock = stock;
this.model = model;
this.description = description;
this.odometer = odometer;
this.price = price;
}
/**
* Gets the stock number of this iventory item.
* @return stock number.
*/
public int getStock() {
return stock;
}
/**
* Gets the model number of this iventory item.
* @return model number.
*/
public String getModel() {
return model;
}
/**
* Gets the description of the this iventory item.
* @return description
*/
public String getDescription() {
return description;
}
/**
* Gets the odometer reading from this iventory item.
* @return odometer reading.
*/
public int getOdometer() {
return odometer;
}
/**
* Gets the price of this item in Canadian Dollars.
* @return price.
*/
public int getPrice() {
return price;
}
}
public boolean isMultipleSelection() {
return multipleSelection;
}
public void setMultipleSelection(boolean multipleSelection)
{
this.multipleSelection = multipleSelection;
}
}
*********************************SortableList.java********************************************
package com.workflowmanager;
/**
* The SortableList class is a utility class used by the data table
* paginator example.
*
* @since 0.3.0
*/
public abstract class SortableList {
protected String sortColumnName;
protected boolean ascending;
// we only want to resort if the oder or column has changed.
protected String oldSort;
protected boolean oldAscending;
protected SortableList(String defaultSortColumn) {
sortColumnName = defaultSortColumn;
ascending = isDefaultAscending(defaultSortColumn);
oldSort = sortColumnName;
// make sure sortColumnName on first render
oldAscending = !ascending;
}
/**
* Sort the list.
*/
protected abstract void sort();
/**
* Is the default sortColumnName direction for the given column "ascending" ?
*/
protected abstract boolean isDefaultAscending(String sortColumn);
/**
* Gets the sortColumnName column.
*
* @return column to sortColumnName
*/
public String getSortColumnName() {
return sortColumnName;
}
/**
* Sets the sortColumnName column
*
* @param sortColumnName column to sortColumnName
*/
public void setSortColumnName(String sortColumnName) {
oldSort = this.sortColumnName;
this.sortColumnName = sortColumnName;
}
/**
* Is the sortColumnName ascending.
*
* @return true if the ascending sortColumnName otherwise false.
*/
public boolean isAscending() {
return ascending;
}
/**
* Set sortColumnName type.
*
* @param ascending true for ascending sortColumnName, false for desending sortColumnName.
*/
public void setAscending(boolean ascending) {
oldAscending = this.ascending;
this.ascending = ascending;
}
}
thanks,
Satyajit
|
 |
|
|
Hi,
I have created the datatable and datapaginator programmatically.Unfortunately nothing happens when I click the paginator buttons from browser.Would somebody please help me to solve the issue.Please find the code which is used to create them as below.
<ice:form id="myForm">
<ice:panelGrid styleClass="navConnectionStatus" columnClasses="statusLeft, statusRight" columns="2">
<!-- Connection Status -->
<ice:outputConnectionStatus />
</ice:panelGrid>
<!-- Demo Title -->
<h3>
<ice:outputText value="Demo"/>
</h3>
<ice:panelGrid columns="1"
columnClasses="contentLayoutGridColumn"
cellpadding="5" style="width: 100%;border: 1px solid gray;">
<ice:commandButton image="./xmlhttp/css/xp/css-images/arrow-previous.gif"
actionListener="#{dataTableCreator.constructComponent}"
styleClass=""/>
<ice:panelGroup style="border: 1px solid gray; height: 250px;"
binding="#{dataTableCreator.myPanelGroup}">
</ice:panelGroup>
</ice:panelGrid>
</ice:form>
public void constructComponent(ActionEvent e) {
// initialize column names
columnNames.add("stock");
columnNames.add("model");
columnNames.add("odometer");
columnNames.add("price");
List panelGroupChildren=myPanelGroup.getChildren();
HtmlDataTable obj=createDataTable();
panelGroupChildren.add(obj);
panelGroupChildren.add(createDataPaginator());
}
private HtmlDataTable createDataTable()
{
if(dataTable == null)
{
dataTable = new HtmlDataTable();
}
dataTable.setRendered(true);
dataTable.setBorder(1);
List list = dataTable.getChildren();
list.clear();
ValueBinding binding = app.createValueBinding("#{dataTableCreator.tableData}");
dataTable.setValueBinding("vartableData", binding);
dataTable.setVar("vartableData");
dataTable.setId("dynamicDataTable");
dataTable.setRows(5);
if(columnNames.size() == 0)
{
System.out.println("No Columns found");
return null;
}
int columnCount = columnNames.size();
for(int index = 0; index < columnCount; index++)
{
String columnName = (String)columnNames.get(index);
String columnBinding = "#{vartableData."+columnName+"}";
UIColumn column = new UIColumn();
column.setId("col_" + columnName);
HtmlOutputText header = new HtmlOutputText();
header.setId("hdr_" + columnName);
header.setValue(columnName);
column.setHeader(header);
HtmlOutputText text = new HtmlOutputText();
text.setId("txt_" + columnName);
ValueBinding vb = app.createValueBinding(columnBinding);
text.setValueBinding("value", vb);
HtmlPanelGroup htmlpg=new HtmlPanelGroup();
htmlpg.setId("pnl_" + columnName);
htmlpg.setStyle("text-align: center; white-space: nowrap;");
htmlpg.getChildren().add(text);
column.getChildren().add(htmlpg);
list.add(column);
}
dataTable.setValue(getTableData());
return dataTable;
}
private DataPaginator createDataPaginator()
{
dataPaginator=new DataPaginator();
ValueBinding binding = app.createValueBinding("#{dataTableCreator.dataPaginator}");
dataTable.setValueBinding("value", binding);
dataPaginator.setFor("dynamicDataTable");
dataPaginator.setPaginator(true);
dataPaginator.setId("dataScroll_3");
dataPaginator.setFastStep(3);
dataPaginator.setPaginatorMaxPages(4);
HtmlGraphicImage first=new HtmlGraphicImage();
first.setUrl("./xmlhttp/css/xp/css-images/arrow-first.gif");
first.setStyle("border:none;");
first.setTitle("First Page");
first.setId("id_first");
dataPaginator.setFirst(first);
HtmlGraphicImage last=new HtmlGraphicImage();
last.setUrl("./xmlhttp/css/xp/css-images/arrow-last.gif");
last.setStyle("border:none;");
last.setTitle("Last Page");
last.setId("id_last");
dataPaginator.setLast(last);
HtmlGraphicImage previous=new HtmlGraphicImage();
previous.setUrl("./xmlhttp/css/xp/css-images/arrow-previous.gif");
previous.setStyle("border:none;");
previous.setTitle("Previous Page");
previous.setId("id_previous");
dataPaginator.setPrevious(previous);
HtmlGraphicImage next=new HtmlGraphicImage();
next.setUrl("./xmlhttp/css/xp/css-images/arrow-next.gif");
next.setStyle("border:none;");
next.setTitle("Next Page");
next.setId("id_next");
dataPaginator.setNext(next);
HtmlGraphicImage fastforward=new HtmlGraphicImage();
fastforward.setUrl("./xmlhttp/css/xp/css-images/arrow-ff.gif");
fastforward.setStyle("border:none;");
fastforward.setTitle("Fast Forward");
fastforward.setId("id_fastforward");
dataPaginator.setFastForward(fastforward);
HtmlGraphicImage fastrewind=new HtmlGraphicImage();
fastrewind.setUrl("./xmlhttp/css/xp/css-images/arrow-fr.gif");
fastrewind.setStyle("border:none;");
fastrewind.setTitle("Fast Backwards");
fastrewind.setId("id_fastrewind");
dataPaginator.setFastRewind(fastrewind);
return dataPaginator;
}
Any help will be highly appriciated.
Thanks
Satyajit
|
 |
|
|
|
|