Author: nbelaevski
Date: 2009-07-07 09:08:56 -0400 (Tue, 07 Jul 2009)
New Revision: 14808
Added:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java
Removed:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXEndElementEvent.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXStartElementEvent.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXTextEvent.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java
Modified:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/event/EventsQueue.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/exception/FileUploadException.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/ByteBuffer.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/CharBuffer.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/FastBufferOutputStream.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/FastBufferWriter.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/SAXResponseWriter.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/XMLResponseWriterState.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/javascript/JSMin.java
Log:
Reintegrated community/3.3.x into JSF 2.0 branch
Deleted:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXEndElementEvent.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXEndElementEvent.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXEndElementEvent.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -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:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXStartElementEvent.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXStartElementEvent.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXStartElementEvent.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -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:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXTextEvent.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXTextEvent.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/SAXTextEvent.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -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:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -23,9 +23,12 @@
import java.io.IOException;
import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -42,6 +45,7 @@
import javax.faces.render.RenderKitFactory;
import javax.faces.render.Renderer;
+import org.ajax4jsf.component.QueueRegistry;
import org.ajax4jsf.io.SAXResponseWriter;
import org.ajax4jsf.renderkit.HeaderResourceProducer;
import org.ajax4jsf.renderkit.HeaderResourceProducer2;
@@ -62,6 +66,8 @@
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
import org.richfaces.skin.SkinNotFoundException;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
/**
* @author Nick Belaevski
@@ -86,7 +92,7 @@
private RenderKit renderKit;
- private Object[] result = null;
+ private Node[] headNodes = null;
private static final String EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY =
ViewResources.class.getName() + "EXTENDED_SKINNING_ON_NO_SCRIPTS_INFO_KEY";
@@ -147,16 +153,69 @@
this.extendedSkinningAllowed = extendedSkinningAllowed;
}
- public Object getHeadEvents() {
- List componentList = componentWriter.getEventsList();
- List userList = userWriter.getEventsList();
+ private static String SCRIPT = HTML.SCRIPT_ELEM;
+ private static String SCRIPT_UC = SCRIPT.toUpperCase(Locale.US);
+
+ private static String SRC = HTML.src_ATTRIBUTE;
+ private static String SRC_UC = SRC.toUpperCase(Locale.US);
- result = new Object[componentList.size() + userList.size()];
- componentList.toArray(result);
- System.arraycopy(userList.toArray(), 0, result, componentList.size(),
userList.size());
-
- return result;
+ private void mergeHeadResourceNode(List<Node> nodes, Set<String>
renderedScripts, Node node) {
+ boolean shouldAdd = true;
+
+ String nodeName = node.getNodeName();
+ if (SCRIPT.equals(nodeName) || SCRIPT_UC.equals(nodeName)) {
+ if (node.getFirstChild() == null) {
+ //no text content etc.
+
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes != null) {
+ Node item = attributes.getNamedItem(SRC);
+ if (item == null) {
+ attributes.getNamedItem(SRC_UC);
+ }
+
+ if (item != null) {
+ String src = item.getNodeValue();
+ if (src != null) {
+ if (renderedScripts.contains(src)) {
+ shouldAdd = false;
+ } else {
+ renderedScripts.add(src);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (shouldAdd) {
+ nodes.add(node);
+ }
}
+
+ private Node[] mergeHeadResourceNodes() {
+ List<Node> result = new ArrayList<Node>();
+
+ Set<String> scripts = new HashSet<String>();
+
+ for (Node node : componentWriter.getNodes()) {
+ mergeHeadResourceNode(result, scripts, node);
+ }
+
+ for (Node node : userWriter.getNodes()) {
+ mergeHeadResourceNode(result, scripts, node);
+ }
+
+ return result.toArray(new Node[result.size()]);
+ }
+
+ public Node[] getHeadEvents() {
+ if (headNodes == null) {
+ headNodes = mergeHeadResourceNodes();
+ }
+
+ return headNodes;
+ }
private static final Log log = LogFactory.getLog(ViewResources.class);
@@ -170,6 +229,8 @@
public static final String SKINNING_STYLES_PATH =
"/org/richfaces/renderkit/html/css/";
+ public static final String QUEUE_SCRIPT_RESOURCE =
"org.ajax4jsf.renderkit.html.scripts.QueueScript";
+
private boolean extendedSkinningAllowed;
private boolean processScripts;
@@ -190,8 +251,8 @@
class HeadResponseWriter extends SAXResponseWriter {
- public List getEventsList() {
- return ((ResponseWriterContentHandler) getXmlConsumer()).events;
+ public Node[] getNodes() {
+ return ((ResponseWriterContentHandler) getXmlConsumer()).getNodes();
}
public HeadResponseWriter(String linkClass) {
@@ -371,7 +432,9 @@
skinExtendedStyleSheetUri = (String) skin.getParameter(context,
Skin.extendedStyleSheet);
} catch (SkinNotFoundException e) {
- log.warn("Current Skin is not found", e);
+ if (log.isWarnEnabled()) {
+ log.warn("Current Skin is not found", e);
+ }
}
resourceBuilder = InternetResourceBuilder.getInstance();
@@ -452,6 +515,16 @@
context.setResponseWriter(componentWriter);
+ QueueRegistry queueRegistry = QueueRegistry.getInstance(context);
+ if (Boolean.valueOf(getInitParameterValue(context,
"org.richfaces.queue.global.enabled"))) {
+ queueRegistry.setShouldCreateDefaultGlobalQueue();
+ }
+
+ if (queueRegistry.hasQueuesToEncode()) {
+ InternetResource queueScriptResource =
resourceBuilder.getResource(QUEUE_SCRIPT_RESOURCE);
+ queueScriptResource.encode(context, null);
+ }
+
// Append Skin StyleSheet after a
if (null != skinStyleSheetUri) {
String resourceURL = context.getApplication()
@@ -506,11 +579,13 @@
stringWriter.flush();
- log.info("Extended skinning is on and NONE scripts loading strategy was
detected. " +
- "Do not forget that one of " +
InternetResourceBuilder.SKINNING_SCRIPT + " or " +
- InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT + " resources should be
presented " +
- "on the page together with the following code: \n" +
stringWriter.getBuffer().toString() +
- "\nfor extended level of skinning to work.");
+ if (log.isInfoEnabled()) {
+ log.info("Extended skinning is on and NONE scripts loading strategy was
detected. " +
+ "Do not forget that one of " +
InternetResourceBuilder.SKINNING_SCRIPT + " or " +
+ InternetResourceBuilder.COMMON_FRAMEWORK_SCRIPT + " resources should be
presented " +
+ "on the page together with the following code: \n" +
stringWriter.getBuffer().toString() +
+ "\nfor extended level of skinning to work.");
+ }
} finally {
if (writer != null) {
context.setResponseWriter(writer);
Copied: branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el (from rev 14238,
trunk/framework/impl/src/main/java/org/ajax4jsf/el)
Deleted:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java 2009-05-18
14:55:17 UTC (rev 14238)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -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.ajax4jsf.el;
-
-import java.util.Locale;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.el.FunctionMapper;
-import javax.el.VariableMapper;
-
-/**
- * @author asmirnov
- *
- */
-public class ELContextWrapper extends ELContext {
-
- private final ELContext parent;
-
- private final ELResolver resolver;
-
- /**
- * @param parent
- */
- public ELContextWrapper(ELContext parent,ELResolver resolver) {
- super();
- this.resolver = resolver;
- this.parent = parent;
- }
-
- /* (non-Javadoc)
- * @see javax.el.ELContext#getELResolver()
- */
- @Override
- public ELResolver getELResolver() {
- return resolver;
- }
-
- /**
- * @return
- * @see javax.el.ELContext#getFunctionMapper()
- */
- public FunctionMapper getFunctionMapper() {
- return parent.getFunctionMapper();
- }
-
- /**
- * @return
- * @see javax.el.ELContext#getVariableMapper()
- */
- public VariableMapper getVariableMapper() {
- return parent.getVariableMapper();
- }
-
- /**
- * @param key
- * @return
- * @see javax.el.ELContext#getContext(java.lang.Class)
- */
- public Object getContext(Class key) {
- return parent.getContext(key);
- }
-
- /**
- * @param key
- * @param contextObject
- * @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
- */
- public void putContext(Class key, Object contextObject) {
- parent.putContext(key, contextObject);
- }
-
- public Locale getLocale() {
- return parent.getLocale();
- }
-
- public void setLocale(Locale locale) {
- parent.setLocale(locale);
- }
-}
Copied: branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java
(from rev 14238,
trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java)
===================================================================
--- branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java
(rev 0)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -0,0 +1,98 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.ajax4jsf.el;
+
+import java.util.Locale;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.VariableMapper;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ELContextWrapper extends ELContext {
+
+ private final ELContext parent;
+
+ private final ELResolver resolver;
+
+ /**
+ * @param parent
+ */
+ public ELContextWrapper(ELContext parent,ELResolver resolver) {
+ super();
+ this.resolver = resolver;
+ this.parent = parent;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ELContext#getELResolver()
+ */
+ @Override
+ public ELResolver getELResolver() {
+ return resolver;
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getFunctionMapper()
+ */
+ public FunctionMapper getFunctionMapper() {
+ return parent.getFunctionMapper();
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getVariableMapper()
+ */
+ public VariableMapper getVariableMapper() {
+ return parent.getVariableMapper();
+ }
+
+ /**
+ * @param key
+ * @return
+ * @see javax.el.ELContext#getContext(java.lang.Class)
+ */
+ public Object getContext(Class key) {
+ return parent.getContext(key);
+ }
+
+ /**
+ * @param key
+ * @param contextObject
+ * @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
+ */
+ public void putContext(Class key, Object contextObject) {
+ parent.putContext(key, contextObject);
+ }
+
+ public Locale getLocale() {
+ return parent.getLocale();
+ }
+
+ public void setLocale(Locale locale) {
+ parent.setLocale(locale);
+ }
+}
Deleted:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java 2009-05-18
14:55:17 UTC (rev 14238)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -1,109 +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.el;
-
-import java.beans.FeatureDescriptor;
-import java.util.Iterator;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-
-public class ELResolverWrapper extends ELResolver {
-
- public ELResolverWrapper(ELResolver resolver) {
- super();
- this.resolver = resolver;
- }
-
- private ELResolver resolver;
-
- /**
- * @param context
- * @param base
- * @return
- * @see javax.el.ELResolver#getCommonPropertyType(javax.el.ELContext, java.lang.Object)
- */
- public Class<?> getCommonPropertyType(ELContext context, Object base) {
- return resolver.getCommonPropertyType(context, base);
- }
-
- /**
- * @param context
- * @param base
- * @return
- * @see javax.el.ELResolver#getFeatureDescriptors(javax.el.ELContext, java.lang.Object)
- */
- public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
- Object base) {
- return resolver.getFeatureDescriptors(context, base);
- }
-
- /**
- * @param context
- * @param base
- * @param property
- * @return
- * @see javax.el.ELResolver#getType(javax.el.ELContext, java.lang.Object,
java.lang.Object)
- */
- public Class<?> getType(ELContext context, Object base, Object property) {
- return resolver.getType(context, base, property);
- }
-
- /**
- * @param context
- * @param base
- * @param property
- * @return
- * @see javax.el.ELResolver#getValue(javax.el.ELContext, java.lang.Object,
java.lang.Object)
- */
- public Object getValue(ELContext context, Object base, Object property) {
- return resolver.getValue(context, base, property);
- }
-
- /**
- * @param context
- * @param base
- * @param property
- * @return
- * @see javax.el.ELResolver#isReadOnly(javax.el.ELContext, java.lang.Object,
java.lang.Object)
- */
- public boolean isReadOnly(ELContext context, Object base, Object property) {
- return resolver.isReadOnly(context, base, property);
- }
-
- /**
- * @param context
- * @param base
- * @param property
- * @param value
- * @see javax.el.ELResolver#setValue(javax.el.ELContext, java.lang.Object,
java.lang.Object, java.lang.Object)
- */
- public void setValue(ELContext context, Object base, Object property,
- Object value) {
- resolver.setValue(context, base, property, value);
- }
-}
Copied:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java (from
rev 14238, trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java)
===================================================================
--- branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java
(rev 0)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -0,0 +1,109 @@
+/**
+ * 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.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class ELResolverWrapper extends ELResolver {
+
+ public ELResolverWrapper(ELResolver resolver) {
+ super();
+ this.resolver = resolver;
+ }
+
+ private ELResolver resolver;
+
+ /**
+ * @param context
+ * @param base
+ * @return
+ * @see javax.el.ELResolver#getCommonPropertyType(javax.el.ELContext, java.lang.Object)
+ */
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ return resolver.getCommonPropertyType(context, base);
+ }
+
+ /**
+ * @param context
+ * @param base
+ * @return
+ * @see javax.el.ELResolver#getFeatureDescriptors(javax.el.ELContext, java.lang.Object)
+ */
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
+ Object base) {
+ return resolver.getFeatureDescriptors(context, base);
+ }
+
+ /**
+ * @param context
+ * @param base
+ * @param property
+ * @return
+ * @see javax.el.ELResolver#getType(javax.el.ELContext, java.lang.Object,
java.lang.Object)
+ */
+ public Class<?> getType(ELContext context, Object base, Object property) {
+ return resolver.getType(context, base, property);
+ }
+
+ /**
+ * @param context
+ * @param base
+ * @param property
+ * @return
+ * @see javax.el.ELResolver#getValue(javax.el.ELContext, java.lang.Object,
java.lang.Object)
+ */
+ public Object getValue(ELContext context, Object base, Object property) {
+ return resolver.getValue(context, base, property);
+ }
+
+ /**
+ * @param context
+ * @param base
+ * @param property
+ * @return
+ * @see javax.el.ELResolver#isReadOnly(javax.el.ELContext, java.lang.Object,
java.lang.Object)
+ */
+ public boolean isReadOnly(ELContext context, Object base, Object property) {
+ return resolver.isReadOnly(context, base, property);
+ }
+
+ /**
+ * @param context
+ * @param base
+ * @param property
+ * @param value
+ * @see javax.el.ELResolver#setValue(javax.el.ELContext, java.lang.Object,
java.lang.Object, java.lang.Object)
+ */
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) {
+ resolver.setValue(context, base, property, value);
+ }
+}
Modified:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/event/EventsQueue.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/event/EventsQueue.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/event/EventsQueue.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -1,5 +1,22 @@
/**
- *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.ajax4jsf.event;
Modified:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/exception/FileUploadException.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/exception/FileUploadException.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/exception/FileUploadException.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -1,3 +1,24 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
package org.ajax4jsf.exception;
/**
Modified: branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/ByteBuffer.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/ByteBuffer.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/ByteBuffer.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -205,4 +205,13 @@
return new CharBuffer(s.toCharArray());
}
+ /**
+ * Resets this byte buffer to empty state
+ * @since 3.3.0
+ */
+ public void reset() {
+ usedSize = 0;
+ next = null;
+ prev = null;
+ }
}
Modified: branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/CharBuffer.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/CharBuffer.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/CharBuffer.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -208,4 +208,13 @@
return new ByteBuffer(bs);
}
+ /**
+ * Resets this char buffer to empty state
+ * @since 3.3.0
+ */
+ public void reset() {
+ usedSize = 0;
+ next = null;
+ prev = null;
+ }
}
Modified:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/FastBufferOutputStream.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/FastBufferOutputStream.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/FastBufferOutputStream.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -204,4 +204,15 @@
return new FastBufferWriter(first);
}
+ /**
+ * Resets stream to empty state
+ *
+ * @since 3.3.0
+ */
+ public void reset() {
+ this.firstBuffer.reset();
+ this.lastBuffer = this.firstBuffer;
+
+ this.length = 0;
+ }
}
Modified:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/FastBufferWriter.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/FastBufferWriter.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/FastBufferWriter.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -78,6 +78,7 @@
*/
public void write(int c) throws IOException {
lastBuffer = lastBuffer.append((char)c);
+ length++;
}
/**
@@ -132,7 +133,7 @@
public void flush() throws IOException {
}
-
+
/**
* Writes all data written up to the moment to string buffer.
* @param out
@@ -212,5 +213,16 @@
}
return new FastBufferOutputStream(first);
}
+
+ /**
+ * Resets writer to empty state
+ *
+ * @since 3.3.0
+ */
+ public void reset() {
+ this.firstBuffer.reset();
+ this.lastBuffer = this.firstBuffer;
+ this.length = 0;
+ }
}
Modified:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/SAXResponseWriter.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/SAXResponseWriter.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/SAXResponseWriter.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -1,8 +1,22 @@
-/*
- * Created on 07.10.2004
+/**
+ * License Agreement.
*
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.ajax4jsf.io;
Modified:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/XMLResponseWriterState.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/XMLResponseWriterState.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/XMLResponseWriterState.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -1,8 +1,22 @@
-/*
- * Created on 07.10.2004
+/**
+ * License Agreement.
*
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.ajax4jsf.io;
Modified:
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -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: branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/javascript/JSMin.java
===================================================================
---
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/javascript/JSMin.java 2009-07-07
12:45:54 UTC (rev 14807)
+++
branches/jsf2.0/framework/impl/src/main/java/org/ajax4jsf/javascript/JSMin.java 2009-07-07
13:08:56 UTC (rev 14808)
@@ -1,24 +1,3 @@
-/**
- * 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
- */
-
/*
* JSMin.java 2006-02-13
*
@@ -65,8 +44,6 @@
import java.io.PushbackInputStream;
-
-
public class JSMin {
private static final int EOF = -1;
@@ -81,7 +58,7 @@
private int column;
public JSMin(InputStream in, OutputStream out) {
- this.in = new PushbackInputStream(in);
+ this.in = new PushbackInputStream(in,2);
this.out = out;
this.line = 0;
this.column = 0;
@@ -138,6 +115,10 @@
in.unread(lookaheadChar);
return lookaheadChar;
}
+
+ void back(int c) throws IOException {
+ in.unread(c);
+ }
/**
* next -- get the next character, excluding comments. peek() is used to see
@@ -154,20 +135,25 @@
return c;
}
}
-
case '*':
get();
- for (;;) {
- switch (get()) {
- case '*':
- if (peek() == '/') {
- get();
- return ' ';
+ if (peek()=='@') {
+ // TODO: add spaces skipping
+ back('*');
+ return c;
+ } else {
+ for (;;) {
+ switch (get()) {
+ case '*':
+ if (peek() == '/') {
+ get();
+ return ' ';
+ }
+ break;
+ case EOF:
+ throw new UnterminatedCommentException(line,column);
}
- break;
- case EOF:
- throw new UnterminatedCommentException(line,column);
- }
+ }
}
default:
@@ -213,7 +199,7 @@
case 3:
theB = next();
- if (theB == '/' && (theA == '(' || theA == ',' || theA
== '='|| theA == ':' || theA == '[')) {
+ if (theB == '/' && (theA == '(' || theA == '!' || theA
== '&' || theA == '|' || theA == ',' || theA == '='||
theA == ':' || theA == '[')) {
out.write(theA);
out.write(theB);
for (;;) {