Author: lfryc(a)redhat.com
Date: 2010-07-10 15:28:04 -0400 (Sat, 10 Jul 2010)
New Revision: 17847
Added:
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/PhasesBean.java
Modified:
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/RichPhaseListener.java
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/TemplatesList.java
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/TemplateBean.java
root/tests/metamer/trunk/src/main/webapp/components/a4jAjax/hSelectManyCheckbox.xhtml
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandButton/simple.xhtml
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandLink/simple.xhtml
root/tests/metamer/trunk/src/main/webapp/templates/header.xhtml
Log:
RFPL-466
* listener changed so that JSF lifecycle phases can be tracked on the page
* added attribute bypassUpdates to a4j:commandButton and a4j:commandLink's page
* page for selectManyCheckbox fixed
* header modified to display JSF lifecycle phases
* class TemplatesList reimplemented in order to make it much simpler
Modified:
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/RichPhaseListener.java
===================================================================
---
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/RichPhaseListener.java 2010-07-10
19:27:02 UTC (rev 17846)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/RichPhaseListener.java 2010-07-10
19:28:04 UTC (rev 17847)
@@ -19,9 +19,12 @@
* 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.testapp;
+import java.util.List;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
@@ -52,6 +55,12 @@
*/
public void beforePhase(PhaseEvent event) {
logger.debug("BEFORE - " + event.getPhaseId());
+
+ FacesContext ctx = event.getFacesContext();
+ ExpressionFactory factory = ctx.getApplication().getExpressionFactory();
+ ValueExpression exp = factory.createValueExpression(ctx.getELContext(),
"#{phasesBean.phases}", List.class);
+ List<PhaseEvent> phases = (List<PhaseEvent>)
exp.getValue(ctx.getELContext());
+ phases.add(event);
}
/**
@@ -60,4 +69,4 @@
public PhaseId getPhaseId() {
return PhaseId.ANY_PHASE;
}
-}
\ No newline at end of file
+}
Modified: root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/TemplatesList.java
===================================================================
---
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/TemplatesList.java 2010-07-10
19:27:02 UTC (rev 17846)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/TemplatesList.java 2010-07-10
19:28:04 UTC (rev 17847)
@@ -22,155 +22,76 @@
package org.richfaces.testapp;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
+ * An implementation of list for storing templates. This list ensures that the last item
+ * in list is always template "plain".
*
- *
* @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
* @version $Revision$
*/
-public class TemplatesList implements List<Template> {
+public class TemplatesList extends ArrayList<Template> {
- private List<Template> templates;
private Logger logger;
public TemplatesList() {
logger = LoggerFactory.getLogger(TemplatesList.class);
- templates = new ArrayList<Template>();
- templates.add(Template.PLAIN);
+ super.add(Template.PLAIN);
}
+ @Override
public boolean add(Template e) {
if (e == Template.PLAIN) {
return false;
}
- templates.add(templates.size() - 1, e);
+ super.add(super.size() - 1, e);
return true;
}
+ @Override
public void add(int index, Template element) {
- templates.add(index, element);
+ super.add(index, element);
// remove the rest of list if plain is set
if (element == Template.PLAIN) {
- while (templates.size() > index + 1) {
- templates.remove(index + 1);
+ while (super.size() > index + 1) {
+ super.remove(index + 1);
}
}
}
- public boolean addAll(Collection<? extends Template> c) {
- return templates.addAll(c);
- }
-
- public boolean addAll(int index, Collection<? extends Template> c) {
- return templates.addAll(index, c);
- }
-
- public void clear() {
- templates.clear();
- }
-
- public boolean contains(Object o) {
- return templates.contains(o);
- }
-
- public boolean containsAll(Collection<?> c) {
- return templates.containsAll(c);
- }
-
- public Template get(int index) {
- return templates.get(index);
- }
-
- public int indexOf(Object o) {
- return templates.indexOf(o);
- }
-
- public boolean isEmpty() {
- return templates.isEmpty();
- }
-
- public Iterator<Template> iterator() {
- return templates.iterator();
- }
-
- public int lastIndexOf(Object o) {
- return templates.lastIndexOf(o);
- }
-
- public ListIterator<Template> listIterator() {
- return templates.listIterator();
- }
-
- public ListIterator<Template> listIterator(int index) {
- return templates.listIterator(index);
- }
-
- public boolean remove(Object o) {
- return templates.remove(o);
- }
-
- public Template remove(int index) {
- return templates.remove(index);
- }
-
- public boolean removeAll(Collection<?> c) {
- return templates.removeAll(c);
- }
-
- public boolean retainAll(Collection<?> c) {
- return templates.retainAll(c);
- }
-
+ @Override
public Template set(int index, Template element) {
- Template old = templates.set(index, element);
+ Template old = super.set(index, element);
// remove the rest of list if plain is set
if (element == Template.PLAIN) {
- while (templates.size() > index + 1) {
- templates.remove(index + 1);
+ while (super.size() > index + 1) {
+ super.remove(index + 1);
}
} else {
- if (index == templates.size() - 1) {
- templates.add(Template.PLAIN);
+ if (index == super.size() - 1) {
+ super.add(Template.PLAIN);
}
}
return old;
}
- public int size() {
- return templates.size();
- }
-
- public List<Template> subList(int fromIndex, int toIndex) {
- return templates.subList(fromIndex, toIndex);
- }
-
- public Object[] toArray() {
- return templates.toArray();
- }
-
- public <T> T[] toArray(T[] a) {
- return templates.toArray(a);
- }
-
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
- for (Template t : templates) {
- sb.append(t.toString());
+
+ for (int i = 0; i < size(); i++) {
+ sb.append(get(i).toString());
sb.append(",");
}
+
return sb.toString();
}
-}
\ No newline at end of file
+}
Copied: root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/PhasesBean.java
(from rev 17846,
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/RichPhaseListener.java)
===================================================================
--- root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/PhasesBean.java
(rev 0)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/PhasesBean.java 2010-07-10
19:28:04 UTC (rev 17847)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.testapp.bean;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.faces.event.PhaseEvent;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed bean for storing information about invoked phases of JSF lifecycle.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "phasesBean")
+@RequestScoped
+public class PhasesBean {
+
+ private static Logger logger;
+ private List<PhaseEvent> phases;
+
+ /**
+ * Initializes the managed bean.
+ */
+ @PostConstruct
+ public void init() {
+ logger = LoggerFactory.getLogger(getClass());
+ logger.debug("initializing bean " + getClass().getName());
+ phases = new ArrayList<PhaseEvent>();
+ }
+
+ public List<PhaseEvent> getPhases() {
+ return phases;
+ }
+
+ public void setPhases(List<PhaseEvent> phases) {
+ this.phases = phases;
+ }
+
+ public Date getDate() {
+ return new Date();
+ }
+}
Modified:
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/TemplateBean.java
===================================================================
---
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/TemplateBean.java 2010-07-10
19:27:02 UTC (rev 17846)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/TemplateBean.java 2010-07-10
19:28:04 UTC (rev 17847)
@@ -59,12 +59,20 @@
/**
* @return the templates
*/
- public TemplatesList getTemplates() {
+ public ArrayList<Template> getTemplates() {
return templates;
}
- public void setTemplates(TemplatesList templates) {
- this.templates = templates;
+ public void setTemplates(ArrayList<Template> templates) {
+ if (templates instanceof TemplatesList) {
+ this.templates = (TemplatesList) templates;
+ return;
+ }
+
+ this.templates = new TemplatesList();
+ for (Template t : templates) {
+ this.templates.add(t);
+ }
}
public List<SelectItem> getAvailableTemplates() {
Modified:
root/tests/metamer/trunk/src/main/webapp/components/a4jAjax/hSelectManyCheckbox.xhtml
===================================================================
---
root/tests/metamer/trunk/src/main/webapp/components/a4jAjax/hSelectManyCheckbox.xhtml 2010-07-10
19:27:02 UTC (rev 17846)
+++
root/tests/metamer/trunk/src/main/webapp/components/a4jAjax/hSelectManyCheckbox.xhtml 2010-07-10
19:28:04 UTC (rev 17847)
@@ -24,14 +24,24 @@
<f:selectItem itemValue="Ferrari"
itemLabel="Ferrari"/>
<f:selectItem itemValue="Lexus"
itemLabel="Lexus"/>
<f:selectItem itemValue="BMW"
itemLabel="BMW"/>
-
-
- <a4j:ajax id="a4jAjaxxx"
+
+ <a4j:ajax id="a4jAjax"
bypassUpdates="#{a4jAjaxBean.attributes['bypassUpdates']}"
+ data="#{a4jAjaxBean.attributes['data']}"
+
disabled="#{a4jAjaxBean.attributes['disabled']}"
event="change"
- execute="@form"
- render="output"
-
+
execute="#{a4jAjaxBean.attributes['execute']}"
+
immediate="#{a4jAjaxBean.attributes['immediate']}"
+
limitRender="#{a4jAjaxBean.attributes['limitRender']}"
+
onbeforedomupdate="#{a4jAjaxBean.attributes['onbeforedomupdate']}"
+
onbegin="#{a4jAjaxBean.attributes['onbegin']}"
+
oncomplete="#{a4jAjaxBean.attributes['oncomplete']}"
+
onerror="#{a4jAjaxBean.attributes['onerror']}"
+
onevent="#{a4jAjaxBean.attributes['onevent']}"
+
queueId="#{a4jAjaxBean.attributes['queueId']}"
+ render="#{a4jAjaxBean.attributes['render']}"
+ status="#{a4jAjaxBean.attributes['status']}"
/>
+
</h:selectManyCheckbox>
<br/>
Modified:
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandButton/simple.xhtml
===================================================================
---
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandButton/simple.xhtml 2010-07-10
19:27:02 UTC (rev 17846)
+++
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandButton/simple.xhtml 2010-07-10
19:28:04 UTC (rev 17847)
@@ -26,6 +26,7 @@
<a4j:commandButton id="a4jCommandButton"
action="#{a4jButtonBean.attributes.action}"
actionListener="#{a4jButtonBean.attributes.actionListener}"
+
bypassUpdates="#{a4jButtonBean.attributes['bypassUpdates']}"
disabled="#{a4jButtonBean.attributes['disabled']}"
immediate="#{a4jButtonBean.attributes['immediate']}"
onclick="#{a4jButtonBean.attributes['onclick']}"
Modified: root/tests/metamer/trunk/src/main/webapp/components/a4jCommandLink/simple.xhtml
===================================================================
---
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandLink/simple.xhtml 2010-07-10
19:27:02 UTC (rev 17846)
+++
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandLink/simple.xhtml 2010-07-10
19:28:04 UTC (rev 17847)
@@ -26,6 +26,7 @@
<a4j:commandLink id="a4jCommandLink"
action="#{a4jLinkBean.attributes.action}"
actionListener="#{a4jLinkBean.attributes.actionListener}"
+
bypassUpdates="#{a4jLinkBean.attributes['bypassUpdates']}"
disabled="#{a4jLinkBean.attributes['disabled']}"
immediate="#{a4jLinkBean.attributes['immediate']}"
onclick="#{a4jLinkBean.attributes['onclick']}"
Modified: root/tests/metamer/trunk/src/main/webapp/templates/header.xhtml
===================================================================
--- root/tests/metamer/trunk/src/main/webapp/templates/header.xhtml 2010-07-10 19:27:02
UTC (rev 17846)
+++ root/tests/metamer/trunk/src/main/webapp/templates/header.xhtml 2010-07-10 19:28:04
UTC (rev 17847)
@@ -2,13 +2,13 @@
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:panelGrid id="headerTable" columns="6" border="1"
styleClass="external-table" columnClasses="header-column, header-column,
header-column, header-column, header-column, header-column">
+ <h:panelGrid id="headerTable" columns="7" border="1"
styleClass="external-table" columnClasses="header-column, header-column,
header-column, header-column, header-column, header-column, header-column">
<h:panelGrid columns="3">
- <h:link outcome="/index"><h:graphicImage
library="images" name="home.png" title="Go Home"
style="width: 36px;"/></h:link>
- <h:link outcome="list"><h:graphicImage
library="images" name="back.png" title="Go to List of Pages"
style="width: 36px;"/></h:link>
- <h:graphicImage library="images" name="refresh.png"
title="Rerender All" style="width: 36px;">
- <a4j:ajax event="click" render="commonGrid"/>
+ <h:link id="goHomeLink"
outcome="/index"><h:graphicImage id="goHomeImage"
library="images" name="home.png" title="Go Home"
style="width: 36px;"/></h:link>
+ <h:link id="goToListLink"
outcome="list"><h:graphicImage id="goToListImage"
library="images" name="back.png" title="Go to List of Pages"
style="width: 36px;"/></h:link>
+ <h:graphicImage id="reRenderAllImage" library="images"
name="refresh.png" title="Rerender All" style="width:
36px;">
+ <a4j:ajax id="reRenderAllAjax" event="click"
render="commonGrid"/>
</h:graphicImage>
</h:panelGrid>
@@ -50,7 +50,7 @@
<h:panelGrid id="templatesSelector" columns="1">
<h:outputText id="templateSelectMenuLabel"
value="Template:" />
- <ui:repeat var="var" value="#{templateBean.templates}"
varStatus="status">
+ <ui:repeat id="templates" var="var"
value="#{templateBean.templates}" varStatus="status">
<h:selectOneMenu
value="#{templateBean.templates[status.index]}" id="templateSelect"
style="width: 150px;">
<f:selectItems
value="#{templateBean.availableTemplates}" />
@@ -65,8 +65,23 @@
</h:panelGrid>
<h:panelGrid columns="1">
- <h:commandButton action="#{richBean.invalidateSession}"
value="Invalidate Session"
image="#{resource['images:cancel.png']}" style="width:
36px;"/>
+ <a4j:outputPanel layout="block"
ajaxRendered="true">
+ <h:outputText id="requestTime"
value="#{phasesBean.date}">
+ <f:convertDateTime pattern="HH:mm:ss.SSS"/>
+ </h:outputText>
+ <ul>
+ <a4j:repeat value="#{phasesBean.phases}"
var="phase">
+ <li>#{phase.phaseId}</li>
+ </a4j:repeat>
+ </ul>
+ </a4j:outputPanel>
</h:panelGrid>
+
+ <h:panelGrid columns="1">
+ <h:commandButton id="invalidateSessionButton"
action="#{richBean.invalidateSession}" value="Invalidate Session"
image="#{resource['images:cancel.png']}" title="Invalidate
Session" style="width: 36px;"/>
+ </h:panelGrid>
+
+
</h:panelGrid>
</ui:composition>
\ No newline at end of file