Author: nbelaevski
Date: 2010-05-15 10:25:19 -0400 (Sat, 15 May 2010)
New Revision: 17063
Added:
root/examples/core-demo/trunk/src/main/java/org/richfaces/demo/ActionListenerBean.java
root/examples/core-demo/trunk/src/main/webapp/actionListener.xhtml
root/examples/core-demo/trunk/src/main/webapp/resources/demo/
root/examples/core-demo/trunk/src/main/webapp/resources/demo/actionComposite.xhtml
Modified:
root/examples/core-demo/trunk/src/main/webapp/welcome.xhtml
Log:
https://jira.jboss.org/browse/RF-8444
Added:
root/examples/core-demo/trunk/src/main/java/org/richfaces/demo/ActionListenerBean.java
===================================================================
---
root/examples/core-demo/trunk/src/main/java/org/richfaces/demo/ActionListenerBean.java
(rev 0)
+++
root/examples/core-demo/trunk/src/main/java/org/richfaces/demo/ActionListenerBean.java 2010-05-15
14:25:19 UTC (rev 17063)
@@ -0,0 +1,75 @@
+/*
+ * 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.demo;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.NoneScoped;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean
+@NoneScoped
+public class ActionListenerBean {
+
+ public static final class ActionListenerImpl implements ActionListener {
+
+ public void processAction(ActionEvent event) throws AbortProcessingException {
+ addFacesMessage("Implementation of ActionListener created and called:
" + this);
+ }
+
+ }
+
+ private static final class BoundActionListener implements ActionListener {
+
+ public void processAction(ActionEvent event) throws AbortProcessingException {
+ addFacesMessage("Bound listener called");
+ }
+
+ }
+
+ private ActionListener actionListener = new BoundActionListener();
+
+ private static void addFacesMessage(String messageText) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ context.addMessage(null, new FacesMessage(messageText));
+ }
+
+ public void handleActionMethod(ActionEvent event) throws AbortProcessingException {
+ addFacesMessage("Method expression listener called");
+ }
+
+ public void handleActionMethodComposite(ActionEvent event) throws
AbortProcessingException {
+ addFacesMessage("Method expression listener called from composite
component");
+ }
+
+ public ActionListener getActionListener() {
+ return actionListener;
+ }
+
+}
Added: root/examples/core-demo/trunk/src/main/webapp/actionListener.xhtml
===================================================================
--- root/examples/core-demo/trunk/src/main/webapp/actionListener.xhtml
(rev 0)
+++ root/examples/core-demo/trunk/src/main/webapp/actionListener.xhtml 2010-05-15 14:25:19
UTC (rev 17063)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!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:a4j_ext="http://richfaces.org/a4j_ext"
+
xmlns:demo="http://java.sun.com/jsf/composite/demo">
+<f:view>
+ <h:head>
+ </h:head>
+ <h:body>
+ <h:form id="form">
+ <h:messages id="messages" />
+
+ <h:panelGrid columns="1">
+ <h:commandButton value="Invoke listener by type">
+ <a4j_ext:actionListener
type="org.richfaces.demo.ActionListenerBean$ActionListenerImpl" />
+ <f:ajax render="messages" />
+ </h:commandButton>
+
+ <h:commandButton value="Invoke listener by binding">
+ <a4j_ext:actionListener binding="#{actionListenerBean.actionListener}"
/>
+ <f:ajax render="messages" />
+ </h:commandButton>
+
+ <h:commandButton value="Invoke listener method">
+ <a4j_ext:actionListener
listener="#{actionListenerBean.handleActionMethod}" />
+ <f:ajax render="messages" />
+ </h:commandButton>
+
+ <demo:actionComposite render=":form:messages" value="Invoke
listener method in composite component">
+ <a4j_ext:actionListener for="button"
listener="#{actionListenerBean.handleActionMethodComposite}" />
+ </demo:actionComposite>
+ </h:panelGrid>
+ </h:form>
+ </h:body>
+</f:view>
+</html>
\ No newline at end of file
Added: root/examples/core-demo/trunk/src/main/webapp/resources/demo/actionComposite.xhtml
===================================================================
--- root/examples/core-demo/trunk/src/main/webapp/resources/demo/actionComposite.xhtml
(rev 0)
+++
root/examples/core-demo/trunk/src/main/webapp/resources/demo/actionComposite.xhtml 2010-05-15
14:25:19 UTC (rev 17063)
@@ -0,0 +1,23 @@
+<!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:c="http://java.sun.com/jsp/jstl/core"
+
xmlns:composite="http://java.sun.com/jsf/composite">
+
+<composite:interface>
+ <composite:actionSource name="button" />
+ <composite:attribute name="render" />
+ <composite:attribute name="execute" />
+ <composite:attribute name="value" />
+</composite:interface>
+
+<composite:implementation>
+ <h:commandButton id="button" value="#{cc.attrs.value}">
+ <composite:insertChildren />
+
+ <f:ajax render="#{cc.attrs.render}"
execute="#{cc.attrs.execute}" />
+ </h:commandButton>
+</composite:implementation>
+</html>
Modified: root/examples/core-demo/trunk/src/main/webapp/welcome.xhtml
===================================================================
--- root/examples/core-demo/trunk/src/main/webapp/welcome.xhtml 2010-05-15 14:24:28 UTC
(rev 17062)
+++ root/examples/core-demo/trunk/src/main/webapp/welcome.xhtml 2010-05-15 14:25:19 UTC
(rev 17063)
@@ -9,6 +9,7 @@
<center>
<h1>Welcome To RichFaces 4.x Core Demo</h1>
<ul>
+ <li><h:link
outcome="actionListener">a4j:actionListener</h:link></li>
<li><h:link outcome="ajax">a4j:ajax</h:link></li>
<li><h:link
outcome="attachQueue">a4j:attachQueue</h:link></li>
<li><h:link
outcome="button">a4j:commandButton</h:link></li>