JBoss Rich Faces SVN: r11060 - in trunk/sandbox/ui/queue/src: main/java/org/ajax4jsf/taglib/html and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-07 18:45:44 -0500 (Fri, 07 Nov 2008)
New Revision: 11060
Added:
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRegistry.java
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
Removed:
trunk/sandbox/ui/queue/src/main/java/org/ajax4jsf/taglib/html/facelets/
trunk/sandbox/ui/queue/src/main/java/org/ajax4jsf/taglib/html/jsp/
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueDiscoveryVisitor.java
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueRegistry.java
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
trunk/sandbox/ui/queue/src/main/resources/META-INF/
trunk/sandbox/ui/queue/src/test/java/org/richfaces/component/
Modified:
trunk/sandbox/ui/queue/src/main/config/component/queue.xml
trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java
trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/scripts/QueueScriptResourceRenderer.java
Log:
Queue: discovery services & renderer implemented in draft
Modified: trunk/sandbox/ui/queue/src/main/config/component/queue.xml
===================================================================
--- trunk/sandbox/ui/queue/src/main/config/component/queue.xml 2008-11-07 23:44:42 UTC (rev 11059)
+++ trunk/sandbox/ui/queue/src/main/config/component/queue.xml 2008-11-07 23:45:44 UTC (rev 11060)
@@ -15,7 +15,7 @@
<superclass>org.ajax4jsf.webapp.taglib.HtmlComponentTagBase</superclass>
<test/>
</tag>
- <renderer>
+ <renderer generate="false">
<name>org.richfaces.QueueRenderer</name>
<classname>org.richfaces.renderkit.html.QueueRenderer</classname>
</renderer>
@@ -25,30 +25,63 @@
</taghandler>
-->
<property>
+ <name>enabled</name>
+ <classname>java.lang.Boolean</classname>
+ </property>
+ <property>
+ <name>size</name>
+ <classname>java.lang.Integer</classname>
+ </property>
+ <property>
<name>name</name>
<classname>java.lang.String</classname>
<defaultvalue>GLOBAL_QUEUE_NAME</defaultvalue>
</property>
+
<property>
<name>limitToList</name>
- <classname>boolean</classname>
+ <classname>java.lang.Boolean</classname>
</property>
<property >
<name>requestDelay</name>
- <classname>int</classname>
+ <classname>java.lang.Integer</classname>
</property>
<property>
<name>ignoreDupResponses</name>
- <classname>boolean</classname>
+ <classname>java.lang.Boolean</classname>
</property>
<property>
<name>timeout</name>
- <classname>int</classname>
+ <classname>java.lang.Integer</classname>
</property>
+
<property>
- <name>size</name>
- <classname>int</classname>
- <defaultvalue>1</defaultvalue>
+ <name>onsubmit</name>
+ <classname>java.lang.String</classname>
</property>
+ <property>
+ <name>oncomplete</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onbeforedomupdate</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>sizeExceededBehavior</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onSizeExceeded</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onError</name>
+ <classname>java.lang.String</classname>
+ </property>
+ <property>
+ <name>onExpired</name>
+ <classname>java.lang.String</classname>
+ </property>
</component>
</components>
Deleted: trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueDiscoveryVisitor.java
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueDiscoveryVisitor.java 2008-11-07 23:44:42 UTC (rev 11059)
+++ trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueDiscoveryVisitor.java 2008-11-07 23:45:44 UTC (rev 11060)
@@ -1,98 +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.richfaces.component;
-
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseEvent;
-
-import org.richfaces.event.RenderPhaseComponentVisitor;
-
-/**
- * <p>This visitor is intended to build lookup table for queues.</p>
- * <p>
- * The reason to use visitor and not queue component renderer is the fact that queue lookup table will be
- * used by view components just after the start of view rendering. Render phase visitor guarantees that component
- * placed in component tree <i>before</i> the queue can lookup the queue when necessary.
- * </p>
- * @author Nick Belaevski
- * @since 3.3.0
- */
-
-//TODO create light version of component tree visitor for view root only
-public class QueueDiscoveryVisitor implements RenderPhaseComponentVisitor {
-
- /* (non-Javadoc)
- * @see org.richfaces.event.RenderPhaseComponentVisitor#afterComponent(javax.faces.component.UIComponent, javax.faces.event.PhaseEvent, java.lang.Object)
- */
- public void afterComponent(UIComponent component, PhaseEvent event,
- Object state) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * <p>
- * Collects all queue components and registers them in queue registry.
- * </p>
- * <p>
- * <b>Note:</b> assumes that queues can be used only as <i>immediate</i> children of UIViewRoot
- * </p>
- * @see org.richfaces.event.RenderPhaseComponentVisitor#afterRoot(javax.faces.event.PhaseEvent, java.lang.Object)
- */
- public void afterRoot(PhaseEvent event, Object state) {
- FacesContext context = event.getFacesContext();
- UIViewRoot viewRoot = context.getViewRoot();
-
- if (viewRoot.getChildCount() > 0) {
- List<UIComponent> children = viewRoot.getChildren();
- for (UIComponent component : children) {
- if (component instanceof UIQueue) {
- UIQueue queue = (UIQueue) component;
-
- QueueRegistry.addQueue(context, queue);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.event.RenderPhaseComponentVisitor#beforeComponent(javax.faces.component.UIComponent, javax.faces.event.PhaseEvent, java.lang.Object)
- */
- public void beforeComponent(UIComponent component, PhaseEvent event,
- Object state) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.event.RenderPhaseComponentVisitor#beforeRoot(javax.faces.event.PhaseEvent)
- */
- public Object beforeRoot(PhaseEvent event) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Deleted: trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueRegistry.java
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueRegistry.java 2008-11-07 23:44:42 UTC (rev 11059)
+++ trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/QueueRegistry.java 2008-11-07 23:45:44 UTC (rev 11060)
@@ -1,78 +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.richfaces.component;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-public class QueueRegistry {
-
- private static final String QUEUE_DISCOVERY_SERVICE_ATTRIBUTE_NAME = QueueRegistry.class.getName();
-
- public static void addQueue(FacesContext context, UIQueue queue) {
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-
- Map<String, UIQueue> queuesMap = (Map<String, UIQueue>) requestMap.get(QUEUE_DISCOVERY_SERVICE_ATTRIBUTE_NAME);
- if (queuesMap == null) {
- queuesMap = new HashMap<String, UIQueue>();
-
- requestMap.put(QUEUE_DISCOVERY_SERVICE_ATTRIBUTE_NAME, queuesMap);
- }
-
- queuesMap.put(queue.getName(), queue);
- }
-
- public static UIQueue getQueue(FacesContext context, String name) {
- UIQueue result = null;
-
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-
- Map<String, UIQueue> queuesMap = (Map<String, UIQueue>) requestMap.get(QUEUE_DISCOVERY_SERVICE_ATTRIBUTE_NAME);
- if (queuesMap != null) {
- result = queuesMap.get(name);
- }
-
- return result;
- }
-
- public static UIQueue[] getQueues(FacesContext context) {
- UIQueue[] result = null;
-
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
-
- Map<String, UIQueue> queuesMap = (Map<String, UIQueue>) requestMap.get(QUEUE_DISCOVERY_SERVICE_ATTRIBUTE_NAME);
- if (queuesMap != null) {
- Collection<UIQueue> queues = queuesMap.values();
- result = queues.toArray(new UIQueue[queues.size()]);
- }
-
- return result;
- }
-}
Modified: trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java 2008-11-07 23:44:42 UTC (rev 11059)
+++ trunk/sandbox/ui/queue/src/main/java/org/richfaces/component/UIQueue.java 2008-11-07 23:45:44 UTC (rev 11060)
@@ -21,29 +21,28 @@
package org.richfaces.component;
+import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIForm;
import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
/**
* @author Nick Belaevski
* @since 3.3.0
*/
-public abstract class UIQueue extends UIComponentBase {
+public abstract class UIQueue extends UIComponentBase {
public static final String COMPONENT_TYPE = "org.richfaces.Queue";
public static final String COMPONENT_FAMILY = "org.richfaces.Queue";
- //That is used in JavaScript code also
public static final String GLOBAL_QUEUE_NAME = "org.richfaces.queue.global";
public abstract String getName();
public abstract void setName(String name);
- public abstract int getSize();
- public abstract void setSize(int size);
-
@Override
public String getFamily() {
return COMPONENT_FAMILY;
@@ -51,11 +50,20 @@
@Override
public void setParent(UIComponent parent) {
- if (!(parent instanceof UIViewRoot)) {
+ if (parent != null && !(parent instanceof UIViewRoot) && !(parent instanceof UIForm)) {
throw new IllegalArgumentException("Queue component:" + getClientId(getFacesContext()) +
- " should have UIViewRoot as its immediate parent");
+ " should have UIViewRoot or UIForm as its immediate parent");
}
super.setParent(parent);
}
+
+ public String getClientName(FacesContext context) {
+ UIComponent parent = getParent();
+ if (parent instanceof UIForm) {
+ return parent.getClientId(context) + NamingContainer.SEPARATOR_CHAR + getName();
+ } else {
+ return context.getExternalContext().encodeNamespace(getName());
+ }
+ }
}
Added: trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRegistry.java
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRegistry.java (rev 0)
+++ trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRegistry.java 2008-11-07 23:45:44 UTC (rev 11060)
@@ -0,0 +1,64 @@
+/**
+ * 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.util.LinkedHashMap;
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class QueueRegistry {
+
+ private static final String REGISTRY_ATTRIBUTE_NAME = QueueRegistry.class.getName();
+
+ public static void registerQueue(FacesContext context, String clientName, Object data) {
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, Object> requestMap = externalContext.getRequestMap();
+
+ Map<String, Object> registryMap = (Map<String, Object>)
+ requestMap.get(REGISTRY_ATTRIBUTE_NAME);
+
+ if (registryMap == null) {
+ registryMap = new LinkedHashMap<String, Object>();
+ requestMap.put(REGISTRY_ATTRIBUTE_NAME, registryMap);
+ }
+
+ if (!registryMap.containsKey(clientName)) {
+ registryMap.put(clientName, data);
+ } else {
+ throw new IllegalArgumentException("Queue with name '" + clientName + "' has already been registered");
+ }
+ }
+
+ public static Map<String, Object> getRegisteredQueues(FacesContext context) {
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, Object> requestMap = externalContext.getRequestMap();
+
+ return (Map<String, Object>) requestMap.get(REGISTRY_ATTRIBUTE_NAME);
+ }
+}
Deleted: trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2008-11-07 23:44:42 UTC (rev 11059)
+++ trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2008-11-07 23:45:44 UTC (rev 11060)
@@ -1,61 +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.richfaces.renderkit.html;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.javascript.AjaxScript;
-import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
-import org.ajax4jsf.resource.InternetResource;
-import org.richfaces.component.UIQueue;
-import org.richfaces.renderkit.html.scripts.QueueScript;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-public class QueueRenderer extends HeaderResourcesRendererBase {
-
- private volatile InternetResource[] scripts;
-
- @Override
- protected InternetResource[] getScripts() {
- if (scripts == null) {
- synchronized (this) {
- if (scripts == null) {
- scripts = new InternetResource[] {
- getResource(AjaxScript.class.getName()),
- getResource(QueueScript.class.getName())
- };
- }
- }
- }
-
- return scripts;
- }
-
- @Override
- protected Class<? extends UIComponent> getComponentClass() {
- return UIQueue.class;
- }
-
-}
Copied: trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java (from rev 10990, trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java)
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java (rev 0)
+++ trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2008-11-07 23:45:44 UTC (rev 11060)
@@ -0,0 +1,142 @@
+/**
+ * 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.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.AjaxScript;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.resource.InternetResource;
+import org.richfaces.component.UIQueue;
+import org.richfaces.renderkit.html.scripts.QueueScript;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class QueueRenderer extends HeaderResourcesRendererBase {
+
+ private static final String[] PLAIN_ATTRIBUTES = new String[] {
+ "enabled",
+ "size",
+ "sizeExceededBehavior",
+ "requestDelay",
+ "timeout",
+ "ignoreDupResponses",
+ "limitToList",
+ };
+
+ private static final String[] FUNCTION_ATTRIBUTES = new String[] {
+ "onsubmit",
+ "oncomplete",
+ "onbeforedomupdate",
+ "onSizeExceeded",
+ "onError",
+ "onExpired"
+ };
+
+
+
+ private volatile InternetResource[] scripts;
+
+ @Override
+ protected InternetResource[] getScripts() {
+ if (scripts == null) {
+ synchronized (this) {
+ if (scripts == null) {
+ scripts = new InternetResource[] {
+ getResource(AjaxScript.class.getName()),
+ getResource(QueueScript.class.getName())
+ };
+ }
+ }
+ }
+
+ return scripts;
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIQueue.class;
+ }
+
+ private boolean isNotEmpty(Object object) {
+ if (object == null) {
+ return false;
+ }
+
+ if (object instanceof String) {
+ String s = (String) object;
+ if (s.length() == 0) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private Object createRendererData(FacesContext context, UIQueue queue) {
+ Map<String, Object> attributes = queue.getAttributes();
+
+ Map<String,Object> data = new HashMap<String, Object>();
+
+ for (String attributeName : PLAIN_ATTRIBUTES) {
+ Object value = attributes.get(attributeName);
+ if (isNotEmpty(value)) {
+ data.put(attributeName, value);
+ }
+ }
+
+ for (String attributeName : FUNCTION_ATTRIBUTES) {
+ Object value = attributes.get(attributeName);
+ if (isNotEmpty(value)) {
+ //TODO nick - apply proper functions signature
+ data.put(attributeName, new JSFunctionDefinition("event").addToBody(value));
+ }
+ }
+
+ return data;
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeBegin(context, component);
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeEnd(context, component);
+
+ UIQueue queue = (UIQueue) component;
+
+ QueueRegistry.registerQueue(context, queue.getClientName(context),
+ createRendererData(context, queue));
+ }
+}
Property changes on: trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/scripts/QueueScriptResourceRenderer.java
===================================================================
--- trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/scripts/QueueScriptResourceRenderer.java 2008-11-07 23:44:42 UTC (rev 11059)
+++ trunk/sandbox/ui/queue/src/main/java/org/richfaces/renderkit/html/scripts/QueueScriptResourceRenderer.java 2008-11-07 23:45:44 UTC (rev 11060)
@@ -25,8 +25,8 @@
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
+import java.util.Map.Entry;
-import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -35,8 +35,6 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.BaseResourceRenderer;
import org.ajax4jsf.resource.InternetResource;
-import org.richfaces.component.QueueRegistry;
-import org.richfaces.component.UIQueue;
/**
* @author Nick Belaevski
@@ -55,9 +53,9 @@
if (requestMap.get(resourceKey) == null) {
requestMap.put(resourceKey, Boolean.TRUE);
- UIQueue[] queues = QueueRegistry.getQueues(context);
+ Map<String, Object> queues = org.richfaces.renderkit.html.QueueRegistry.getRegisteredQueues(context);
- if (queues != null && queues.length != 0) {
+ if (queues != null && !queues.isEmpty()) {
super.encode(resource, context, queues, attributes);
}
}
@@ -83,15 +81,12 @@
FacesContext context, Object data) throws IOException {
ResponseWriter writer = context.getResponseWriter();
- ExternalContext externalContext = context.getExternalContext();
- UIQueue[] queues = (UIQueue[]) data;
+ Map<String, Object> queues = (Map<String, Object>) data;
- for (UIQueue queue : queues) {
- String name = externalContext.encodeNamespace(queue.getName());
- int size = queue.getSize();
+ for (Entry<String, Object> entry : queues.entrySet()) {
writer.writeText("A4J.AJAX.EventQueue.addQueue(", null);
- writer.writeText(new JSObject("A4J.AJAX.EventQueue", name, size).toScript(), null);
+ writer.writeText(new JSObject("A4J.AJAX.EventQueue", entry.getKey(), entry.getValue()).toScript(), null);
writer.writeText(");", null);
}
16 years, 10 months
JBoss Rich Faces SVN: r11059 - in trunk/framework/impl/src/main: javascript/ajaxjsf and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-07 18:44:42 -0500 (Fri, 07 Nov 2008)
New Revision: 11059
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
Log:
Queue: discovery services & renderer implemented in draft
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2008-11-07 17:06:13 UTC (rev 11058)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2008-11-07 23:44:42 UTC (rev 11059)
@@ -239,7 +239,7 @@
parameters.put(controlName, controlValue);
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
// Setup action URL. For portlet environment, it will be different from
- // page.
+ // page.
options.put("actionUrl", ajaxContext.getAjaxActionURL(facesContext));
// Add application-wide Ajax parameters
parameters.putAll(ajaxContext.getCommonAjaxParameters());
@@ -321,21 +321,29 @@
.get(AJAX_DELAY_ATTR);
if (null != requestDelay && requestDelay.intValue() > 0) {
options.put(AJAX_DELAY_ATTR, requestDelay);
- if (null == queue) {
- queue = clientId;
- }
+// if (null == queue) {
+// queue = clientId;
+// }
}
Boolean ignoreDupResponses = (Boolean) componentAttributes
.get(AJAX_ABORT_ATTR);
if (null != ignoreDupResponses && ignoreDupResponses.booleanValue()) {
options.put(AJAX_ABORT_ATTR, JSReference.TRUE);
- if (null == queue) {
- queue = clientId;
- }
+// if (null == queue) {
+// queue = clientId;
+// }
}
if (null != queue) {
options.put(AJAX_QUEUE_ATTR, queue);
}
+
+ String namespace = facesContext.getExternalContext().encodeNamespace("");
+ if (namespace != null && namespace.length() != 0) {
+ options.put("namespace", namespace);
+ }
+
+ options.put("requestId", clientId);
+
// request timeout.
Integer timeout = (Integer) componentAttributes.get("timeout");
if (null != timeout && timeout.intValue() > 0) {
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-11-07 17:06:13 UTC (rev 11058)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-11-07 23:44:42 UTC (rev 11059)
@@ -15,6 +15,7 @@
*/
A4J.AJAX.XMLHttpRequest = function(query){
this._query = query;
+
// Store document element, to check page replacement.
this._documentElement = window.document.documentElement;
};
@@ -602,7 +603,7 @@
// Onsubmit disable current poll, start next interval.
A4J.AJAX.Poll(containerId,form,options);
} else {
- A4J.AJAX.SubmitRequest(containerId,form,null,options);
+ A4J.AJAX.Submit(containerId,form,null,options);
}
},options.pollinterval);
};
@@ -631,7 +632,7 @@
try {
if(request.status == 200){
if(request.getResponseHeader("Ajax-Push-Status")=="READY"){
- A4J.AJAX.SubmitRequest(containerId,form||options.dummyForm,null,options);
+ A4J.AJAX.Submit(containerId,form||options.dummyForm,null,options);
}
}
} catch(e){
@@ -691,9 +692,14 @@
A4J.AJAX.Submit(containerId,form,null,opt);
}
-// Submit or put in queue request. It not full queues - framework perform waiting only one request to same queue, new events simple replace last.
-// If request for same queue already performed, replace with current parameters.
-A4J.AJAX.Submit = function( containerId, form, evt , options ) {
+/**
+ * This method should be deprecated and maybe even removed?
+ */
+A4J.AJAX.SubmiteventsQueue = function( eventsQueue ) {
+ eventsQueue.submit();
+};
+
+A4J.AJAX.PrepareQuery = function(containerId, formId, evt, options) {
var domEvt;
evt = evt || window.event || null;
if(evt){
@@ -705,30 +711,7 @@
}
LOG.debug("Have Event "+domEvt+" with properties: target: "+domEvt.target+", srcElement: "+domEvt.srcElement+", type: "+domEvt.type);
}
-
- var queue = A4J.AJAX.EventQueue.getOrCreateQueue(options.eventsQueue);
- if (queue) {
- queue.push(containerId, form, domEvt, options);
- } else {
- A4J.AJAX.SubmitRequest(containerId, form, domEvt, options);
- }
-};
-/**
- * This method should be deprecated and maybe even removed?
- */
-A4J.AJAX.SubmiteventsQueue = function( eventsQueue ) {
- eventsQueue.immediateSubmit();
-};
- // Main request submitting functions.
- // parameters :
- // form - HtmlForm object for submit.
- // control - form element, called request, or, clientID for JSF view.
- // affected - Array of ID's for DOM Objects, updated after request. Override
- // list of updated areas in response.
- // statusID - DOM id request status tags.
- // oncomplete - function for call after complete request.
-A4J.AJAX.SubmitRequest = function( containerId, formId ,domEvt , options ) {
// Process listeners.
for(var li = 0; li < A4J.AJAX._listeners.length; li++){
var listener = A4J.AJAX._listeners[li];
@@ -737,7 +720,7 @@
}
}
// First - run onsubmit event for client-side validation.
- LOG.debug("NEW AJAX REQUEST !!! with form :"+formId );
+ LOG.debug("Query preparation for form '" + formId + "' requested");
// var form = A4J.AJAX.locateForm(event);
var form = window.document.getElementById(formId);
if( (!form || form.nodeName.toUpperCase() != "FORM") && domEvt ) {
@@ -753,7 +736,7 @@
return false;
};
};
- var tosend = new A4J.Query(containerId, form);
+ var tosend = new A4J.Query(containerId, form, domEvt);
tosend.appendFormControls(options.single, options.control);
//appending options.control moved to appendFormControls
//if(options.control){
@@ -762,19 +745,26 @@
if(options.parameters){
tosend.appendParameters(options.parameters);
};
- if(options.eventsCount){
- tosend.appendParameter("AJAX:EVENTS_COUNT",options.eventsCount);
- };
if(options.actionUrl){
tosend.setActionUrl(options.actionUrl);
};
- // build xxxHttpRequest. by Sarissa / JSHttpRequest class always defined.
- var req = new A4J.AJAX.XMLHttpRequest(tosend);
+
+ return tosend;
+};
+
+A4J.AJAX.SubmitQuery = function (query, options) {
+ // build xxxHttpRequest. by Sarissa / JSHttpRequest class always defined.
+ var req = new A4J.AJAX.XMLHttpRequest(query);
+ var form = query._form;
+ var containerId = query._containerId;
+ var domEvt = query._event;
+
req.options = options;
req.containerId = containerId;
req.domEvt = domEvt;
req.form = form;
+
if(options.timeout){
req.setRequestTimeout(options.timeout);
};
@@ -789,17 +779,49 @@
}
req.onfinish = A4J.AJAX.finishRequest;
- A4J.AJAX.status(containerId,options.status,true);
+ LOG.debug("NEW AJAX REQUEST !!! with form: " + (form.id || form.name || form));
+
+ A4J.AJAX.status(containerId,options.status,true);
req.send();
- var queue = A4J.AJAX.EventQueue.getQueue(options.eventsQueue);
- if (queue) {
- queue.request = req;
- }
-
+ return req;
+};
+
+//Submit or put in queue request. It not full queues - framework perform waiting only one request to same queue, new events simple replace last.
+//If request for same queue already performed, replace with current parameters.
+A4J.AJAX.Submit = function( containerId, formId, event , options ) {
+ var query = A4J.AJAX.PrepareQuery(containerId, formId, event, options);
+ if (query) {
+ var queue = A4J.AJAX.EventQueue.getOrCreateQueue(options.eventsQueue, options.requestId, options.namespace, formId);
+
+ if (queue) {
+ queue.push(query, options);
+ } else {
+ A4J.AJAX.SubmitQuery(query, options);
+ }
+ }
+
return false;
- };
+};
+
+ // Main request submitting functions.
+ // parameters :
+ // form - HtmlForm object for submit.
+ // control - form element, called request, or, clientID for JSF view.
+ // affected - Array of ID's for DOM Objects, updated after request. Override
+ // list of updated areas in response.
+ // statusID - DOM id request status tags.
+ // oncomplete - function for call after complete request.
+A4J.AJAX.SubmitRequest = function( containerId, formId, event, options ) {
+ var query = A4J.AJAX.PrepareQuery(containerId, formId, event, options);
+ if (query) {
+ A4J.AJAX.SubmitQuery(query, options);
+ }
+
+ return false;
+};
+
A4J.AJAX.processResponseAfterUpdateHeadElements = function (req, ids)
{
for ( var k =0; k < ids.length ; k++ ) {
@@ -1076,9 +1098,8 @@
A4J.AJAX.status(request.containerId,options.status,false);
}
- var queue = A4J.AJAX.EventQueue.getQueue(options.eventsQueue);
- if (queue) {
- queue.pop();
+ if (request.queue) {
+ request.queue.pop();
}
};
@@ -1160,11 +1181,13 @@
// Class for build query string.
-A4J.Query = function(containerId,form){
+A4J.Query = function(containerId, form, event){
// For detect AJAX Request.
this._query = {AJAXREQUEST : containerId};
this._oldSubmit = null ;
- this._form = form ;
+ this._form = form;
+ this._containerId = containerId;
+ this._event = event;
this._actionUrl = ( this._form.action)?this._form.action:this._form;
};
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-07 17:06:13 UTC (rev 11058)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-11-07 23:44:42 UTC (rev 11059)
@@ -1,12 +1,13 @@
+//TODO observe unload
+//unload
+
A4J.AJAX._eventQueues = {};
//queue constructor
-A4J.AJAX.EventQueue = function(name, size) {
- LOG.debug("Creating new queue " + name + " with settings: [size= " + size + "]");
-
- this.eventCounter = 0;
+A4J.AJAX.EventQueue = function(name, options) {
this.name = name;
- this.size = size || 1;
+ this.options = options;
+
this.queue = new Array();
};
@@ -18,159 +19,188 @@
if (A4J.AJAX._eventQueues[name]) {
throw "Queue already registered";
} else {
+ LOG.debug("Adding queue '" + name + "' to queues registry");
A4J.AJAX._eventQueues[name] = queue;
}
};
-A4J.AJAX.EventQueue.getQueue = function(name) {
- //uncomment to switch on global queue
- //name = name || A4J.AJAX.EventQueue.DEFAULT_QUEUE_NAME;
-
- return A4J.AJAX._eventQueues[name];
+A4J.AJAX.EventQueue.removeQueue = function(name) {
+ delete A4J.AJAX._eventQueues[name];
};
-A4J.AJAX.EventQueue.getOrCreateQueue = function(name) {
+//TODO A4J.AJAX.EventQueue.getQueue ?
+
+A4J.AJAX.EventQueue.getOrCreateQueue = function(queueName, requestId, namespace, formId) {
//uncomment to switch on global queue
- //name = name || A4J.AJAX.EventQueue.DEFAULT_QUEUE_NAME;
+ var name = queueName || A4J.AJAX.EventQueue.DEFAULT_QUEUE_NAME;
- if (name) {
- var queue = A4J.AJAX._eventQueues[name];
- if (!queue) {
- LOG.debug("Creating new queue " + name + " with default settings");
- queue = new A4J.AJAX.EventQueue(name);
- A4J.AJAX.EventQueue.addQueue(queue);
- }
+ var queue;
+ if (formId) {
+ queue = A4J.AJAX._eventQueues[formId + ":" + name];
+ }
+
+ if (!queue) {
+ queue = A4J.AJAX._eventQueues[namespace ? (namespace + ":" + name) : name];
+ }
+
+ if (!queue) {
+ name = queueName || requestId;
- return queue;
- }
+ LOG.debug("Creating new transient queue '" + name + "' with default settings");
+ queue = new A4J.AJAX.EventQueue(name);
+ queue._transient = true;
+
+ A4J.AJAX.EventQueue.addQueue(queue);
+ }
+
+ return queue;
};
A4J.AJAX.EventQueue.prototype = function() {
- var replaceForDupResponse = function(event) {
- this.queue = new Array();
- this.queue.push(event);
+ var EventQueueData = function(queue) {
+ this.queue = queue;
+ this.eventsCount = 0;
};
+
+ EventQueueData.prototype.setEventData = function(query, options) {
+ this.query = query;
+ this.options = options;
+
+ this.eventsCount++;
+ };
+
+ EventQueueData.prototype.executeDelay = function(delay) {
+ LOG.debug("Queue will wait " + (delay || 0) + "ms before submit");
- var replaceForOversize = function(event) {
- this.queue.shift();
- this.queue.push(event);
+ if (delay) {
+ var _this = this;
+
+ this.timerId = setTimeout(function() {
+ try {
+ _this.delayPassed = true;
+ _this.queue.submit();
+ } finally {
+ _this = undefined;
+ }
+ }, delay);
+ } else {
+ this.delayPassed = true;
+ this.queue.submit();
+ }
};
+
+ EventQueueData.prototype.abortDelay = function() {
+ if (this.timerId) {
+ clearTimeout(this.timerId);
+ this.timerId = undefined;
+ }
+
+ this.delayPassed = false;
+ };
+
+ EventQueueData.prototype.submit = function() {
+ this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
+
+ return A4J.AJAX.SubmitQuery(this.query, this.options)
+ };
+
+ var extendOptions = function(options) {
+ var opts = {};
+
+ for (var name in options) {
+ opts[name] = options[name];
+ }
+
+ for (var name in this.options) {
+ if (!opts[name]) {
+ opts[name] = this.options[name];
+ }
+ }
+
+ return opts;
+ };
+
return {
//TODO separate service functions
- replace: function(event, policy) {
- if (this.request) {
- LOG.debug("Abort uncompleted request in queue " + this.name);
-
- this.request.abort();
- this.request = undefined;
+ submit: function() {
+ if (this.inactive) {
+ throw "Queue inactive";
+ }
- policy.call(this, event);
-
- if (this.queue.length == 1) {
- this.delayedSubmit();
+ if (!this.request) {
+ var queueData = this.queue.shift();
+ if (queueData) {
+ LOG.debug("Queue '" + this.name + "' will submit request NOW");
+
+ if (this.queue.length == 0) {
+ LOG.debug("The last queue request is being submitted, resetting requestId");
+ this._requestId = undefined;
+ }
+
+ this.request = queueData.submit();
+ this.request.queue = this;
} else {
- this.immediateSubmit();
+ LOG.debug("Queue '" + this.name + "' is empty, nothing to submit");
}
} else {
- //there should be waiting request, let's wait for it
- policy.call(this, event);
+ LOG.debug("Request in queue '" + this.name + "' is active now, wait until its completion");
}
- },
+ },
- push: function(containerId, form, evt, options) {
- var eventInfo = {containerId: containerId, form: form, domEvt: evt, options: options};
+ push: function(query, opts) {
+ if (this.inactive) {
+ throw "Queue inactive";
+ }
+
+ var options = extendOptions.call(this, opts);
- this.eventCounter++;
+ //TODO add processing for ignoreDupResponse
+
+ var queueData;
+
+ var requestId = options.requestId;
+ var delay = options.requestDelay;
- if (this.queue.length == 0) {
- LOG.debug("New event added to empty queue " + this.name);
+ if (!this._requestId || requestId != this._requestId) {
+ queueData = new EventQueueData(this);
+
+ this.queue.push(queueData);
+ this._requestId = requestId;
- this.queue.push(eventInfo);
- this.delayedSubmit();
+ LOG.debug("New event added to queue '" + this.name + "'. Queue requestId changed to " + requestId);
} else {
- if (options.ignoreDupResponses) {
- LOG.debug("Doing replace due to ignoreDupResponses event in queue " + this.name);
+ queueData = this.queue[this.queue.length - 1];
+ queueData.abortDelay();
- this.replace(eventInfo, replaceForDupResponse);
- } else {
- //size != 0
- if (this.size == this.queue.length) {
- LOG.debug("Doing replace due to queue's " + this.name + " oversize");
-
- this.replace(eventInfo, replaceForOversize);
- } else {
- LOG.debug("New event added to queue " + this.name);
-
- //there should be waiting request, let's wait for it
- this.queue.push(eventInfo);
- }
- }
+ LOG.debug("Similar request already in queue '" + this.name + "'");
}
+
+ queueData.setEventData(query, options);
+ queueData.executeDelay(delay);
},
-
- immediateSubmit: function() {
- var packet = this.queue[0];
- if (packet) {
- if (!this.request) {
- //TODO externalize this?
- packet.options.eventsCount = this.eventCounter;
- A4J.AJAX.SubmitRequest(packet.containerId, packet.form, packet.domEvt, packet.options);
-
- if (!this.request) {
- //ajax submission stopped by onsubmit form handler
- this.pop();
- }
- } else {
- LOG.debug("Submit method called for queue " + this.name +
- " processing another request right now. Method call has been ignored");
- }
- } else {
- LOG.debug("Submit method called for empty queue " + this.name);
- }
- },
-
- delayedSubmit: function() {
- var packet = this.queue[0];
- if (packet) {
- var options = packet.options;
- if (options.requestDelay) {
- var _this = this;
-
- window.setTimeout(function() {
- try {
- LOG.debug("End delay waiting, make request in queue " + _this.name);
- _this.immediateSubmit();
- } finally {
- _this = undefined;
- }
- }, options.requestDelay);
-
- LOG.debug("Create new waiting for request in queue " + this.name);
- } else {
- LOG.debug("No request delay, submit " + this.name + " queue's request just now");
-
- this.immediateSubmit();
- }
- }
- },
-
+
pop: function() {
this.request = undefined;
- this.queue.shift();
+
if (this.queue.length == 0) {
- LOG.debug("Queue " + this.name + " is empty now");
+ LOG.debug("After request: queue '" + this.name + "' is empty now");
- this.eventCounter = 0;
+ if (this._transient) {
+ this.inactive = true;
+
+ LOG.debug("Deleting transient queue '" + this.name + "' from queues registry");
+ A4J.AJAX.EventQueue.removeQueue(this.name);
+ }
} else {
- LOG.debug("Queue not empty, execute next request in queue " + this.name);
-
- this.eventCounter--;
- //TODO - check that counter is still greater than zero
- this.immediateSubmit();
+ LOG.debug("After request: queue not empty, processing next event in queue '" + this.name + "'");
+ var queueData = this.queue[0];
+ if (queueData.delayPassed) {
+ this.submit();
+ }
}
}
}
16 years, 10 months
JBoss Rich Faces SVN: r11058 - in trunk: framework and 13 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-07 12:06:13 -0500 (Fri, 07 Nov 2008)
New Revision: 11058
Modified:
trunk/extensions/gwt/pom.xml
trunk/framework/pom.xml
trunk/framework/test/pom.xml
trunk/samples/pom.xml
trunk/samples/richfaces-demo/pom.xml
trunk/samples/richfaces-ear-demo/webapp/pom.xml
trunk/samples/seamEAR/wars/seamWebapp/pom.xml
trunk/sandbox/samples/rex-demo/pom.xml
trunk/test-applications/facelets/
trunk/test-applications/jsp/pom.xml
trunk/test-applications/seamApp/web/pom.xml
trunk/test-applications/seleniumTest/
trunk/test-applications/seleniumTest/pom.xml
trunk/test-applications/seleniumTest/richfaces/
trunk/test-applications/seleniumTest/samples/
trunk/ui/pom.xml
Log:
JSF version updated:
Sun RI: to 1.2_10
MyFaces to 1.2.5
Service files svn:ignored
Modified: trunk/extensions/gwt/pom.xml
===================================================================
--- trunk/extensions/gwt/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/extensions/gwt/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -120,12 +120,12 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
</dependency>
<dependency>
Modified: trunk/framework/pom.xml
===================================================================
--- trunk/framework/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/framework/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -99,7 +99,7 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>provided</scope>
</dependency>
<dependency>
Modified: trunk/framework/test/pom.xml
===================================================================
--- trunk/framework/test/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/framework/test/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -47,7 +47,7 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
Modified: trunk/samples/pom.xml
===================================================================
--- trunk/samples/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/samples/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -183,12 +183,12 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>runtime</scope>
</dependency>
</dependencies>
@@ -238,12 +238,12 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>runtime</scope>
</dependency>
</dependencies>
@@ -283,12 +283,12 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>runtime</scope>
</dependency>
<dependency>
@@ -337,13 +337,13 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -351,8 +351,8 @@
<profile>
<id>myfaces</id>
<properties>
- <myfaces>1.2.4</myfaces>
- <tomahawk>1.1.6</tomahawk>
+ <myfaces>1.2.5</myfaces>
+ <tomahawk>1.1.7</tomahawk>
</properties>
<build>
<plugins>
@@ -493,4 +493,4 @@
<module>darkX</module>
<module>richfaces-demo</module>
</modules>
-</project>
\ No newline at end of file
+</project>
Modified: trunk/samples/richfaces-demo/pom.xml
===================================================================
--- trunk/samples/richfaces-demo/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/samples/richfaces-demo/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -182,12 +182,12 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>runtime</scope>
</dependency>
</dependencies>
@@ -275,16 +275,16 @@
<version>2.1</version>
<scope>provided</scope>
</dependency>
- <dependency>
+ <!-- dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>runtime</scope>
- </dependency>
+ </dependency -->
</dependencies>
</project>
Modified: trunk/samples/richfaces-ear-demo/webapp/pom.xml
===================================================================
--- trunk/samples/richfaces-ear-demo/webapp/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/samples/richfaces-ear-demo/webapp/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -93,13 +93,13 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>provided</scope>
</dependency>
</dependencies>
Modified: trunk/samples/seamEAR/wars/seamWebapp/pom.xml
===================================================================
--- trunk/samples/seamEAR/wars/seamWebapp/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/samples/seamEAR/wars/seamWebapp/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -55,13 +55,13 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>provided</scope>
</dependency>
<dependency>
Modified: trunk/sandbox/samples/rex-demo/pom.xml
===================================================================
--- trunk/sandbox/samples/rex-demo/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/sandbox/samples/rex-demo/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -163,12 +163,12 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>runtime</scope>
</dependency>
</dependencies>
Property changes on: trunk/test-applications/facelets
___________________________________________________________________
Name: svn:ignore
- target
.classpath
.project
.settings
+ target
.classpath
.project
.settings
bin
Modified: trunk/test-applications/jsp/pom.xml
===================================================================
--- trunk/test-applications/jsp/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/test-applications/jsp/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -17,7 +17,7 @@
<dependency>
<groupId>org.apache.myfaces.tomahawk</groupId>
<artifactId>tomahawk</artifactId>
- <version>1.1.6</version>
+ <version>1.1.7</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
Modified: trunk/test-applications/seamApp/web/pom.xml
===================================================================
--- trunk/test-applications/seamApp/web/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/test-applications/seamApp/web/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -16,13 +16,13 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>provided</scope>
</dependency>
<dependency>
Property changes on: trunk/test-applications/seleniumTest
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
.settings
target
test-output
+ .classpath
.project
.settings
target
test-output
bin
Modified: trunk/test-applications/seleniumTest/pom.xml
===================================================================
--- trunk/test-applications/seleniumTest/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/test-applications/seleniumTest/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -222,7 +222,7 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
Property changes on: trunk/test-applications/seleniumTest/richfaces
___________________________________________________________________
Name: svn:ignore
- target
test-output
+ target
test-output
.classpath
.project
.settings
Property changes on: trunk/test-applications/seleniumTest/samples
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
Modified: trunk/ui/pom.xml
===================================================================
--- trunk/ui/pom.xml 2008-11-07 13:02:28 UTC (rev 11057)
+++ trunk/ui/pom.xml 2008-11-07 17:06:13 UTC (rev 11058)
@@ -182,7 +182,7 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_09</version>
+ <version>1.2_10</version>
<scope>provided</scope>
</dependency>
</dependencies>
16 years, 10 months
JBoss Rich Faces SVN: r11057 - trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: pgolawski
Date: 2008-11-07 08:02:28 -0500 (Fri, 07 Nov 2008)
New Revision: 11057
Modified:
trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java
Log:
fixing table to work without facet='header' for columns/table
set focus to filter input after table rerender
Modified: trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java
===================================================================
--- trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java 2008-11-07 13:00:48 UTC (rev 11056)
+++ trunk/ui/extendedDataTable/src/main/java/org/richfaces/renderkit/AbstractExtendedTableRenderer.java 2008-11-07 13:02:28 UTC (rev 11057)
@@ -37,6 +37,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.component.AjaxActionComponent;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
@@ -134,89 +135,74 @@
ResponseWriter writer = context.getResponseWriter();
UIComponent header = table.getHeader();
- boolean columnFacetPresent = isColumnFacetPresent(table, "header");
+ boolean columnFacetHeaderPresent = isColumnFacetPresent(table, "header");
Iterator<UIColumn> colums = table.getSortedColumns();
// int numberOfColumns = getColumnsCount(table);
int numberOfColumns = table.getVisibleColumnsCount() + 1;
String headerClass = (String) table.getAttributes().get("headerClass");
- if (header != null || columnFacetPresent) {
- writer.startElement("thead", table);
- writer.writeAttribute(HTML.id_ATTRIBUTE, table
- .getBaseClientId(context)
- + ":header", null);
- writer.writeAttribute(HTML.class_ATTRIBUTE, "extdt-thead", null);
-
- // String menuId = (String) table.getAttributes().get(MENU_ID);
-
- writer.startElement("tr", header);
+ writer.startElement("thead", table);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, table.getBaseClientId(context) + ":header", null);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "extdt-thead", null);
+ //add special fake IE row
+ writer.startElement("tr", header);
+ encodeStyleClass(writer, null,
+ "extdt-header rich-extdt-header", headerClass, null);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, table
+ .getBaseClientId(context)
+ + ":fakeIeRow", null);
+ for (int i = 0; i < numberOfColumns; i++) {
+ writer.startElement("th", header);
encodeStyleClass(writer, null,
- "extdt-header rich-extdt-header", headerClass, null);
- writer.writeAttribute(HTML.id_ATTRIBUTE, table
- .getBaseClientId(context)
- + ":fakeIeRow", null);
- for (int i = 0; i < numberOfColumns; i++) {
+ "extdt-headercell extdt-fakeierow rich-extdt-headercell",
+ headerClass, null);
+ writer.endElement("th");
+ }
+ writer.endElement("tr");
+ if (header != null) {
+
+ encodeTableHeaderFacet(context, numberOfColumns, writer,
+ header, "extdt-header rich-extdt-header",
+ "extdt-header-continue rich-extdt-header-continue",
+ "extdt-headercell rich-extdt-headercell",
+ headerClass, "th", "header");
+ }
+
+ writer.startElement("tr", table);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, table
+ .getBaseClientId(context)
+ + ":headerRow", null);
+ encodeStyleClass(writer, null,
+ "extdt-subheader rich-extdt-subheader", null,
+ headerClass);
+ if (columnFacetHeaderPresent) {
+ encodeHeaderFacets(
+ context,
+ writer,
+ table,
+ colums,
+ "extdt-menucell extdt-subheadercell rich-extdt-subheadercell",
+ headerClass, "header", "th", numberOfColumns);
+ /* encoding additional empty column used in resizing columns */
+ writer.startElement("th", table);
+ encodeStyleClass(writer, null,
+ "extdt-empty-cell rich-extdt-subheadercell", null,
+ null);
+ writer.endElement("th");
+ }
+ else{
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "height: 0px", null);
+ for (int i = 0; i < numberOfColumns; i++) {
writer.startElement("th", header);
- encodeStyleClass(writer, null,
- "extdt-headercell extdt-fakeierow rich-extdt-headercell",
- headerClass, null);
writer.endElement("th");
}
- writer.endElement("tr");
- if (header != null) {
- writer.endElement("tr");
-
- encodeTableHeaderFacet(context, numberOfColumns, writer,
- header, "extdt-header rich-extdt-header",
- "extdt-header-continue rich-extdt-header-continue",
- "extdt-headercell rich-extdt-headercell",
- headerClass, "th", "header");
- }
-
- if (columnFacetPresent) {
- writer.startElement("tr", table);
- writer.writeAttribute(HTML.id_ATTRIBUTE, table
- .getBaseClientId(context)
- + ":headerRow", null);
- encodeStyleClass(writer, null,
- "extdt-subheader rich-extdt-subheader", null,
- headerClass);
- encodeHeaderFacets(
- context,
- writer,
- table,
- colums,
- "extdt-menucell extdt-subheadercell rich-extdt-subheadercell",
- headerClass, "header", "th", numberOfColumns);
- /* encoding additional empty column used in resizing columns */
- writer.startElement("th", table);
- encodeStyleClass(writer, null,
- "extdt-empty-cell rich-extdt-subheadercell", null,
- null);
- writer.endElement("th");
- writer.endElement("tr");
-
- encodeFilterRow(context, writer, table, table
- .getSortedColumns(),
- "extdt-subheadercell rich-extdt-subheadercell",
- headerClass, "header", HTML.th_ELEM);
-
- }
- else if (isColumnFacetPresent(table, "filter")){
- encodeFilterRow(context, writer, table, table
- .getSortedColumns(),
- "extdt-subheadercell rich-extdt-subheadercell",
- headerClass, "filter", HTML.th_ELEM);
- }
- writer.endElement("thead");
}
- else if (isColumnFacetPresent(table, "filter")){
- writer.startElement("thead", table);
- encodeFilterRow(context, writer, table, table
- .getSortedColumns(),
- "extdt-subheadercell rich-extdt-subheadercell",
- headerClass, "filter", HTML.th_ELEM);
- writer.endElement("thead");
- }
+ writer.endElement("tr");
+
+ encodeFilterRow(context, writer, table, table
+ .getSortedColumns(),
+ "extdt-subheadercell rich-extdt-subheadercell",
+ headerClass, "filter", HTML.th_ELEM);
+ writer.endElement("thead");
}
private void encodeFilterRow(FacesContext context, ResponseWriter writer,
@@ -1163,9 +1149,10 @@
}
boolean filterChanged = (newFilterValue == null ? (oldFilterValue != null)
: !newFilterValue.equals(oldFilterValue));
- //if (filterChanged) {
- // table.resetGroupVisibilityState();
- //}
+ if (filterChanged) {
+ //set focus on changed field
+ AjaxContext.getCurrentInstance().getResponseDataMap().put(AjaxActionComponent.FOCUS_DATA_ID, filterValueInput.getClientId(context));
+ }
filtering = (filtering || filterChanged);
}
}
16 years, 10 months
JBoss Rich Faces SVN: r11056 - trunk/ui/extendedDataTable/src/main/templates/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pgolawski
Date: 2008-11-07 08:00:48 -0500 (Fri, 07 Nov 2008)
New Revision: 11056
Modified:
trunk/ui/extendedDataTable/src/main/templates/org/richfaces/htmlExtendedDataTable.jspx
Log:
fixing table to work without facet='header' for columns/table
visibility CSS rule is not set for main table, splash screen has correct CSS style class
Modified: trunk/ui/extendedDataTable/src/main/templates/org/richfaces/htmlExtendedDataTable.jspx
===================================================================
--- trunk/ui/extendedDataTable/src/main/templates/org/richfaces/htmlExtendedDataTable.jspx 2008-11-07 12:58:36 UTC (rev 11055)
+++ trunk/ui/extendedDataTable/src/main/templates/org/richfaces/htmlExtendedDataTable.jspx 2008-11-07 13:00:48 UTC (rev 11056)
@@ -82,8 +82,7 @@
<div id="#{clientId}:innerd" class="extdt-innerdiv" style="height:100%;width:100%;">
<div id="#{clientId}:cs" class="extdt-hsplit" style="display: none;"/>
<table id="#{clientId}:tu"
- class="extdt-table-layout rich-table #{component.attributes['styleClass']}"
- style="visibility:hidden;"
+ class="extdt-table-layout rich-table #{component.attributes['styleClass']}"
cellpadding="0"
cellspacing="0"
width="100%"
@@ -121,7 +120,7 @@
<f:call name="contributorsEncodeHere" />
</div>
<f:clientid var="clientId"/>
- <div id="#{clientId}:splashscreen" class=".extdt-ss-vsbl">
+ <div id="#{clientId}:splashscreen" class="extdt-ss-vsbl">
</div>
<script type="text/javascript">
//<![CDATA[
16 years, 10 months
JBoss Rich Faces SVN: r11055 - trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable.
by richfaces-svn-commits@lists.jboss.org
Author: pgolawski
Date: 2008-11-07 07:58:36 -0500 (Fri, 07 Nov 2008)
New Revision: 11055
Modified:
trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableHeader.js
Log:
code refactoring
fixing table to work without facet='header' for columns/table
Modified: trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js
===================================================================
--- trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2008-11-07 12:57:22 UTC (rev 11054)
+++ trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTable.js 2008-11-07 12:58:36 UTC (rev 11055)
@@ -12,10 +12,6 @@
this.options = options;
this.selectionManager = new ExtendedDataTable.SelectionManager(options, this);
- if (this.options.sortFunction) {
- this.sortFct = this.options.sortFunction;
- this.eventCellClicked = this.OnCellMouseClicked.bindAsEventListener(this);
- }
this.onGroupToggleFct = this.options.onGroupToggleFunction;
if (this.options.onColumnResize != null){
this.onColumnResize = this.options.onColumnResize;
@@ -36,21 +32,11 @@
},
destroy: function() {
- //var rows = this.tableB.rows;
- //rowCount = rows.length;
- //for(var i = 0; i < rowCount; i++) {
- // Utils.DOM.Event.removeListeners(rows[i]);
- //}
//remove listeners
this.selectionManager.removeListeners();
if (this.header) {
this.header.removeListeners();
- var headerChildren = this.header.getColumnCells();
- l = headerChildren.length;
- for (var i=0; i<l-1; i++) {
- Utils.DOM.Event.removeListeners(headerChildren[i]);
- };
}
if (this.groupRows) {
var l = this.groupRows.length;
@@ -130,23 +116,9 @@
return el;
},
- OnCellMouseClicked: function(event) {
- //get column id
- var el = this._findParentElement(event, "th");
- var columnId = (el) ? el.id : null;
-
- if (columnId && (columnId != "")){
- this.showSplashScreen();
- this.sortFct(event, columnId);
- }
- Event.stop(event);
- },
-
preSendAjaxRequest: function(){
//remove listeners
Event.stopObserving(window, 'resize', this.eventContainerResize);
- //Event.stopObserving(document, 'mousemove', this.header.eventSepMouseMove);
- //Event.stopObserving(document, 'mouseup', this.header.eventSepMouseUp);
//show splash screen
this.showSplashScreen();
},
@@ -159,7 +131,7 @@
this.mainDiv.setStyle({display:'none'});
}
*/
- this.table.setStyle({visibility:'hidden'});
+ //this.table.setStyle({visibility:'hidden'});
var splshscr = this.splashScreen;
splshscr.className = 'extdt-ss-vsbl';
},
@@ -172,7 +144,7 @@
this.mainDiv.setStyle({display:''});
}
*/
- this.table.setStyle({visibility:''});
+ //this.table.setStyle({visibility:''});
this.splashScreen.className = 'extdt-ss-hdn';
},
@@ -273,6 +245,7 @@
this.fakeIeBodyRow = $(this.id +":body:fakeIeRow");
this.header = new ExtendedDataTable.DataTable.header(this.id +":header",this);
this.header.minColumnWidth = this.minColumnWidth;
+ this.header.addListeners();
var colgroup = $(this.id +":colgroup:body");
this.cols = colgroup.getElementsByTagName("col");
this.columnsNumber = this.cols.length;
@@ -377,14 +350,6 @@
this.header.setColumnWidth(i, width);
this.setColumnWidth(i, width);
}
- var headerChild = headerChildren[i];
- Utils.DOM.Event.removeListeners(headerChild);
- Utils.DOM.Event.observe(headerChild,'mouseover',this.header.eventHeaderCellMouseOver);
- Utils.DOM.Event.observe(headerChild,'mouseout',this.header.eventHeaderCellMouseOut);
- var isSortable = headerChild.getAttribute('sortable');
- if ((isSortable) && (isSortable.indexOf('true') == 0)) {
- Utils.DOM.Event.observe(headerChild, 'click', this.eventCellClicked);
- }
}
//var excessWidth = this.header.getVisibleWidth() - maxAllowedWidth - 1;
//if (excessWidth > 0) {
@@ -395,7 +360,9 @@
var newHeight = mainDivHeight - header.getHeight() - footerHeight - 2;
newHeight -= this.header.getCaptionHeight();
scrollingDiv.setStyle('height:'+ newHeight +'px;');
+ this._redrawTable(table);
header.adjustSeparators();
+ this._redrawTable(this.tableB);
this.saveRatios();
this.hideSplashScreen();
},
@@ -480,6 +447,18 @@
_percentsToPixels: function(percents, maxAllowedWidth) {
var val = (percents.substr(0, percents.length-1)*1)/100;
return maxAllowedWidth*val;
+ },
+
+ _redrawTable: function(table) {
+ table.hide(); //this is for opera < 9.5
+ if (ClientUILib.isSafari){
+ var tr = table.insertRow(0);
+ var td = tr.insertCell(0);
+ td.setAttribute("colspan", 5);
+ td.innerHTML = "safari-must-have-something-inserted-to-redraw-table";
+ table.deleteRow(tr.rowIndex);
+ }
+ table.show();
}
});
\ No newline at end of file
Modified: trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableHeader.js
===================================================================
--- trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableHeader.js 2008-11-07 12:57:22 UTC (rev 11054)
+++ trunk/ui/extendedDataTable/src/main/javascript/ClientUI/controls/datatable/ExtendedDataTableHeader.js 2008-11-07 12:58:36 UTC (rev 11055)
@@ -16,6 +16,11 @@
this.eventHeaderCellMouseOver = this.OnHeaderCellMouseOver.bindAsEventListener(this);
this.eventHeaderCellMouseOut = this.OnHeaderCellMouseOut.bindAsEventListener(this);
+ if (this.extDt.options.sortFunction) {
+ this.sortFct = this.extDt.options.sortFunction;
+ this.eventHeaderCellClicked = this.OnHeaderCellMouseClicked.bindAsEventListener(this);
+ }
+
var showMenuFct = this.extDt.options.showMenuFunction;
if (showMenuFct) {
this.showMenuFct = showMenuFct;
@@ -31,7 +36,25 @@
menuDiv.className = "extdt-menu-div-on";
},
- getCaption: function() {
+ OnHeaderCellMouseOut: function(event) {
+ var el = this.extDt._findParentElement(event, "th");
+ var menuDiv = $(el.id+"header:menuDiv");
+ menuDiv.className = "extdt-menu-div-out";
+ },
+
+ OnHeaderCellMouseClicked: function(event) {
+ //get column id
+ var el = this.extDt._findParentElement(event, "th");
+ var columnId = (el) ? el.id : null;
+
+ if (columnId && (columnId != "")){
+ this.extDt.showSplashScreen();
+ this.sortFct(event, columnId);
+ }
+ Event.stop(event);
+ },
+
+ getCaption: function() {
return this.caption;
},
@@ -44,18 +67,58 @@
}
},
- OnHeaderCellMouseOut: function(event) {
- var el = this.extDt._findParentElement(event, "th");
- var menuDiv = $(el.id+"header:menuDiv");
- menuDiv.className = "extdt-menu-div-out";
- },
+ addListeners: function(){
+ var columnCells = this.getColumnCells();
+ var l = columnCells.length;
+ for (var i = 0; i< l-1; i++) {
+ var headerChild = columnCells[i];
+ //remove listeners
+ Utils.DOM.Event.removeListeners(headerChild);
+ //add listeners
+ Utils.DOM.Event.observe(headerChild,'mouseover',this.eventHeaderCellMouseOver);
+ Utils.DOM.Event.observe(headerChild,'mouseout',this.eventHeaderCellMouseOut);
+
+ var isSortable = headerChild.getAttribute('sortable');
+ if ((isSortable) && (isSortable.indexOf('true') == 0)) {
+ var sortDiv = $(headerChild.id + ":sortDiv");
+ if (sortDiv){
+ Utils.DOM.Event.observe(sortDiv, 'click', this.eventHeaderCellClicked);
+ }
+ }
+ var headerChildChildren = headerChild.childElements();
+ if (headerChildChildren == null || headerChildChildren.size() == 0){
+ continue;
+ }
+ var sepSpan = headerChildChildren[2];
+ var menuImage = headerChildChildren[7];
+ //remove listeners
+ Utils.DOM.Event.removeListeners(menuImage);
+ Utils.DOM.Event.removeListeners(sepSpan);
+ //add listeners
+ Utils.DOM.Event.observe(menuImage,'click',this.menuImageMouseDown);
+ Utils.DOM.Event.observe(sepSpan, 'click', this.eventSepClick);
+ Utils.DOM.Event.observe(sepSpan, 'mousedown', this.eventSepMouseDown);
+ Utils.DOM.Event.observe(sepSpan, 'mousemove', this.eventSepMouseMove);
+ Utils.DOM.Event.observe(sepSpan, 'mouseup', this.eventSepMouseUp);
+ }
+ },
removeListeners: function() {
var columnCells = this.getColumnCells();
var l = columnCells.length;
for (var i = 0; i< l-1; i++) {
var headerChild = columnCells[i];
+ Utils.DOM.Event.removeListeners(headerChild);
+
+ var sortDiv = $(headerChild.id + ":sortDiv");
+ if (sortDiv){
+ Utils.DOM.Event.stopObserving(sortDiv, 'click');
+ }
+
var headerChildChildren = headerChild.childElements();
+ if (headerChildChildren == null || headerChildChildren.size() == 0){
+ continue;
+ }
var sepSpan = headerChildChildren[2];
var menuImage = headerChildChildren[7];
@@ -72,6 +135,7 @@
}
return sum;
},
+
createControl: function(elementId) {
if(!elementId) {
errMsg = "Invalid id specified for ExtendedDataTableGridHeader.";
@@ -85,8 +149,6 @@
}
},
-
-
parseTemplate: function(template) {
if(!template) {
return false;
@@ -187,11 +249,13 @@
adjustSeparators: function() {
var columnCells = this.getColumnCells();
var l = columnCells.length;
- this._redrawTable(this.extDt.table.getElement());
for (var i=0; i<l-1; i++) {
var headerChild = columnCells[i];
var headerNextChild = columnCells[i+1];
var headerChildChildren = headerChild.childElements();
+ if (headerChildChildren == null || headerChildChildren.size() == 0){
+ continue;
+ }
var sepSpan = headerChildChildren[2];
var headerRowHeight = this.headerRow.getHeight();
var headerRowY = this.headerRow.getY();
@@ -200,39 +264,18 @@
var dropSpanLeft = headerChildChildren[3];
var dropSpanRight = headerChildChildren[5];
var menuImage = headerChildChildren[7];
-
- //remove listeners
- Utils.DOM.Event.removeListeners(menuImage);
- Utils.DOM.Event.removeListeners(sepSpan);
- //add listeners
- Utils.DOM.Event.observe(menuImage,'click',this.menuImageMouseDown);
- Utils.DOM.Event.observe(sepSpan, 'click', this.eventSepClick);
- Utils.DOM.Event.observe(sepSpan, 'mousedown', this.eventSepMouseDown);
- Utils.DOM.Event.observe(sepSpan, 'mousemove', this.eventSepMouseMove, true);
- Utils.DOM.Event.observe(sepSpan, 'mouseup', this.eventSepMouseUp, true);
-
var spanLeft = headerNextChild.offsetLeft - sd;
- sepSpan.setStyle('height:'+headerRowHeight+'px');
- sepSpan.setStyle('top:'+headerRowY+'px');
- sepSpan.setStyle('left:'+spanLeft+'px');
- menuImage.setStyle('top:' + headerRowY + 'px');
+ sepSpan.setStyle({height: headerRowHeight+'px', top: headerRowY+'px', left: spanLeft+'px'});
+ menuImage.setStyle({top: headerRowY + 'px', left: (headerNextChild.offsetLeft-menuImage.offsetWidth - 1)+'px'});
//menuImage.setStyle('left:'+(spanLeft-menuImage.offsetWidth)+'px');
- menuImage.setStyle('left:'+(headerNextChild.offsetLeft-menuImage.offsetWidth - 1)+'px');
- dropSpanLeft.setStyle('top:'+headerRowY+'px');
- var w = headerChild.getWidth();
- dropSpanLeft.setStyle('left:'+ (headerChild.offsetLeft) +'px');
- dropSpanLeft.setStyle('height:'+headerRowHeight+'px');
- dropSpanLeft.setStyle('width:'+(w/2)+'px');
- dropSpanRight.setStyle('top:'+headerRowY+'px');
- dropSpanRight.setStyle('left:'+ (headerChild.offsetLeft + w/2) +'px');
- dropSpanRight.setStyle('height:'+headerRowHeight+'px');
- dropSpanRight.setStyle('width:'+(w/2)+'px');
+ var w = parseInt(headerChild.getWidth()/2);
+ dropSpanLeft.setStyle({top: headerRowY+'px', left: (headerChild.offsetLeft) +'px', height: headerRowHeight+'px', width: w+'px'});
+ dropSpanRight.setStyle({top: headerRowY+'px', left: (headerChild.offsetLeft + w) +'px', height: headerRowHeight+'px', width: w+'px'});
}
this.lastColWidth = this.extDt.getColumnWidth(this.getColumnsNumber()-1);
if (ClientUILib.isIE){
this.lastColWidth -= 15;
}
- this._redrawTable(this.extDt.tableB);
},
OnSepClick: function(event) {
@@ -318,6 +361,7 @@
}
}
this._hideSplitter();
+
},
OnSepMouseMove: function(event) {
@@ -339,14 +383,6 @@
this.columnSplitter.moveToX(finalX);
Event.stop(event);
}
- },
- _redrawTable: function(table) {
- table.hide(); //this is for opera < 9.5
- var tr = table.insertRow(0);
- var td = tr.insertCell(0);
- td.setAttribute("colspan", 5);
- td.innerHTML = "safari-must-have-something-inserted-to-redraw-table";
- table.deleteRow(tr.rowIndex);
- table.show();
- }
+ }
+
});
\ No newline at end of file
16 years, 10 months
JBoss Rich Faces SVN: r11054 - trunk/ui/extendedDataTable/src/main/resources/org/richfaces/renderkit/html/css.
by richfaces-svn-commits@lists.jboss.org
Author: pgolawski
Date: 2008-11-07 07:57:22 -0500 (Fri, 07 Nov 2008)
New Revision: 11054
Modified:
trunk/ui/extendedDataTable/src/main/resources/org/richfaces/renderkit/html/css/extendedDataTable.xcss
Log:
fix table to work without facet='header' for columns/table
changed styles for splash screen and menu image
Modified: trunk/ui/extendedDataTable/src/main/resources/org/richfaces/renderkit/html/css/extendedDataTable.xcss
===================================================================
--- trunk/ui/extendedDataTable/src/main/resources/org/richfaces/renderkit/html/css/extendedDataTable.xcss 2008-11-07 00:03:11 UTC (rev 11053)
+++ trunk/ui/extendedDataTable/src/main/resources/org/richfaces/renderkit/html/css/extendedDataTable.xcss 2008-11-07 12:57:22 UTC (rev 11054)
@@ -27,7 +27,7 @@
}
.extdt-menu-div-out {
- height: 23px;
+ height: 22px;
position: absolute;
width: 20px;
}
@@ -40,7 +40,7 @@
}
.extdt-menu-div-on {
- height: 23px;
+ height: 22px;
position: absolute;
width: 20px;
}
@@ -70,6 +70,7 @@
background-color: white;
background-repeat:no-repeat;
background-position:center;
+ z-index: 4;
}
.extdt-group-cell {
16 years, 10 months
JBoss Rich Faces SVN: r11053 - trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-06 19:03:11 -0500 (Thu, 06 Nov 2008)
New Revision: 11053
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
Log:
Calls changed to superclass calls
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java 2008-11-06 23:29:40 UTC (rev 11052)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java 2008-11-07 00:03:11 UTC (rev 11053)
@@ -424,21 +424,21 @@
switch (node.getNodeType()) {
case Node.TEXT_NODE:
String charData = ((CharacterData) node).getData();
- characters(createXMLString(charData), augs);
+ super.characters(createXMLString(charData), augs);
break;
case Node.COMMENT_NODE:
charData = ((CharacterData) node).getData();
- comment(createXMLString(charData), augs);
+ super.comment(createXMLString(charData), augs);
break;
case Node.CDATA_SECTION_NODE:
charData = ((CharacterData) node).getData();
- startCDATA(augs);
- characters(createXMLString(charData), augs);
- endCDATA(augs);
+ super.startCDATA(augs);
+ super.characters(createXMLString(charData), augs);
+ super.endCDATA(augs);
break;
@@ -459,7 +459,7 @@
}
- startElement(name, attrs, augs);
+ super.startElement(name, attrs, augs);
NodeList childNodes = node.getChildNodes();
int nodesLength = childNodes.getLength();
@@ -467,7 +467,7 @@
addNode(childNodes.item(i), prefix, uri, augs);
}
- endElement(name, augs);
+ super.endElement(name, augs);
break;
16 years, 10 months
JBoss Rich Faces SVN: r11052 - in trunk/framework/impl/src: main/java/org/ajax4jsf/io/parser and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-06 18:29:40 -0500 (Thu, 06 Nov 2008)
New Revision: 11052
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXEndElementEvent.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXStartElementEvent.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXTextEvent.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/HtmlParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java
trunk/framework/impl/src/test/java/org/ajax4jsf/io/parser/FastParserTest.java
Log:
Parsers: Head SAX Events changed to Node
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java 2008-11-06 19:11:19 UTC (rev 11051)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java 2008-11-06 23:29:40 UTC (rev 11052)
@@ -21,9 +21,7 @@
package org.ajax4jsf.context;
-import java.util.ArrayList;
-import java.util.List;
-
+import javax.faces.FacesException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -51,8 +49,7 @@
node = document.createElement("head");
document.appendChild(node);
} catch (ParserConfigurationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new FacesException(e.getLocalizedMessage(), e);
}
this.linkClass = linkClass;
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXEndElementEvent.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXEndElementEvent.java 2008-11-06 19:11:19 UTC (rev 11051)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXEndElementEvent.java 2008-11-06 23:29:40 UTC (rev 11052)
@@ -1,49 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.context;
-
-
-/**
- * Created 19.07.2008
- * @author Nick Belaevski
- * @since 3.2.2
- */
-
-public class SAXEndElementEvent {
-
- private String name;
-
- public SAXEndElementEvent(String name) {
- super();
-
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return "</" + name + ">";
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXStartElementEvent.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXStartElementEvent.java 2008-11-06 19:11:19 UTC (rev 11051)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXStartElementEvent.java 2008-11-06 23:29:40 UTC (rev 11052)
@@ -1,80 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.context;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created 19.07.2008
- * @author Nick Belaevski
- * @since 3.2.2
- */
-
-public class SAXStartElementEvent {
-
- private String name;
-
- private Map<String, String> attributes;
-
- /**
- * Constructor that parses string into map for usage in unit tests
- * @param name
- * @param attributesString
- */
- public SAXStartElementEvent(String name, String attributesString) {
- super();
- this.name = name;
-
- Map<String, String> attributes = null;
- if (attributesString != null) {
- attributes = new HashMap<String, String>();
- String[] split = attributesString.split(",");
- for (String s : split) {
- String[] split2 = s.split("=");
-
- attributes.put(split2[0], split2[1]);
- }
- }
-
- this.attributes = attributes;
- }
-
- public SAXStartElementEvent(String name, Map<String, String> attributes) {
- super();
- this.name = name;
- this.attributes = attributes;
- }
-
- public String getName() {
- return name;
- }
-
- public Map<String, String> getAttributes() {
- return attributes;
- }
-
- @Override
- public String toString() {
- return "<" + name + " " + attributes + " >";
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXTextEvent.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXTextEvent.java 2008-11-06 19:11:19 UTC (rev 11051)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/SAXTextEvent.java 2008-11-06 23:29:40 UTC (rev 11052)
@@ -1,46 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.context;
-
-/**
- * Created 19.07.2008
- * @author Nick Belaevski
- * @since 3.2.2
- */
-
-public class SAXTextEvent {
- private String text;
-
- public SAXTextEvent(String text) {
- super();
- this.text = text;
- }
-
- public String getText() {
- return text;
- }
-
- @Override
- public String toString() {
- return "'" + text + "'";
- }
-}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2008-11-06 19:11:19 UTC (rev 11051)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2008-11-06 23:29:40 UTC (rev 11052)
@@ -27,16 +27,19 @@
import java.io.Reader;
import java.io.Writer;
import java.lang.reflect.Field;
-import java.util.LinkedList;
-import java.util.Map;
-import org.ajax4jsf.context.SAXEndElementEvent;
-import org.ajax4jsf.context.SAXStartElementEvent;
-import org.ajax4jsf.context.SAXTextEvent;
import org.ajax4jsf.io.FastBufferReader;
import org.ajax4jsf.webapp.HtmlParser;
+import org.ajax4jsf.xml.serializer.Method;
+import org.ajax4jsf.xml.serializer.OutputPropertiesFactory;
+import org.ajax4jsf.xml.serializer.Serializer;
+import org.ajax4jsf.xml.serializer.SerializerFactory;
+import org.ajax4jsf.xml.serializer.TreeWalker;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
/**
* Simplified and fast HTML parsed - for find insertion point of <html><head>
@@ -57,7 +60,7 @@
private String mimeType;
- private Object[] headEvents;
+ private Node[] headEvents;
public void parse(Reader in, Writer out) throws IOException {
boolean haveHtml = false;
@@ -183,62 +186,25 @@
}
if (headEvents != null && headEvents.length > 0) {
- LinkedList<Boolean> closedStack = new LinkedList<Boolean>();
+ Serializer serializer = SerializerFactory.getSerializer(
+ OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML));
- for (Object event : headEvents) {
- if (event instanceof SAXStartElementEvent) {
- SAXStartElementEvent startElementEvent = (SAXStartElementEvent) event;
+ serializer.setWriter(out);
+
+ ContentHandler contentHandler = serializer.asContentHandler();
+ TreeWalker walker = new TreeWalker(contentHandler);
- if (!closedStack.isEmpty() && Boolean.FALSE.equals(closedStack.peek())) {
- out.write('>');
- closedStack.set(0, Boolean.TRUE);
- }
-
- out.write('<');
- out.write(startElementEvent.getName());
-
- for (Map.Entry<String, String> entry : startElementEvent.getAttributes().entrySet()) {
- String name = entry.getKey();
- String value = entry.getValue();
- out.write(' ');
- out.write(name);
- out.write("='");
- out.write(value);
- out.write('\'');
- }
-
- closedStack.addFirst(Boolean.FALSE);
- } else if (event instanceof SAXTextEvent) {
- SAXTextEvent textEvent = (SAXTextEvent) event;
-
- if (!closedStack.isEmpty() && Boolean.FALSE.equals(closedStack.peek())) {
- out.write('>');
- closedStack.set(0, Boolean.TRUE);
- }
-
- out.write(textEvent.getText());
-
- } else if (event instanceof SAXEndElementEvent) {
- SAXEndElementEvent endElementEvent = (SAXEndElementEvent) event;
- String elementName = endElementEvent.getName();
-
- if (Boolean.FALSE.equals(closedStack.removeFirst())) {
- if ("script".equals(elementName)) {
- out.write('>');
- out.write("</");
- out.write(elementName);
- out.write('>');
- } else {
- out.write(" />");
- }
- } else {
- out.write("</");
- out.write(elementName);
- out.write('>');
- }
- } else {
- throw new IllegalArgumentException();
+ try {
+ contentHandler.startDocument();
+
+ for (Node node : headEvents) {
+ walker.traverseFragment(node);
}
+
+ contentHandler.endDocument();
+
+ } catch (SAXException e) {
+ throw new IOException(e.getMessage());
}
}
@@ -286,7 +252,7 @@
return true;
}
- public void setHeadEvents(Object[] events) {
+ public void setHeadNodes(Node[] events) {
this.headEvents = events;
}
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2008-11-06 19:11:19 UTC (rev 11051)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2008-11-06 23:29:40 UTC (rev 11052)
@@ -45,6 +45,7 @@
import org.ajax4jsf.renderkit.AjaxContainerRenderer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Node;
public abstract class BaseXMLFilter {
public static final String AJAX_EXPIRED = "Ajax-Expired";
@@ -202,7 +203,7 @@
}
String viewId = (String) request
.getAttribute(AjaxViewHandler.VIEW_ID_KEY);
- Object[] headEvents = (Object[]) request
+ Node[] headEvents = (Node[]) request
.getAttribute(AjaxContext.HEAD_EVENTS_PARAMETER);
HtmlParser parser = null;
@@ -359,7 +360,7 @@
try {
// Setup scripts and styles
- parser.setHeadEvents(headEvents);
+ parser.setHeadNodes(headEvents);
// Process parsing.
long startTimeMills = System.currentTimeMillis();
servletResponseWrapper.parseContent(output, parser);
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/HtmlParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/HtmlParser.java 2008-11-06 19:11:19 UTC (rev 11051)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/HtmlParser.java 2008-11-06 23:29:40 UTC (rev 11052)
@@ -26,6 +26,8 @@
import java.io.Reader;
import java.io.Writer;
+import org.w3c.dom.Node;
+
public interface HtmlParser {
public abstract void parseHtml(InputStream input, Writer output)
@@ -48,7 +50,7 @@
*/
public abstract void setMoveElements(boolean move);
- public abstract void setHeadEvents(Object[] events);
+ public abstract void setHeadNodes(Node[] events);
public abstract void setDoctype(String doctype);
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java 2008-11-06 19:11:19 UTC (rev 11051)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java 2008-11-06 23:29:40 UTC (rev 11052)
@@ -26,8 +26,6 @@
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StringReader;
-import java.util.LinkedList;
-import java.util.Map;
import java.util.Properties;
import javax.servlet.ServletException;
@@ -36,9 +34,6 @@
import javax.xml.parsers.ParserConfigurationException;
import org.ajax4jsf.application.AjaxViewHandler;
-import org.ajax4jsf.context.SAXEndElementEvent;
-import org.ajax4jsf.context.SAXStartElementEvent;
-import org.ajax4jsf.context.SAXTextEvent;
import org.ajax4jsf.webapp.BaseXMLFilter;
import org.ajax4jsf.webapp.HtmlParser;
import org.ajax4jsf.xml.serializer.Method;
@@ -65,8 +60,12 @@
import org.cyberneko.html.filters.Purifier;
import org.cyberneko.html.filters.Writer;
import org.cyberneko.html.parsers.DOMFragmentParser;
+import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -94,7 +93,7 @@
private DocumentFragment fragment = null;
- private Object[] headEvents;
+ private Node[] headEvents;
private String _viewState;
@@ -416,51 +415,75 @@
super.endElement(element, augs);
}
- private void insertResources(String prefix, String uri) {
- headParsed = true;
-
- if (headEvents != null && headEvents.length > 0) {
- Augmentations augs = null;
- LinkedList<QName> stack = new LinkedList<QName>();
- int depth = 0;
+ private XMLString createXMLString(String string) {
+ char[] cs = string.toCharArray();
+ return new XMLString(cs, 0, cs.length);
+ }
+
+ private void addNode(Node node, String prefix, String uri, Augmentations augs) {
+ switch (node.getNodeType()) {
+ case Node.TEXT_NODE:
+ String charData = ((CharacterData) node).getData();
+ characters(createXMLString(charData), augs);
+
+ break;
- for (Object event : headEvents) {
- if (event instanceof SAXStartElementEvent) {
- SAXStartElementEvent startElementEvent = (SAXStartElementEvent) event;
+ case Node.COMMENT_NODE:
+ charData = ((CharacterData) node).getData();
+ comment(createXMLString(charData), augs);
+
+ break;
+
+ case Node.CDATA_SECTION_NODE:
+ charData = ((CharacterData) node).getData();
+ startCDATA(augs);
+ characters(createXMLString(charData), augs);
+ endCDATA(augs);
- String elementName = startElementEvent.getName();
- QName element = new QName(prefix, elementName, elementName, uri);
- stack.add(element);
+ break;
- XMLAttributes attrs = new XMLAttributesImpl();
- for (Map.Entry<String, String> entry : startElementEvent.getAttributes().entrySet()) {
-
- String name = entry.getKey();
- String value = entry.getValue();
- attrs.addAttribute(new QName(prefix, name, name, uri), "CDATA", value);
- }
+ case Node.ELEMENT_NODE:
+ QName name = new QName(prefix, node.getNodeName(), node.getNodeName(), uri);
+ XMLAttributes attrs = new XMLAttributesImpl();
+
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes != null) {
+ int l = attributes.getLength();
+
+ for (int i = 0; i < l; i++) {
+ Node attributeNode = attributes.item(i);
+ attrs.addAttribute(new QName(prefix, attributeNode.getNodeName(),
+ attributeNode.getNodeName(), uri), "CDATA",
+ attributeNode.getNodeValue());
+ }
+
+ }
- if (depth++ == 0) {
- augs = new HTMLAugmentations();
- }
+ startElement(name, attrs, augs);
- super.startElement(element, attrs, augs);
- } else if (event instanceof SAXTextEvent) {
- SAXTextEvent textEvent = (SAXTextEvent) event;
+ NodeList childNodes = node.getChildNodes();
+ int nodesLength = childNodes.getLength();
+ for (int i = 0; i < nodesLength; i++) {
+ addNode(childNodes.item(i), prefix, uri, augs);
+ }
+
+ endElement(name, augs);
+
+ break;
+
+ default:
+ throw new IllegalArgumentException("Node type " + node.getNodeType() + " is not supported!");
+ }
+ }
+
+ private void insertResources(String prefix, String uri) {
+ headParsed = true;
+
+ if (headEvents != null && headEvents.length > 0) {
+ Augmentations augs = new HTMLAugmentations();
- char[] ch = textEvent.getText().toCharArray();
-
- super.characters(new XMLString(ch, 0, ch.length), augs);
-
- } else if (event instanceof SAXEndElementEvent) {
- super.endElement(stack.removeLast(), augs);
-
- if (--depth == 0) {
- augs = null;
- }
- } else {
- throw new IllegalArgumentException();
- }
+ for (Node node : headEvents) {
+ addNode(node, prefix, uri, augs);
}
}
}
@@ -774,7 +797,7 @@
return false;
}
- public void setHeadEvents(Object[] headEvents) {
+ public void setHeadNodes(Node[] headEvents) {
this.headEvents = headEvents;
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java 2008-11-06 19:11:19 UTC (rev 11051)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java 2008-11-06 23:29:40 UTC (rev 11052)
@@ -27,14 +27,10 @@
import java.io.Reader;
import java.io.Writer;
import java.util.LinkedList;
-import java.util.Map;
import java.util.Properties;
import org.ajax4jsf.Messages;
import org.ajax4jsf.application.AjaxViewHandler;
-import org.ajax4jsf.context.SAXEndElementEvent;
-import org.ajax4jsf.context.SAXStartElementEvent;
-import org.ajax4jsf.context.SAXTextEvent;
import org.ajax4jsf.org.w3c.tidy.Lexer;
import org.ajax4jsf.org.w3c.tidy.Node;
import org.ajax4jsf.org.w3c.tidy.Tidy;
@@ -43,8 +39,11 @@
import org.ajax4jsf.webapp.HtmlParser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Attr;
+import org.w3c.dom.CharacterData;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
/**
@@ -64,7 +63,7 @@
private String _outputEncoding;
- private Object[] headEvents;
+ private org.w3c.dom.Node[] headEvents;
private static final String[] _htmlTypes = { "text/html" };
@@ -88,6 +87,63 @@
tidy.setMessageListener(this);
}
+ private org.w3c.dom.Node importNode(Document document, org.w3c.dom.Node node, boolean recursive) {
+
+ switch (node.getNodeType()) {
+ case org.w3c.dom.Node.ELEMENT_NODE:
+ Element element = document.createElement(node.getNodeName());
+
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes != null) {
+ int length = attributes.getLength();
+ for (int i = 0; i < length; i++) {
+ element.setAttributeNode((Attr) importNode(
+ document, attributes.item(i), recursive));
+ }
+ }
+
+ if (recursive) {
+ NodeList childNodes = node.getChildNodes();
+ if (childNodes != null) {
+ int length = childNodes.getLength();
+ for (int i = 0; i < length; i++) {
+ element.appendChild(importNode(document, childNodes.item(i), recursive));
+ }
+ }
+ }
+
+ return element;
+
+ case org.w3c.dom.Node.ATTRIBUTE_NODE:
+ Attr attr = document.createAttribute(node.getNodeName());
+ attr.setNodeValue(node.getNodeValue());
+
+ return attr;
+
+ case org.w3c.dom.Node.TEXT_NODE:
+ String charData = ((CharacterData) node).getData();
+
+ return document.createTextNode(charData);
+
+ case org.w3c.dom.Node.CDATA_SECTION_NODE:
+ charData = ((CharacterData) node).getData();
+
+ return document.createCDATASection(charData);
+ case org.w3c.dom.Node.COMMENT_NODE:
+ charData = ((CharacterData) node).getData();
+
+ return document.createComment(charData);
+ case org.w3c.dom.Node.DOCUMENT_FRAGMENT_NODE:
+ case org.w3c.dom.Node.DOCUMENT_NODE:
+ case org.w3c.dom.Node.ENTITY_NODE:
+ case org.w3c.dom.Node.ENTITY_REFERENCE_NODE:
+ case org.w3c.dom.Node.NOTATION_NODE:
+ case org.w3c.dom.Node.PROCESSING_INSTRUCTION_NODE:
+ default:
+ throw new IllegalArgumentException("Unsupported node type: " + node.getNodeType());
+ }
+ }
+
/*
* (non-Javadoc)
*
@@ -163,33 +219,9 @@
child = null;
}
- LinkedList<Element> nodesStack = new LinkedList<Element>();
-
- for (Object event : headEvents) {
- if (event instanceof SAXStartElementEvent) {
- SAXStartElementEvent startElement = (SAXStartElementEvent) event;
-
- Element element = document.createElement(startElement.getName());
- for (Map.Entry<String, String> attributeEntry : startElement.getAttributes().entrySet()) {
- element.setAttribute(attributeEntry.getKey(), attributeEntry.getValue());
- }
-
- if (nodesStack.isEmpty()) {
- head.insertBefore(element, child);
- } else {
- nodesStack.peek().appendChild(element);
- }
- nodesStack.addFirst(element);
-
- } else if (event instanceof SAXTextEvent) {
- SAXTextEvent textEvent = (SAXTextEvent) event;
-
- nodesStack.peek().appendChild(document.createTextNode(textEvent.getText()));
-
- } else if (event instanceof SAXEndElementEvent) {
- nodesStack.removeFirst();
- } else {
- throw new IllegalArgumentException();
+ if (headEvents != null) {
+ for (org.w3c.dom.Node node : headEvents) {
+ head.insertBefore(importNode(document, node, true), child);
}
}
}
@@ -393,7 +425,7 @@
_viewState = viewState;
}
- public void setHeadEvents(Object[] headEvents) {
+ public void setHeadNodes(org.w3c.dom.Node[] headEvents) {
this.headEvents = headEvents;
}
}
Modified: trunk/framework/impl/src/test/java/org/ajax4jsf/io/parser/FastParserTest.java
===================================================================
--- trunk/framework/impl/src/test/java/org/ajax4jsf/io/parser/FastParserTest.java 2008-11-06 19:11:19 UTC (rev 11051)
+++ trunk/framework/impl/src/test/java/org/ajax4jsf/io/parser/FastParserTest.java 2008-11-06 23:29:40 UTC (rev 11052)
@@ -25,10 +25,13 @@
import java.io.StringReader;
import java.io.StringWriter;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import junit.framework.TestCase;
-import org.ajax4jsf.context.SAXEndElementEvent;
-import org.ajax4jsf.context.SAXStartElementEvent;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
public class FastParserTest extends TestCase {
@@ -36,7 +39,7 @@
/*
* Test method for 'org.ajax4jsf.io.parser.FastHtmlParser.parse(Reader, Writer)'
*/
- public void testParse() {
+ public void testParse() throws Exception {
String toParse="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
@@ -58,7 +61,7 @@
assertTrue(indexOf3>indexOf2);
}
- public void testParseWithHead() {
+ public void testParseWithHead() throws Exception {
String toParse="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
@@ -73,7 +76,7 @@
assertTrue(resultString.indexOf("</head>")==resultString.lastIndexOf("</head>"));
}
- public void testParseWithHeadTitle() {
+ public void testParseWithHeadTitle() throws Exception {
String toParse="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
@@ -95,7 +98,7 @@
assertTrue(resultString.indexOf("</head>")>resultString.lastIndexOf("<link"));
}
- public void testParseWithHeadTitleMeta() {
+ public void testParseWithHeadTitleMeta() throws Exception {
String toParse="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
@@ -118,22 +121,27 @@
assertTrue(resultString.indexOf("<meta")>resultString.lastIndexOf("</script"));
assertTrue(resultString.indexOf("<meta")>resultString.lastIndexOf("<link"));
}
-
+
/**
* @param toParse
* @return
*/
- private String parseString(String toParse) {
+ private String parseString(String toParse) throws Exception {
FastHtmlParser parser = new FastHtmlParser();
StringReader in = new StringReader(toParse);
StringWriter out = new StringWriter();
- Object[] headEvents = new Object[] {
- new SAXStartElementEvent("script", "src=/some/script.js"),
- new SAXEndElementEvent("script"),
- new SAXStartElementEvent("link", "href=/some/script.js"),
- new SAXEndElementEvent("link")
- };
- parser.setHeadEvents(headEvents);
+ Document document = DocumentBuilderFactory.newInstance().
+ newDocumentBuilder().newDocument();
+
+ Element scriptNode = document.createElement("script");
+ scriptNode.setAttribute("src", "/some/script.js");
+
+ Element linkNode = document.createElement("link");
+ linkNode.setAttribute("href", "/some/script.css");
+
+ parser.setHeadNodes(new Node[] {
+ scriptNode, linkNode
+ });
try {
parser.parse(in,out);
} catch (IOException e) {
16 years, 10 months
JBoss Rich Faces SVN: r11051 - trunk/framework/impl/src/main/java/org/ajax4jsf/context.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-11-06 14:11:19 -0500 (Thu, 06 Nov 2008)
New Revision: 11051
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
Log:
SAX Events changed to Node
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java 2008-11-06 18:16:58 UTC (rev 11050)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java 2008-11-06 19:11:19 UTC (rev 11051)
@@ -22,11 +22,16 @@
package org.ajax4jsf.context;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
@@ -34,19 +39,29 @@
class ResponseWriterContentHandler implements ContentHandler {
- List<Object> events = new ArrayList<Object>();
-
private String linkClass;
+ private Node node;
+
public ResponseWriterContentHandler(String linkClass) {
super();
+
+ try {
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+ node = document.createElement("head");
+ document.appendChild(node);
+ } catch (ParserConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
this.linkClass = linkClass;
}
public void characters(char[] ch, int start, int length)
throws SAXException {
- events.add(new SAXTextEvent(new String(ch, start, length)));
+ node.appendChild(node.getOwnerDocument().createTextNode(new String(ch, start, length)));
}
public void endDocument() throws SAXException {
@@ -54,7 +69,8 @@
public void endElement(String uri, String localName, String name)
throws SAXException {
- events.add(new SAXEndElementEvent(localName));
+
+ node = node.getParentNode();
}
public void endPrefixMapping(String prefix) throws SAXException {
@@ -84,23 +100,35 @@
public void startElement(String uri, String localName,
String name, Attributes atts) throws SAXException {
- Map<String, String> attsMap = new HashMap<String, String>(atts.getLength());
+ Document document = node.getOwnerDocument();
+ Element element = document.createElement(localName);
+
int length = atts.getLength();
for (int i = 0; i < length; i++) {
- attsMap.put(atts.getLocalName(i), atts.getValue(i));
+ element.setAttribute(atts.getLocalName(i), atts.getValue(i));
}
if (HTML.LINK_ELEMENT.equals(localName)) {
- attsMap.put(HTML.class_ATTRIBUTE, linkClass);
+ element.setAttribute(HTML.class_ATTRIBUTE, linkClass);
}
-
- events.add(new SAXStartElementEvent(localName, attsMap));
+
+ node = node.appendChild(element);
}
public void startPrefixMapping(String prefix, String uri)
throws SAXException {
throw new UnsupportedOperationException();
}
+
+ public Node[] getNodes() {
+ NodeList childNodes = node.getChildNodes();
+ Node[] list = new Node[childNodes.getLength()];
+ for (int i = 0; i < list.length; i++) {
+ list[i] = childNodes.item(i);
+ }
+
+ return list;
+ }
}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2008-11-06 18:16:58 UTC (rev 11050)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2008-11-06 19:11:19 UTC (rev 11051)
@@ -62,6 +62,7 @@
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
import org.richfaces.skin.SkinNotFoundException;
+import org.w3c.dom.Node;
/**
* @author Nick Belaevski
@@ -86,7 +87,7 @@
private RenderKit renderKit;
- private Object[] result = null;
+ private Node[] result = null;
private static final String EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY = ViewResources.class.getName() + "EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY";
@@ -147,13 +148,13 @@
this.extendedSkinningAllowed = extendedSkinningAllowed;
}
- public Object getHeadEvents() {
- List componentList = componentWriter.getEventsList();
- List userList = userWriter.getEventsList();
+ public Node[] getHeadEvents() {
+ Node[] componentResourceNodes = componentWriter.getNodes();
+ Node[] userResourceNodes = userWriter.getNodes();
- result = new Object[componentList.size() + userList.size()];
- componentList.toArray(result);
- System.arraycopy(userList.toArray(), 0, result, componentList.size(), userList.size());
+ result = new Node[componentResourceNodes.length + userResourceNodes.length];
+ System.arraycopy(componentResourceNodes, 0, result, 0, componentResourceNodes.length);
+ System.arraycopy(userResourceNodes, 0, result, componentResourceNodes.length, userResourceNodes.length);
return result;
}
@@ -190,8 +191,8 @@
class HeadResponseWriter extends SAXResponseWriter {
- public List getEventsList() {
- return ((ResponseWriterContentHandler) getXmlConsumer()).events;
+ public Node[] getNodes() {
+ return ((ResponseWriterContentHandler) getXmlConsumer()).getNodes();
}
public HeadResponseWriter(String linkClass) {
16 years, 10 months