[richfaces-svn-commits] JBoss Rich Faces SVN: r11780 - in trunk/samples/richfaces-demo/src/main: webapp/richfaces and 2 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Mon Dec 15 10:48:29 EST 2008
Author: ilya_shaikovsky
Date: 2008-12-15 10:48:29 -0500 (Mon, 15 Dec 2008)
New Revision: 11780
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/queue/QueueBean.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/customization.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/repeater.xhtml
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue.xhtml
Log:
Added: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/queue/QueueBean.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/queue/QueueBean.java (rev 0)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/queue/QueueBean.java 2008-12-15 15:48:29 UTC (rev 11780)
@@ -0,0 +1,121 @@
+package org.richfaces.demo.queue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.model.SelectItem;
+
+import org.ajax4jsf.event.AjaxEvent;
+
+public class QueueBean {
+ public int requestDelay = 500;
+ public boolean ignoreDupResponces = false;
+ public boolean disabled = false;
+ public int size = -1;
+ public String sizeExceededBehavior = "dropNew";
+ public String text="";
+ public int requests=0;
+ public int events=0;
+ private static final String AJAX_REQUESTS_COUNT_ATTRIBUTE = "ajaxRequestsCount";
+
+ public List<SelectItem> strategies = new ArrayList<SelectItem>();
+
+ public QueueBean() {
+ SelectItem item = new SelectItem("dropNext", "Drop Next");
+ strategies.add(item);
+ item = new SelectItem("dropNew", "Drop New");
+ strategies.add(item);
+ item = new SelectItem("fireNext", "Fire Next");
+ strategies.add(item);
+ item = new SelectItem("fireNew", "Fire New");
+ strategies.add(item);
+ }
+
+ public void waitDelay() throws InterruptedException {
+ System.out.println("QueueBean.waitDelay()");
+ Thread.sleep(1000);
+ }
+
+ public void processAjax(AjaxEvent event) {
+ ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+ Map<String, Object> sessionMap = externalContext.getSessionMap();
+ Long count = (Long) sessionMap.get(AJAX_REQUESTS_COUNT_ATTRIBUTE);
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+ sessionMap.put(AJAX_REQUESTS_COUNT_ATTRIBUTE, ++count);
+ }
+
+
+ public int getRequestDelay() {
+ return requestDelay;
+ }
+
+ public void setRequestDelay(int requestDelay) {
+ this.requestDelay = requestDelay;
+ }
+
+ public boolean isIgnoreDupResponces() {
+ return ignoreDupResponces;
+ }
+
+ public void setIgnoreDupResponces(boolean ignoreDupResponces) {
+ this.ignoreDupResponces = ignoreDupResponces;
+ }
+
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public void setSize(int size) {
+ this.size = size;
+ }
+
+ public String getSizeExceededBehavior() {
+ return sizeExceededBehavior;
+ }
+
+ public void setSizeExceededBehavior(String sizeExceedStrategy) {
+ this.sizeExceededBehavior = sizeExceedStrategy;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public List<SelectItem> getStrategies() {
+ return strategies;
+ }
+
+ 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;
+ }
+
+}
Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/customization.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/customization.xhtml (rev 0)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/customization.xhtml 2008-12-15 15:48:29 UTC (rev 11780)
@@ -0,0 +1,26 @@
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+ <ui:composition template="/templates/component-sample.xhtml">
+ <ui:define name="sample">
+ <p>
+ Description
+ </p>
+ <fieldset class="demo_fieldset">
+ <legend class="demo_legend">Queue demo</legend>
+ <div class="sample-container">
+ <ui:include src="/richfaces/queue/examples/repeater.xhtml"/>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="sourcepath" value="/richfaces/queue/examples/repeater.xhtml"/>
+ <ui:param name="openlabel" value="View Source" />
+ </ui:include>
+ </div>
+ </fieldset>
+ </ui:define>
+
+ </ui:composition>
+</html>
Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/repeater.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/repeater.xhtml (rev 0)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/repeater.xhtml 2008-12-15 15:48:29 UTC (rev 11780)
@@ -0,0 +1,92 @@
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:c="http://java.sun.com/jstl/core">
+ <h:form id="form">
+ <a4j:queue requestDelay="#{queueBean.requestDelay}"
+ ignoreDupResponses="#{queueBean.ignoreDupResponces}"
+ disabled="#{queueBean.disabled}" size="#{queueBean.size}"
+ sizeExceededBehavior="#{queueBean.sizeExceededBehavior}" onsubmit="addRequest();"/>
+ <h:panelGrid columns="1" width="800px">
+ <rich:panel>
+ <h:panelGrid columns="2">
+ <h:outputText value="Type here:" />
+ <h:inputText id="myinput" value="#{queueBean.text}">
+ <a4j:support event="onkeyup" reRender="outtext,reqs"
+ onsubmit="addEvent();" ajaxSingle="true"
+ oncomplete="printCounts()"
+ onbeforedomupdate="addUpdate()" action="#{queueBean.waitDelay}"/>
+ </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:panel>
+ <rich:panel>
+ <h:panelGrid columns="2">
+ <h:outputText value="Request delay:" />
+ <h:inputText value="#{queueBean.requestDelay}">
+ <f:convertNumber integerOnly="true" maxIntegerDigits="5" />
+ </h:inputText>
+
+ <h:outputText value="Ignore Duplicated Responces" />
+ <h:selectBooleanCheckbox value="#{queueBean.ignoreDupResponces}" />
+
+ <h:outputText value="Queue size" />
+ <h:inputText value="#{queueBean.size}">
+ <f:convertNumber integerOnly="true" maxIntegerDigits="5" />
+ </h:inputText>
+ <h:outputText value="Size Exceed Behavior" />
+ <h:selectOneMenu value="#{queueBean.sizeExceededBehavior}">
+ <f:selectItems value="#{queueBean.strategies}" />
+ </h:selectOneMenu>
+
+
+ <h:outputText value="Disable Queue" />
+ <h:selectBooleanCheckbox value="#{queueBean.disabled}" />
+ <f:facet name="footer">
+ <h:panelGroup>
+ <h:commandButton value="Apply"/>
+ <h:commandButton value="Reset"/>
+ </h:panelGroup>
+ </f:facet>
+ </h:panelGrid>
+ </rich:panel>
+ </h:panelGrid>
+ <a4j:log popup="false" style="width:800px; height:400px; overflow:auto;"/>
+ </h:form>
+ <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>
+</ui:composition>
+
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue.xhtml 2008-12-15 15:34:58 UTC (rev 11779)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue.xhtml 2008-12-15 15:48:29 UTC (rev 11780)
@@ -7,7 +7,20 @@
<ui:composition template="/templates/main.xhtml">
<ui:define name="title">RichFaces - Open Source Rich JSF Components - Queue Component</ui:define>
<ui:define name="body">
- <ui:include src="/templates/include/tab-panel.xhtml" />
+ <rich:tabPanel switchType="server" styleClass="top_tab" contentClass="content_tab" headerClass="header_tabs_class" inactiveTabClass="inactive_tab" activeTabClass="active_tab"
+ selectedTab="#{componentNavigator.currentComponent.activeTab}" valueChangeListener="#{componentNavigator.tabPanelSwitched}">
+ <rich:tab label="Usage" name="usage">
+ <ui:include src="/richfaces/queue/usage.xhtml"/>
+ </rich:tab>
+ <rich:tab label="Queue Settings" name="queueSettings">
+ <ui:include src="/richfaces/queue/customization.xhtml"/>
+ </rich:tab>
+ <rich:tab name="info" label="Tag Information">
+ <rich:insert
+ src="/WEB-INF/#{componentNavigator.currentComponent.tagInfoLocation}"
+ errorContent="/templates/include/tagInfoNotes.xhtml" />
+ </rich:tab>
+ </rich:tabPanel>
</ui:define>
</ui:composition>
</html>
More information about the richfaces-svn-commits
mailing list