Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSF
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JSF
Programmatically create HTMLextendeddatatable
Gina vernon
Ranch Hand
Posts: 108
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I am trying to programmatically create HTMLextendeddatatable. Here's the view code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xml:lang="en" lang="en"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> </head> <f:view contentType="text/html; charset=iso-8859-1"/> <body> <h:form id="form1"> <h:panelGrid id="gridPanel1" binding="#{test.gridPanel1}"> </h:panelGrid> </h:form> </body> </html>
And the backing bean:
private HtmlExtendedDataTable dataTable = null; private List<UserInfo> testData = null; private HtmlPanelGrid gridPanel1; public HtmlExtendedDataTable getDataTable() { if (testData == null) { testData = new ArrayList<UserInfo>(); for (int i = 0; i < 100; i++) { UserInfo data = new UserInfo(); data.setUser_id(new Long(i)); data.setFname(("TestEntity" + i)); data.setLname("lname"+i); data.setEmail("email"+i); data.setPassword("password"+i); testData.add(data); } } String[] columns = new String[] {"user_id","fname","lname","email", "password"}; String[] valueExprs = new String[] {"#{ui.user_id}","#{ui.fname}", "#{ui.lname}", "#{ui.email}", "#{ui.password}"}; FacesContext facesContext = FacesContext.getCurrentInstance(); ELContext elContext = facesContext.getELContext(); ExpressionFactory elFactory = facesContext.getApplication().getExpressionFactory(); dataTable = new HtmlExtendedDataTable(); dataTable.setValue(getTestData()); dataTable.setVar("ui"); dataTable.setSortMode("multi"); for (int i = 0; i < columns.length; i++) { FacesContext context = FacesContext.getCurrentInstance(); HtmlOutputText header = new HtmlOutputText(); header.setValue(columns[i]); HtmlOutputText content = new HtmlOutputText(); content.setValueExpression("value", context.getApplication().getExpressionFactory() .createValueExpression(valueExprs[i],String.class)); HtmlColumn column = new HtmlColumn(); column.setId("col" + i); column.setWidth("600"); column.setHeader(header); column.getChildren().add(content); column.setSortBy(valueExprs[i]); column.setSortable(true); column.setSelfSorted(true); dataTable.getChildren().add(column); } return dataTable; } public void setDataTable(HtmlExtendedDataTable dataTable) { this.dataTable = dataTable; } public List<UserInfo> getTestData() { return testData; } public void setTestData(List<UserInfo> testData) { this.testData = testData; } public void setGridPanel1(HtmlPanelGrid gridPanel1) { this.gridPanel1 = gridPanel1; } public HtmlPanelGrid getGridPanel1() { this.gridPanel1 = new HtmlPanelGrid(); gridPanel1.getChildren().add(this.getDataTable()); return gridPanel1; }
The datatable isn't rendered as expected. Any thoughts?
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Dynamic JSF, programatically adding components
Dynamic UI generation problem while opening popup
java.lang.NumberFormatException: For input string
Multiple Data Tables
FaceletContext.includeFacelet trouble
More...