Author: ppitonak(a)redhat.com
Date: 2010-07-22 08:11:08 -0400 (Thu, 22 Jul 2010)
New Revision: 18191
Added:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JJSFunctionBean.java
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/TimeBean.java
root/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JJSFunctionBean.properties
root/tests/metamer/trunk/application/src/main/webapp/components/a4jJSFunction/
root/tests/metamer/trunk/application/src/main/webapp/components/a4jJSFunction/list.xhtml
root/tests/metamer/trunk/application/src/main/webapp/components/a4jJSFunction/simple.xhtml
root/tests/metamer/trunk/application/src/main/webapp/resources/css/a4jJSFunction.css
Modified:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attributes.java
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JCommandButtonBean.java
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JCommandLinkBean.java
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
Log:
* one page for a4j:jsFunction added
* class Attributes works even if property file is not found
* all actions and action listeners are automatically loggen on page
Modified:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attributes.java
===================================================================
---
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attributes.java 2010-07-22
11:55:06 UTC (rev 18190)
+++
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attributes.java 2010-07-22
12:11:08 UTC (rev 18191)
@@ -32,6 +32,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.TreeMap;
@@ -47,6 +48,7 @@
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
+import org.richfaces.tests.metamer.bean.RichBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -137,7 +139,13 @@
* Loads help strings from property file.
*/
private void loadHelp() {
- ResourceBundle rb = ResourceBundle.getBundle(beanClass.getName());
+ ResourceBundle rb = null;
+ try {
+ rb = ResourceBundle.getBundle(beanClass.getName());
+ } catch (MissingResourceException mre) {
+ return;
+ }
+
Enumeration<String> keys = rb.getKeys();
String key = null;
Attribute attribute = null;
@@ -159,7 +167,13 @@
* @return map where key is attribute's name and value is list of select items
usable to select attribute value
*/
private void loadSelectOptions() {
- ResourceBundle rb = ResourceBundle.getBundle(beanClass.getName());
+ ResourceBundle rb = null;
+ try {
+ rb = ResourceBundle.getBundle(beanClass.getName());
+ } catch (MissingResourceException mre) {
+ return;
+ }
+
Enumeration<String> keys = rb.getKeys();
String key = null;
@@ -352,6 +366,8 @@
return null;
}
+ RichBean.logToPage("action invoked");
+
// if no select options for "action" are defined in property file and
it is an EL expression
if (!hasSelectOptions("action") && isStringEL(outcome)) {
method = getExpressionFactory().createMethodExpression(elContext, outcome,
String.class, new Class[0]);
@@ -391,6 +407,8 @@
return;
}
+ RichBean.logToPage("action listener invoked");
+
// if no select options for "actionListener" are defined in property
file and it is an EL expression
if (!hasSelectOptions("actionListener") &&
isStringEL(listener)) {
method =
Modified:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JCommandButtonBean.java
===================================================================
---
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JCommandButtonBean.java 2010-07-22
11:55:06 UTC (rev 18190)
+++
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JCommandButtonBean.java 2010-07-22
12:11:08 UTC (rev 18191)
@@ -141,8 +141,6 @@
* @return null since no navigation should be performed
*/
public String first6CharsAction() {
- RichBean.logToPage("action invoked");
-
if (input == null) {
return "";
} else {
@@ -158,8 +156,6 @@
* @return null since no navigation should be performed
*/
public String doubleStringAction() {
- RichBean.logToPage("action invoked");
-
if (input == null) {
input2 = "";
} else {
@@ -175,8 +171,6 @@
* @return null since no navigation should be performed
*/
public String toUpperCaseAction() {
- RichBean.logToPage("action invoked");
-
if (input == null) {
return "";
} else {
@@ -192,8 +186,6 @@
* an event representing the activation of a user interface component (not
used)
*/
public void first6CharsActionListener(ActionEvent event) {
- RichBean.logToPage("action listener invoked");
-
if (input == null) {
input3 = "";
} else {
@@ -209,8 +201,6 @@
* an event representing the activation of a user interface component (not
used)
*/
public void doubleStringActionListener(ActionEvent event) {
- RichBean.logToPage("action listener invoked");
-
if (input == null) {
input3 = "";
} else {
@@ -225,8 +215,6 @@
* an event representing the activation of a user interface component (not
used)
*/
public void toUpperCaseActionListener(ActionEvent event) {
- RichBean.logToPage("action listener invoked");
-
if (input == null) {
input3 = "";
} else {
Modified:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JCommandLinkBean.java
===================================================================
---
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JCommandLinkBean.java 2010-07-22
11:55:06 UTC (rev 18190)
+++
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JCommandLinkBean.java 2010-07-22
12:11:08 UTC (rev 18191)
@@ -134,8 +134,6 @@
* @return null since no navigation should be performed
*/
public String first6CharsAction() {
- RichBean.logToPage("action invoked");
-
if (input == null) {
return "";
} else {
@@ -151,8 +149,6 @@
* @return null since no navigation should be performed
*/
public String doubleStringAction() {
- RichBean.logToPage("action invoked");
-
if (input == null) {
input2 = "";
} else {
@@ -168,8 +164,6 @@
* @return null since no navigation should be performed
*/
public String toUpperCaseAction() {
- RichBean.logToPage("action invoked");
-
if (input == null) {
return "";
} else {
@@ -185,8 +179,6 @@
* an event representing the activation of a user interface component (not
used)
*/
public void first6CharsActionListener(ActionEvent event) {
- RichBean.logToPage("action listener invoked");
-
if (input == null) {
input3 = "";
} else {
@@ -202,8 +194,6 @@
* an event representing the activation of a user interface component (not
used)
*/
public void doubleStringActionListener(ActionEvent event) {
- RichBean.logToPage("action listener invoked");
-
if (input == null) {
input3 = "";
} else {
@@ -218,8 +208,6 @@
* an event representing the activation of a user interface component (not
used)
*/
public void toUpperCaseActionListener(ActionEvent event) {
- RichBean.logToPage("action listener invoked");
-
if (input == null) {
input3 = "";
} else {
Added:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JJSFunctionBean.java
===================================================================
---
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JJSFunctionBean.java
(rev 0)
+++
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JJSFunctionBean.java 2010-07-22
12:11:08 UTC (rev 18191)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.SimpleDateFormat;
+import java.util.Date;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+import javax.faces.event.ActionEvent;
+import org.richfaces.component.UIFunction;
+
+import org.richfaces.tests.metamer.Attributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed bean for a4j:jsFunction.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "a4jJSFunctionBean")
+@ViewScoped
+public class A4JJSFunctionBean implements Serializable {
+
+ private static final long serialVersionUID = 48333649809L;
+ private static Logger logger;
+ private Attributes attributes;
+ private int year;
+
+ /**
+ * Initializes the managed bean.
+ */
+ @PostConstruct
+ public void init() {
+ logger = LoggerFactory.getLogger(getClass());
+ logger.info("initializing bean " + getClass().getName());
+ year = Integer.parseInt(new SimpleDateFormat("yyyy").format(new
Date()));
+
+ // initialize attributes
+ attributes = Attributes.getUIComponentAttributes(UIFunction.class, getClass());
+
+ attributes.setAttribute("execute", "@form");
+ attributes.setAttribute("render", "time1, time2, year");
+ attributes.setAttribute("rendered", true);
+
+ // TODO has to be tested in other way
+ attributes.remove("name");
+ }
+
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Attributes attributes) {
+ this.attributes = attributes;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String increaseYearAction() {
+ year++;
+ return null;
+ }
+
+ public String decreaseYearAction() {
+ year--;
+ return null;
+ }
+
+ public void increaseYearActionListener(ActionEvent event) {
+ year++;
+ }
+
+ public void decreaseYearActionListener(ActionEvent event) {
+ year--;
+ }
+}
Property changes on:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JJSFunctionBean.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-22
11:55:06 UTC (rev 18190)
+++
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-07-22
12:11:08 UTC (rev 18191)
@@ -94,6 +94,7 @@
components.put("a4jAjax", "A4J Ajax");
components.put("a4jCommandLink", "A4J Command Link");
components.put("a4jCommandButton", "A4J Command Button");
+ components.put("a4jJSFunction", "A4J JavaScript Function");
components.put("a4jLog", "A4J Log");
components.put("a4jMediaOutput", "A4J Media Output");
components.put("a4jOutputPanel", "A4J Output Panel");
Added:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/TimeBean.java
===================================================================
---
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/TimeBean.java
(rev 0)
+++
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/TimeBean.java 2010-07-22
12:11:08 UTC (rev 18191)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.SimpleDateFormat;
+import java.util.Date;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+/**
+ * Request-scoped managed bean providing current time.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "timeBean")
+@RequestScoped
+public class TimeBean implements Serializable {
+
+ private Date date;
+ private String formattedTime;
+
+ public String getFormattedTime() {
+ if (formattedTime == null) {
+ formattedTime = new
SimpleDateFormat("HH:mm:ss.SSS").format(getDate());
+ }
+
+ return formattedTime;
+ }
+
+ public Date getDate() {
+ if (date == null) {
+ date = new Date();
+ }
+
+ return date;
+ }
+}
Added:
root/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JJSFunctionBean.properties
===================================================================
---
root/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JJSFunctionBean.properties
(rev 0)
+++
root/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JJSFunctionBean.properties 2010-07-22
12:11:08 UTC (rev 18191)
@@ -0,0 +1,7 @@
+attr.action.increaseYearAction=increaseYearAction
+attr.action.decreaseYearAction=decreaseYearAction
+attr.action.none=
+
+attr.actionListener.increaseYearActionListener=increaseYearActionListener
+attr.actionListener.decreaseYearActionListener=decreaseYearActionListener
+attr.actionListener.none=
Added:
root/tests/metamer/trunk/application/src/main/webapp/components/a4jJSFunction/list.xhtml
===================================================================
---
root/tests/metamer/trunk/application/src/main/webapp/components/a4jJSFunction/list.xhtml
(rev 0)
+++
root/tests/metamer/trunk/application/src/main/webapp/components/a4jJSFunction/list.xhtml 2010-07-22
12:11:08 UTC (rev 18191)
@@ -0,0 +1,41 @@
+<!--
+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 JavaScript Function</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:jsFunction</b> and
+ input boxes for all its attributes.</div>
+
+ </h:body>
+</html>
\ No newline at end of file
Added:
root/tests/metamer/trunk/application/src/main/webapp/components/a4jJSFunction/simple.xhtml
===================================================================
---
root/tests/metamer/trunk/application/src/main/webapp/components/a4jJSFunction/simple.xhtml
(rev 0)
+++
root/tests/metamer/trunk/application/src/main/webapp/components/a4jJSFunction/simple.xhtml 2010-07-22
12:11:08 UTC (rev 18191)
@@ -0,0 +1,84 @@
+<!--
+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="a4jJSFunction.css" />
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+ <fieldset id="outputFieldset">
+ <legend>standard outputs</legend>
+ <h:panelGrid columns="2">
+ time1: <h:outputText id="time1"
value="#{timeBean.formattedTime}"/>
+ time2: <h:outputText id="time2"
value="#{timeBean.formattedTime}"/>
+ year: <h:outputText id="year"
value="#{a4jJSFunctionBean.year}"/>
+ </h:panelGrid>
+ </fieldset>
+ <br/>
+ <fieldset id="autoOutputFieldset">
+ <legend>ajaxRendered="true"</legend>
+ <a4j:outputPanel id="autoTime"
ajaxRendered="true">#{timeBean.formattedTime}</a4j:outputPanel>
+ </fieldset>
+
+ <a4j:jsFunction id="jsFunction"
+ action="#{a4jJSFunctionBean.attributes.action}"
+
actionListener="#{a4jJSFunctionBean.attributes.actionListener}"
+
bypassUpdates="#{a4jJSFunctionBean.attributes['bypassUpdates'].value}"
+
execute="#{a4jJSFunctionBean.attributes['execute'].value}"
+
immediate="#{a4jJSFunctionBean.attributes['immediate'].value}"
+
limitRender="#{a4jJSFunctionBean.attributes['limitRender'].value}"
+ name="metamerFunction"
+
onbeforedomupdate="#{a4jJSFunctionBean.attributes['onbeforedomupdate'].value}"
+
onbegin="#{a4jJSFunctionBean.attributes['onbegin'].value}"
+
oncomplete="#{a4jJSFunctionBean.attributes['oncomplete'].value}"
+
render="#{a4jJSFunctionBean.attributes['render'].value}"
+
rendered="#{a4jJSFunctionBean.attributes['rendered'].value}"
+
status="#{a4jJSFunctionBean.attributes['status'].value}"
+
value="#{a4jJSFunctionBean.attributes['value'].value}"
+ >
+ </a4j:jsFunction>
+
+ <br/>
+ <a href="javascript:metamerFunction()">Call JavaScript
function</a>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <ta:attributes value="#{a4jJSFunctionBean.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/a4jJSFunction.css
===================================================================