Author: lfryc(a)redhat.com
Date: 2010-07-10 15:06:08 -0400 (Sat, 10 Jul 2010)
New Revision: 17833
Added:
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JPollBean.java
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JPushBean.java
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JPollBean.properties
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JPushBean.properties
root/tests/metamer/trunk/src/main/webapp/components/a4jPoll/
root/tests/metamer/trunk/src/main/webapp/components/a4jPoll/list.xhtml
root/tests/metamer/trunk/src/main/webapp/components/a4jPoll/simple.xhtml
root/tests/metamer/trunk/src/main/webapp/components/a4jPush/
root/tests/metamer/trunk/src/main/webapp/components/a4jPush/list.xhtml
root/tests/metamer/trunk/src/main/webapp/components/a4jPush/simple.xhtml
root/tests/metamer/trunk/src/main/webapp/resources/css/a4jPoll.css
root/tests/metamer/trunk/src/main/webapp/resources/css/a4jPush.css
Modified:
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/Attributes.java
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/RichBean.java
Log:
https://jira.jboss.org/jira/browse/RFPL-466
* added a4j:push and a4j:poll
* invocation of action and actionListener in class Attributes fixed
Modified: root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/Attributes.java
===================================================================
---
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/Attributes.java 2010-07-10
19:02:19 UTC (rev 17832)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/Attributes.java 2010-07-10
19:06:08 UTC (rev 17833)
@@ -390,6 +390,10 @@
MethodExpression method = null;
String outcome = (String) attributes.get("action");
+ if (outcome == null) {
+ return null;
+ }
+
// if no select options for "action" are defined in property file and
it is an EL expression
if (!hasSelectOptions("action") && isStringEL(outcome)) {
method = ExpressionFactory.newInstance().createMethodExpression(elContext,
outcome, String.class, new Class[0]);
@@ -419,6 +423,10 @@
MethodExpression method = null;
String listener = (String) attributes.get("actionListener");
+ if (listener == null) {
+ return;
+ }
+
// if no select options for "actionListener" are defined in property
file and it is an EL expression
if (!hasSelectOptions("actionListener") &&
isStringEL(listener)) {
method = ExpressionFactory.newInstance().createMethodExpression(elContext,
listener, void.class,
Added: root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JPollBean.java
===================================================================
--- root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JPollBean.java
(rev 0)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JPollBean.java 2010-07-10
19:06:08 UTC (rev 17833)
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * 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.io.Serializable;
+import java.util.Date;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.event.ActionEvent;
+import org.richfaces.component.UIPoll;
+
+import org.richfaces.testapp.Attributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed bean for a4j:push.
+ *
+ * @author Nick Belaevski, <a href="mailto:ppitonak@redhat.com">Pavol
Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "a4jPollBean")
+@SessionScoped
+public class A4JPollBean implements Serializable {
+
+ private static final long serialVersionUID = 4810889475400649809L;
+ private static Logger logger;
+ private Attributes attributes;
+ private int counter;
+
+ /**
+ * Initializes the managed bean.
+ */
+ @PostConstruct
+ public void init() {
+ logger = LoggerFactory.getLogger(getClass());
+ logger.debug("initializing bean " + getClass().getName());
+
+ attributes = Attributes.getUIComponentAttributes(UIPoll.class, getClass());
+ attributes.put("rendered", true);
+ attributes.put("interval", 5000);
+ attributes.put("action", "increaseCounterAction");
+ attributes.put("actionListener",
"increaseCounter3ActionListener");
+ }
+
+ /**
+ * Getter for attributes.
+ *
+ * @return A map containing all attributes of tested component. Name of the component
is key in the map.
+ */
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * Setter for attributes.
+ *
+ * @param attributes
+ * map containing all attributes of tested component. Name of the
component is key in the map.
+ */
+ public void setAttributes(Attributes attributes) {
+ this.attributes = attributes;
+ }
+
+ public Date getDate() {
+ return new Date();
+ }
+
+ public void enablePoll(ActionEvent event) {
+ logger.debug("enablePoll");
+ attributes.put("enabled", true);
+ }
+
+ public void disablePoll(ActionEvent event) {
+ logger.debug("disablePoll");
+ attributes.put("enabled", false);
+ }
+
+ public int getCounter() {
+ return counter;
+ }
+
+ public void setCounter(int counter) {
+ this.counter = counter;
+ }
+
+ public String increaseCounterAction() {
+ logger.debug("increaseCounterAction");
+ counter++;
+ return null;
+ }
+
+ public String decreaseCounterAction() {
+ counter--;
+ return null;
+ }
+
+ public void increaseCounter3ActionListener(ActionEvent event) {
+ counter += 3;
+ }
+
+ public void decreaseCounter3ActionListener(ActionEvent event) {
+ counter -= 3;
+ }
+}
+
Added: root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JPushBean.java
===================================================================
--- root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JPushBean.java
(rev 0)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JPushBean.java 2010-07-10
19:06:08 UTC (rev 17833)
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * 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.io.Serializable;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.EventListener;
+import java.util.EventObject;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.event.ActionEvent;
+import org.ajax4jsf.event.PushEventListener;
+import org.richfaces.component.UIPush;
+
+import org.richfaces.testapp.Attributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed bean for a4j:push.
+ *
+ * @author Nick Belaevski, <a href="mailto:ppitonak@redhat.com">Pavol
Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "a4jPushBean")
+@SessionScoped
+public class A4JPushBean implements Serializable {
+
+ private static final long serialVersionUID = 4810889475400649809L;
+ private static Logger logger;
+ private Attributes attributes;
+ private int counter = 0;
+ private transient volatile PushEventListener listener;
+ private String formattedDate = null;
+
+ /**
+ * Initializes the managed bean.
+ */
+ @PostConstruct
+ public void init() {
+ logger = LoggerFactory.getLogger(getClass());
+ logger.debug("initializing bean " + getClass().getName());
+
+ attributes = Attributes.getUIComponentAttributes(UIPush.class, getClass());
+ attributes.put("interval", 1000);
+ attributes.put("action", "increaseCounterAction");
+ attributes.put("actionListener",
"increaseCounter3ActionListener");
+ attributes.put("rendered", true);
+ attributes.put("enabled", true);
+
+ // will be set on page and cannot be changed
+ attributes.remove("eventProducer");
+ }
+
+ /**
+ * Getter for attributes.
+ *
+ * @return A map containing all attributes of tested component. Name of the component
is key in the map.
+ */
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * Setter for attributes.
+ *
+ * @param attributes
+ * map containing all attributes of tested component. Name of the
component is key in the map.
+ */
+ public void setAttributes(Attributes attributes) {
+ this.attributes = attributes;
+ }
+
+ public void setListener(EventListener listener) {
+ this.listener = (PushEventListener) listener;
+ }
+
+ public void generateEvent() {
+ listener.onEvent(new EventObject(this));
+ }
+
+ public int getCounter() {
+ return counter;
+ }
+
+ public String increaseCounterAction() {
+ counter++;
+ return null;
+ }
+
+ public String decreaseCounterAction() {
+ counter--;
+ return null;
+ }
+
+ public void increaseCounter3ActionListener(ActionEvent event) {
+ counter += 3;
+ }
+
+ public void decreaseCounter3ActionListener(ActionEvent event) {
+ counter -= 3;
+ }
+
+ public String getDateString() {
+ if (formattedDate == null) {
+ formattedDate = new SimpleDateFormat("HH:mm:ss SSSS").format(new
Date());
+ }
+
+ return formattedDate;
+ }
+}
+
Modified: root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/RichBean.java
===================================================================
---
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/RichBean.java 2010-07-10
19:02:19 UTC (rev 17832)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/RichBean.java 2010-07-10
19:06:08 UTC (rev 17833)
@@ -94,6 +94,8 @@
components.put("a4jCommandButton", "A4J Command Button");
components.put("a4jLog", "A4J Log");
components.put("a4jMediaOutput", "A4J Media Output");
+ components.put("a4jPoll", "A4J Poll");
+ components.put("a4jPush", "A4J Push");
components.put("commandButton", "JSF Command Button");
}
Added:
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JPollBean.properties
===================================================================
---
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JPollBean.properties
(rev 0)
+++
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JPollBean.properties 2010-07-10
19:06:08 UTC (rev 17833)
@@ -0,0 +1,5 @@
+attr.action.increaseCounterAction=increaseCounterAction
+attr.action.decreaseCounterAction=decreaseCounterAction
+
+attr.actionListener.increaseCounter3ActionListener=increaseCounter3ActionListener
+attr.actionListener.decreaseCounter3ActionListener=decreaseCounter3ActionListener
\ No newline at end of file
Added:
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JPushBean.properties
===================================================================
---
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JPushBean.properties
(rev 0)
+++
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JPushBean.properties 2010-07-10
19:06:08 UTC (rev 17833)
@@ -0,0 +1,5 @@
+attr.action.increaseCounterAction=increaseCounterAction
+attr.action.decreaseCounterAction=decreaseCounterAction
+
+attr.actionListener.increaseCounter3ActionListener=increaseCounter3ActionListener
+attr.actionListener.decreaseCounter3ActionListener=decreaseCounter3ActionListener
\ No newline at end of file
Added: root/tests/metamer/trunk/src/main/webapp/components/a4jPoll/list.xhtml
===================================================================
--- root/tests/metamer/trunk/src/main/webapp/components/a4jPoll/list.xhtml
(rev 0)
+++ root/tests/metamer/trunk/src/main/webapp/components/a4jPoll/list.xhtml 2010-07-10
19:06:08 UTC (rev 17833)
@@ -0,0 +1,17 @@
+<!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 Poll</title>
+ <meta http-equiv="Content-Type" content="text/xhtml;
charset=UTF-8" />
+ <h:outputStylesheet library="css" name="list.css" />
+</h:head>
+
+<h:body>
+
+ <h:outputLink value="simple.xhtml"
styleClass="link">Simple</h:outputLink>
+ <div class="description">Simple page that contains
<b>a4j:poll</b> and input boxes for all its attributes.</div>
+
+</h:body>
+</html>
\ No newline at end of file
Added: root/tests/metamer/trunk/src/main/webapp/components/a4jPoll/simple.xhtml
===================================================================
--- root/tests/metamer/trunk/src/main/webapp/components/a4jPoll/simple.xhtml
(rev 0)
+++ root/tests/metamer/trunk/src/main/webapp/components/a4jPoll/simple.xhtml 2010-07-10
19:06:08 UTC (rev 17833)
@@ -0,0 +1,50 @@
+<!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">
+
+ <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="a4jPoll.css"/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+ <h:panelGroup id="pollPanel">
+ <a4j:poll id="poll"
+ action="#{a4jPollBean.attributes.action}"
+
actionListener="#{a4jPollBean.attributes.actionListener}"
+
bypassUpdates="#{a4jPollBean.attributes['bypassUpdates']}"
+
enabled="#{a4jPollBean.attributes['enabled']}"
+
immediate="#{a4jPollBean.attributes['immediate']}"
+
interval="#{a4jPollBean.attributes['interval']}"
+
onbeforedomupdate="#{a4jPollBean.attributes['onbeforedomupdate']}"
+
onbegin="#{a4jPollBean.attributes['onbegin']}"
+
oncomplete="#{a4jPollBean.attributes['oncomplete']}"
+
ontimer="#{a4jPollBean.attributes['ontimer']}"
+
rendered="#{a4jPollBean.attributes['rendered']}"
+ value="#{a4jPollBean.attributes['value']}"
+ >
+ <a4j:ajax event="timer" render="time" />
+ </a4j:poll>
+ </h:panelGroup>
+
+ <h:panelGroup id="time">
+ #{a4jPollBean.date} *** #{a4jPollBean.counter}
+ </h:panelGroup>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <ta:attributes value="#{a4jPollBean.attributes}"
id="attributes" />
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added: root/tests/metamer/trunk/src/main/webapp/components/a4jPush/list.xhtml
===================================================================
--- root/tests/metamer/trunk/src/main/webapp/components/a4jPush/list.xhtml
(rev 0)
+++ root/tests/metamer/trunk/src/main/webapp/components/a4jPush/list.xhtml 2010-07-10
19:06:08 UTC (rev 17833)
@@ -0,0 +1,17 @@
+<!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 Push</title>
+ <meta http-equiv="Content-Type" content="text/xhtml;
charset=UTF-8" />
+ <h:outputStylesheet library="css" name="list.css" />
+</h:head>
+
+<h:body>
+
+ <h:outputLink value="simple.xhtml"
styleClass="link">Simple</h:outputLink>
+ <div class="description">Simple page that contains
<b>a4j:push</b> and input boxes for all its attributes.</div>
+
+</h:body>
+</html>
\ No newline at end of file
Added: root/tests/metamer/trunk/src/main/webapp/components/a4jPush/simple.xhtml
===================================================================
--- root/tests/metamer/trunk/src/main/webapp/components/a4jPush/simple.xhtml
(rev 0)
+++ root/tests/metamer/trunk/src/main/webapp/components/a4jPush/simple.xhtml 2010-07-10
19:06:08 UTC (rev 17833)
@@ -0,0 +1,55 @@
+<!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">
+
+ <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="a4jPush.css"/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+ <h:panelGrid columns="2">
+ Time: <h:panelGroup id="time">#{a4jPushBean.dateString} *
#{a4jPushBean.counter}</h:panelGroup>
+ </h:panelGrid>
+ <a4j:push id="push"
+ action="#{a4jPushBean.attributes.action}"
+
actionListener="#{a4jPushBean.attributes.actionListener}"
+
bypassUpdates="#{a4jPushBean.attributes['bypassUpdates']}"
+ enabled="#{a4jPushBean.attributes['enabled']}"
+ eventProducer="#{a4jPushBean.setListener}"
+
hasActiveBehavior="#{a4jPushBean.attributes['hasActiveBehavior']}"
+
immediate="#{a4jPushBean.attributes['immediate']}"
+ interval="#{a4jPushBean.attributes['interval']}"
+
onbeforedomupdate="#{a4jPushBean.attributes['onbeforedomupdate']}"
+ onbegin="#{a4jPushBean.attributes['onbegin']}"
+
oncomplete="#{a4jPushBean.attributes['oncomplete']}"
+
ondataavailable="#{a4jPushBean.attributes['ondataavailable']}"
+ rendered="#{a4jPushBean.attributes['rendered']}"
+ value="#{a4jPushBean.attributes['value']}"
+ >
+ <f:ajax render="#{'form:time'}" />
+ <f:param name="testParam" value="testValue" />
+ <f:param name="testParam1" value="testValue1"
/>
+ </a4j:push>
+
+ <h:commandLink value="Generate push event"
action="#{a4jPushBean.generateEvent}">
+ <f:ajax render="@none" />
+ </h:commandLink>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <ta:attributes value="#{a4jPushBean.attributes}"
id="attributes" />
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added: root/tests/metamer/trunk/src/main/webapp/resources/css/a4jPoll.css
===================================================================
Added: root/tests/metamer/trunk/src/main/webapp/resources/css/a4jPush.css
===================================================================