JBoss Rich Faces SVN: r17086 - root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-05-17 12:13:33 -0400 (Mon, 17 May 2010)
New Revision: 17086
Modified:
root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java
Log:
fix behavior processing
Modified: root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java
===================================================================
--- root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java 2010-05-17 16:05:01 UTC (rev 17085)
+++ root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java 2010-05-17 16:13:33 UTC (rev 17086)
@@ -25,10 +25,8 @@
import java.beans.BeanDescriptor;
import java.beans.BeanInfo;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
@@ -36,7 +34,6 @@
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.context.FacesContext;
-import javax.faces.view.AttachedObjectHandler;
import javax.faces.view.AttachedObjectTarget;
import javax.faces.view.BehaviorHolderAttachedObjectTarget;
import javax.faces.view.facelets.BehaviorConfig;
@@ -53,18 +50,12 @@
*
*/
public class AjaxHandler extends CustomBehaviorHandler {
-
- private static final String JAVAX_FACES_RETARGETABLE_HANDLERS = "javax.faces.RetargetableHandlers";
-
-
public AjaxHandler(BehaviorConfig config) {
super(config);
-
}
public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
- String eventName = getEventName();
Application application = ctx.getFacesContext().getApplication();
Behavior behavior = application.createBehavior(getBehaviorId());
@@ -73,7 +64,9 @@
AjaxBehavior ajaxBehavior = (AjaxBehavior)behavior;
FacesContext context = ctx.getFacesContext();
+
BehaviorStack ajaxBehaviors = BehaviorStack.getBehaviorStack(context, true);
+ String eventName = getEventName();
ajaxBehaviors.pushBehavior(context, ajaxBehavior, AjaxBehavior.BEHAVIOR_ID, eventName);
AttachQueueStack attachQueueStack = AttachQueueStack.getStack(context, true);
@@ -93,7 +86,7 @@
if (behaviors != null) {
for (ClientBehavior processBehavior : behaviors) {
if (processBehavior instanceof AjaxBehavior) {
- AjaxBehavior createdAjaxBehavior = (AjaxBehavior) behavior;
+ AjaxBehavior createdAjaxBehavior = (AjaxBehavior) processBehavior;
attachQueue.associateWith(createdAjaxBehavior);
}
}
@@ -160,7 +153,7 @@
}
if (supportedEvent) {
- getOrCreateRetargetableHandlersList(parent).add(this);
+ TagHandlerUtils.getOrCreateRetargetableHandlersList(parent).add(this);
} else {
throw new TagException(tag, "Error: enclosing composite component does not support event " + eventName);
}
@@ -173,20 +166,6 @@
}
}
- private static List<AttachedObjectHandler> getOrCreateRetargetableHandlersList(UIComponent component) {
- Map<String, Object> attrs = component.getAttributes();
- @SuppressWarnings({
- "unchecked"}) List<AttachedObjectHandler> list =
- (List<AttachedObjectHandler>) attrs.get(JAVAX_FACES_RETARGETABLE_HANDLERS);
-
- if (list == null) {
- list = new ArrayList<AttachedObjectHandler>();
- attrs.put(JAVAX_FACES_RETARGETABLE_HANDLERS, list);
- }
-
- return list;
- }
-
private String resolveEventName(ClientBehaviorHolder bHolder) {
String eventName = getEventName();
if (null == eventName) {
14 years, 5 months
JBoss Rich Faces SVN: r17085 - root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/tag.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-05-17 12:05:01 -0400 (Mon, 17 May 2010)
New Revision: 17085
Modified:
root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/tag/BehaviorRule.java
Log:
checkstyle fix
Modified: root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/tag/BehaviorRule.java
===================================================================
--- root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/tag/BehaviorRule.java 2010-05-17 15:47:21 UTC (rev 17084)
+++ root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/tag/BehaviorRule.java 2010-05-17 16:05:01 UTC (rev 17085)
@@ -103,7 +103,7 @@
+ meta.getTargetClass().getName());
}
return new LiteralAttributeMetadata(name, attribute.getValue());
- }
+ }
}
}
14 years, 5 months
JBoss Rich Faces SVN: r17084 - root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-05-17 11:47:21 -0400 (Mon, 17 May 2010)
New Revision: 17084
Modified:
root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java
Log:
use CustomBehaviorHandler as base
Modified: root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java
===================================================================
--- root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java 2010-05-17 14:41:26 UTC (rev 17083)
+++ root/ui/core/trunk/api/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java 2010-05-17 15:47:21 UTC (rev 17084)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
@@ -25,113 +25,96 @@
import java.beans.BeanDescriptor;
import java.beans.BeanInfo;
import java.io.IOException;
-import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
-import javax.el.ELContext;
-import javax.el.MethodExpression;
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.Behavior;
import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.AjaxBehaviorEvent;
-import javax.faces.event.AjaxBehaviorListener;
+import javax.faces.view.AttachedObjectHandler;
import javax.faces.view.AttachedObjectTarget;
-import javax.faces.view.BehaviorHolderAttachedObjectHandler;
import javax.faces.view.BehaviorHolderAttachedObjectTarget;
import javax.faces.view.facelets.BehaviorConfig;
import javax.faces.view.facelets.ComponentHandler;
import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.TagAttribute;
import javax.faces.view.facelets.TagException;
-import javax.faces.view.facelets.TagHandler;
import org.ajax4jsf.component.behavior.AjaxBehavior;
import org.richfaces.component.AbstractAttachQueue;
import org.richfaces.view.facelets.html.BehaviorStack.BehaviorInfo;
-//TODO nick - use TagHandlerDelegate
-public class AjaxHandler extends TagHandler implements BehaviorHolderAttachedObjectHandler {
+/**
+ * @author Anton Belevich
+ *
+ */
+public class AjaxHandler extends CustomBehaviorHandler {
- private final TagAttribute disabled;
- private final TagAttribute event;
- private final TagAttribute execute;
- private final TagAttribute immediate;
- private final TagAttribute limitRender;
- private final TagAttribute listener;
- private final TagAttribute onbeforedomupdate;
- private final TagAttribute onbegin;
- private final TagAttribute oncomplete;
- private final TagAttribute onerror;
- private final TagAttribute onevent;
- private final TagAttribute render;
- private final TagAttribute similarityGroupingId;
- private final TagAttribute statusId;
-
+ private static final String JAVAX_FACES_RETARGETABLE_HANDLERS = "javax.faces.RetargetableHandlers";
+
+
+
public AjaxHandler(BehaviorConfig config) {
- super(config);
- this.event = this.getAttribute("event");
- this.execute = this.getAttribute("execute");
- this.render = this.getAttribute("render");
- this.disabled = this.getAttribute("disabled");
- this.immediate = this.getAttribute("immediate");
- this.listener = this.getAttribute("listener");
- this.limitRender = this.getAttribute("limitRender");
- this.statusId = this.getAttribute("status");
- this.similarityGroupingId = this.getAttribute("similarityGroupingId");
- this.onevent = this.getAttribute("onevent");
- this.onerror = this.getAttribute("onerror");
- this.onbegin = this.getAttribute("onbegin");
- this.oncomplete = this.getAttribute("oncomplete");
- this.onbeforedomupdate = this.getAttribute("onbeforedomupdate");
+ super(config);
+
}
-
+
public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
String eventName = getEventName();
- AjaxBehavior ajaxBehavior = createAjaxBehavior(ctx, eventName);
- FacesContext context = ctx.getFacesContext();
- BehaviorStack ajaxBehaviors = BehaviorStack.getBehaviorStack(context, true);
- ajaxBehaviors.pushBehavior(context, ajaxBehavior, AjaxBehavior.BEHAVIOR_ID, eventName);
-
- AttachQueueStack attachQueueStack = AttachQueueStack.getStack(context, true);
- AttachQueueInfo attachQueueInfo = new AttachQueueInfo(parent);
- attachQueueStack.push(attachQueueInfo);
-
- nextHandler.apply(ctx, parent);
-
- attachQueueStack.pop();
-
- BehaviorInfo behaviorInfo = ajaxBehaviors.popBehavior();
- if (behaviorInfo != null) {
- if (behaviorInfo.isWrapping()) {
- AbstractAttachQueue attachQueue = attachQueueInfo.getAttachQueue();
- if (attachQueue != null) {
- List<ClientBehavior> behaviors = behaviorInfo.getBehaviors();
- if (behaviors != null) {
- for (ClientBehavior behavior : behaviors) {
- if (behavior instanceof AjaxBehavior) {
- AjaxBehavior createdAjaxBehavior = (AjaxBehavior) behavior;
- attachQueue.associateWith(createdAjaxBehavior);
+
+ Application application = ctx.getFacesContext().getApplication();
+ Behavior behavior = application.createBehavior(getBehaviorId());
+ if(behavior instanceof AjaxBehavior) {
+ setAttributes(ctx, behavior);
+ AjaxBehavior ajaxBehavior = (AjaxBehavior)behavior;
+
+ FacesContext context = ctx.getFacesContext();
+ BehaviorStack ajaxBehaviors = BehaviorStack.getBehaviorStack(context, true);
+ ajaxBehaviors.pushBehavior(context, ajaxBehavior, AjaxBehavior.BEHAVIOR_ID, eventName);
+
+ AttachQueueStack attachQueueStack = AttachQueueStack.getStack(context, true);
+ AttachQueueInfo attachQueueInfo = new AttachQueueInfo(parent);
+ attachQueueStack.push(attachQueueInfo);
+
+ nextHandler.apply(ctx, parent);
+
+ attachQueueStack.pop();
+
+ BehaviorInfo behaviorInfo = ajaxBehaviors.popBehavior();
+ if (behaviorInfo != null) {
+ if (behaviorInfo.isWrapping()) {
+ AbstractAttachQueue attachQueue = attachQueueInfo.getAttachQueue();
+ if (attachQueue != null) {
+ List<ClientBehavior> behaviors = behaviorInfo.getBehaviors();
+ if (behaviors != null) {
+ for (ClientBehavior processBehavior : behaviors) {
+ if (processBehavior instanceof AjaxBehavior) {
+ AjaxBehavior createdAjaxBehavior = (AjaxBehavior) behavior;
+ attachQueue.associateWith(createdAjaxBehavior);
+ }
}
}
}
+ } else {
+ AbstractAttachQueue attachQueue = attachQueueInfo.getAttachQueue();
+ if (attachQueue != null) {
+ attachQueue.associateWith(ajaxBehavior);
+ }
+
+ applyNested(ctx, parent, ajaxBehavior);
}
} else {
- AbstractAttachQueue attachQueue = attachQueueInfo.getAttachQueue();
- if (attachQueue != null) {
- attachQueue.associateWith(ajaxBehavior);
- }
-
- applyNested(ctx, parent, ajaxBehavior);
+ //TODO nick - is this possible?
}
- } else {
- //TODO nick - is this possible?
+
}
}
-
+
+
private void applyNested(FaceletContext ctx, UIComponent parent, AjaxBehavior behavior) {
if (!ComponentHandler.isNew(parent)) {
return;
@@ -177,7 +160,7 @@
}
if (supportedEvent) {
- TagHandlerUtils.getOrCreateRetargetableHandlersList(parent).add(this);
+ getOrCreateRetargetableHandlersList(parent).add(this);
} else {
throw new TagException(tag, "Error: enclosing composite component does not support event " + eventName);
}
@@ -189,7 +172,21 @@
throw new TagException(this.tag, "Unable to attach <a4j:ajax> to non-ClientBehaviorHolder parent");
}
}
+
+ private static List<AttachedObjectHandler> getOrCreateRetargetableHandlersList(UIComponent component) {
+ Map<String, Object> attrs = component.getAttributes();
+ @SuppressWarnings({
+ "unchecked"}) List<AttachedObjectHandler> list =
+ (List<AttachedObjectHandler>) attrs.get(JAVAX_FACES_RETARGETABLE_HANDLERS);
+ if (list == null) {
+ list = new ArrayList<AttachedObjectHandler>();
+ attrs.put(JAVAX_FACES_RETARGETABLE_HANDLERS, list);
+ }
+
+ return list;
+ }
+
private String resolveEventName(ClientBehaviorHolder bHolder) {
String eventName = getEventName();
if (null == eventName) {
@@ -210,87 +207,4 @@
return eventName;
}
-
- public AjaxBehavior createAjaxBehavior(FaceletContext fContext, String eventName) {
- Application application = fContext.getFacesContext().getApplication();
- AjaxBehavior ajaxBehavior = (AjaxBehavior) application.createBehavior(AjaxBehavior.BEHAVIOR_ID);
-
- setBehaviorAttribute(fContext, ajaxBehavior, this.disabled, Boolean.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.immediate, Boolean.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.execute, Object.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.render, Object.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.limitRender, Boolean.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.statusId, String.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.similarityGroupingId, String.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.onevent, String.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.onerror, String.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.onbegin, String.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.oncomplete, String.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.onbeforedomupdate, String.class);
- registerBehaviorListener(fContext, ajaxBehavior, listener);
-
- return ajaxBehavior;
- }
-
- public void applyAttachedObject(FacesContext context, UIComponent parent) {
- FaceletContext ctx = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
-
- ClientBehaviorHolder bHolder = (ClientBehaviorHolder) parent;
- String eventName = resolveEventName(bHolder);
-
- AjaxBehavior ajaxBehavior = createAjaxBehavior(ctx, eventName);
- bHolder.addClientBehavior(eventName, ajaxBehavior);
- }
-
- private void setBehaviorAttribute(FaceletContext ctx, AjaxBehavior behavior, TagAttribute attr, Class<?> type) {
- if (attr != null) {
- behavior.setValueExpression(attr.getLocalName(), attr.getValueExpression(ctx, type));
- }
- }
-
- public String getEventName() {
- return (this.event != null) ? this.event.getValue() : null;
- }
-
- public String getFor() {
- return null;
- }
-
- public void registerBehaviorListener(FaceletContext fContext, AjaxBehavior behavior, TagAttribute listenerAttr) {
- if (listenerAttr != null) {
- MethodExpression mExpression = listenerAttr.getMethodExpression(fContext, Object.class,
- new Class[] {AjaxBehaviorEvent.class});
-
- behavior.addAjaxBehaviorListener(new AjaxBehaviorListenerImpl(mExpression));
- }
- }
-
- static class AjaxBehaviorListenerImpl implements AjaxBehaviorListener, Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 1812543470662919310L;
-
- private MethodExpression methodExpression;
-
- public AjaxBehaviorListenerImpl() {}
-
- public AjaxBehaviorListenerImpl(MethodExpression expression) {
- this.methodExpression = expression;
- }
-
- public void processAjaxBehavior(AjaxBehaviorEvent event) throws AbortProcessingException {
- if (methodExpression != null) {
- ELContext elContext = FacesContext.getCurrentInstance().getELContext();
-
- try {
- methodExpression.invoke(elContext, new Object[] {event});
- } catch (Exception e) {
-
- // TODO: log or message ??
- throw new AbortProcessingException(e);
- }
- }
- }
- }
}
14 years, 5 months
JBoss Rich Faces SVN: r17083 - in root: cdk/trunk/parent and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-05-17 10:41:26 -0400 (Mon, 17 May 2010)
New Revision: 17083
Modified:
root/build/parent/trunk/pom.xml
root/cdk/trunk/parent/pom.xml
Log:
https://jira.jboss.org/browse/RFPL-596
Checkstyle artifactId updated in CDK pom
Modified: root/build/parent/trunk/pom.xml
===================================================================
--- root/build/parent/trunk/pom.xml 2010-05-17 14:21:49 UTC (rev 17082)
+++ root/build/parent/trunk/pom.xml 2010-05-17 14:41:26 UTC (rev 17083)
@@ -106,21 +106,12 @@
-->
<pluginManagement>
<plugins>
- <!-- TODO: change to the current CDK version -->
<plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-javascript-plugin</artifactId>
- <version>3.3.1.GA</version>
- </plugin>
- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.3</version>
Modified: root/cdk/trunk/parent/pom.xml
===================================================================
--- root/cdk/trunk/parent/pom.xml 2010-05-17 14:21:49 UTC (rev 17082)
+++ root/cdk/trunk/parent/pom.xml 2010-05-17 14:41:26 UTC (rev 17083)
@@ -121,7 +121,7 @@
<dependencies>
<dependency>
<groupId>org.richfaces</groupId>
- <artifactId>checkstyle</artifactId>
+ <artifactId>richfaces-build-checkstyle</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
14 years, 5 months
JBoss Rich Faces SVN: r17082 - in root/examples/richfaces-showcase/trunk/src/main: java/org/richfaces/demo/common/navigation and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-05-17 10:21:49 -0400 (Mon, 17 May 2010)
New Revision: 17082
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/BaseDescriptor.java
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoDescriptor.java
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoNavigator.java
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/NavigationParser.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/
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Modified:
root/examples/richfaces-showcase/trunk/src/main/webapp/resources/rich/panel.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/component-sample.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/includes/navigation.xhtml
root/examples/richfaces-showcase/trunk/src/main/webapp/templates/main.xhtml
Log:
https://jira.jboss.org/browse/RF-8663
Added: root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/BaseDescriptor.java
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/BaseDescriptor.java (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/BaseDescriptor.java 2010-05-17 14:21:49 UTC (rev 17082)
@@ -0,0 +1,37 @@
+package org.richfaces.demo.common.navigation;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+public class BaseDescriptor {
+ private String name;
+ private boolean newItem;
+ private boolean currentItem;
+
+ @XmlElement
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @XmlAttribute(name = "new")
+ public boolean isNewItem() {
+ return newItem;
+ }
+
+ public void setNewItem(boolean newItem) {
+ this.newItem = newItem;
+ }
+
+ @XmlAttribute(name = "current")
+ public boolean isCurrentItem() {
+ return currentItem;
+ }
+
+ public void setCurrentItem(boolean currentItem) {
+ this.currentItem = currentItem;
+ }
+}
Added: root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoDescriptor.java
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoDescriptor.java (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoDescriptor.java 2010-05-17 14:21:49 UTC (rev 17082)
@@ -0,0 +1,66 @@
+package org.richfaces.demo.common.navigation;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class DemoDescriptor extends BaseDescriptor {
+ private static final String BASE_SAMPLES_DIR = "/richfaces/";
+ // TODO: could get from JSF instead of constant using
+ private static final String PAGE_EXT = ".xhtml";
+
+ private String page;
+ private String id;
+ private boolean current;
+ private String activeSample;
+ private List<SampleDescriptor> samples;
+
+
+ public String getDemoURI() {
+ return BASE_SAMPLES_DIR + getPage() + PAGE_EXT;
+ }
+
+ @XmlElement
+ public String getPage() {
+ return page;
+ }
+
+ public void setPage(String page) {
+ this.page = page;
+ }
+
+ @XmlElement
+ public List<SampleDescriptor> getSamples() {
+ return samples;
+ }
+
+ public void setSamples(List<SampleDescriptor> samples) {
+ this.samples = samples;
+ }
+
+ public boolean isCurrent() {
+ return current;
+ }
+
+ public void setCurrent(boolean current) {
+ this.current = current;
+ }
+
+ public String getActiveSample() {
+ return activeSample;
+ }
+
+ public void setActiveSample(String activeSample) {
+ this.activeSample = activeSample;
+ }
+
+ @XmlElement
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+}
Added: root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoNavigator.java
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoNavigator.java (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/DemoNavigator.java 2010-05-17 14:21:49 UTC (rev 17082)
@@ -0,0 +1,99 @@
+package org.richfaces.demo.common.navigation;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.SessionScoped;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+
+@ManagedBean
+@SessionScoped
+public class DemoNavigator {
+ @ManagedProperty(value = "#{navigationParser.groupsList}")
+ private List<GroupDescriptor> groups;
+ private DemoDescriptor currentDemo = null;
+
+ public DemoDescriptor getCurrentDemo() {
+ String id = getDemoParam("demo");
+ if (id != null) {
+ setCurrentDemo(findDemoById(id));
+ } else {
+ String uri = getDemoUri();
+ setCurrentDemo(findDemoByUri(uri));
+ }
+
+ // set active sample for current component if any
+ if (null != currentDemo) {
+ String sample = getDemoParam("sample");
+ if (null != sample) {
+ currentDemo.setActiveSample(sample);
+ }
+ }
+
+ return currentDemo;
+ }
+
+ private String getDemoUri() {
+ FacesContext fc = FacesContext.getCurrentInstance();
+ return ((HttpServletRequest) fc.getExternalContext().getRequest()).getRequestURI();
+ }
+
+ private String getDemoParam(String name) {
+ FacesContext fc = FacesContext.getCurrentInstance();
+ String param = (String) fc.getExternalContext().getRequestParameterMap().get(name);
+ if (param != null && param.trim().length() > 0) {
+ return param;
+ } else {
+ return null;
+ }
+ }
+
+ public DemoDescriptor findDemoByUri(String uri) {
+ Iterator<GroupDescriptor> it = groups.iterator();
+ while (it.hasNext()) {
+ GroupDescriptor group = it.next();
+ Iterator<DemoDescriptor> dit = group.getDemos().iterator();
+ while (dit.hasNext()) {
+ DemoDescriptor demo = dit.next();
+ if (uri.endsWith(demo.getDemoURI())) {
+ return demo;
+ }
+ }
+ }
+ return null;
+ }
+
+ public DemoDescriptor findDemoById(String id) {
+ Iterator<GroupDescriptor> it = groups.iterator();
+ while (it.hasNext()) {
+ GroupDescriptor group = it.next();
+ Iterator<DemoDescriptor> dit = group.getDemos().iterator();
+ while (dit.hasNext()) {
+ DemoDescriptor demo = (DemoDescriptor) dit.next();
+ if (demo.getId().equals(id)) {
+ return demo;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setCurrentDemo(DemoDescriptor currentDemo) {
+ if (currentDemo == null) {
+ this.currentDemo = (DemoDescriptor) groups.get(0).getDemos().get(0);
+ }
+ this.currentDemo = currentDemo;
+ }
+
+ public List<GroupDescriptor> getGroups() {
+ return groups;
+ }
+
+ public void setGroups(List<GroupDescriptor> groups) {
+ this.groups = groups;
+ }
+
+}
Added: 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 (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/GroupDescriptor.java 2010-05-17 14:21:49 UTC (rev 17082)
@@ -0,0 +1,21 @@
+package org.richfaces.demo.common.navigation;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+
+public class GroupDescriptor extends BaseDescriptor{
+ private List<DemoDescriptor> demos;
+
+ @XmlElementWrapper(name="demos")
+ @XmlElement(name="demo")
+ public List<DemoDescriptor> getDemos() {
+ return demos;
+ }
+
+ public void setDemos(List<DemoDescriptor> demos) {
+ this.demos = demos;
+ }
+
+}
Added: root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/NavigationParser.java
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/NavigationParser.java (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/NavigationParser.java 2010-05-17 14:21:49 UTC (rev 17082)
@@ -0,0 +1,52 @@
+package org.richfaces.demo.common.navigation;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.faces.FacesException;
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@ManagedBean
+@ApplicationScoped
+public class NavigationParser {
+
+ private List<GroupDescriptor> groupsList;
+
+ @XmlRootElement(name = "root")
+ private static final class CapitalsHolder {
+
+ private List<GroupDescriptor> groups;
+
+ @XmlElement(name = "group")
+ public List<GroupDescriptor> getGroups() {
+ return groups;
+ }
+
+ @SuppressWarnings("unused")
+ public void setGroups(List<GroupDescriptor> groups) {
+ this.groups = groups;
+ }
+ }
+
+ public synchronized List<GroupDescriptor> getGroupsList() {
+ if (groupsList == null) {
+ ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+ URL resource = ccl.getResource("org/richfaces/demo/data/common/navigation.xml");
+ JAXBContext context;
+ try {
+ context = JAXBContext.newInstance(CapitalsHolder.class);
+ CapitalsHolder capitalsHolder = (CapitalsHolder) context.createUnmarshaller().unmarshal(resource);
+ groupsList = capitalsHolder.getGroups();
+ } catch (JAXBException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
+
+ return groupsList;
+ }
+}
Added: 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 (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/common/navigation/SampleDescriptor.java 2010-05-17 14:21:49 UTC (rev 17082)
@@ -0,0 +1,6 @@
+package org.richfaces.demo.common.navigation;
+
+
+public class SampleDescriptor extends BaseDescriptor{
+
+}
Added: 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 (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-05-17 14:21:49 UTC (rev 17082)
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+ <group>
+ <name>Ajax Action</name>
+ <demos>
+ <demo>
+ <id>ajax</id>
+ <name>a4j:ajax</name>
+ <page>ajax</page>
+ <samples>
+ <sample new="true">
+ <name>Ajax Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>commandButton</id>
+ <name>a4j:commandButton</name>
+ <page>commandButton</page>
+ <samples>
+ <sample>
+ <name>Command Button Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>commandLink</id>
+ <name>a4j:commandLink</name>
+ <page>commandLink</page>
+ <samples>
+ <sample>
+ <name>Command Link Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>jsFunction</id>
+ <name>a4j:jsFunction</name>
+ <page>jsFunction</page>
+ <samples>
+ <sample>
+ <name>jsFunction Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>poll</id>
+ <name>a4j:poll</name>
+ <page>poll</page>
+ <samples>
+ <sample>
+ <name>Poll Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>push</id>
+ <name>a4j:push</name>
+ <page>push</page>
+ <samples>
+ <sample>
+ <name>push Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
+ <group>
+ <name>Ajax Queue</name>
+ <demos>
+ <demo new="true">
+ <id>queue</id>
+ <name>a4j:queue</name>
+ <page>queue</page>
+ <samples>
+ <sample>
+ <name>queue</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>attachQueue</id>
+ <name>a4j:attachQueue</name>
+ <page>attachQueue</page>
+ <samples>
+ <sample>
+ <name>attachQueue</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
+ <group>
+ <name>Ajax Output/Indication</name>
+ <demos>
+ <demo new="true">
+ <id>outputPanel</id>
+ <name>a4j:outputPanel</name>
+ <page>outputPanel</page>
+ <samples>
+ <sample>
+ <name>outputPanel Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>status</id>
+ <name>a4j:status</name>
+ <page>status</page>
+ <samples>
+ <sample>
+ <name>status Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>mediaoutput</id>
+ <name>a4j:mediaOutput</name>
+ <page>mediaOutput</page>
+ <samples>
+ <sample>
+ <name>mediaOutput Simple</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
+ <id>log</id>
+ <name>a4j:log</name>
+ <page>log</page>
+ <samples>
+ <sample>
+ <name>log</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
+ <group new="true">
+ <name>Data Iteration</name>
+ <demos>
+ <demo>
+ <id>dataTable</id>
+ <name>rich:dataTable</name>
+ <page>dataTable</page>
+ <samples>
+ <sample>
+ <name>Data Table Basic</name>
+ </sample>
+ <sample>
+ <name>Data Table Sorting</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group>
+</root>
Modified: root/examples/richfaces-showcase/trunk/src/main/webapp/resources/rich/panel.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/resources/rich/panel.xhtml 2010-05-17 14:20:08 UTC (rev 17081)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/resources/rich/panel.xhtml 2010-05-17 14:21:49 UTC (rev 17082)
@@ -15,14 +15,14 @@
<composite:attribute name="style" required="false"/>
<composite:attribute name="styleClass" required="false"/>
<composite:attribute name="headerClass" required="false"/>
- <composite:attribute name="bodyClass" required="true"/>
+ <composite:attribute name="bodyClass" required="false"/>
</composite:interface>
<composite:implementation>
<h:outputStylesheet name="rich/css/panel.css" />
<div class="rich-panel #{compositeComponent.attrs.styleClass}"
- style="#{compositeComponent.attrs.style}"
+ style="#{cc.attrs.style}"
onclick="#{compositeComponent.attrs.onclick}"
ondblclick="#{compositeComponent.attrs.ondblclick}"
onkeydown="#{compositeComponent.attrs.onkeydown}"
Modified: root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax.xhtml 2010-05-17 14:20:08 UTC (rev 17081)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/ajax.xhtml 2010-05-17 14:21:49 UTC (rev 17082)
@@ -6,6 +6,9 @@
<ui:composition template="/templates/main.xhtml">
<ui:define name="body">
+ <f:metadata>
+ <f:viewParam name="sampleId" value="#{demoNavigator.currentDemo.activeSample}"/>
+ </f:metadata>
<p>
The behavior that adds javascript call for sending Ajax request
to specified event on parent component
Modified: root/examples/richfaces-showcase/trunk/src/main/webapp/templates/component-sample.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/templates/component-sample.xhtml 2010-05-17 14:20:08 UTC (rev 17081)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/templates/component-sample.xhtml 2010-05-17 14:21:49 UTC (rev 17082)
@@ -7,7 +7,9 @@
<ui:composition template="/templates/main.xhtml">
<ui:define name="body">
-
+ <fieldset>
+ <legend></legend>
+ </fieldset>
<ui:insert/>
</ui:define>
</ui:composition>
Modified: root/examples/richfaces-showcase/trunk/src/main/webapp/templates/includes/navigation.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/templates/includes/navigation.xhtml 2010-05-17 14:20:08 UTC (rev 17081)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/templates/includes/navigation.xhtml 2010-05-17 14:21:49 UTC (rev 17082)
@@ -4,34 +4,28 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://java.sun.com/jsf/composite/rich">
- <rich:panel bodyClass="">
+ <rich:panel style="width:250px" bodyClass="">
<f:facet name="header">
<h:outputText value="Navigation" />
- </f:facet>
- <h:panelGrid columns="1">
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/ajax.jsf">a4j:ajax</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/jsFunction.jsf">a4j:jsFunction</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/mediaOutput.jsf">a4j:mediaOutput</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/push.jsf">a4j:push</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/status.jsf">a4j:status</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/outputPanel.jsf">a4j:outputPanel</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/commandButton.jsf">a4j:commandButton</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/commandLink.jsf">a4j:commandLink</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/log.jsf">a4j:log</h:outputLink>
- <hr/>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/dataTable.jsf">h:dataTable vs Ajax</h:outputLink>
- <h:outputLink
- value="#{facesContext.externalContext.requestContextPath}/richfaces/skin.jsf">Skin sample</h:outputLink>
- </h:panelGrid>
+ </f:facet>
+ <ul>
+ <a4j:repeat value="#{demoNavigator.groups}" var="gr">
+ <li>
+ <h:outputText value="#{gr.name}" />
+ <h:outputText value="NEW!" rendered="#{gr.newItem}"/>
+ </li>
+ <ul>
+ <a4j:repeat value="#{gr.demos}" var="d">
+ <li>
+ <h:link outcome="#{d.demoURI}" value="#{d.name}" includeViewParams="true">
+ <f:param name="demo" value="#{d.id}"/>
+ </h:link>
+ <h:outputText value="NEW!" rendered="#{d.newItem or gr.newItem}" style="color:red"/>
+ <h:outputText value="CUR!" rendered="#{d.id == demoNavigator.currentDemo.id}" style="color:orange"/>
+ </li>
+ </a4j:repeat>
+ </ul>
+ </a4j:repeat>
+ </ul>
</rich:panel>
</ui:composition>
Modified: root/examples/richfaces-showcase/trunk/src/main/webapp/templates/main.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/templates/main.xhtml 2010-05-17 14:20:08 UTC (rev 17081)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/templates/main.xhtml 2010-05-17 14:21:49 UTC (rev 17082)
@@ -36,6 +36,13 @@
style="width:#{cc.attrs.sidebarWidth}px"></div>
<ui:include src="/templates/includes/navigation.xhtml" /></td>
<td class="content_col rich-page-body #{cc.attrs.bodyClass}">
+
+ <ui:remove>
+ <fieldset>
+ <legend>#{demoNavigator.currentComponent}</legend>
+ </fieldset>
+ </ui:remove>
+
<ui:insert name="body">
Body content missed
</ui:insert></td>
14 years, 5 months
JBoss Rich Faces SVN: r17081 - root/core/trunk/parent.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-05-17 10:20:08 -0400 (Mon, 17 May 2010)
New Revision: 17081
Modified:
root/core/trunk/parent/pom.xml
Log:
Modified: root/core/trunk/parent/pom.xml
===================================================================
--- root/core/trunk/parent/pom.xml 2010-05-17 14:16:50 UTC (rev 17080)
+++ root/core/trunk/parent/pom.xml 2010-05-17 14:20:08 UTC (rev 17081)
@@ -51,6 +51,22 @@
<scope>import</scope>
</dependency>
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-jsf</groupId>
+ <artifactId>jsf-mock</artifactId>
+ <version>1.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-jsf</groupId>
+ <artifactId>htmlunit-client</artifactId>
+ <version>1.0.3</version>
+ </dependency>
<!--
These dependencies are usually provided by
org.jboss.test-jsf:htmlunit-client, but the latest 2.7
14 years, 5 months
JBoss Rich Faces SVN: r17080 - root/core/trunk/impl/src/test/resources/javascript.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-05-17 10:16:50 -0400 (Mon, 17 May 2010)
New Revision: 17080
Added:
root/core/trunk/impl/src/test/resources/javascript/timer-simulation.js
Modified:
root/core/trunk/impl/src/test/resources/javascript/richfaces-client-api.html
root/core/trunk/impl/src/test/resources/javascript/richfaces-queue-qunit-request.js
Log:
timer simulation was added to tests
Modified: root/core/trunk/impl/src/test/resources/javascript/richfaces-client-api.html
===================================================================
--- root/core/trunk/impl/src/test/resources/javascript/richfaces-client-api.html 2010-05-17 13:40:59 UTC (rev 17079)
+++ root/core/trunk/impl/src/test/resources/javascript/richfaces-client-api.html 2010-05-17 14:16:50 UTC (rev 17080)
@@ -7,6 +7,7 @@
<link type="text/css" rel="Stylesheet" media="screen" href="qunit/qunit.css" />
<script type="text/javascript" src="../../classes/META-INF/resources/jquery.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
+ <script type="text/javascript" src="timer-simulation.js"></script>
<script type="text/javascript" src="../../classes/META-INF/resources/richfaces.js"></script>
<script type="text/javascript" src="richfaces-jsf-ajax-qunit.js"></script>
<script type="text/javascript" src="../../classes/META-INF/resources/jquery.position.js"></script>
Modified: root/core/trunk/impl/src/test/resources/javascript/richfaces-queue-qunit-request.js
===================================================================
--- root/core/trunk/impl/src/test/resources/javascript/richfaces-queue-qunit-request.js 2010-05-17 13:40:59 UTC (rev 17079)
+++ root/core/trunk/impl/src/test/resources/javascript/richfaces-queue-qunit-request.js 2010-05-17 14:16:50 UTC (rev 17080)
@@ -37,7 +37,8 @@
test("setQueueOptions/getQueueOptions - params: object", function() {
expect(6);
RichFaces.queue.setQueueOptions("testId1", {myParam:"hello1"});
- RichFaces.queue.setQueueOptions({"testId2": {myParam:"hello2"}, "testId3": {myParam:"hello3"}});
+ RichFaces.queue.setQueueOptions("testId2", {myParam:"hello2"});
+ RichFaces.queue.setQueueOptions({"testId2": {myParam:"hello2-new"}, "testId3": {myParam:"hello3"}});
var options1 = RichFaces.queue.getQueueOptions("testId1");
equals(typeof options1, "object");
@@ -45,7 +46,7 @@
var options2 = RichFaces.queue.getQueueOptions("testId2");
equals(typeof options2, "object");
- equals(options2.myParam, "hello2", "myParam");
+ equals(options2.myParam, "hello2-new", "myParam");
var options3 = RichFaces.queue.getQueueOptions("testId3");
equals(typeof options3, "object");
@@ -139,15 +140,16 @@
});
//jsf.ajax.request - requestDelay
- asyncTest("jsf.ajax.request - requestDelay", function() {
+ test("jsf.ajax.request - requestDelay", function() {
+ Timer.beginSimulation();
var time;
var newTime;
var onTimeOut = function () {
expect(1);
try {
- if (typeof newTime == "object") {
- var timeout = newTime.getTime() - time.getTime();
- ok((timeout>900 && timeout<1100), timeout);
+ if (typeof newTime != "undefined") {
+ var timeout = newTime - time;
+ equals(timeout, 1000);
} else {
ok(false, "newTime is object");
}
@@ -160,7 +162,7 @@
for (var i=0; i<jsf.ajax.eventHandlers.length;i++) {
jsf.ajax.eventHandlers[i]({type:"event", status:"success"});
}
- newTime = new Date();
+ newTime = Timer.currentTime;
}
var elements = RichFaces.QUnit.appendDomElements(body,
@@ -172,25 +174,28 @@
var options1 = {requestDelay: 1000};
RichFaces.queue.setQueueOptions({'testQueueId1': options1});
- window.setTimeout(onTimeOut, 2000);
- time = new Date();
+ setTimeout(onTimeOut, 2000);
+ time = Timer.currentTime;
document.getElementById("testButton4").click({type:"onclick"});
+ Timer.execute();
+ Timer.endSimulation();
});
//jsf.ajax.request - equal requestGroupId
- asyncTest("jsf.ajax.request - equal requestGroupId", function() {
+ test("jsf.ajax.request - equal requestGroupId", function() {
+ Timer.beginSimulation();
var time;
var newTime;
var param = "";
var onTimeOut = function () {
expect(2);
try {
- if (typeof newTime == "object") {
- var timeout = newTime.getTime() - time.getTime();
- ok((timeout>1400 && timeout<1600), timeout);
+ if (typeof newTime != "undefined") {
+ var timeout = newTime - time;
+ equals(timeout, 1500);
equals(param, "value2", "options.param");
} else {
- ok(false, "newTime is object");
+ ok(false, "newTime is undefined");
}
start();
} finally {
@@ -201,7 +206,7 @@
for (var i=0; i<jsf.ajax.eventHandlers.length;i++) {
jsf.ajax.eventHandlers[i]({type:"event", status:"success"});
}
- newTime = new Date();
+ newTime = Timer.currentTime;
param = options.param;
}
@@ -216,13 +221,16 @@
RichFaces.queue.setQueueOptions({'testQueueId1': options1});
window.setTimeout(onTimeOut, 2000);
- time = new Date();
+ time = Timer.currentTime;
document.getElementById("testButton5-1").click({type:"onclick"});
window.setTimeout(function () {document.getElementById("testButton5-2").click({type:"onclick"});}, 500);
+ Timer.execute();
+ Timer.endSimulation();
});
//jsf.ajax.request - not equal requestGroupId
- asyncTest("jsf.ajax.request - not equal requestGroupId", function() {
+ test("jsf.ajax.request - not equal requestGroupId", function() {
+ Timer.beginSimulation();
var time;
var newTime;
var newTime2;
@@ -230,18 +238,18 @@
var onTimeOut = function () {
expect(3);
try {
- if (typeof newTime == "object") {
- var timeout = newTime.getTime() - time.getTime();
- ok((timeout>400 && timeout<600), timeout);
+ if (typeof newTime != "undefined") {
+ var timeout = newTime - time;
+ equals(timeout, 500);
equals(param, "value2", "options.param");
} else {
- ok(typeof newTime == "object", "newTime is object");
+ ok(false, "newTime is undefined");
}
- if (typeof newTime2 == "object") {
- var timeout = newTime2.getTime() - time.getTime();
- ok((timeout>1400 && timeout<1600), timeout);
+ if (typeof newTime2 != "undefined") {
+ var timeout = newTime2 - time;
+ equals(timeout, 1500);
} else {
- ok(typeof newTime2 == "object", "newTime2 is object");
+ ok(false, "newTime2 is undefined");
}
start();
} finally {
@@ -253,10 +261,10 @@
jsf.ajax.eventHandlers[i]({type:"event", status:"success"});
}
param = options.param;
- if (typeof newTime != "object") {
- newTime = new Date();
+ if (typeof newTime == "undefined") {
+ newTime = Timer.currentTime;
} else {
- newTime2 = new Date();
+ newTime2 = Timer.currentTime;
}
}
@@ -272,8 +280,10 @@
RichFaces.queue.setQueueOptions({'testQueueId1': options1, 'testQueueId2': options2});
window.setTimeout(onTimeOut, 2000);
- time = new Date();
+ time = Timer.currentTime;
document.getElementById("testButton6-1").click({type:"onclick"});
window.setTimeout(function () {document.getElementById("testButton6-2").click({type:"onclick"});}, 500);
+ Timer.execute();
+ Timer.endSimulation();
});
});
\ No newline at end of file
Added: root/core/trunk/impl/src/test/resources/javascript/timer-simulation.js
===================================================================
--- root/core/trunk/impl/src/test/resources/javascript/timer-simulation.js (rev 0)
+++ root/core/trunk/impl/src/test/resources/javascript/timer-simulation.js 2010-05-17 14:16:50 UTC (rev 17080)
@@ -0,0 +1,84 @@
+var Timer = {
+
+ _eventCounter: 0,
+
+ currentTime: 0,
+
+ maxTime: 10000000,
+
+ events: new Array(),
+
+ wSetTimeout: window.setTimeout,
+
+ wClearTimeout: window.clearTimeout,
+
+ addEventToTimer: function(callback, delay) {
+ var eventTime = this.currentTime + delay;
+
+ var i = 0;
+
+ while (this.events[i] && (this.events[i].eventTime <= eventTime)) {
+ i++;
+ }
+
+ var eventId = this._eventCounter++;
+
+ this.events.splice(i, 0, {eventTime: eventTime, callback: callback, eventId: eventId});
+
+ return eventId;
+ },
+
+ removeEventFromTimer: function(eventId) {
+ for ( var i = 0; i < this.events.length; i++) {
+ if (this.events[i].eventId == eventId) {
+ this.events.splice(i, 1);
+
+ break;
+ }
+ }
+ },
+
+ execute: function() {
+ while (this.events.length > 0) {
+
+ var eventData = this.events.shift();
+
+ this.currentTime = eventData.eventTime;
+ if (this.currentTime > this.maxTime) {
+ throw "Maximum execution time reached, aborting timer";
+ }
+
+ try {
+ eventData.callback();
+ } catch (e) {
+ alert(e.message);
+ }
+ }
+ },
+
+ isEmpty: function() {
+ return this.events.length == 0;
+ },
+
+ clear: function() {
+ this._eventCounter = 0;
+ this.currentTime = 0;
+ this.events = [];
+ },
+
+ beginSimulation: function() {
+ this.clear();
+ window.setTimeout = document.setTimeout = function(callback, delay) {
+ return Timer.addEventToTimer(callback, delay);
+ };
+
+ window.clearTimeout = document.clearTimeout = function(timerId) {
+ Timer.removeEventFromTimer(timerId);
+ };
+ },
+
+ endSimulation: function() {
+ window.setTimeout = Timer.wSetTimeout;
+ window.clearTimeout = Timer.wClearTimeout;
+ }
+};
\ No newline at end of file
14 years, 5 months
JBoss Rich Faces SVN: r17079 - in root/core/trunk/impl: src/main and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-05-17 09:40:59 -0400 (Mon, 17 May 2010)
New Revision: 17079
Removed:
root/core/trunk/impl/src/main/javascript/
Modified:
root/core/trunk/impl/pom.xml
Log:
https://jira.jboss.org/browse/RFPL-596
Modified: root/core/trunk/impl/pom.xml
===================================================================
--- root/core/trunk/impl/pom.xml 2010-05-17 13:38:00 UTC (rev 17078)
+++ root/core/trunk/impl/pom.xml 2010-05-17 13:40:59 UTC (rev 17079)
@@ -133,14 +133,6 @@
</dependencies>
<build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- <resource>
- <directory>target/javascript</directory>
- </resource>
- </resources>
<plugins>
<!-- Trigger checkstyle checking for this module -->
@@ -174,100 +166,6 @@
</execution>
</executions>
</plugin>
-
- <!--
- The following 2 plugins are specific to impl, and
- create, process, and document JavaScript resources NOTE:
- these are legacy and they and the resources they
- reference can be removed
- -->
- <plugin>
- <!-- Configure ant scripts to generate javascript -->
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>javascript</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <ant antfile="${basedir}/generatescript.xml"
- inheritRefs="true">
- <target name="assembly" />
- <property name="target-dir"
- value="${project.build.directory}/javascript" />
- </ant>
- </tasks>
- <resourceRoot>${project.build.directory}/javascript</resourceRoot>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <!-- Configure csk maven plugin to process javascript -->
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-javascript-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>compress</goal>
- </goals>
- <configuration>
- <nosuffix>false</nosuffix>
- <outputDirectory>${project.build.directory}/compressed/</outputDirectory>
- <aggregations>
- <aggregation>
- <insertNewLine>true</insertNewLine>
- <output>${project.build.outputDirectory}/org/ajax4jsf/framework.pack.js</output>
- <includes>
- <include>${project.build.directory}/compressed/org/ajax4jsf/javascript/scripts/prototype-min.js</include>
- <include>${project.build.directory}/compressed/org/ajax4jsf/javascript/scripts/AJAX-min.js</include>
- <include>${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/scriptaculous/scriptaculous-min.js</include>
- <include>${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/jquery/jquery-min.js</include>
- <include>${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/jquery.utils-min.js</include>
- <include>${project.build.directory}/compressed/org/ajax4jsf/javascript/scripts/dnd-min.js</include>
- <include>**/*-min.js</include>
- </includes>
- <excludes>
- <exclude>**/*.pack.js</exclude>
- <exclude>**/scriptaculous/*.js</exclude>
- <exclude>**/extend-min.js</exclude>
- <exclude>**/jquery.jcarousel-min.js</exclude>
- <exclude>**/compressed.css</exclude>
- </excludes>
- </aggregation>
- </aggregations>
- <resources>
- <resource>
- <directory>target/javascript</directory>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- <execution>
- <id>jslint</id>
- <phase>test</phase>
- <goals>
- <goal>jslint</goal>
- </goals>
- <configuration>
- <includes>
- <include>**/framework.pack.js</include>
- </includes>
- <resources>
- <resource>
- <directory>${project.build.outputDirectory}</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
14 years, 5 months
JBoss Rich Faces SVN: r17077 - in root/core/trunk: bom and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-05-17 09:12:07 -0400 (Mon, 17 May 2010)
New Revision: 17077
Modified:
root/core/trunk/bom/pom.xml
root/core/trunk/parent/pom.xml
root/core/trunk/pom.xml
Log:
revert previous commit
Modified: root/core/trunk/bom/pom.xml
===================================================================
--- root/core/trunk/bom/pom.xml 2010-05-17 12:35:26 UTC (rev 17076)
+++ root/core/trunk/bom/pom.xml 2010-05-17 13:12:07 UTC (rev 17077)
@@ -20,17 +20,18 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-aggregator</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-bom</artifactId>
<packaging>pom</packaging>
+ <version>4.0.0-SNAPSHOT</version>
<name>RichFaces Core BOM</name>
+ <parent>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces-parent</artifactId>
+ <version>1-SNAPSHOT</version>
+ </parent>
+
<description>
The RichFaces Core "Bill of Materials". This defines core api/impl specific runtime dependency versions.
</description>
Modified: root/core/trunk/parent/pom.xml
===================================================================
--- root/core/trunk/parent/pom.xml 2010-05-17 12:35:26 UTC (rev 17076)
+++ root/core/trunk/parent/pom.xml 2010-05-17 13:12:07 UTC (rev 17077)
@@ -21,26 +21,22 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-aggregator</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-parent</artifactId>
<packaging>pom</packaging>
+ <version>4.0.0-SNAPSHOT</version>
<name>RichFaces Core Parent</name>
+ <parent>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces-parent</artifactId>
+ <version>1-SNAPSHOT</version>
+ </parent>
+
<description>
The Parent for all RichFaces core sub-projects. This specifies build and project meta-data. Runtime dependencies are imported via the bom.
</description>
- <modules>
- <module>../api</module>
- <module>../impl</module>
- </modules>
-
<properties>
<richfaces.core.version>4.0.0-SNAPSHOT</richfaces.core.version>
</properties>
@@ -55,23 +51,6 @@
<scope>import</scope>
</dependency>
- <!-- Test Dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.6</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.test-jsf</groupId>
- <artifactId>jsf-mock</artifactId>
- <version>1.0.3</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.test-jsf</groupId>
- <artifactId>htmlunit-client</artifactId>
- <version>1.0.3</version>
- </dependency>
-
<!--
These dependencies are usually provided by
org.jboss.test-jsf:htmlunit-client, but the latest 2.7
Modified: root/core/trunk/pom.xml
===================================================================
--- root/core/trunk/pom.xml 2010-05-17 12:35:26 UTC (rev 17076)
+++ root/core/trunk/pom.xml 2010-05-17 13:12:07 UTC (rev 17077)
@@ -40,8 +40,8 @@
<modules>
<module>bom</module>
<module>parent</module>
- <!--<module>api</module>-->
- <!--<module>impl</module>-->
+ <module>api</module>
+ <module>impl</module>
</modules>
</project>
14 years, 5 months