JBoss Rich Faces SVN: r15235 - root/examples/trunk/components/core-demo/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-08-20 11:37:52 -0400 (Thu, 20 Aug 2009)
New Revision: 15235
Modified:
root/examples/trunk/components/core-demo/src/main/webapp/pages/support.xhtml
Log:
Modified: root/examples/trunk/components/core-demo/src/main/webapp/pages/support.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/pages/support.xhtml 2009-08-20 15:37:01 UTC (rev 15234)
+++ root/examples/trunk/components/core-demo/src/main/webapp/pages/support.xhtml 2009-08-20 15:37:52 UTC (rev 15235)
@@ -3,7 +3,7 @@
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:a="http://richfaces.org/a4j/behavior">
+ xmlns:a="http://richfaces.org/a4j">
<h:head>
Richfaces Ajax Sample
</h:head>
@@ -23,12 +23,12 @@
<h:panelGrid columns="2">
<h:inputText value="#{sampleBean.thirdText}">
- <a:ajax/>
+ <a:ajax render="thirdOut"/>
</h:inputText>
<h:outputText id="thirdOut" value="#{sampleBean.thirdText}" />
<h:inputText value="#{sampleBean.fourthText}" >
- <a:ajax event="keyup" execute="fourthOut" render="fourthOut"/>
+ <a:ajax event="keyup" render="fourthOut" limitRender="true" listener="#{sampleBean.behaviorListener}"/>
</h:inputText>
<h:outputText id="fourthOut" value="#{sampleBean.fourthText}" />
</h:panelGrid>
15 years, 4 months
JBoss Rich Faces SVN: r15233 - root/framework/trunk/impl/src/main/java/org/richfaces/context.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-08-20 10:56:29 -0400 (Thu, 20 Aug 2009)
New Revision: 15233
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
Log:
PartialViewContext refactoring for better behaviors support
Added check for "ajaxRendered" attribute
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-08-20 12:08:37 UTC (rev 15232)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-08-20 14:56:29 UTC (rev 15233)
@@ -132,26 +132,18 @@
return result;
}
- protected Object getAttributeObject(UIComponent target) {
- Object result = null;
- if (behaviorEvent != null) {
- AjaxBehavior ajaxBehavior = findBehavior(target);
- if (ajaxBehavior != null) {
- result = getBehaviorAttributeValue(ajaxBehavior);
- }
- } else {
- result = getAttributeValue(target);
- }
-
- return result;
- }
-
protected abstract Object getBehaviorAttributeValue(AjaxBehavior behavior);
protected abstract Object getAttributeValue(UIComponent component);
- public VisitResult visit(VisitContext context, UIComponent target) {
- Object attributeObject = getAttributeObject(target);
+ protected void doVisit(FacesContext context, UIComponent target, AjaxBehavior behavior) {
+ Object attributeObject = null;
+ if (behavior != null) {
+ attributeObject = getBehaviorAttributeValue(behavior);
+ } else {
+ attributeObject = getAttributeValue(target);
+ }
+
Collection<String> attributeIds = AjaxRendererUtils.asSet(attributeObject);
if (attributeIds != null && !attributeIds.isEmpty()) {
if (attributeIds.contains(AjaxRendererUtils.ALL)) {
@@ -174,11 +166,20 @@
addDefaultComponents(attributeIds);
componentIds.addAll(RendererUtils.getInstance().findComponentsFor(
- context.getFacesContext(), target, attributeIds));
+ context, target, attributeIds));
}
}
}
-
+ }
+
+ public final VisitResult visit(VisitContext visitContext, UIComponent target) {
+ AjaxBehavior ajaxBehavior = null;
+ if (behaviorEvent != null) {
+ ajaxBehavior = findBehavior(target);
+ }
+
+ doVisit(visitContext.getFacesContext(), target, ajaxBehavior);
+
return VisitResult.COMPLETE;
}
@@ -230,14 +231,13 @@
return limitToList;
}
- public VisitResult visit(VisitContext context, UIComponent target) {
- VisitResult visitResult = super.visit(context, target);
-
+ @Override
+ protected void doVisit(FacesContext context, UIComponent target,
+ AjaxBehavior behavior) {
+ super.doVisit(context, target, behavior);
limitToList = AjaxRendererUtils.isAjaxLimitToList(target);
-
- return visitResult;
}
-
+
@Override
public Object getAttributeValue(UIComponent component) {
return component.getAttributes().get("render");
@@ -254,8 +254,10 @@
List<String> ids = new ArrayList<String>();
Collection<AjaxOutput> ajaxOutputComponentsSet = PartialViewContextAjaxOutputTracker.getAjaxOutputComponentsSet(facesContext);
for (AjaxOutput ajaxOutput : ajaxOutputComponentsSet) {
- UIComponent ajaxOutputComponent = (UIComponent) ajaxOutput;
- ids.add(ajaxOutputComponent.getClientId(facesContext));
+ if (ajaxOutput.isAjaxRendered()) {
+ UIComponent ajaxOutputComponent = (UIComponent) ajaxOutput;
+ ids.add(ajaxOutputComponent.getClientId(facesContext));
+ }
}
return ids;
15 years, 4 months
JBoss Rich Faces SVN: r15232 - branches/community/3.3.X/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: ochikvina
Date: 2009-08-20 08:08:37 -0400 (Thu, 20 Aug 2009)
New Revision: 15232
Modified:
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/rich_dataTable.xml
Log:
https://jira.jboss.org/jira/browse/RF-7680 - the component description and Identification Parameters are reviewed;
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/rich_dataTable.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/rich_dataTable.xml 2009-08-20 10:26:45 UTC (rev 15231)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/rich_dataTable.xml 2009-08-20 12:08:37 UTC (rev 15232)
@@ -10,7 +10,7 @@
</title>
<section>
<title>Description</title>
- <para>The component for tables rendering that allows choosing data from a model and obtains
+ <para>The component is meant for rendering tables. It allows choosing data from a model and obtains
built-in support of Ajax updates.</para>
<figure>
<title>
@@ -40,18 +40,8 @@
<para>Possibility to update a limited set of strings with Ajax</para>
</listitem>
<listitem>
- <para>Possibility to sort and to filter of columns</para>
+ <para><link linkend="sort">Sorting</link> and <link linkend="filter">filtering</link> functionalities for a table columns</para>
</listitem>
- <listitem>
- <para>
- <link linkend="sort">Sorting column values</link>
- </para>
- </listitem>
- <listitem>
- <para>
- <link linkend="filter">Filtering column values</link>
- </para>
- </listitem>
</itemizedlist>
</section>
<section>
@@ -63,33 +53,14 @@
</emphasis> one, except Ajax support and skinnability. Ajax support is possible, because the
component was created basing on the <emphasis role="bold">
<property><a4j:repeat></property>
- </emphasis> component and as a result it could be partially updated with Ajax. <emphasis>
+ </emphasis> component and as a result it could be partially updated with Ajax. The <emphasis>
<property>"ajaxKeys"</property>
- </emphasis> attribute allows to define row keys that is updated after an Ajax request.</para>
+ </emphasis> attribute allows to define row keys which are updated after an Ajax request. You can find an example which demonstrate the usage of the
+ <emphasis>
+ <property>"ajaxKeys"</property>
+ </emphasis> attributes for data iteration components in the
+ <ulink url="http://www.jboss.org/community/wiki/UsingtheajaxKeysattributeforrichdataList">RichFaces Cookbook article</ulink>.</para>
- <para>Here is an example:</para>
-
- <para>
- <emphasis role="bold">Example:</emphasis>
- </para>
- <programlisting role="XML">...
-<rich:dataTable value="#{capitalsBean.capitals}" var="capitals"
- ajaxKeys="#{bean.ajaxSet}" binding="#{bean.table}" id="table">
- ...
-</rich:dataTable>
-...
-<a4j:commandButton action="#{tableBean.action}" reRender="table" value="Submit"/>
-...
-</programlisting>
-
- <para> In the example <emphasis>
- <property>"reRender"</property>
- </emphasis> attribute contains value of <emphasis>
- <property>"id"</property>
- </emphasis> attribute for <emphasis role="bold">
- <property><rich:dataTable></property>
- </emphasis> component. As a result the component is updated after an Ajax request.</para>
-
<para id="table_ex">The component allows to use <emphasis>
<property>"header"</property>
</emphasis>, <emphasis>
15 years, 4 months
JBoss Rich Faces SVN: r15231 - branches/community/3.3.X/docs/userguide/en/src/main/resources/images.
by richfaces-svn-commits@lists.jboss.org
Author: ochikvina
Date: 2009-08-20 06:26:45 -0400 (Thu, 20 Aug 2009)
New Revision: 15231
Removed:
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/subTable_cn.png
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/subTable_oc.png
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/subTable_pc.png
Log:
https://jira.jboss.org/jira/browse/RF-7681 - deleting unnecessaru images;
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/subTable_cn.png
===================================================================
(Binary files differ)
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/subTable_oc.png
===================================================================
(Binary files differ)
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/subTable_pc.png
===================================================================
(Binary files differ)
15 years, 4 months
JBoss Rich Faces SVN: r15230 - branches/community/3.3.X/docs/userguide/en/src/main/resources/images.
by richfaces-svn-commits@lists.jboss.org
Author: ochikvina
Date: 2009-08-20 06:10:21 -0400 (Thu, 20 Aug 2009)
New Revision: 15230
Removed:
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataTable_cn.png
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataTable_oc.png
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataTable_pc.png
Log:
https://jira.jboss.org/jira/browse/RF-7682 - deleting unnecessaru images;
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataTable_cn.png
===================================================================
(Binary files differ)
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataTable_oc.png
===================================================================
(Binary files differ)
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataTable_pc.png
===================================================================
(Binary files differ)
15 years, 4 months
JBoss Rich Faces SVN: r15229 - branches/community/3.3.X/docs/userguide/en/src/main/resources/images.
by richfaces-svn-commits@lists.jboss.org
Author: ochikvina
Date: 2009-08-20 05:49:32 -0400 (Thu, 20 Aug 2009)
New Revision: 15229
Removed:
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataDefinitionList_cn.png
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataDefinitionList_oc.png
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataDefinitionList_pc.png
Log:
https://jira.jboss.org/jira/browse/RF-7682 - deleting unnecessaru images;
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataDefinitionList_cn.png
===================================================================
(Binary files differ)
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataDefinitionList_oc.png
===================================================================
(Binary files differ)
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataDefinitionList_pc.png
===================================================================
(Binary files differ)
15 years, 4 months
JBoss Rich Faces SVN: r15228 - root/framework/trunk/impl/src/test/java/org/richfaces/javascript.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-08-20 05:48:16 -0400 (Thu, 20 Aug 2009)
New Revision: 15228
Modified:
root/framework/trunk/impl/src/test/java/org/richfaces/javascript/QUnitTest.java
Log:
small fix
Modified: root/framework/trunk/impl/src/test/java/org/richfaces/javascript/QUnitTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/javascript/QUnitTest.java 2009-08-20 09:37:55 UTC (rev 15227)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/javascript/QUnitTest.java 2009-08-20 09:48:16 UTC (rev 15228)
@@ -30,8 +30,6 @@
import org.junit.Before;
import org.junit.Test;
-import com.gargoylesoftware.htmlunit.AlertHandler;
-import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlListItem;
@@ -49,11 +47,6 @@
@Before
public void setUp() {
webClient_ = new WebClient();
- webClient_.setAlertHandler(new AlertHandler() {
- public void handleAlert(Page page, String message) {
- System.out.println(" .handleAlert() " + message);
- }
- });
}
@After
15 years, 4 months
JBoss Rich Faces SVN: r15227 - branches/community/3.3.X/docs/userguide/en/src/main/resources/images.
by richfaces-svn-commits@lists.jboss.org
Author: ochikvina
Date: 2009-08-20 05:37:55 -0400 (Thu, 20 Aug 2009)
New Revision: 15227
Removed:
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataList_cn.png
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataList_oc.png
branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataList_pc.png
Log:
https://jira.jboss.org/jira/browse/RF-7682 - deleting unnecessaru images;
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataList_cn.png
===================================================================
(Binary files differ)
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataList_oc.png
===================================================================
(Binary files differ)
Deleted: branches/community/3.3.X/docs/userguide/en/src/main/resources/images/dataList_pc.png
===================================================================
(Binary files differ)
15 years, 4 months
JBoss Rich Faces SVN: r15226 - in root: examples/trunk/components/core-demo/src/main/webapp and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-08-19 18:00:23 -0400 (Wed, 19 Aug 2009)
New Revision: 15226
Added:
root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/StatusBean.java
root/examples/trunk/components/core-demo/src/main/webapp/status.xhtml
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxStatus.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxStatus.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java
Removed:
root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
Modified:
root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/PushBean.java
root/examples/trunk/components/core-demo/src/main/webapp/push.xhtml
root/framework/trunk/api/src/main/java/org/ajax4jsf/javascript/JSReference.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js
root/ui-sandbox/trunk/
root/ui-sandbox/trunk/components/
root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIPush.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml
root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml
Log:
Further updates for a4j:push and a4j:status components
Modified: root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/PushBean.java
===================================================================
--- root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/PushBean.java 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/PushBean.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -39,6 +39,8 @@
private volatile PushEventListener listener;
+ private int counter = 0;
+
public void setListener(EventListener listener) {
this.listener = (PushEventListener) listener;
}
@@ -46,4 +48,12 @@
public void generateEvent() {
listener.onEvent(new EventObject(this));
}
+
+ public int getCounter() {
+ return counter;
+ }
+
+ public void increaseCounter() {
+ counter++;
+ }
}
Added: root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/StatusBean.java
===================================================================
--- root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/StatusBean.java (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/java/org/richfaces/demo/StatusBean.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -0,0 +1,43 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean(name = "statusBean")
+@RequestScoped
+public class StatusBean {
+
+ public void delay() throws InterruptedException {
+ Thread.sleep(2000);
+ }
+
+ public void delayWithError() throws InterruptedException {
+ delay();
+ throw new RuntimeException("Test exception");
+ }
+}
Modified: root/examples/trunk/components/core-demo/src/main/webapp/push.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/push.xhtml 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/examples/trunk/components/core-demo/src/main/webapp/push.xhtml 2009-08-19 22:00:23 UTC (rev 15226)
@@ -10,12 +10,14 @@
</h:head>
<h:body>
<h:panelGrid columns="2">
- Time: <h:panelGroup id="time">#{timeBean.dateString}</h:panelGroup>
+ Time: <h:panelGroup id="time">#{timeBean.dateString} - #{pushBean.counter}</h:panelGroup>
</h:panelGrid>
<h:form id="form">
- <a4j:push eventProducer="#{pushBean.setListener}" interval="5000">
+ <a4j:push ondataavailable="return confirm('execute action?')" eventProducer="#{pushBean.setListener}" interval="1000" action="#{pushBean.increaseCounter}">
<f:ajax render="#{':time'}" />
+ <f:param name="testParam" value="testValue" />
+ <f:param name="testParam1" value="testValue1" />
</a4j:push>
<h:commandLink value="Generate push event" action="#{pushBean.generateEvent}">
Added: root/examples/trunk/components/core-demo/src/main/webapp/status.xhtml
===================================================================
--- root/examples/trunk/components/core-demo/src/main/webapp/status.xhtml (rev 0)
+++ root/examples/trunk/components/core-demo/src/main/webapp/status.xhtml 2009-08-19 22:00:23 UTC (rev 15226)
@@ -0,0 +1,60 @@
+<?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">
+<f:view>
+ <h:head>
+ </h:head>
+ <h:body>
+ <script type="text/javascript">
+ function selectEventSource(source, borderStyle) {
+ jQuery(source).css('border', borderStyle);
+ }
+ </script>
+
+ <a4j:status startStyle="color: green" errorStyle="color: red" onstart="selectEventSource(event.source, '3px dotted navy')"
+ onerror="selectEventSource(event.source, '2px solid red')" onsuccess="selectEventSource(event.source, '0px none white')">
+ <f:facet name="start">...start...</f:facet>
+ <f:facet name="stop">stop</f:facet>
+ <f:facet name="error">error</f:facet>
+ </a4j:status>
+
+ <br />
+
+ <a4j:status startStyle="color: green">
+ <f:facet name="start">...start...</f:facet>
+ <f:facet name="stop">stop</f:facet>
+ </a4j:status>
+
+ <h:form>
+ <h:commandLink value="Ajax" action="#{statusBean.delay}">
+ <f:ajax />
+ </h:commandLink>
+  
+ <h:commandLink value="Ajax error" action="#{statusBean.delayWithError}">
+ <f:ajax />
+ </h:commandLink>
+ </h:form>
+
+ Another form:
+ <h:form>
+ <a4j:status>
+ <f:facet name="start">+++</f:facet>
+ <f:facet name="stop"></f:facet>
+ <f:facet name="error">!!!</f:facet>
+ </a4j:status><br />
+
+ <h:commandLink value="Ajax" action="#{statusBean.delay}">
+ <f:ajax />
+ </h:commandLink>
+  
+ <h:commandLink value="Ajax error" action="#{statusBean.delayWithError}">
+ <f:ajax />
+ </h:commandLink>
+ </h:form>
+ </h:body>
+</f:view>
+</html>
\ No newline at end of file
Modified: root/framework/trunk/api/src/main/java/org/ajax4jsf/javascript/JSReference.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/ajax4jsf/javascript/JSReference.java 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/framework/trunk/api/src/main/java/org/ajax4jsf/javascript/JSReference.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -29,6 +29,7 @@
*/
public class JSReference extends ScriptStringBase {
+ public static final JSReference EVENT = new JSReference("event");
public static final JSReference THIS = new JSReference("this");
public static final JSReference TRUE = new JSReference("true");
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -23,6 +23,7 @@
import java.io.IOException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -30,6 +31,7 @@
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -39,6 +41,11 @@
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.component.UIParameter;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.component.behavior.ClientBehaviorHint;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.component.behavior.ClientBehaviorContext.Parameter;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -141,7 +148,6 @@
public static final String NONE = "@none";
public static final Collection<String> NONE_SET = Collections.singleton(NONE);
-
/**
* Static class - protect constructor
@@ -463,22 +469,22 @@
return options;
}
- /**
- * Create call to Ajax Submit function with first two parameters
- *
- * @param uiComponent
- * @param facesContext
- * @param functionName
- * @return
- */
- public static JSFunction buildAjaxFunction(UIComponent uiComponent,
- FacesContext facesContext) {
- JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext,
- AJAX_FUNCTION_NAME);
- // client-side script must have reference to event-enabled object.
- ajaxFunction.addParameter(new JSReference("event"));
- return ajaxFunction;
- }
+// /**
+// * Create call to Ajax Submit function with first two parameters
+// *
+// * @param uiComponent
+// * @param facesContext
+// * @param functionName
+// * @return
+// */
+// public static JSFunction buildAjaxFunction(UIComponent uiComponent,
+// FacesContext facesContext) {
+// JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext,
+// AJAX_FUNCTION_NAME);
+// // client-side script must have reference to event-enabled object.
+// ajaxFunction.addParameter(new JSReference("event"));
+// return ajaxFunction;
+// }
/**
* Create call to Ajax Submit function with first two parameters
@@ -492,7 +498,7 @@
FacesContext facesContext, String functionName) {
JSFunction ajaxFunction = new JSFunction(functionName);
ajaxFunction.addParameter(uiComponent.getClientId(facesContext));
- ajaxFunction.addParameter(new JSReference("event"));
+ ajaxFunction.addParameter(JSReference.EVENT);
return ajaxFunction;
}
@@ -1068,4 +1074,71 @@
AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(component);
}
+ private static final boolean isNonEmpty(String s) {
+ return s!= null && s.length() != 0;
+ }
+
+ public static String createBehaviorsChain(FacesContext facesContext, UIComponent component, String attributeName) {
+ String result = null;
+
+ List<String> handlers = new ArrayList<String>(2);
+ String eventHandler = (String) component.getAttributes().get(attributeName);
+ if (isNonEmpty(eventHandler)) {
+ handlers.add(eventHandler);
+ }
+
+ boolean hasSubmittingBehavior = false;
+ Map<String, Object> parametersMap = new LinkedHashMap<String, Object>();
+ AjaxRendererUtils.appendParameters(facesContext, component, parametersMap);
+
+ if (component instanceof ClientBehaviorHolder) {
+ ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
+ List<ClientBehavior> behaviors = clientBehaviorHolder.getClientBehaviors().get(attributeName);
+ if (behaviors != null) {
+ ClientBehaviorContext behaviorContext = ClientBehaviorContext.createClientBehaviorContext(facesContext,
+ component, attributeName, null, adaptParametersMap(parametersMap));
+
+ for (ClientBehavior clientBehavior : behaviors) {
+ String behaviorScript = clientBehavior.getScript(behaviorContext);
+ if (isNonEmpty(behaviorScript)) {
+ if (clientBehavior.getHints().contains(ClientBehaviorHint.SUBMITTING)) {
+ hasSubmittingBehavior = true;
+ }
+
+ handlers.add(behaviorScript);
+ }
+ }
+ }
+ }
+
+ if (!hasSubmittingBehavior || (parametersMap != null && !parametersMap.isEmpty())) {
+ JSFunction jsFunction = new JSFunction(AJAX_FUNCTION_NAME, JSReference.THIS, JSReference.EVENT);
+ if (parametersMap != null && !parametersMap.isEmpty()) {
+ jsFunction.addParameter(parametersMap);
+ }
+ handlers.add(jsFunction.toScript());
+ }
+
+ if (!handlers.isEmpty()) {
+ if (handlers.size() == 1) {
+ result = handlers.get(0);
+ } else {
+ JSFunction jsFunction = new JSFunction("jsf.util.chain", JSReference.THIS, JSReference.EVENT);
+ for (String handler : handlers) {
+ jsFunction.addParameter(handler);
+ }
+ result = jsFunction.toScript();
+ }
+ }
+
+ return result;
+ }
+
+ private static Collection<ClientBehaviorContext.Parameter> adaptParametersMap(Map<String, Object> parametersMap) {
+ List<Parameter> result = new ArrayList<ClientBehaviorContext.Parameter>(parametersMap.size());
+ for (Map.Entry<String, Object> entry : parametersMap.entrySet()) {
+ result.add(new ClientBehaviorContext.Parameter(entry.getKey(), entry.getValue()));
+ }
+ return result;
+ }
}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -22,8 +22,13 @@
package org.ajax4jsf.renderkit;
import java.io.IOException;
+import java.util.List;
+import java.util.Map;
import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;
@@ -68,10 +73,37 @@
preDecode(context,component);
// TODO - create set od common decoders ( UIInput, ActionSource etc. ) for process decoding.
if (component.isRendered()) {
+ decodeBehaviors(context, component);
doDecode(context, component);
}
}
+ protected void decodeBehaviors(FacesContext context, UIComponent component) {
+ if (component instanceof ClientBehaviorHolder) {
+ ClientBehaviorHolder holder = (ClientBehaviorHolder) component;
+ Map<String, List<ClientBehavior>> behaviors = holder.getClientBehaviors();
+ if (!behaviors.isEmpty()) {
+ ExternalContext external = context.getExternalContext();
+ Map<String, String> params = external.getRequestParameterMap();
+ String behaviorEvent = params.get("javax.faces.behavior.event");
+
+ if (null != behaviorEvent) {
+ List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);
+
+ if (behaviors.size() > 0) {
+ String behaviorSource = params.get("javax.faces.source");
+ String clientId = component.getClientId();
+ if (null != behaviorSource && behaviorSource.equals(clientId)) {
+ for (ClientBehavior behavior: behaviorsForEvent) {
+ behavior.decode(context, component);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
protected void preDecode(FacesContext context, UIComponent component) {
}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -283,6 +283,8 @@
public static final String DT_ELEMENT = "dt";
public static final String DL_ELEMENT = "dl";
+
+ public static final String TEXT_JAVASCRIPT_TYPE = "text/javascript";
}
/**
@@ -979,7 +981,8 @@
} else if (AjaxRendererUtils.FORM.equals(id)) {
result.add(getNestingForm(context, component).getClientId(context));
} else {
- result.add(id);
+ UIComponent foundComponent = findComponentFor(component, id);
+ result.add(foundComponent != null ? foundComponent.getClientId(context) : id);
}
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -115,6 +115,7 @@
if (behavior instanceof AjaxBehavior) {
AjaxBehavior ajaxBehavior = (AjaxBehavior) behavior;
if (!ajaxBehavior.isDisabled()) {
+ //TODO need more reliable algorithm
result = (AjaxBehavior) behavior;
break;
}
Modified: root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js/4_0_0.js 2009-08-19 22:00:23 UTC (rev 15226)
@@ -213,6 +213,7 @@
var pushTracker = {};
richfaces.startPush = function(options) {
+ var clientId = options.clientId;
var pushId = options.pushId;
var interval = options.interval;
var ondataavailable = options.ondataavailable;
@@ -223,6 +224,7 @@
var ajaxOptions = {
type: "HEAD",
//TODO - encodeURIComponent; URL sessionId handling check
+ //TODO - add pushUri supports
url: PUSH_RESOURCE_URL + "?id=" + pushId,
dataType: "text",
complete: function(xhr) {
@@ -232,10 +234,13 @@
delete pushTracker[pushId];
if (xhr.status == 200 && xhr.getResponseHeader("Ajax-Push-Status") == "READY") {
- try {
- ondataavailable();
- } catch (e) {
- // TODO: handle exception
+ var pushElement = document.getElementById(clientId);
+ if (pushElement) {
+ try {
+ ondataavailable.call(pushElement);
+ } catch (e) {
+ // TODO: handle exception
+ }
}
}
@@ -261,14 +266,153 @@
};
richfaces.ajax = function(source, event, options) {
- var sourceId = source;
+ options = options || {};
+ var sourceId = (typeof source == 'object' && source.id) ? source.id : source;
options.execute = "@component";
options.render = "@component";
options.RICHFACES_AJAX = sourceId;
+ options[sourceId] = sourceId;
jsf.ajax.request(source, event, options);
};
+ var RICHFACES_AJAX_STATUS = "richfaces:ajaxStatus";
+
+ var statusAjaxEventHandler = function(data) {
+ var source = data.source;
+ var status = data.status;
+ var type = data.type;
+
+ var methodName;
+
+ if (type == 'event') {
+ if (status == 'begin') {
+ methodName = 'start';
+ } else if (status == 'success') {
+ methodName = 'success';
+ }
+ } else if (type == 'error') {
+ methodName = 'error';
+ }
+
+ if (methodName) {
+ var statusApplied = false;
+ var statusContainers = [jQuery(source).parent('form'), jQuery()];
+ for (var containerIdx = 0; containerIdx < statusContainers.length && !statusApplied;
+ containerIdx++) {
+
+ var statusContainer = statusContainers[containerIdx];
+ var statuses = statusContainer.data(RICHFACES_AJAX_STATUS);
+ if (statuses) {
+ for (var statusId in statuses) {
+ var status = statuses[statusId];
+ var result = status[methodName].apply(status, arguments);
+ if (result) {
+ statusApplied = true;
+ } else {
+ delete statuses[statusId];
+ }
+ }
+
+ if (!statusApplied) {
+ statusContainer.removeData(RICHFACES_AJAX_STATUS)
+ }
+ }
+ }
+ }
+ };
+
+ var initializeStatuses = function() {
+ var thisFunction = arguments.callee;
+ if (!thisFunction.initialized) {
+ thisFunction.initialized = true;
+
+ jsf.ajax.addOnEvent(statusAjaxEventHandler);
+ //TODO blocks default alert error handler
+ jsf.ajax.addOnError(statusAjaxEventHandler);
+ }
+ };
+
+ richfaces.status = function(statusId, options) {
+ this.statusId = statusId;
+ this.options = options || {};
+ this.register();
+ };
+
+ jQuery.extend(richfaces.status.prototype, (function() {
+ //TODO - support for parallel requests
+
+ var getElement = function() {
+ var elt = document.getElementById(this.statusId);
+ return elt ? jQuery(elt) : null;
+ };
+
+ var showHide = function(selector) {
+ var element = getElement.call(this);
+ if (element) {
+ var statusElts = element.children();
+ statusElts.each(function() {
+ var t = jQuery(this);
+ t.css('display', t.is(selector) ? '': 'none');
+ });
+
+ return true;
+ }
+
+ return false;
+ };
+
+ return {
+ register: function() {
+ initializeStatuses();
+ var container = getElement.call(this).parent('form');
+ if (container.length == 0) {
+ container = jQuery();
+ };
+
+ var statuses = container.data(RICHFACES_AJAX_STATUS);
+ if (!statuses) {
+ statuses = {};
+ container.data(RICHFACES_AJAX_STATUS, statuses);
+ }
+
+ statuses[this.statusId] = this;
+ },
+
+ start: function() {
+ if (this.options.onstart) {
+ this.options.onstart.apply(this, arguments);
+ }
+
+ return showHide.call(this, '.rich-status-start');
+ },
+
+ stop: function() {
+ if (this.options.onstop) {
+ this.options.onstop.apply(this, arguments);
+ }
+ },
+
+ success: function() {
+ if (this.options.onsuccess) {
+ this.options.onsuccess.apply(this, arguments);
+ }
+ this.stop();
+
+ return showHide.call(this, '.rich-status-stop');
+ },
+
+ error: function() {
+ if (this.options.onerror) {
+ this.options.onerror.apply(this, arguments);
+ }
+ this.stop();
+
+ return showHide.call(this, ':not(.rich-status-error) + .rich-status-stop, .rich-status-error');
+ }
+ };
+ }()));
+
}(window.RichFaces = {}, jQuery));
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxStatus.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxStatus.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIAjaxStatus.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -0,0 +1,37 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIOutput;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class UIAjaxStatus extends UIOutput {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Status";
+
+ public static String getComponentType() {
+ return COMPONENT_TYPE;
+ }
+}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIPush.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIPush.java 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/UIPush.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -27,9 +27,11 @@
import javax.el.MethodExpression;
import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponentBase;
+import javax.faces.component.UICommand;
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.context.FacesContext;
+import javax.faces.event.BehaviorEvent;
+import javax.faces.event.FacesEvent;
import javax.servlet.http.HttpSession;
/**
@@ -37,7 +39,7 @@
* @author shura
*
*/
-public class UIPush extends UIComponentBase implements ClientBehaviorHolder {
+public class UIPush extends UICommand implements ClientBehaviorHolder {
public static final String COMPONENT_TYPE = "org.richfaces.Push";
@@ -47,6 +49,8 @@
private static final Collection<String> EVENT_NAMES = Collections.singleton(ON_DATA_AVAILABLE);
+ private transient boolean hasActiveBehavior = false;
+
private static enum PropertyKeys {
eventProducer, enabled, interval
}
@@ -124,4 +128,19 @@
return COMPONENT_FAMILY;
}
+ @Override
+ public void queueEvent(FacesEvent e) {
+ if (e instanceof BehaviorEvent) {
+ hasActiveBehavior = true;
+ }
+
+ super.queueEvent(e);
+ }
+
+ /**
+ * @return the hasActiveBehavior
+ */
+ public boolean isHasActiveBehavior() {
+ return hasActiveBehavior;
+ }
}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxStatus.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxStatus.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/component/html/HtmlAjaxStatus.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -0,0 +1,44 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.html;
+
+import org.richfaces.component.UIAjaxStatus;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class HtmlAjaxStatus extends UIAjaxStatus {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Status";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Status";
+
+ public HtmlAjaxStatus() {
+ setRendererType("org.richfaces.StatusRenderer");
+ }
+
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+}
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -43,11 +43,11 @@
* @author shura
*
*/
-@ResourceDependencies(value = {
- @ResourceDependency(library = "javax.faces", name = "jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js")
- })
+@ResourceDependencies({
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js")
+})
public class AjaxFunctionRendererBase extends AjaxCommandRendererBase {
/*
@@ -99,7 +99,7 @@
}
//TODO - added in 4.0 - ?
- func.addParameter(new JSReference("event"));
+ func.addParameter(JSReference.EVENT);
func.addToBody(ajaxFunction.toScript());
func.appendScript(script);
Modified: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -28,13 +28,14 @@
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.ClientBehavior;
-import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIPush;
@@ -95,9 +96,14 @@
options.put("interval", new Integer(interval));
options.put("pushId", push.getListenerId(context));
- ClientBehaviorContext behaviorContext = ClientBehaviorContext.createClientBehaviorContext(context, push, push.getDefaultEventName(), push.getClientId(context), null);
- ClientBehavior clientBehavior = push.getClientBehaviors().get(push.getDefaultEventName()).get(0);
- options.put(UIPush.ON_DATA_AVAILABLE, new JSFunctionDefinition("event").addToBody(clientBehavior.getScript(behaviorContext)));
+ options.put("clientId", component.getClientId(context));
+
+ String behaviorsChain = AjaxRendererUtils.createBehaviorsChain(context, push, push.getDefaultEventName());
+ if (behaviorsChain != null) {
+ JSFunctionDefinition dataAvailableHandler = new JSFunctionDefinition(JSReference.EVENT);
+ dataAvailableHandler.addToBody(behaviorsChain);
+ options.put(UIPush.ON_DATA_AVAILABLE, dataAvailableHandler);
+ }
function.addParameter(options);
script.append(function.toScript());
} else {
@@ -117,12 +123,18 @@
// only push component is allowed.
return UIPush.class;
}
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ super.doDecode(context, component);
+
+ UIPush push = (UIPush) component;
+ if (push.isEnabled()) {
+ Map<String, String> requestParameterMap = context.getExternalContext().getRequestParameterMap();
+ if (requestParameterMap.get(push.getClientId(context)) != null || push.isHasActiveBehavior()) {
+ new ActionEvent(push).queue();
+ }
+ }
+ }
-// protected boolean isSubmitted(FacesContext facesContext, UIComponent uiComponent) {
-// boolean submitted = super.isSubmitted(facesContext, uiComponent);
-// UIPush push = (UIPush) uiComponent;
-// push.setSubmitted(submitted);
-// return submitted;
-// }
-
}
Added: root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java
===================================================================
--- root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java (rev 0)
+++ root/ui/trunk/components/core/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -0,0 +1,216 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
+import org.richfaces.component.UIAjaxStatus;
+import org.richfaces.component.util.HtmlUtil;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ResourceDependencies( {
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js") })
+public class AjaxStatusRenderer extends Renderer {
+
+ private static final String START = "start";
+ private static final String STOP = "stop";
+ private static final String ERROR = "error";
+
+ private static final String[] EVENT_ATTRIBUTES = {
+ "onstart", "onstop", "onerror", "onsuccess"
+ };
+
+ private static enum StatusState {
+ // NOTE: states encode order is important for script!
+ start(START),
+ error(ERROR) {
+ {
+ this.setOptional();
+ }
+ },
+ stop(STOP) {
+ {
+ this.setInitial();
+ }
+ };
+
+ private String stateName;
+
+ private String styleAttributeName;
+
+ private String styleClassAttributeName;
+
+ private String textAttributeName;
+
+ private String defaultStyleClass;
+
+ private boolean initial;
+
+ private boolean optional;
+
+ private StatusState(String stateName) {
+ this.stateName = stateName;
+ this.styleAttributeName = stateName + "Style";
+ this.styleClassAttributeName = stateName + "StyleClass";
+ this.textAttributeName = stateName + "Text";
+ this.defaultStyleClass = "rich-status-" + stateName;
+ }
+
+ public String getStyleAttributeName() {
+ return styleAttributeName;
+ }
+
+ public String getStyleClassAttributeName() {
+ return styleClassAttributeName;
+ }
+
+ public String getFacetName() {
+ return stateName;
+ }
+
+ public String getTextAttributeName() {
+ return textAttributeName;
+ }
+
+ public String getDefaultStyleClass() {
+ return defaultStyleClass;
+ }
+
+ public boolean isInitial() {
+ return initial;
+ }
+
+ public boolean isOptional() {
+ return optional;
+ }
+
+ protected void setOptional() {
+ this.optional = true;
+ }
+
+ protected void setInitial() {
+ this.initial = true;
+ }
+ }
+
+ private RendererUtils rendererUtils = RendererUtils.getInstance();
+
+ protected void encodeState(FacesContext facesContext, UIAjaxStatus status,
+ StatusState state) throws IOException {
+
+ Map<String, Object> statusAttributes = status.getAttributes();
+ UIComponent stateFacet = status.getFacet(state.getFacetName());
+ String stateText = null;
+
+ if (stateFacet == null) {
+ stateText = (String) statusAttributes.get(state.getTextAttributeName());
+ }
+
+ if (state.isOptional() && stateFacet == null && stateText == null) {
+ return ;
+ }
+
+ ResponseWriter writer = facesContext.getResponseWriter();
+ writer.startElement(HTML.SPAN_ELEM, status);
+
+ String stateStyle = (String) statusAttributes.get(state.getStyleAttributeName());
+
+ rendererUtils.writeAttribute(writer, HTML.style_ATTRIBUTE,
+ HtmlUtil.concatStyles(stateStyle,
+ state.isInitial() ? null : "display:none")
+ );
+
+ String stateStyleClass = (String) statusAttributes.get(state.getStyleClassAttributeName());
+
+ rendererUtils.writeAttribute(writer, HTML.class_ATTRIBUTE,
+ HtmlUtil.concatClasses(state.getDefaultStyleClass(),
+ stateStyleClass));
+
+ if (stateFacet != null && stateFacet.isRendered()) {
+ stateFacet.encodeAll(facesContext);
+ } else {
+ if (stateText != null) {
+ writer.writeText(stateText, null);
+ }
+ }
+
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeEnd(context, component);
+
+ UIAjaxStatus ajaxStatus = (UIAjaxStatus) component;
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.SPAN_ELEM, component);
+ String clientId = component.getClientId(context);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, clientId, "id");
+
+ for (StatusState state : StatusState.values()) {
+ encodeState(context, ajaxStatus, state);
+ }
+
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.TEXT_JAVASCRIPT_TYPE, null);
+
+ JSFunction statusConstructor = new JSFunction("new RichFaces.status",
+ clientId);
+
+ Map<String, Object> options = new HashMap<String, Object>();
+
+ Map<String, Object> attributes = ajaxStatus.getAttributes();
+ for (String eventAttribute : EVENT_ATTRIBUTES) {
+ rendererUtils.addToScriptHash(options, eventAttribute,
+ (String) attributes.get(eventAttribute), null,
+ ScriptHashVariableWrapper.EVENT_HANDLER);
+ }
+
+ if (!options.isEmpty()) {
+ statusConstructor.addParameter(options);
+ }
+
+ writer.writeText(statusConstructor.toScript(), null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+}
Modified: root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml
===================================================================
--- root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml 2009-08-19 22:00:23 UTC (rev 15226)
@@ -34,6 +34,13 @@
</component>
</tag>
<tag>
+ <tag-name>status</tag-name>
+ <component>
+ <component-type>org.richfaces.Status</component-type>
+ <renderer-type>org.richfaces.StatusRenderer</renderer-type>
+ </component>
+ </tag>
+ <tag>
<tag-name>log</tag-name>
<component>
<component-type>org.richfaces.AjaxLog</component-type>
Modified: root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml
===================================================================
--- root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/ui/trunk/components/core/src/main/resources/META-INF/faces-config.xml 2009-08-19 22:00:23 UTC (rev 15226)
@@ -30,6 +30,11 @@
</component>
<component>
+ <component-type>org.richfaces.Status</component-type>
+ <component-class>org.richfaces.component.html.HtmlAjaxStatus</component-class>
+ </component>
+
+ <component>
<component-type>org.richfaces.AjaxLog</component-type>
<component-class>org.richfaces.component.html.HtmlAjaxLog</component-class>
</component>
@@ -57,6 +62,11 @@
<renderer-class>org.richfaces.renderkit.html.AjaxOutputPanelRenderer</renderer-class>
</renderer>
<renderer>
+ <component-family>org.richfaces.Status</component-family>
+ <renderer-type>org.richfaces.StatusRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.AjaxStatusRenderer</renderer-class>
+ </renderer>
+ <renderer>
<component-family>org.richfaces.AjaxLog</component-family>
<renderer-type>org.richfaces.AjaxLogRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.AjaxLogRenderer</renderer-class>
Property changes on: root/ui-sandbox/trunk
___________________________________________________________________
Name: svn:ignore
+ .project
Property changes on: root/ui-sandbox/trunk/components
___________________________________________________________________
Name: svn:ignore
+ .project
Deleted: root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
===================================================================
--- root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java 2009-08-19 18:54:02 UTC (rev 15225)
+++ root/ui-sandbox/trunk/components/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java 2009-08-19 22:00:23 UTC (rev 15226)
@@ -1,118 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.taglib.html.facelets;
-
-import java.io.OutputStream;
-
-import javax.faces.view.facelets.ComponentConfig;
-import javax.faces.view.facelets.ComponentHandler;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.MetaRule;
-import javax.faces.view.facelets.MetaRuleset;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.MetadataTarget;
-import javax.faces.view.facelets.TagAttribute;
-
-import org.ajax4jsf.component.UIMediaOutput;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
- *
- */
-public class MediaOutputHandler extends ComponentHandler {
-
- private static final MetaRule mmediaMetaRule = new MMediaMetaRule();
- /**
- * @param config
- */
- public MediaOutputHandler(ComponentConfig config) {
- super(config);
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tag.AjaxComponentHandler#createMetaRuleset(java.lang.Class)
- */
- protected MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset metaRules = super.createMetaRuleset(type);
- metaRules.addRule(mmediaMetaRule);
- return metaRules;
- }
-
- /**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
- *
- */
- static class MMediaMetaRule extends MetaRule{
-
- /**
- *
- */
- public MMediaMetaRule() {
- super();
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String, com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
- */
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (meta.isTargetInstanceOf(UIMediaOutput.class)) {
-
-
- if ("createContent".equals(name)) {
- return new MMediaActionMapper(attribute);
- }
- }
- return null;
- }
-
- }
- /**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
- *
- */
- static class MMediaActionMapper extends Metadata {
-
- private static final Class<?>[] MMEDIA_ACTION_SIG = new Class[] {OutputStream.class,Object.class};
-
- private final TagAttribute _send;
- /**
- * @param attribute
- */
- public MMediaActionMapper(TagAttribute attribute) {
- _send = attribute;
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext, java.lang.Object)
- */
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIMediaOutput) instance).setCreateContentExpression(this._send.getMethodExpression(ctx, null,
- MMEDIA_ACTION_SIG));
- }
-
- }
-
-}
15 years, 4 months