Author: andrei_exadel
Date: 2007-12-10 09:37:16 -0500 (Mon, 10 Dec 2007)
New Revision: 4654
Added:
trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Facet.java
trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.xhtml
Removed:
trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.xhtml
Modified:
trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java
trunk/sandbox/samples/columnsDemo/src/main/webapp/WEB-INF/faces-config.xml
trunk/sandbox/samples/columnsDemo/src/main/webapp/WEB-INF/web.xml
trunk/sandbox/samples/columnsDemo/src/main/webapp/index.jsp
trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.jsp
Log:
RF-1394
Modified:
trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java
===================================================================
---
trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java 2007-12-10
14:36:13 UTC (rev 4653)
+++
trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Bean.java 2007-12-10
14:37:16 UTC (rev 4654)
@@ -22,28 +22,197 @@
package org.richfaces.sandbox.samples;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
/**
* @author k
- *
+ *
*/
public class Bean {
+
+ private List model = new ArrayList();
+
+ private List columns = new ArrayList();
+
+ private Integer columnsCount = 3;
+
+ private Integer rowCount = 3;
+
+ private String columnsCountStr;
+
+ private String rowCountStr;
+
+ private String str;
+
+ private boolean changed = false;
+
+
+ public String xhtml() {
- private List<String> model = new ArrayList<String>();
+ return "xhtml";
+ }
+
+ public String jsp() {
- public Bean() {
- for (int i = 0; i < 1000; i++) {
- model.add(Integer.toString(i));
- }
+ return "jsp";
+ }
+
+ public String action() {
+
+ return null;
+ }
+
+ public Bean() {
+ init();
+ }
+
+ private Integer getInteger (String str) {
+ Integer i = new Integer(0);
+ try {
+ i = Integer.parseInt(str);
+ }catch (Exception e) {
+ // TODO: handle exception
}
+ return i;
+ }
+
+ private void init () {
+
+ model = new ArrayList();
+ columns = new ArrayList();
+
+ if (columnsCountStr != null) {
+ columnsCount = getInteger(columnsCountStr);
+ }
+ if (rowCountStr != null) {
+ rowCount = getInteger(rowCountStr);
+ }
+
+ initColumns();
+
+ for (int i = 0; i < rowCount; i++) {
+// Map map = new HashMap();
+// initMap(map,i);
+ model.add(initArray(i));
+ }
+
+ }
+
+ private void initColumns () {
+ String header;
+ String footer;
+ for (int i = 0; i < columnsCount; i++) {
+ header = "Header" + Integer.toString(i);
+ footer = "Footer" + Integer.toString(i);
+ Facet facet = new Facet(header,footer);
+ columns.add(facet);
+
+ }
+ }
+
+ private String [] initArray(int row) {
+ String [] arr = new String [columns.size()];
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = Integer.toString(row+i);
+ }
+ return arr;
+ }
+
+ private void initMap(Map map, int row) {
+// Iterator it = columns.iterator();
+// while (it.hasNext()) {
+// String column = (String) it.next();
+// map.put(column, column + row);
+// }
+ }
- public List<String> getModel() {
- return model;
+ /**
+ * @return the model
+ */
+ public List getModel() {
+ if (changed) {
+ init();
+ changed = false;
}
+ return model;
+ }
- public void setModel(List<String> model) {
- this.model = model;
+ /**
+ * @param model the model to set
+ */
+ public void setModel(List model) {
+ this.model = model;
+ }
+
+ /**
+ * @return the columns
+ */
+ public List getColumns() {
+ if (changed) {
+ init();
+ changed = false;
}
-
+ return columns;
+ }
+
+ /**
+ * @param columns the columns to set
+ */
+ public void setColumns(List columns) {
+ this.columns = columns;
+ }
+
+ /**
+ * @return the columnsCountStr
+ */
+ public String getColumnsCountStr() {
+ return columnsCount.toString();
+ }
+
+ /**
+ * @param columnsCountStr the columnsCountStr to set
+ */
+ public void setColumnsCountStr(String columnsCountStr) {
+ if (!columnsCountStr.equals(this.columnsCountStr)) {
+ changed = true;
+ }
+ this.columnsCountStr = columnsCountStr;
+ }
+
+ /**
+ * @return the rowCountStr
+ */
+ public String getRowCountStr() {
+ return rowCount.toString();
+ }
+
+ /**
+ * @param rowCountStr the rowCountStr to set
+ */
+ public void setRowCountStr(String rowCountStr) {
+ if (!rowCountStr.equals(this.rowCountStr)) {
+ changed = true;
+ }
+ this.rowCountStr = rowCountStr;
+ }
+
+ /**
+ * @return the str
+ */
+ public String getStr() {
+ return str;
+ }
+
+ /**
+ * @param str the str to set
+ */
+ public void setStr(String str) {
+ this.str = str;
+ }
+
+
+
}
\ No newline at end of file
Added:
trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Facet.java
===================================================================
---
trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Facet.java
(rev 0)
+++
trunk/sandbox/samples/columnsDemo/src/main/java/org/richfaces/sandbox/samples/Facet.java 2007-12-10
14:37:16 UTC (rev 4654)
@@ -0,0 +1,53 @@
+/*
+ * Facet.java Date created: 10.12.2007
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.richfaces.sandbox.samples;
+
+/**
+ * TODO Class description goes here.
+ * @author "Andrey Markavtsov"
+ *
+ */
+public class Facet {
+ private String header;
+ private String footer;
+
+ /**
+ * TODO Description goes here.
+ * @param header
+ * @param footer
+ */
+ public Facet(String header, String footer) {
+ super();
+ this.header = header;
+ this.footer = footer;
+ }
+ /**
+ * @return the header
+ */
+ public String getHeader() {
+ return header;
+ }
+ /**
+ * @param header the header to set
+ */
+ public void setHeader(String header) {
+ this.header = header;
+ }
+ /**
+ * @return the footer
+ */
+ public String getFooter() {
+ return footer;
+ }
+ /**
+ * @param footer the footer to set
+ */
+ public void setFooter(String footer) {
+ this.footer = footer;
+ }
+
+}
Modified: trunk/sandbox/samples/columnsDemo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/sandbox/samples/columnsDemo/src/main/webapp/WEB-INF/faces-config.xml 2007-12-10
14:36:13 UTC (rev 4653)
+++ trunk/sandbox/samples/columnsDemo/src/main/webapp/WEB-INF/faces-config.xml 2007-12-10
14:37:16 UTC (rev 4654)
@@ -5,6 +5,17 @@
<managed-bean>
<managed-bean-name>bean</managed-bean-name>
<managed-bean-class>org.richfaces.sandbox.samples.Bean</managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
- </managed-bean>
+ <managed-bean-scope>application</managed-bean-scope>
+ </managed-bean>
+ <navigation-rule>
+ <display-name>xhtml</display-name>
+ <navigation-case>
+ <from-outcome>xhtml</from-outcome>
+ <to-view-id>/faces/pages/index.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>jsp</from-outcome>
+ <to-view-id>/faces/pages/index.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
</faces-config>
Modified: trunk/sandbox/samples/columnsDemo/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/sandbox/samples/columnsDemo/src/main/webapp/WEB-INF/web.xml 2007-12-10 14:36:13
UTC (rev 4653)
+++ trunk/sandbox/samples/columnsDemo/src/main/webapp/WEB-INF/web.xml 2007-12-10 14:37:16
UTC (rev 4654)
@@ -10,6 +10,23 @@
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
+ <!-- Use Documents Saved as *.xhtml -->
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.jsp</param-value>
+ </context-param>
+
+ <!-- Facelets pages will use the .xhtml extension -->
+ <context-param>
+ <param-name>facelets.VIEW_MAPPINGS</param-name>
+ <param-value>*xhtml</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
+ <param-value>com.sun.facelets.FaceletViewHandler</param-value>
+ </context-param>
+
<!--
-->
<filter>
@@ -23,21 +40,21 @@
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
- <dispatcher>ERROR</dispatcher>
+ <dispatcher>ERROR</dispatcher>
</filter-mapping>
- <servlet>
- <servlet-name>Faces Servlet</servlet-name>
- <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>Faces Servlet</servlet-name>
- <url-pattern>/faces/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>Faces Servlet</servlet-name>
- <url-pattern>*.jsf</url-pattern>
- </servlet-mapping>
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ </servlet>
+
+ <!-- Use prefix mapping for Facelets pages, e.g.
http://localhost:8080/webapp/faces/mypage.xhtml -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+
+
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
Modified: trunk/sandbox/samples/columnsDemo/src/main/webapp/index.jsp
===================================================================
--- trunk/sandbox/samples/columnsDemo/src/main/webapp/index.jsp 2007-12-10 14:36:13 UTC
(rev 4653)
+++ trunk/sandbox/samples/columnsDemo/src/main/webapp/index.jsp 2007-12-10 14:37:16 UTC
(rev 4654)
@@ -5,7 +5,8 @@
<head></head>
<body>
- <jsp:forward page="/pages/index.jsf" />
+ <a href="faces/pages/index.jsp">JSP</a><br/>
+ <a href="faces/pages/index.xhtml">XHTML</a>
</body>
</html>
\ No newline at end of file
Modified: trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.jsp 2007-12-10 14:36:13
UTC (rev 4653)
+++ trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.jsp 2007-12-10 14:37:16
UTC (rev 4654)
@@ -1,24 +1,44 @@
+<%@ taglib
uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/dataTable"
prefix="dt"%>
+<%@ taglib prefix="columns"
uri="http://labs.jboss.com/jbossrichfaces/ui/ui/columns" %>
+
+
+
<html>
<head>
<title></title>
</head>
<body>
- <f:view>
- <dt:dataTable id="table" value="#{bean.model}"
var="issues"
- first="0" rows="40" width="100%">
- <dt:column width="200px">
- <f:facet name="header">
- <h:outputText value="header"></h:outputText>
- </f:facet>
- <h:outputText value="#{issues}"></h:outputText>
- <f:facet name="footer">
- <h:outputText value="footer"></h:outputText>
- </f:facet>
- </dt:column>
- </dt:dataTable>
+ <f:view>
+ <h:form>
+
+ Columns: <h:inputText
value="#{bean.columnsCountStr}"></h:inputText> <br/>
+ Rows: <h:inputText value="#{bean.rowCountStr}"></h:inputText>
<br/>
+
+
+ <a4j:commandButton value="Submit" action="#{bean.jsp}"
reRender="tb"></a4j:commandButton>
+
+ <br/>
+
+
+ <dt:dataTable value="#{bean.model}" var="var"
id="tb">
+ <columns:columns value="#{bean.columns}" var="col"
index="counter"
+ style="color: Green;">
+ <f:facet name="header">
+ <h:outputText value="#{col.header}"></h:outputText>
+ </f:facet>
+ <f:facet name="footer">
+ <h:outputText value="#{col.footer}"></h:outputText>
+ </f:facet>
+ <h:outputText value="#{var[counter]}"></h:outputText>
+ <h:inputText value="#{var[counter]}"></h:inputText>
+ </columns:columns>
+ </dt:dataTable>
+
+
+ </h:form>
</f:view>
</body>
</html>
Deleted: trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.xhtml 2007-12-10
14:36:13 UTC (rev 4653)
+++ trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.xhtml 2007-12-10
14:37:16 UTC (rev 4654)
@@ -1,12 +0,0 @@
-<!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="https://ajax4jsf.dev.java.net/ajax"
-
xmlns:c="http://java.sun.com/jsp/jstl/core"
- >
- <f:view>
-
- </f:view>
-</html>
\ No newline at end of file
Added: trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.xhtml
(rev 0)
+++ trunk/sandbox/samples/columnsDemo/src/main/webapp/pages/index.xhtml 2007-12-10
14:37:16 UTC (rev 4654)
@@ -0,0 +1,42 @@
+<!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:jstl="http://java.sun.com/jstl/core"
+
xmlns:dt="http://labs.jboss.com/jbossrichfaces/ui/dataTable"
+
xmlns:columns="http://labs.jboss.com/jbossrichfaces/ui/ui/columns&qu...
+ <f:view>
+ XHTML
+ <h:form>
+
+
+ Columns: <h:inputText
value="#{bean.columnsCountStr}"></h:inputText> <br/>
+ Rows: <h:inputText value="#{bean.rowCountStr}"></h:inputText>
<br/>
+
+
+ <a4j:commandButton value="Submit" action="#{bean.xhtml}"
reRender="tb"></a4j:commandButton>
+
+ <br/>
+
+
+ <dt:dataTable value="#{bean.model}" var="var"
id="tb">
+ <columns:columns value="#{bean.columns}" var="col"
index="counter"
+ style="color: Green;">
+ <f:facet name="header">
+ <h:outputText value="#{col.header}"></h:outputText>
+ </f:facet>
+ <f:facet name="footer">
+ <h:outputText value="#{col.footer}"></h:outputText>
+ </f:facet>
+ <h:outputText value="#{var[counter]}"></h:outputText>
+ <h:inputText value="#{var[counter]}"></h:inputText>
+ </columns:columns>
+ </dt:dataTable>
+
+ </h:form>
+
+ </f:view>
+
+</html>
\ No newline at end of file