Author: ppitonak(a)redhat.com
Date: 2010-07-20 09:17:34 -0400 (Tue, 20 Jul 2010)
New Revision: 18157
Added:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JRepeatBean.java
root/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JRepeatBean.properties
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/list.xhtml
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/matrix.xhtml
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/simple.xhtml
root/tests/metamer/trunk/application/src/main/webapp/resources/css/a4jRepeat.css
Modified:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
Log:
* added two pages with a4j:repeat
Added:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JRepeatBean.java
===================================================================
---
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JRepeatBean.java
(rev 0)
+++
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JRepeatBean.java 2010-07-20
13:17:34 UTC (rev 18157)
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.bean;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+
+import org.richfaces.component.UIRepeat;
+import org.richfaces.tests.metamer.Attributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed bean for a4j:repeat.
+ *
+ * @author Nick Belaevski, <a href="mailto:ppitonak@redhat.com">Pavol
Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "a4jRepeatBean")
+@ViewScoped
+public class A4JRepeatBean implements Serializable {
+
+ private static final long serialVersionUID = 4864439475400649809L;
+ private static final int MATRIX_DIMENSION = 4;
+ private static Logger logger;
+ private Attributes attributes;
+ private List<Data> dataList;
+ private Data selectedDataItem = null;
+ private List<MatrixRow> matrixRows;
+
+ public static final class MatrixCell implements Serializable {
+
+ private static final long serialVersionUID = -5911659561854593681L;
+ private int value = 0;
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setValue(int value) {
+ this.value = value;
+ }
+
+ public void clearValueAction() {
+ setValue(0);
+ }
+
+ public void increaseValueAction() {
+ value++;
+ }
+
+ public void decreaseValueAction() {
+ value--;
+ }
+ }
+
+ public static final class MatrixRow implements Serializable {
+
+ private static final long serialVersionUID = -5051037819565283283L;
+ private List<MatrixCell> cells = new ArrayList<MatrixCell>();
+
+ public List<MatrixCell> getCells() {
+ return cells;
+ }
+
+ public void addCell(MatrixCell cell) {
+ cells.add(cell);
+ }
+ }
+
+ public static final class Data implements Serializable {
+
+ private static final long serialVersionUID = -1461777632529492912L;
+ private String text;
+
+ /**
+ * @return the text
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+ }
+
+ /**
+ * Initializes the managed bean.
+ */
+ @PostConstruct
+ public void init() {
+ logger = LoggerFactory.getLogger(getClass());
+ logger.debug("initializing bean " + getClass().getName());
+
+ // initialize model for page simple.xhtml
+ dataList = new ArrayList<Data>();
+ for (int i = 0; i < 20; i++) {
+ Data data = new Data();
+ data.setText(MessageFormat.format("Item {0}", i));
+ dataList.add(data);
+ }
+
+ // initialize model for page matrix.xhtml
+ matrixRows = new ArrayList<MatrixRow>();
+ for (int i = 0; i < MATRIX_DIMENSION; i++) {
+ MatrixRow matrixRow = new MatrixRow();
+
+ for (int j = 0; j < MATRIX_DIMENSION; j++) {
+ MatrixCell matrixCell = new MatrixCell();
+ matrixRow.addCell(matrixCell);
+ }
+
+ matrixRows.add(matrixRow);
+ }
+
+ // initialize attributes
+ attributes = Attributes.getUIComponentAttributes(UIRepeat.class, getClass());
+ attributes.setAttribute("rendered", true);
+ // TODO has to be tested in other way
+ attributes.remove("componentState");
+ attributes.remove("iterationStatusVar");
+ attributes.remove("rowKeyVar");
+ attributes.remove("value");
+ attributes.remove("var");
+ }
+
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Attributes attributes) {
+ this.attributes = attributes;
+ }
+
+ /**
+ * @return the data
+ */
+ public List<Data> getDataList() {
+ return dataList;
+ }
+
+ /**
+ * @return the selectedDataItem
+ */
+ public Data getSelectedDataItem() {
+ return selectedDataItem;
+ }
+
+ /**
+ * @param selectedDataItem the selectedDataItem to set
+ */
+ public void setSelectedDataItem(Data selectedDataItem) {
+ this.selectedDataItem = selectedDataItem;
+ }
+
+ public List<MatrixRow> getMatrixRows() {
+ return matrixRows;
+ }
+}
Property changes on:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JRepeatBean.java
___________________________________________________________________
Name: svn:keywords
+ Revision
Modified:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
---
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-07-20
11:43:50 UTC (rev 18156)
+++
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-07-20
13:17:34 UTC (rev 18157)
@@ -100,6 +100,7 @@
components.put("a4jParam", "A4J Action Parameter");
components.put("a4jPoll", "A4J Poll");
components.put("a4jPush", "A4J Push");
+ components.put("a4jRepeat", "A4J Repeat");
components.put("commandButton", "JSF Command Button");
components.put("richDataGrid", "Rich Data Grid");
components.put("richDataScroller", "Rich Data Scroller");
Added:
root/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JRepeatBean.properties
===================================================================
Added:
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/list.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/list.xhtml
(rev 0)
+++
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/list.xhtml 2010-07-20
13:17:34 UTC (rev 18157)
@@ -0,0 +1,44 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2010, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+
+<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:c="http://java.sun.com/jsp/jstl/core">
+
+ <h:head>
+ <title>A4J Repeat</title>
+ <meta http-equiv="Content-Type" content="text/xhtml;
charset=UTF-8" />
+ <h:outputStylesheet library="css" name="list.css" />
+ </h:head>
+
+ <h:body>
+
+ <h:link outcome="simple" value="Simple"
styleClass="link" />
+ <div class="description">Simple page that contains
<b>a4j:repeat</b> and
+ input boxes for all its attributes.</div>
+
+ <h:link outcome="matrix" value="Matrix"
styleClass="link" />
+ <div class="description">Simple page that contains
<b>a4j:repeat</b> rendering a table. Page contains input boxes for all
repeat's attributes.</div>
+
+ </h:body>
+</html>
\ No newline at end of file
Added:
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/matrix.xhtml
===================================================================
---
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/matrix.xhtml
(rev 0)
+++
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/matrix.xhtml 2010-07-20
13:17:34 UTC (rev 18157)
@@ -0,0 +1,99 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2010, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+
+<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:ta="http://java.sun.com/jsf/composite/testapp"
xmlns:rich="http://richfaces.org/rich">
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ <h:outputStylesheet library="css" name="a4jRepeat.css"
/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+ <h:panelGroup id="matrixInput" layout="block">
+ <table>
+ <tbody>
+ <a4j:repeat id="a4jRepeatRows"
+ iterationStatusVar="rowStatus"
+ value="#{a4jRepeatBean.matrixRows}"
+ var="row">
+ <tr>
+ <a4j:repeat id="a4jRepeatColumns"
value="#{row.cells}" var="cell"
iterationStatusVar="cellStatus">
+ <td><h:panelGroup layout="block"
+ styleClass="cell
#{rowStatus.even ? 'row-even' : 'row-odd'} #{cellStatus.even ?
'cell-even' : 'cell-odd'}">
+ <h:inputText id="valueInput"
value="#{cell.value}" size="3">
+ <f:convertNumber
id="valueConvertNumber" />
+ <a4j:ajax
id="valueInputAjax" render="matrixInput matrixOutput" />
+ </h:inputText>
+
+ <h:commandLink id="clearLink"
action="#{cell.clearValueAction}" value="C">
+ <a4j:ajax render="matrixInput
matrixOutput" />
+ </h:commandLink>
+ <h:outputText value=" / " />
+ <h:commandLink id="increaseLink"
action="#{cell.increaseValueAction}" value="+">
+ <a4j:ajax render="matrixInput
matrixOutput" />
+ </h:commandLink>
+ <h:outputText value=" / " />
+ <h:commandLink id="decreaseLink"
action="#{cell.decreaseValueAction}" value="-">
+ <a4j:ajax render="matrixInput
matrixOutput" />
+ </h:commandLink>
+ </h:panelGroup></td>
+ </a4j:repeat>
+ </tr>
+ </a4j:repeat>
+ </tbody>
+ </table>
+ </h:panelGroup>
+ <hr/>
+ <h:panelGroup id="matrixOutput" layout="block">
+ <table>
+ <tbody>
+ <a4j:repeat value="#{a4jRepeatBean.matrixRows}"
var="row">
+ <tr>
+ <a4j:repeat value="#{row.cells}"
var="cell">
+ <td><h:panelGroup
styleClass="cell" layout="block">
+ #{cell.value}
+ </h:panelGroup></td>
+ </a4j:repeat>
+ </tr>
+ </a4j:repeat>
+ </tbody>
+ </table>
+ </h:panelGroup>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added:
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/simple.xhtml
===================================================================
---
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/simple.xhtml
(rev 0)
+++
root/tests/metamer/trunk/application/src/main/webapp/components/a4jRepeat/simple.xhtml 2010-07-20
13:17:34 UTC (rev 18157)
@@ -0,0 +1,86 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright 2010, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+
+<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:ta="http://java.sun.com/jsf/composite/testapp"
xmlns:rich="http://richfaces.org/rich">
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ <h:outputStylesheet library="css" name="a4jRepeat.css"
/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+ <h:outputText id="output"
value="#{a4jRepeatBean.selectedDataItem.text}"/>
+
+ <ul id="list">
+ <a4j:repeat id="a4jRepeat"
+
first="#{a4jRepeatBean.attributes['first'].value}"
+
iterationState="#{a4jRepeatBean.attributes['iterationState'].value}"
+ iterationStatusVar="status"
+
keepSaved="#{a4jRepeatBean.attributes['keepSaved'].value}"
+
relativeRowIndex="#{a4jRepeatBean.attributes['relativeRowIndex'].value}"
+
rendered="#{a4jRepeatBean.attributes['rendered'].value}"
+
rowAvailable="#{a4jRepeatBean.attributes['rowAvailable'].value}"
+
rowCount="#{a4jRepeatBean.attributes['rowCount'].value}"
+
rowData="#{a4jRepeatBean.attributes['rowData'].value}"
+
rowIndex="#{a4jRepeatBean.attributes['rowIndex'].value}"
+
rowKey="#{a4jRepeatBean.attributes['rowKey'].value}"
+
rowKeyConverter="#{a4jRepeatBean.attributes['rowKeyConverter'].value}"
+
rows="#{a4jRepeatBean.attributes['rows'].value}"
+ value="#{a4jRepeatBean.dataList}"
+ var="item">
+ <li><h:inputText value="#{item.text}" />
+ <h:commandLink value="Link">
+ <f:ajax render="@form" execute="@form"
/>
+ <f:setPropertyActionListener
target="#{a4jRepeatBean.selectedDataItem}" value="#{item}" />
+ </h:commandLink>
+
+ <h:outputText id="statusBegin"
value="begin=#{status.begin}, "/>
+ <h:outputText id="statusEnd"
value="end=#{status.end}, "/>
+ <h:outputText id="statusIndex"
value="index=#{status.index}, "/>
+ <h:outputText id="statusCount"
value="count=#{status.count}, "/>
+ <h:outputText id="statusFirst"
value="first=#{status.first}, "/>
+ <h:outputText id="statusLast"
value="last=#{status.last}, "/>
+ <h:outputText id="statusEven"
value="even=#{status.even}, "/>
+ <h:outputText id="statusRowCount"
value="rowCount=#{status.rowCount}"/>
+ </li>
+ </a4j:repeat>
+ </ul>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <ta:attributes value="#{a4jRepeatBean.attributes}"
id="attributes" />
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added: root/tests/metamer/trunk/application/src/main/webapp/resources/css/a4jRepeat.css
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/resources/css/a4jRepeat.css
(rev 0)
+++
root/tests/metamer/trunk/application/src/main/webapp/resources/css/a4jRepeat.css 2010-07-20
13:17:34 UTC (rev 18157)
@@ -0,0 +1,8 @@
+.cell {
+ width: 120px;
+ padding: 10px;
+}
+
+.cell-even.row-even,.cell-odd.row-odd {
+ background-color: #CFC;
+}
\ No newline at end of file