Author: ilya_shaikovsky
Date: 2010-05-30 10:01:03 -0400 (Sun, 30 May 2010)
New Revision: 17400
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/queue/
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/queue/QueueBean.java
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/attachQueue/
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/attachQueue/attachQueue.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/functions/
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/functions/functions.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/queue/
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/queue/queue.xhtml
Modified:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/GroupDescriptor.java
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/SampleDescriptor.java
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Log:
https://jira.jboss.org/browse/RF-8293
https://jira.jboss.org/browse/RF-8297
Modified:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/GroupDescriptor.java
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/GroupDescriptor.java 2010-05-30
11:10:00 UTC (rev 17399)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/GroupDescriptor.java 2010-05-30
14:01:03 UTC (rev 17400)
@@ -1,11 +1,16 @@
package org.richfaces.demo.common.navigation;
+import java.io.Serializable;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
-public class GroupDescriptor extends BaseDescriptor{
+public class GroupDescriptor extends BaseDescriptor implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3481702232804120885L;
private List<DemoDescriptor> demos;
@XmlElementWrapper(name="demos")
Modified:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/SampleDescriptor.java
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/SampleDescriptor.java 2010-05-30
11:10:00 UTC (rev 17399)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/SampleDescriptor.java 2010-05-30
14:01:03 UTC (rev 17400)
@@ -1,5 +1,12 @@
package org.richfaces.demo.common.navigation;
-public class SampleDescriptor extends BaseDescriptor{
+import java.io.Serializable;
+public class SampleDescriptor extends BaseDescriptor implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2704627392818039062L;
+
}
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/queue/QueueBean.java
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/queue/QueueBean.java
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/queue/QueueBean.java 2010-05-30
14:01:03 UTC (rev 17400)
@@ -0,0 +1,65 @@
+package org.richfaces.demo.queue;
+
+import java.io.Serializable;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+
+@ManagedBean
+@ViewScoped
+public class QueueBean implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7503791626510224913L;
+ private Long requestDelay = new Long(500);
+ private boolean ignoreDupResponces = false;
+ private String text = "";
+ private int requests = 0;
+ private int events = 0;
+
+ public void resetText() {
+ setText("");
+ }
+
+ public Long getRequestDelay() {
+ return requestDelay;
+ }
+
+ public void setRequestDelay(Long requestDelay) {
+ this.requestDelay = requestDelay;
+ }
+
+ public boolean isIgnoreDupResponces() {
+ return ignoreDupResponces;
+ }
+
+ public void setIgnoreDupResponces(boolean ignoreDupResponces) {
+ this.ignoreDupResponces = ignoreDupResponces;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public int getRequests() {
+ return requests;
+ }
+
+ public void setRequests(int reuqests) {
+ this.requests = reuqests;
+ }
+
+ public int getEvents() {
+ return events;
+ }
+
+ public void setEvents(int events) {
+ this.events = events;
+ }
+
+}
Modified:
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-05-30
11:10:00 UTC (rev 17399)
+++
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-05-30
14:01:03 UTC (rev 17400)
@@ -277,6 +277,16 @@
</sample>
</samples>
</demo>
+ <demo>
+ <id>functions</id>
+ <name>RichFaces functions</name>
+ <samples>
+ <sample>
+ <id>functions</id>
+ <name>RichFaces Functions</name>
+ </sample>
+ </samples>
+ </demo>
</demos>
</group>
</root>
Added:
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/attachQueue/attachQueue.xhtml
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/attachQueue/attachQueue.xhtml
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/attachQueue/attachQueue.xhtml 2010-05-30
14:01:03 UTC (rev 17400)
@@ -0,0 +1,38 @@
+<ui:composition
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/jstl/core"
+
xmlns:rich="http://java.sun.com/jsf/composite/rich">
+<p>In RichFaces 4 all request settings related to queue was moved out of components
attributes and
+now customization available using new a4j:attachQueue tag. Next sample shows how
requestGroupingId
+(former similarityGroupingId) could be set for different components making the requests
from them similar.
+Besides setting requestGroupingId - attach queue tag at second button redefines default
queue
+request delay from 500ms to 1500ms.
+</p>
+
+<a4j:queue name="buttons_queue"
requestDelay="500"></a4j:queue>
+ <h:form>
+ <rich:panel>
+ <h:panelGrid columns="2">
+ <a4j:commandButton value="Set Name to Alex" render="rep">
+ <a4j:attachQueue queueName="buttons_queue"
requestGroupingId="group1"/>
+ <a4j:param name="username" value="Alex"
assignTo="#{userBean.name}" />
+ </a4j:commandButton>
+
+ <a4j:commandButton value="Set Name to John" render="rep">
+ <a4j:attachQueue queueName="buttons_queue"
requestGroupingId="group1" requestDelay="1500"/>
+ <a4j:param name="username" value="John"
+ assignTo="#{userBean.name}" />
+ </a4j:commandButton>
+ </h:panelGrid>
+ </rich:panel>
+
+ <rich:panel>
+ <h:outputText id="rep" value="Selected Name:#{userBean.name}"
/>
+ </rich:panel>
+ </h:form>
+ <a4j:log/>
+</ui:composition>
+
Added:
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/functions/functions.xhtml
===================================================================
---
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/functions/functions.xhtml
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/functions/functions.xhtml 2010-05-30
14:01:03 UTC (rev 17400)
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
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:rich="http://java.sun.com/jsf/composite/rich"
+
xmlns:fn="http://richfaces.org/misc">
+ <p>
+ RichFaces provides set of functions for more convinient work with DOM tree and
+ to use some server side expressions.
+ </p>
+ <p>
+ Here is the current list:
+ </p>
+ <ul>
+ <li>fn:clientId(id) - returns client Id for component by it's short
id.</li>
+ <li>fn:element(id) - returns DOM element for the passed short id</li>
+ <li>fn:component(id) - returns richfaces client component instance to call some
API method.</li>
+ <li>fn:isUserInRole(role) - returns is the user has specified role.</li>
+ <li>fn:findComponent(id) - returns component instance for given short
id</li>
+ </ul>
+<p>For example the result of #{fn:element('input')} expression will be -
document.getElementById('formId:input').</p>
+<p>And here is one more simple example. There is no need in Bean creation in order
to store the value. It's picked from component instance by using rich:findComponent
call.</p>
+ <h:form>
+ <h:inputText id="input">
+ <a4j:ajax render="out"/>
+ </h:inputText>
+ <h:outputText value="#{fn:findComponent('input').value}"
id="out"/>
+ </h:form>
+ <p>One more sample could be found at dataScroller API page. There are fn:component
used for calling JS API of dataScroller.</p>
+ <p>This set goes to be extended continously. Rise jira or forum requests if you
have
+ proposals on new useful functions.</p>
+</ui:composition>
\ No newline at end of file
Added: root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/queue/queue.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/queue/queue.xhtml
(rev 0)
+++
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/queue/queue.xhtml 2010-05-30
14:01:03 UTC (rev 17400)
@@ -0,0 +1,96 @@
+<ui:composition
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/jstl/core"
+
xmlns:rich="http://java.sun.com/jsf/composite/rich">
+<p>JSF 2 provides queue mechanism out-of the box already. And RichFaces queue just
provides
+some additional customizations to improve the queue usability and allow to tune your
+performance while using Ajax as much as possible.</p>
+<p>The only big difference which the developers who used queue in 3.3.x should
remember:
+as JSF 2 already provides single queue and not allows to have more than one queue
instance(currently)
+you can't really fire concurrent requests anymore. So the queue in RF now not
actually defines
+logical queue but just a component for defining queueing options.
+</p>
+<p>Here you could explore additional optimization parameters of the queue and learn
how they
+influence Ajax requests. This example is a good start to learn about Ajax requests
+flood protection.</p>
+
+<p>Pay attention to next points in the example:</p>
+<ul>
+<li>Setting ignoreDupResponces to true reduces the count of DOM updates on typing
inside the input. (in initial state count of updates is equals to count of
requests)</li>
+<li>Setting request delay to greater value reduces the greatly requests count on
fast typing. (More similar requests are combined in the result)</li>
+</ul>
+Also pay your attention to the queue definition. Such definition (inside some form
without a name) means that the queue options becomes global for the form.
+ <rich:panel>
+ <h:form id="form">
+ <a4j:queue requestDelay="#{queueBean.requestDelay}"
+ ignoreDupResponses="#{queueBean.ignoreDupResponces}"
+ />
+ <h:panelGrid columns="1" width="100%">
+ <h:panelGrid columns="2">
+ <h:outputText value="Type here:" />
+ <h:inputText id="myinput" value="#{queueBean.text}"
+ onkeypress="addEvent();" disabled="#{not
(facesContext.maximumSeverity==null)}">
+ <a4j:ajax onbegin="addRequest();" event="keypress"
render="outtext"
+ oncomplete="printCounts()" onbeforedomupdate="addUpdate()"
/>
+ </h:inputText>
+ <h:outputText value="Repeated text:" />
+ <h:outputText value="#{queueBean.text}" id="outtext"
+ style="font-weight:bold;" />
+ <h:outputText value="Events count:" />
+ <h:outputText value="0" id="events" />
+ <h:outputText value="Requests count:" />
+ <h:outputText value="0" id="requests" />
+ <h:outputText value="DOM updates count:" />
+ <h:outputText value="0" id="updates" />
+ </h:panelGrid>
+ <rich:message for="form:delay" style="color:red;" />
+ <h:panelGrid columns="2">
+ <h:outputText value="Request delay:" />
+ <h:inputText value="#{queueBean.requestDelay}" id="delay"
+ converterMessage="Delay field should be a number (Demo input disabled till
this resolved)">
+ <f:convertNumber integerOnly="true"/>
+ </h:inputText>
+ <h:outputText value="Ignore Duplicated Responces" />
+ <h:selectBooleanCheckbox value="#{queueBean.ignoreDupResponces}" />
+ <f:facet name="footer">
+ <h:commandButton value="Apply"
action="#{queueBean.resetText}" />
+ </f:facet>
+ </h:panelGrid>
+ </h:panelGrid>
+ </h:form>
+ </rich:panel>
+ <script type="text/javascript">
+ var events=0;
+ var updates=0;
+ var outEvents=document.getElementById('form:events');
+ var outUpdates=document.getElementById('form:updates');
+ var outRequests=document.getElementById('form:requests');
+
+ var requests=0;
+ function addEvent(){
+ events++;
+ }
+ function addUpdate(){
+ updates++;
+ }
+ function addRequest(){
+ requests++;
+ }
+
+ function printCounts(){
+ outEvents.innerHTML=events;
+ outUpdates.innerHTML=updates;
+ outRequests.innerHTML=requests;
+ }
+ </script>
+ <p>Queue could be defined as</p>
+ <ul><li><b>Default for view.</b> In this case - the parameters
will be used for all
+ the Ajax requests in view(if not redefined). In order to define such queue - just place
+ <b>a4j:queu</b> outside of any forms without defining
<b>name</b></li>
+ <li><b>Default for form.</b> Similar to view-scoped but should be
defiend in some form without defining <b>name</b></li>
+ <li><b>Referenced from ajax behaviors/components.</b> Queue should be
defined with name and referenced using attachQueue tag(see corresponding
sample).</li></ul>
+</ui:composition>
+