JBoss Rich Faces SVN: r10204 - in trunk/ui/listShuttle/src: test/java/org/richfaces/component and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-08-26 19:38:52 -0400 (Tue, 26 Aug 2008)
New Revision: 10204
Modified:
trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java
trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java
Log:
https://jira.jboss.org/jira/browse/RF-2049
Modified: trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
===================================================================
--- trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2008-08-26 22:11:44 UTC (rev 10203)
+++ trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2008-08-26 23:38:52 UTC (rev 10204)
@@ -76,6 +76,10 @@
this.map = null;
}
}
+
+ protected Map getMap() {
+ return this.map;
+ }
}
public static final class ValueHolder implements Serializable {
Modified: trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java
===================================================================
--- trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java 2008-08-26 22:11:44 UTC (rev 10203)
+++ trunk/ui/listShuttle/src/test/java/org/richfaces/component/ListShuttleComponentTest.java 2008-08-26 23:38:52 UTC (rev 10204)
@@ -22,7 +22,10 @@
package org.richfaces.component;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import javax.faces.application.FacesMessage;
import javax.faces.component.UICommand;
@@ -38,6 +41,8 @@
import javax.faces.validator.ValidatorException;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIListShuttle.SubmittedValue;
+import org.richfaces.model.ListShuttleRowKey;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
@@ -205,6 +210,63 @@
assertEquals(value, value2);
}
+ public void testSourceTargetDecode() throws Exception {
+ String shuttleId = listShuttle.getClientId(facesContext);
+
+ externalContext.addRequestParameterMap(shuttleId, "0:a");
+ externalContext.addRequestParameterMap(shuttleId, "t5:b");
+ externalContext.addRequestParameterMap(shuttleId, ":");
+ externalContext.addRequestParameterMap(shuttleId, "t1:c");
+ externalContext.addRequestParameterMap(shuttleId, "2:d");
+ externalContext.addRequestParameterMap(shuttleId, "t10:e");
+
+ listShuttle.decode(facesContext);
+
+ SubmittedValue value = (SubmittedValue) listShuttle.getSubmittedValue();
+ assertNotNull(value);
+
+ Map map = value.getMap();
+
+ Iterator<Map.Entry<ListShuttleRowKey, Object>> itr = map.entrySet().iterator();
+ Entry<ListShuttleRowKey, Object> entry;
+ ListShuttleRowKey rowKey;
+
+ entry = itr.next();
+ rowKey = entry.getKey();
+ assertEquals("a", entry.getValue());
+ assertTrue(rowKey.isFacadeSource());
+ assertTrue(rowKey.isSource());
+ assertEquals(Integer.valueOf(0), rowKey.getRowKey());
+
+ entry = itr.next();
+ rowKey = entry.getKey();
+ assertEquals("b", entry.getValue());
+ assertTrue(rowKey.isFacadeSource());
+ assertFalse(rowKey.isSource());
+ assertEquals(Integer.valueOf(5), rowKey.getRowKey());
+
+ entry = itr.next();
+ rowKey = entry.getKey();
+ assertEquals("c", entry.getValue());
+ assertFalse(rowKey.isFacadeSource());
+ assertFalse(rowKey.isSource());
+ assertEquals(Integer.valueOf(1), rowKey.getRowKey());
+
+ entry = itr.next();
+ rowKey = entry.getKey();
+ assertEquals("d", entry.getValue());
+ assertFalse(rowKey.isFacadeSource());
+ assertTrue(rowKey.isSource());
+ assertEquals(Integer.valueOf(2), rowKey.getRowKey());
+
+ entry = itr.next();
+ rowKey = entry.getKey();
+ assertEquals("e", entry.getValue());
+ assertFalse(rowKey.isFacadeSource());
+ assertFalse(rowKey.isSource());
+ assertEquals(Integer.valueOf(10), rowKey.getRowKey());
+ }
+
protected class ListShuttleBean {
private List value = null;
Modified: trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java
===================================================================
--- trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java 2008-08-26 22:11:44 UTC (rev 10203)
+++ trunk/ui/listShuttle/src/test/java/org/richfaces/renderkit/ListShuttleRenderingTest.java 2008-08-26 23:38:52 UTC (rev 10204)
@@ -394,7 +394,7 @@
}
assertEquals(items.size(), rowsCount);
}
-
+
protected class SimpleItem {
String name;
int salary;
16 years, 4 months
JBoss Rich Faces SVN: r10203 - in trunk: framework/impl/src/main/java/org/ajax4jsf/renderkit and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2008-08-26 18:11:44 -0400 (Tue, 26 Aug 2008)
New Revision: 10203
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebXMLParser.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebXML.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletBean.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/config/FacesConfigHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/config/FilterBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/config/FilterMapping.java
trunk/framework/impl/src/main/java/org/ajax4jsf/config/ParsingException.java
trunk/framework/impl/src/main/java/org/ajax4jsf/config/ServletBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/config/ServletMapping.java
trunk/framework/impl/src/main/java/org/ajax4jsf/config/StateHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/config/StringContentHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebappHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/WebXml.java
trunk/framework/impl/src/test/java/org/ajax4jsf/config/StateHandlerTest.java
trunk/framework/impl/src/test/java/org/ajax4jsf/config/WebXMLTest.java
trunk/framework/impl/src/test/java/org/ajax4jsf/config/WebappHandlerTest.java
trunk/framework/impl/src/test/resources/WEB-INF/web.xml
trunk/samples/seamIntegration/pom.xml
Log:
fix https://jira.jboss.org/jira/browse/RF-2505,https://jira.jboss.org/jira/br...
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/config/FacesConfigHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/FacesConfigHandler.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/FacesConfigHandler.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -49,13 +49,27 @@
// Do nothing, to avoid network requests to external DTD/Schema
return new InputSource(new StringReader(""));
}
+
+ private abstract class FacesConfigElementHandler extends StateHandler {
+
+
+ public FacesConfigElementHandler(ContentHandler parentHandler) {
+ super(parentHandler);
+ }
+
+ @Override
+ protected XMLReader getReader() {
+ return reader;
+ }
+ }
+
/**
* @author asmirnov
*
*/
- private class ApplicationHandler extends StateHandler {
+ private class ApplicationHandler extends FacesConfigElementHandler {
public ApplicationHandler() {
- super(reader,FacesConfigHandler.this);
+ super(FacesConfigHandler.this);
}
@Override
@@ -74,9 +88,9 @@
* @author asmirnov
*
*/
- private class ApplicationExtensionHandler extends StateHandler {
+ private class ApplicationExtensionHandler extends FacesConfigElementHandler {
public ApplicationExtensionHandler(ContentHandler parent) {
- super(reader,parent);
+ super(parent);
}
@Override
@@ -95,10 +109,10 @@
* @author asmirnov
*
*/
- private class ExcludedAttributesHandler extends StateHandler {
+ private class ExcludedAttributesHandler extends FacesConfigElementHandler {
public ExcludedAttributesHandler(ContentHandler parent) {
- super(reader,parent);
+ super(parent);
}
@Override
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/config/FilterBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/FilterBean.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/FilterBean.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -3,16 +3,10 @@
*/
package org.ajax4jsf.config;
-import java.util.ArrayList;
-import java.util.List;
class FilterBean {
- private String name;
- private String className;
- private final List<String> mappings = new ArrayList<String>();
-
- public FilterBean() {
- }
+ private final String name;
+ private final String className;
/**
* @param name
* @param className
@@ -25,16 +19,36 @@
public String getName() {
return name;
}
- public void setName(String name) {
- this.name = name;
- }
public String getClassName() {
return className;
}
- public void setClassName(String className) {
- this.className = className;
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
}
- public List<String> getMappings() {
- return mappings;
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ FilterBean other = (FilterBean) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
}
}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/config/FilterMapping.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/FilterMapping.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/FilterMapping.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -9,16 +9,13 @@
*/
class FilterMapping {
- private String filterName;
- private String servletName;
- private String urlPattern;
+ private final String filterName;
+ private final String servletName;
+ private final String urlPattern;
- public FilterMapping() {
- }
public FilterMapping(String filterName, String servletName,
String urlPattern) {
- super();
this.filterName = filterName;
this.servletName = servletName;
this.urlPattern = urlPattern;
@@ -28,24 +25,44 @@
return filterName;
}
- public void setFilterName(String filterName) {
- this.filterName = filterName;
- }
-
public String getServletName() {
return servletName;
}
- public void setServletName(String servletName) {
- this.servletName = servletName;
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((filterName == null) ? 0 : filterName.hashCode());
+ return result;
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ FilterMapping other = (FilterMapping) obj;
+ if (filterName == null) {
+ if (other.filterName != null)
+ return false;
+ } else if (!filterName.equals(other.filterName))
+ return false;
+ return true;
+ }
+
public String getUrlPattern() {
return urlPattern;
}
-
- public void setUrlPattern(String urlPattern) {
- this.urlPattern = urlPattern;
- }
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/config/ParsingException.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/ParsingException.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/ParsingException.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -12,6 +12,11 @@
/**
*
*/
+ private static final long serialVersionUID = -6052151937934930943L;
+
+ /**
+ *
+ */
public ParsingException() {
// TODO Auto-generated constructor stub
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/config/ServletBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/ServletBean.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/ServletBean.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -3,16 +3,10 @@
*/
package org.ajax4jsf.config;
-import java.util.ArrayList;
-import java.util.List;
class ServletBean {
- private String name;
- private String className;
- private final List<String> mappings = new ArrayList<String>();
-
- public ServletBean() {
- }
+ private final String name;
+ private final String className;
/**
* @param name
* @param className
@@ -25,16 +19,36 @@
public String getName() {
return name;
}
- public void setName(String name) {
- this.name = name;
- }
public String getClassName() {
return className;
}
- public void setClassName(String className) {
- this.className = className;
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
}
- public List<String> getMappings() {
- return mappings;
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ServletBean other = (ServletBean) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
}
}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/config/ServletMapping.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/ServletMapping.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/ServletMapping.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -4,12 +4,9 @@
package org.ajax4jsf.config;
class ServletMapping {
- private String servletName;
- private String urlPattern;
+ private final String servletName;
+ private final String urlPattern;
- public ServletMapping() {
- }
-
/**
* @param servletName
* @param urlPattern
@@ -24,15 +21,39 @@
return servletName;
}
- public void setServletName(String servletName) {
- this.servletName = servletName;
- }
-
public String getUrlPattern() {
return urlPattern;
}
- public void setUrlPattern(String urlPattern) {
- this.urlPattern = urlPattern;
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((servletName == null) ? 0 : servletName.hashCode());
+ return result;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ServletMapping other = (ServletMapping) obj;
+ if (servletName == null) {
+ if (other.servletName != null)
+ return false;
+ } else if (!servletName.equals(other.servletName))
+ return false;
+ return true;
+ }
}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/config/StateHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/StateHandler.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/StateHandler.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -20,13 +20,11 @@
private final ContentHandler parentHandler;
- private final XMLReader reader;
private int depth = 0;
- public StateHandler(XMLReader reader, ContentHandler parentHandler) {
+ public StateHandler(ContentHandler parentHandler) {
super();
- this.reader = reader;
this.parentHandler = parentHandler;
}
@@ -37,7 +35,7 @@
if (null == nextHandler) {
depth++;
} else {
- reader.setContentHandler(nextHandler);
+ getReader().setContentHandler(nextHandler);
}
}
@@ -51,7 +49,7 @@
throws SAXException {
if(depth-- == 0){
if(null != parentHandler){
- reader.setContentHandler(parentHandler);
+ getReader().setContentHandler(parentHandler);
}
endLastElement();
}
@@ -68,7 +66,5 @@
return new InputSource(new StringReader(""));
}
- protected XMLReader getReader() {
- return reader;
- }
+ protected abstract XMLReader getReader();
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/config/StringContentHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/StringContentHandler.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/StringContentHandler.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -11,13 +11,16 @@
* @author asmirnov
*
*/
-public class StringContentHandler extends StateHandler {
+class StringContentHandler extends StateHandler {
private StringBuilder result;
+
+ private final XMLReader reader;
public StringContentHandler(XMLReader reader, ContentHandler parentHandler,
StringBuilder result) {
- super(reader, parentHandler);
+ super(parentHandler);
+ this.reader = reader;
this.result = result;
}
@@ -30,4 +33,9 @@
protected StringBuilder getResult() {
return result;
}
+
+ @Override
+ protected XMLReader getReader() {
+ return reader;
+ }
}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebXML.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebXML.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebXML.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -1,52 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.config;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import javax.servlet.ServletContext;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-/**
- * @author asmirnov
- *
- */
-public class WebXML {
-
- private static final String WEB_XML = "/WEB-INF/web.xml";
- private List<String> facesServletMappings;
-
- public void parse(InputStream webXml) {
- try {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setValidating(false);
- factory.setNamespaceAware(true);
- SAXParser parser = factory.newSAXParser();
- ServletBean facesServlet = new ServletBean();
- parser.parse(webXml, new WebappHandler(parser.getXMLReader(),
- facesServlet));
- facesServletMappings = facesServlet.getMappings();
- } catch (Exception e) {
- // TODO: handle exception
- }
- }
-
- public List<String> getFacesServletMappings() {
- return facesServletMappings;
- }
-
- public void parse(ServletContext portletContext) {
- InputStream inputStream = portletContext.getResourceAsStream(WEB_XML);
- parse(inputStream);
- try {
- inputStream.close();
- } catch (IOException e) {
- // Do nothing, ignore
- }
-
- }
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebXMLParser.java (from rev 10187, trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebXML.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebXMLParser.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebXMLParser.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -0,0 +1,201 @@
+/**
+ *
+ */
+package org.ajax4jsf.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.SAXException;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class WebXMLParser {
+
+ public static final String WEB_XML = "/WEB-INF/web.xml";
+
+ private String _facesFilterPrefix = null;
+ /**
+ * Suffix for Resource-Ajax filter , in common must be same as for
+ * {@link javax.faces.webapp.FacesServlet}
+ */
+ private String _facesFilterSuffix = null;
+ private String _facesServletPrefix = null;
+ private String _facesServletSuffix = null;
+
+ private List<String> facesServletMappings;
+ private List<String> filterMappings;
+ static final String FACES_SERVLET_CLASS = "javax.faces.webapp.FacesServlet";
+
+ public void init(InputStream webXml, String filterName)
+ throws ParsingException {
+ try {
+ // Prepare SAX parser for a web-xml.
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+ SAXParser parser = factory.newSAXParser();
+ // Parse web.xml with state-avare content handler.
+ WebappHandler webappHandler = new WebappHandler(parser
+ .getXMLReader());
+ parser.parse(webXml, webappHandler);
+ // Calculate Faces Servlet and filter mappings.
+ for (ServletBean servlet : webappHandler.getServlets()) {
+ if (FACES_SERVLET_CLASS.equals(servlet.getClassName())) {
+ facesServletMappings = new ArrayList<String>();
+ for (ServletMapping mapping : webappHandler
+ .getServletMappings()) {
+ if (servlet.getName().equals(mapping.getServletName())) {
+ facesServletMappings.add(mapping.getUrlPattern());
+ String asPrefix = getAsPrefix(mapping
+ .getUrlPattern());
+ if (null != asPrefix) {
+ _facesServletPrefix = asPrefix;
+
+ }
+ String asSuffix = getAsSuffix(mapping
+ .getUrlPattern());
+ if (null != asSuffix) {
+ _facesServletSuffix = asSuffix;
+
+ }
+ }
+ }
+ }
+ }
+ // Find named filter configuration.
+ // Got filter, check it's mapping.
+ filterMappings = new ArrayList<String>();
+ for (FilterMapping mapping : webappHandler.getFilterMappings()) {
+ if (mapping.getFilterName().equals(filterName)) {
+ if (null != mapping.getUrlPattern()
+ && !"".equals(mapping.getUrlPattern())) {
+ filterMappings.add(mapping.getUrlPattern());
+ String asPrefix = getAsPrefix(mapping.getUrlPattern());
+ if (null != asPrefix) {
+ _facesFilterPrefix = asPrefix;
+
+ }
+ String asSuffix = getAsSuffix(mapping.getUrlPattern());
+ if (null != asSuffix) {
+ _facesFilterSuffix = asSuffix;
+
+ }
+ } else if (null != mapping.getServletName()
+ && !"".equals(mapping.getServletName())) {
+ for (ServletMapping servletMapping : webappHandler
+ .getServletMappings()) {
+ if (mapping.getServletName().equals(
+ servletMapping.getServletName())) {
+ filterMappings.add(servletMapping
+ .getUrlPattern());
+ String asPrefix = getAsPrefix(servletMapping
+ .getUrlPattern());
+ if (null != asPrefix) {
+ _facesFilterPrefix = asPrefix;
+
+ }
+ String asSuffix = getAsSuffix(servletMapping
+ .getUrlPattern());
+ if (null != asSuffix) {
+ _facesFilterSuffix = asSuffix;
+
+ }
+ }
+ }
+ }
+ }
+ }
+ if (0 == filterMappings.size()) {
+ throw new ParsingException(
+ "No filter mapping set for a filter " + filterName);
+ }
+
+ } catch (IOException e) {
+ throw new ParsingException("Error read web application config", e);
+ } catch (ParserConfigurationException e) {
+ throw new ParsingException("SAX Parser configuration error", e);
+ } catch (SAXException e) {
+ throw new ParsingException(
+ "Error parsing XML for the web application config", e);
+ }
+ }
+
+ private String getAsSuffix(String urlPattern) {
+ String suffix = null;
+ if (urlPattern.startsWith("*")) {
+ suffix = urlPattern.substring(1);
+ }
+ return suffix;
+ }
+
+ private String getAsPrefix(String urlPattern) {
+ String preffix = null;
+ if (urlPattern.endsWith("*")) {
+ int cut = urlPattern.endsWith("/*") ? 2 : 1;
+ preffix = urlPattern.substring(0, urlPattern.length() - cut);
+ }
+ return preffix;
+ }
+
+ public List<String> getFacesServletMappings() {
+ return facesServletMappings;
+ }
+
+ /**
+ * @return the facesFilterPrefix
+ */
+ public String getFacesFilterPrefix() {
+ return _facesFilterPrefix;
+ }
+
+ /**
+ * @return the facesFilterSuffix
+ */
+ public String getFacesFilterSuffix() {
+ return _facesFilterSuffix;
+ }
+
+ /**
+ * @return the facesServletPrefix
+ */
+ public String getFacesServletPrefix() {
+ return _facesServletPrefix;
+ }
+
+ /**
+ * @return the facesServletSuffix
+ */
+ public String getFacesServletSuffix() {
+ return _facesServletSuffix;
+ }
+
+ public void init(ServletContext portletContext, String filterName)
+ throws ServletException {
+ InputStream inputStream = portletContext.getResourceAsStream(WEB_XML);
+ if (null != inputStream) {
+ try {
+ init(inputStream, filterName);
+ } catch (ParsingException e1) {
+ throw new ServletException(
+ "Error parse web application config", e1);
+ }
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ // Do nothing, ignore
+ }
+
+ }
+ }
+}
Property changes on: trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebXMLParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebappHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebappHandler.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/config/WebappHandler.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -28,8 +28,6 @@
static final String SERVLET_CLASS_ELEMENT = "servlet-class";
- static final String FACES_SERVLET_CLASS = "javax.faces.webapp.FacesServlet";
-
static final String FILTER_MAPPING_ELEMENT = "filter-mapping";
static final String FILTER_ELEMENT = "filter";
@@ -39,8 +37,12 @@
static final String FILTER_CLASS_ELEMENT = "filter-class";
private List<ServletBean> servlets = new ArrayList<ServletBean>();
+
+ private List<FilterBean> filters = new ArrayList<FilterBean>();
- private List<ServletMapping> mappings = new ArrayList<ServletMapping>();
+ private List<ServletMapping> servletMappings = new ArrayList<ServletMapping>();
+
+ private List<FilterMapping> filterMappings = new ArrayList<FilterMapping>();
private ServletBean facesServlet;
@@ -49,51 +51,69 @@
static final String URL_PATTERN_ELEMENT = "url-pattern";
- public WebappHandler(XMLReader reader, ServletBean bean) {
+ public WebappHandler(XMLReader reader) {
this.xmlReader = reader;
- this.facesServlet = bean;
}
+ public List<FilterBean> getFilters() {
+ return filters;
+ }
+
+ public List<FilterMapping> getFilterMappings() {
+ return filterMappings;
+ }
+
+ public List<ServletBean> getServlets() {
+ return servlets;
+ }
+
+ public List<ServletMapping> getServletMappings() {
+ return servletMappings;
+ }
+
@Override
public void startElement(String uri, String localName, String name,
Attributes attributes) throws SAXException {
if (SERVLET_ELEMENT.equals(localName)) {
xmlReader.setContentHandler(new ServletHandler());
} else if (SERVLET_MAPPING_ELEMENT.equals(localName)) {
- xmlReader.setContentHandler(new MappingHandler());
+ xmlReader.setContentHandler(new ServletMappingHandler());
+ } else if (FILTER_ELEMENT.equals(localName)) {
+ xmlReader.setContentHandler(new FilterHandler());
+ } else if (FILTER_MAPPING_ELEMENT.equals(localName)) {
+ xmlReader.setContentHandler(new FilterMappingHandler());
}
}
@Override
- public void endDocument() throws SAXException {
- for (ServletBean servlet : servlets) {
- if (FACES_SERVLET_CLASS.equals(servlet.getClassName())) {
- facesServlet.setName(servlet.getName());
- facesServlet.setClassName(servlet.getClassName());
- for (ServletMapping mapping : mappings) {
- if (servlet.getName().equals(mapping.getServletName())) {
- facesServlet.getMappings().add(mapping.getUrlPattern());
- }
- }
- }
- }
- }
-
- @Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException
{
- // Do nothing, to avoid network requests to external DTD/Schema
+ // Do nothing, to avoid network requests for external DTD/Schema
return new InputSource(new StringReader(""));
}
+
+
+ private abstract class WebappElementHandler extends StateHandler {
+
+
+ public WebappElementHandler(ContentHandler parentHandler) {
+ super(parentHandler);
+ }
+ @Override
+ protected XMLReader getReader() {
+ return xmlReader;
+ }
+ }
- final class ServletHandler extends StateHandler {
+ final class ServletHandler extends WebappElementHandler {
+
private StringBuilder servletName = new StringBuilder();
private StringBuilder servletClass = new StringBuilder();
public ServletHandler() {
- super(xmlReader, WebappHandler.this);
+ super(WebappHandler.this);
}
@Override
@@ -117,15 +137,86 @@
}
}
- final class MappingHandler extends StateHandler {
+ final class ServletMappingHandler extends WebappElementHandler {
+
+ private StringBuilder servletName = new StringBuilder();
+ private StringBuilder urlPattern = new StringBuilder();
+
+ public ServletMappingHandler() {
+ super(WebappHandler.this);
+ }
+
+ @Override
+ protected ContentHandler getNextHandler(String uri, String localName,
+ Attributes attributes) {
+ ContentHandler nextHandler = null;
+ if (SERVLET_NAME_ELEMENT.equals(localName)) {
+ nextHandler = new StringContentHandler(getReader(), this,
+ servletName);
+ } else if (URL_PATTERN_ELEMENT.equals(localName)) {
+ nextHandler = new StringContentHandler(getReader(), this,
+ urlPattern);
+ }
+ return nextHandler;
+ }
+
+ @Override
+ protected void endLastElement() {
+ servletMappings.add(new ServletMapping(servletName.toString().trim(),
+ urlPattern.toString().trim()));
+ }
+ }
+
+ /**
+ * @author asmirnov
+ *
+ */
+ public class FilterHandler extends WebappElementHandler {
+
+ private StringBuilder filterName = new StringBuilder();
+ private StringBuilder filterClass = new StringBuilder();
+
+
+ public FilterHandler() {
+ super(WebappHandler.this);
+ }
+
+ @Override
+ protected ContentHandler getNextHandler(String uri, String localName,
+ Attributes attributes) {
+ // TODO Auto-generated method stub
+ ContentHandler handler = null;
+ if(FILTER_CLASS_ELEMENT.equals(localName)){
+ handler = new StringContentHandler(getReader(),this,filterClass);
+ } else if (FILTER_NAME_ELEMENT.equals(localName)) {
+ handler = new StringContentHandler(getReader(),this,filterName);
+ }
+ return handler;
+ }
+
+ @Override
+ protected void endLastElement() {
+ filters.add(new FilterBean(filterName.toString().trim(),filterClass.toString().trim()));
+ }
+
+ }
+
+
+ /**
+ * @author asmirnov
+ *
+ */
+ public class FilterMappingHandler extends WebappElementHandler {
+
private StringBuilder servletName = new StringBuilder();
private StringBuilder urlPattern = new StringBuilder();
+ private StringBuilder filterName = new StringBuilder();
- public MappingHandler() {
- super(xmlReader, WebappHandler.this);
+ public FilterMappingHandler() {
+ super(WebappHandler.this);
}
-
+
@Override
protected ContentHandler getNextHandler(String uri, String localName,
Attributes attributes) {
@@ -136,15 +227,19 @@
} else if (URL_PATTERN_ELEMENT.equals(localName)) {
nextHandler = new StringContentHandler(getReader(), this,
urlPattern);
+ } else if (FILTER_NAME_ELEMENT.equals(localName)) {
+ nextHandler = new StringContentHandler(getReader(), this,
+ filterName);
+
}
return nextHandler;
}
-
+
@Override
protected void endLastElement() {
- mappings.add(new ServletMapping(servletName.toString().trim(),
- urlPattern.toString().trim()));
+ filterMappings.add(new FilterMapping(filterName.toString().trim(),servletName.toString().trim(),urlPattern.toString().trim()));
}
+
}
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -59,7 +59,7 @@
* @return
*/
protected InternetResource[] getScripts() {
- // TODO Auto-generated method stub
+ // return nothing by default.
return null;
}
@@ -110,25 +110,25 @@
* @see org.ajax4jsf.renderkit.RendererBase#preEncodeBegin(javax.faces.context.FacesContext,
* javax.faces.component.UIComponent)
*/
- protected void preEncodeBegin(FacesContext context, UIComponent component)
- throws IOException {
- if ((null == context.getExternalContext().getRequestMap().get(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE))
- /* && (!AjaxRendererUtils.isAjaxRequest(context)) */) {
- // Filter not used - encode scripts and CSS before component.
- ExternalContext externalContext = context.getExternalContext();
- String scriptStrategy = externalContext
- .getInitParameter(InternetResourceBuilder.LOAD_SCRIPT_STRATEGY_PARAM);
- if (null == scriptStrategy || !InternetResourceBuilder.LOAD_NONE.equals(scriptStrategy)) {
- encodeResourcesArray(context, component, getScripts());
- }
- String styleStrategy = externalContext
- .getInitParameter(InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM);
- if (null != styleStrategy || !InternetResourceBuilder.LOAD_NONE.equals(styleStrategy)) {
- encodeResourcesArray(context, component, getStyles());
- }
- }
- }
+// protected void preEncodeBegin(FacesContext context, UIComponent component)
+// throws IOException {
+// if ((null == context.getExternalContext().getRequestMap().get(
+// BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE))
+// /* && (!AjaxRendererUtils.isAjaxRequest(context)) */) {
+// // Filter not used - encode scripts and CSS before component.
+// ExternalContext externalContext = context.getExternalContext();
+// String scriptStrategy = externalContext
+// .getInitParameter(InternetResourceBuilder.LOAD_SCRIPT_STRATEGY_PARAM);
+// if (null == scriptStrategy || !InternetResourceBuilder.LOAD_NONE.equals(scriptStrategy)) {
+// encodeResourcesArray(context, component, getScripts());
+// }
+// String styleStrategy = externalContext
+// .getInitParameter(InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM);
+// if (null != styleStrategy || !InternetResourceBuilder.LOAD_NONE.equals(styleStrategy)) {
+// encodeResourcesArray(context, component, getStyles());
+// }
+// }
+// }
/**
* @param context
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -214,6 +214,7 @@
if (!request.getMethod().equals("HEAD")) {
content.send(response);
}
+ content.flush(response);
} catch (CacheException e) {
log.error(
Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -292,4 +292,19 @@
}
s.defaultWriteObject();
}
+
+ /**
+ * Flush used output writer/stream, to fix https://jira.jboss.org/jira/browse/RF-4017
+ * @param response
+ * @throws IOException
+ */
+ public void flush(HttpServletResponse response) throws IOException {
+ if (filledOutputStream) {
+ OutputStream out = response.getOutputStream();
+ out.flush();
+ } else if (filledOutputWriter) {
+ Writer out = response.getWriter();
+ out.flush();
+ }
+ }
}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterBean.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterBean.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -1,115 +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.webapp;
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:58 $
- *
- */
-public class FilterBean implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 843405125536857609L;
-
- private String _filterName;
- private String _filterClass;
- private String _displayName;
- private String _description;
- private Set<String> _filterMappings = new HashSet<String>();
- private Set<String> _servlets = new HashSet<String>();
-
- /**
- * @return Returns the description.
- */
- public String getDescription() {
- return _description;
- }
- /**
- * @param description The description to set.
- */
- public void setDescription(String description) {
- _description = description;
- }
- /**
- * @return Returns the displayName.
- */
- public String getDisplayName() {
- return _displayName;
- }
- /**
- * @param displayName The displayName to set.
- */
- public void setDisplayName(String displayName) {
- _displayName = displayName;
- }
- /**
- * @return Returns the servletClass.
- */
- public String getFilterClass() {
- return _filterClass;
- }
- /**
- * @param servletClass The servletClass to set.
- */
- public void setFilterClass(String servletClass) {
- _filterClass = servletClass;
- }
- /**
- * @return Returns the servletName.
- */
- public String getFilterName() {
- return _filterName;
- }
- /**
- * @param servletName The servletName to set.
- */
- public void setFilterName(String servletName) {
- _filterName = servletName.trim();
- }
- /* (non-Javadoc)
- * @see java.util.Map#keySet()
- */
- public Set<String> getMappings() {
- return _filterMappings;
- }
- /* (non-Javadoc)
- * @see java.util.Map#put(java.lang.Object, java.lang.Object)
- */
- void addMapping(String mapping) {
- _filterMappings.add(mapping);
- }
-
- public void addServlet(String servlet) {
- _servlets.add(servlet.trim());
-
- }
- public Set<String> getServlets() {
- return _servlets;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletBean.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletBean.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletBean.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -1,105 +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.webapp;
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:59 $
- *
- */
-public class ServletBean implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = -7485005767985264890L;
- private String _servletName;
- private String _servletClass;
- private String _displayName;
- private String _description;
- private Set<String> _servletMappings = new HashSet<String>();
- /**
- * @return Returns the description.
- */
- public String getDescription() {
- return _description;
- }
- /**
- * @param description The description to set.
- */
- public void setDescription(String description) {
- _description = description;
- }
- /**
- * @return Returns the displayName.
- */
- public String getDisplayName() {
- return _displayName;
- }
- /**
- * @param displayName The displayName to set.
- */
- public void setDisplayName(String displayName) {
- _displayName = displayName;
- }
- /**
- * @return Returns the servletClass.
- */
- public String getServletClass() {
- return _servletClass;
- }
- /**
- * @param servletClass The servletClass to set.
- */
- public void setServletClass(String servletClass) {
- _servletClass = servletClass;
- }
- /**
- * @return Returns the servletName.
- */
- public String getServletName() {
- return _servletName;
- }
- /**
- * @param servletName The servletName to set.
- */
- public void setServletName(String servletName) {
- _servletName = servletName.trim();
- }
- /* (non-Javadoc)
- * @see java.util.Map#keySet()
- */
- public Set<String> getMappings() {
- return _servletMappings;
- }
- /* (non-Javadoc)
- * @see java.util.Map#put(java.lang.Object, java.lang.Object)
- */
- void addMapping(String mapping) {
- _servletMappings.add(mapping);
- }
-
-
-}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/WebXml.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/WebXml.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/WebXml.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -21,31 +21,18 @@
package org.ajax4jsf.webapp;
-import java.io.IOException;
-import java.io.InputStream;
import java.io.Serializable;
-import java.io.StringReader;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
-import org.ajax4jsf.Messages;
-import org.apache.commons.digester.Digester;
+import org.ajax4jsf.config.WebXMLParser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.richfaces.VersionBean;
import org.richfaces.VersionBean.Version;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.LocatorImpl;
/**
* Parse at startup application web.xml and store servlet and filter mappings.
@@ -55,7 +42,7 @@
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:59 $
*
*/
-public class WebXml implements Serializable {
+public class WebXml extends WebXMLParser implements Serializable {
public static final String CONTEXT_ATTRIBUTE = WebXml.class.getName();
@@ -64,10 +51,8 @@
*/
private static final long serialVersionUID = -9042908418843695017L;
- private static final Log _log = LogFactory.getLog(WebXml.class);
+ static final Log _log = LogFactory.getLog(WebXml.class);
- static final String WEB_XML = "/WEB-INF/web.xml";
-
public static final String RESOURCE_URI_PREFIX = "a4j";
public static final String GLOBAL_RESOURCE_URI_PREFIX = "a4j/g";
@@ -100,38 +85,16 @@
public static final String SESSION_RESOURCE_URI_PREFIX_PARAM = "org.ajax4jsf.SESSION_RESOURCE_URI_PREFIX";
/**
- * Prefix for Resourse-Ajax filter, in common must be same as for
- * {@link javax.faces.webapp.FacesServlet}
- */
- private String _facesFilterPrefix = null;
-
- /**
- * Suffix for Resource-Ajax filter , in common must be same as for
- * {@link javax.faces.webapp.FacesServlet}
- */
- private String _facesFilterSuffix = null;
-
- private String _facesServletPrefix = null;
-
- private String _facesServletSuffix = null;
-
- private boolean _prefixMapping = false;
-
- private String _filterName;
-
- private Map<String, ServletBean> _servlets = new HashMap<String, ServletBean>();
-
- private Map<String, FilterBean> _filters = new HashMap<String, FilterBean>();
-
- /**
* Prefix for resources handled by Chameleon framework.
*/
- private String _resourcePrefix = RESOURCE_URI_PREFIX;
+ String _resourcePrefix = RESOURCE_URI_PREFIX;
- private String _globalResourcePrefix;
+ String _globalResourcePrefix;
- private String _sessionResourcePrefix;
+ String _sessionResourcePrefix;
+ protected boolean _prefixMapping = false;
+
public static WebXml getInstance() {
return getInstance(FacesContext.getCurrentInstance());
}
@@ -142,145 +105,16 @@
return webXml;
}
-
- /**
- * Parse application web.xml configuration and detect mapping for resources
- * and logs.
- *
- * @param context
- * @param filterName
- * @throws ServletException
- */
+ @Override
public void init(ServletContext context, String filterName)
throws ServletException {
- InputStream webXml = context.getResourceAsStream(WEB_XML);
- if (null == webXml) {
- throw new ServletException(Messages.getMessage(
- Messages.GET_RESOURCE_AS_STREAM_ERROR, WEB_XML));
- }
- Digester dig = new Digester();
- dig.setDocumentLocator(new LocatorImpl());
- // Disable xml validations at all - web.xml already validated by
- // container
- dig.setValidating(false);
- dig.setEntityResolver(new EntityResolver() {
- // Dummi resolver - alvays do nothing
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
- return new InputSource(new StringReader(""));
- }
+ super.init(context, filterName);
+ setupResourcePrefixes(context);
+ // Store Instance to context attribute.
+ context.setAttribute(CONTEXT_ATTRIBUTE, this);
- });
- dig.setNamespaceAware(false);
- // dig.setUseContextClassLoader(true);
- dig.setClassLoader(this.getClass().getClassLoader());
- // Parsing rules.
- // Servlets.
- String path = "web-app/servlet";
- dig.addObjectCreate(path, ServletBean.class);
- dig.addBeanPropertySetter(path + "/servlet-name", "servletName");
- dig.addBeanPropertySetter(path + "/servlet-class", "servletClass");
- dig.addBeanPropertySetter(path + "/display-name", "displayName");
- dig.addBeanPropertySetter(path + "/description");
- dig.addSetNext(path, "addServlet");
- // Filters
- path = "web-app/filter";
- dig.addObjectCreate(path, FilterBean.class);
- dig.addBeanPropertySetter(path + "/filter-name", "filterName");
- dig.addBeanPropertySetter(path + "/filter-class", "filterClass");
- dig.addBeanPropertySetter(path + "/display-name", "displayName");
- dig.addBeanPropertySetter(path + "/description");
- dig.addSetNext(path, "addFilter");
- // Servlet mappings
- path = "web-app/servlet-mapping";
- dig.addCallMethod(path, "addServletMapping", 2);
- dig.addCallParam(path + "/servlet-name", 0);
- dig.addCallParam(path + "/url-pattern", 1);
- // Filter mappings
- // TODO - parse dispatcher.
- path = "web-app/filter-mapping";
- dig.addCallMethod(path, "addFilterMapping", 3);
- dig.addCallParam(path + "/filter-name", 0);
- dig.addCallParam(path + "/url-pattern", 1);
- dig.addCallParam(path + "/servlet-name", 2);
- dig.push(this);
- try {
- dig.parse(webXml);
- this.setFilterName(filterName, context);
- this.findFacesServlet(context);
- // Store Instance to context attribute.
- context.setAttribute(CONTEXT_ATTRIBUTE, this);
- } catch (IOException e) {
- String message = Messages
- .getMessage(Messages.PARSING_WEB_XML_IO_ERROR);
- _log.error(message, e);
- throw new ServletException(message, e);
- } catch (SAXException e) {
- String message = Messages
- .getMessage(Messages.PARSING_WEB_XML_SAX_ERROR);
- _log.error(message, e);
- throw new ServletException(message, e);
- } finally {
- try {
- webXml.close();
- } catch (IOException e) {
- // this exception don't affect any aspects of work and can be
- // ignored.
- }
- }
}
-
- private void findFacesServlet(ServletContext context) {
- for (Iterator<Entry<String, ServletBean>> servletsIterator = _servlets
- .entrySet().iterator(); servletsIterator.hasNext();) {
- Entry<String, ServletBean> servletEntry = servletsIterator.next();
- String servletClass = servletEntry.getValue().getServletClass();
- if("javax.faces.webapp.FacesServlet".equals(servletClass)){
- Mapping mapping = checkMapping(servletEntry.getValue().getMappings());
- if(null != mapping){
- this._facesServletPrefix = mapping.getPrefix();
- this._facesServletSuffix = mapping.getSuffix();
- }
- }
- }
-
- }
-
- public void addServlet(ServletBean bean) {
- String name = bean.getServletName();
- if (null != name) {
- _servlets.put(name, bean);
- }
- }
-
- public void addFilter(FilterBean bean) {
- String name = bean.getFilterName();
- if (null != name) {
- _filters.put(name, bean);
- }
-
- }
-
- public void addServletMapping(String servletName, String mapping) {
- ServletBean servletBean = (ServletBean) _servlets.get(servletName);
- if (null != servletBean) {
- (servletBean).addMapping(mapping);
- }
- }
-
- public void addFilterMapping(String filterName, String mapping,
- String servlet) {
- FilterBean filterBean = (FilterBean) _filters.get(filterName);
- if (null != filterBean) {
- if (null != mapping) {
- (filterBean).addMapping(mapping);
- }
- if (null != servlet) {
- (filterBean).addServlet(servlet);
- }
- }
- }
-
+
/**
* Convert {@link org.ajax4jsf.resource.InternetResource } key to real URL
* for handle by chameleon filter, depend of mapping in WEB.XML . For prefix
@@ -409,36 +243,6 @@
}
/**
- * @return Returns the facesFilterPrefix.
- */
- public String getFacesFilterPrefix() {
- return _facesFilterPrefix;
- }
-
- /**
- * @param facesFilterPrefix
- * The facesFilterPrefix to set.
- */
- void setFacesFilterPrefix(String facesFilterPrefix) {
- _facesFilterPrefix = facesFilterPrefix;
- }
-
- /**
- * @return Returns the facesFilterSuffix.
- */
- public String getFacesFilterSuffix() {
- return _facesFilterSuffix;
- }
-
- /**
- * @param facesFilterSuffix
- * The facesFilterSuffix to set.
- */
- void setFacesFilterSuffix(String facesFilterSuffix) {
- _facesFilterSuffix = facesFilterSuffix;
- }
-
- /**
* @return Returns the resourcePrefix.
*/
@Deprecated
@@ -453,7 +257,7 @@
public String getGlobalResourcePrefix() {
return _globalResourcePrefix;
}
-
+
/**
* @since 3.2.2
* @return
@@ -463,6 +267,13 @@
}
/**
+ * @return Returns the prefixMapping.
+ */
+ public boolean isPrefixMapping() {
+ return _prefixMapping;
+ }
+
+ /**
* @param resourcePrefix
* The resourcePrefix to set.
*/
@@ -486,64 +297,14 @@
* The resourcePrefix to set.
*
*/
-
void setSessionResourcePrefix(String resourcePrefix) {
_sessionResourcePrefix = resourcePrefix;
}
-
- /**
- * @return Returns the filterName.
- */
- public String getFilterName() {
- return _filterName;
- }
/**
- * After parsing web.xml set chameleon filter name, for wich we must
- * calculate mappings for resources, logs etc.
- *
- * @param filterName
- * The filterName to set.
* @param context
- * TODO
*/
- void setFilterName(String filterName, ServletContext context) {
- if (null == filterName) {
- _log.warn(Messages.getMessage(Messages.NULL_FILTER_NAME_WARNING));
- return;
- }
- _filterName = filterName.trim();
- // get config for this filter
- FilterBean filter = (FilterBean) _filters.get(_filterName);
- if (null == filter) {
- _log.warn(Messages.getMessage(Messages.FILTER_NOT_FOUND_ERROR,
- _filterName));
- throw new IllegalStateException(Messages.getMessage(
- Messages.FILTER_NOT_FOUND_ERROR, filterName));
- }
- // find faces servlet
- Mapping mapping = checkMapping(filter.getMappings());
- // Filter mapped only to servlet.
- if (null == mapping) {
- for (Iterator<String> sevlets = filter.getServlets().iterator(); sevlets
- .hasNext()
- && _facesFilterPrefix == null && _facesFilterSuffix == null;) {
- String servletname = sevlets.next();
- ServletBean servlet = (ServletBean) _servlets.get(servletname);
- if (null != servlet) {
- mapping = checkMapping(servlet.getMappings());
- }
- }
- }
- if (null != mapping) {
- setFacesFilterPrefix(mapping.getPrefix());
- setFacesFilterSuffix(mapping.getSuffix());
- } else {
- throw new IllegalStateException(Messages.getMessage(
- Messages.NO_PREFIX_OR_SUFFIX_IN_FILTER_MAPPING_ERROR,
- filterName));
- }
-
+ void setupResourcePrefixes(ServletContext context) {
String globalResourcePrefix = (String) context
.getInitParameter(GLOBAL_RESOURCE_URI_PREFIX_PARAM);
@@ -552,7 +313,7 @@
String resourcePrefix = (String) context
.getInitParameter(RESOURCE_URI_PREFIX_PARAM);
-
+
if (null != resourcePrefix) {
if (globalResourcePrefix == null) {
//TODO overriden
@@ -576,10 +337,10 @@
//TODO overriden
sessionResourcePrefix = SESSION_RESOURCE_URI_PREFIX_VERSIONED;
}
-
- if (null != _facesFilterPrefix) {
+
+ if (null != getFacesFilterPrefix()) {
_prefixMapping = true;
- if (_facesFilterPrefix.endsWith("/")) {
+ if (getFacesFilterPrefix().endsWith("/")) {
setGlobalResourcePrefix(globalResourcePrefix);
setSessionResourcePrefix(sessionResourcePrefix);
setResourcePrefix(resourcePrefix);
@@ -588,97 +349,11 @@
setSessionResourcePrefix("/" + sessionResourcePrefix);
setResourcePrefix("/" + resourcePrefix);
}
- } else if (null != _facesFilterSuffix) {
+ } else if (null != getFacesFilterSuffix()) {
_prefixMapping = false;
setResourcePrefix("/" + resourcePrefix);
setGlobalResourcePrefix("/" + globalResourcePrefix);
setSessionResourcePrefix("/" + sessionResourcePrefix);
}
}
-
- private Mapping checkMapping(Set<String> mappings) {
- Mapping mapping = null;
- if (null != mappings) {
- for (Iterator<String> iter = mappings.iterator(); iter.hasNext();) {
- String mappingPattern = (String) iter.next();
- // first test - for prefix, like /xxx/*
- // TODO - select correct dispatcher.
- if (mappingPattern.endsWith("*")) {
- if (null == mapping) {
- mapping = new Mapping();
- }
- int cut = mappingPattern.endsWith("/*")?2:1;
- mapping.setPrefix(mappingPattern.substring(0,
- mappingPattern.length() - cut));
- break;
- } else
- // test for suffix mapping, eg *.xxx
- if (mappingPattern.startsWith("*")) {
- if (null == mapping) {
- mapping = new Mapping();
- }
- mapping.setSuffix(mappingPattern.substring(1));
- } else {
- // Fixed mapping - do not use it.
- }
- }
- }
- return mapping;
- }
-
- /**
- * @return Returns the prefixMapping.
- */
- public boolean isPrefixMapping() {
- return _prefixMapping;
- }
-
- private static class Mapping {
- private String prefix;
- private String suffix;
-
- /**
- * @return the prefix
- */
- public String getPrefix() {
- return prefix;
- }
-
- /**
- * @param prefix
- * the prefix to set
- */
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
-
- /**
- * @return the suffix
- */
- public String getSuffix() {
- return suffix;
- }
-
- /**
- * @param suffix
- * the suffix to set
- */
- public void setSuffix(String suffix) {
- this.suffix = suffix;
- }
- }
-
- /**
- * @return the facesServletPrefix
- */
- public String getFacesServletPrefix() {
- return _facesServletPrefix;
- }
-
- /**
- * @return the facesServletSuffix
- */
- public String getFacesServletSuffix() {
- return _facesServletSuffix;
- }
}
Modified: trunk/framework/impl/src/test/java/org/ajax4jsf/config/StateHandlerTest.java
===================================================================
--- trunk/framework/impl/src/test/java/org/ajax4jsf/config/StateHandlerTest.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/test/java/org/ajax4jsf/config/StateHandlerTest.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -52,8 +52,11 @@
throw new SAXException();
}
};
- StateHandler handler = new StateHandler(reader,parentHandler){
-
+ StateHandler handler = new StateHandler(parentHandler){
+ @Override
+ protected XMLReader getReader() {
+ return reader;
+ }
};
reader.setContentHandler(handler);
handler.startElement(NS, BAR, PREFIX+BAR, null);
Modified: trunk/framework/impl/src/test/java/org/ajax4jsf/config/WebXMLTest.java
===================================================================
--- trunk/framework/impl/src/test/java/org/ajax4jsf/config/WebXMLTest.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/test/java/org/ajax4jsf/config/WebXMLTest.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -4,6 +4,7 @@
package org.ajax4jsf.config;
import java.io.InputStream;
+import java.util.List;
import junit.framework.TestCase;
@@ -28,16 +29,19 @@
}
/**
- * Test method for {@link org.jboss.portletbridge.util.WebXML#parse(java.io.InputStream)}.
+ * Test method for {@link org.WebXMLParser.portletbridge.util.WebXML#init(java.io.InputStream, String)}.
*/
public void testParse() throws Exception {
- WebXML webXml = new WebXML();
+ WebXMLParser webXml = new WebXMLParser();
InputStream inputStream = this.getClass().getResourceAsStream("/WEB-INF/web.xml");
- webXml.parse(inputStream);
+ webXml.init(inputStream, "foo");
inputStream.close();
- assertEquals(2, webXml.getFacesServletMappings().size());
+ List<String> facesServletMappings = webXml.getFacesServletMappings();
+ assertEquals(2, facesServletMappings.size());
assertEquals("*.jsf", webXml.getFacesServletMappings().get(1));
assertEquals("/faces/*", webXml.getFacesServletMappings().get(0));
+ assertEquals(".jsf", webXml.getFacesServletSuffix());
+ assertEquals("/faces", webXml.getFacesServletPrefix());
}
}
Modified: trunk/framework/impl/src/test/java/org/ajax4jsf/config/WebappHandlerTest.java
===================================================================
--- trunk/framework/impl/src/test/java/org/ajax4jsf/config/WebappHandlerTest.java 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/test/java/org/ajax4jsf/config/WebappHandlerTest.java 2008-08-26 22:11:44 UTC (rev 10203)
@@ -3,8 +3,11 @@
*/
package org.ajax4jsf.config;
+import java.util.List;
+
import junit.framework.TestCase;
+import org.ajax4jsf.config.WebappHandler.ServletMappingHandler;
import org.xml.sax.ContentHandler;
/**
@@ -21,7 +24,6 @@
private static final String SERVLET_CLASS = "servlet-class";
private static final String SERVLET_MAPPING = "servlet-mapping";
private MockXmlReader reader;
- private ServletBean facesServlet;
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
@@ -29,7 +31,6 @@
protected void setUp() throws Exception {
super.setUp();
reader = new MockXmlReader();
- facesServlet = new ServletBean();
}
/* (non-Javadoc)
@@ -40,7 +41,7 @@
}
public void testServletElement() throws Exception {
- WebappHandler handler = new WebappHandler(reader,facesServlet);
+ WebappHandler handler = new WebappHandler(reader);
reader.setContentHandler(handler);
handler.startElement(null, WEBAPP, WEBAPP, null);
assertEquals(handler, reader.getContentHandler());
@@ -63,17 +64,19 @@
assertEquals(handler, reader.getContentHandler());
handler.endElement(null, WEBAPP, WEBAPP);
handler.endDocument();
- assertEquals("Faces Servlet", facesServlet.getName());
+ List<ServletBean> servlets = handler.getServlets();
+ assertEquals(1, servlets.size());
+ assertEquals(0, servlets.indexOf(new ServletBean("Faces Servlet",null)));
}
public void testMappingElement() throws Exception {
- WebappHandler handler = new WebappHandler(reader,facesServlet);
+ WebappHandler handler = new WebappHandler(reader);
reader.setContentHandler(handler);
handler.startElement(null, WEBAPP, WEBAPP, null);
assertEquals(handler, reader.getContentHandler());
handler.startElement(null, SERVLET_MAPPING, SERVLET_MAPPING, null);
ContentHandler servletHandler = reader.getContentHandler();
- assertSame(WebappHandler.MappingHandler.class, reader.getContentHandler().getClass());
+ assertSame(ServletMappingHandler.class, reader.getContentHandler().getClass());
servletHandler.startElement(null, SERVLET_NAME, SERVLET_NAME, null);
assertSame(StringContentHandler.class, reader.getContentHandler().getClass());
Modified: trunk/framework/impl/src/test/resources/WEB-INF/web.xml
===================================================================
--- trunk/framework/impl/src/test/resources/WEB-INF/web.xml 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/framework/impl/src/test/resources/WEB-INF/web.xml 2008-08-26 22:11:44 UTC (rev 10203)
@@ -11,6 +11,15 @@
/WEB-INF/a-faces-config.xml,/WEB-INF/b-faces-config.xml
</param-value>
</context-param>
+
+ <filter>
+ <filter-name>foo</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>foo</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ </filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
Modified: trunk/samples/seamIntegration/pom.xml
===================================================================
--- trunk/samples/seamIntegration/pom.xml 2008-08-26 18:56:48 UTC (rev 10202)
+++ trunk/samples/seamIntegration/pom.xml 2008-08-26 22:11:44 UTC (rev 10203)
@@ -27,29 +27,16 @@
<artifactId>maven-war-plugin</artifactId>
<configuration>
<!--
- <webResources>
- <resource>
- <directory>${seamHome}</directory>
- <targetPath>WEB-INF/lib</targetPath>
- <includes>
+ <webResources> <resource> <directory>${seamHome}</directory>
+ <targetPath>WEB-INF/lib</targetPath> <includes>
<include>jboss-seam.jar</include>
<include>jboss-seam-ui.jar</include>
- <include>jboss-seam-debug.jar</include>
- <include>
- jboss-seam-remoting.jar
- </include>
- <include>
- jboss-seam-pdf.jar
- </include>
- </includes>
- </resource>
- <resource>
+ <include>jboss-seam-debug.jar</include> <include>
+ jboss-seam-remoting.jar </include> <include> jboss-seam-pdf.jar
+ </include> </includes> </resource> <resource>
<directory>${seamHome}/lib</directory>
- <targetPath>WEB-INF/lib</targetPath>
- <includes>
- <include>jboss-el.jar</include>
- </includes>
- </resource>
+ <targetPath>WEB-INF/lib</targetPath> <includes>
+ <include>jboss-el.jar</include> </includes> </resource>
</webResources>
-->
</configuration>
@@ -77,12 +64,17 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
- <version>3.3.2.GA</version>
+ <version>3.4.0.GA</version>
</dependency>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jcl</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
- <version>3.0.0.ga</version>
+ <version>3.1.0.CR2</version>
</dependency>
<dependency>
<groupId>org.jboss.seam</groupId>
16 years, 4 months
JBoss Rich Faces SVN: r10202 - trunk/framework/impl/src/main/java/org/ajax4jsf/application.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-08-26 14:56:48 -0400 (Tue, 26 Aug 2008)
New Revision: 10202
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
Log:
Imports optimized
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2008-08-26 18:55:35 UTC (rev 10201)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2008-08-26 18:56:48 UTC (rev 10202)
@@ -24,13 +24,9 @@
import java.io.IOException;
import java.util.Map;
-import javax.el.ExpressionFactory;
-import javax.el.ValueExpression;
import javax.faces.FacesException;
-import javax.faces.application.Application;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -42,7 +38,6 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.util.ELUtils;
import org.ajax4jsf.webapp.BaseFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
16 years, 4 months
JBoss Rich Faces SVN: r10201 - in trunk/framework/impl/src/main/java/org/ajax4jsf: context and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-08-26 14:55:35 -0400 (Tue, 26 Aug 2008)
New Revision: 10201
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
Log:
Refactoring: initialization code moved from AjaxViewHandler to ViewResources
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2008-08-26 18:05:23 UTC (rev 10200)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2008-08-26 18:55:35 UTC (rev 10201)
@@ -68,9 +68,6 @@
public static final String VIEW_ID_KEY = "org.ajax4jsf.VIEW_ID";
- private static final String INIT_PARAMETER_PREFIX = "_init_parameter_";
- private static final Object NULL = new Object();
-
/**
* @param parent
*/
@@ -213,46 +210,7 @@
ViewResources viewResources = new ViewResources();
- boolean extendedSkinningAllowed = true;
- String skinningLevel = getInitParameterValue(context, InternetResourceBuilder.CONTROL_SKINNING_LEVEL);
- if (skinningLevel != null && skinningLevel.length() > 0) {
- if (InternetResourceBuilder.BASIC.equals(skinningLevel)) {
- extendedSkinningAllowed = false;
- } else if (!InternetResourceBuilder.EXTENDED.equals(skinningLevel)) {
- throw new IllegalArgumentException("Value: " + skinningLevel +
- " of " + InternetResourceBuilder.CONTROL_SKINNING_LEVEL
- + " init parameter is invalid! Only " + InternetResourceBuilder.EXTENDED
- + ", " + InternetResourceBuilder.BASIC + " can be used");
- }
- }
-
- viewResources.setExtendedSkinningAllowed(extendedSkinningAllowed);
-
- viewResources.setScriptStrategy(getInitParameterValue(context,
- InternetResourceBuilder.LOAD_SCRIPT_STRATEGY_PARAM));
-
- boolean useStdControlsSkinning = false;
-
- String stdControlsSkinning = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_PARAM);
- if (stdControlsSkinning != null) {
- useStdControlsSkinning = InternetResourceBuilder.ENABLE.equals(stdControlsSkinning);
- }
-
- viewResources.setUseStdControlsSkinning(useStdControlsSkinning);
-
- boolean useStdControlsSkinningClasses = true;
-
- String stdControlsSkinningClasses = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_CLASSES_PARAM);
- if (stdControlsSkinningClasses != null) {
- useStdControlsSkinningClasses = InternetResourceBuilder.ENABLE.equals(stdControlsSkinningClasses);
- }
-
- viewResources.setUseStdControlsSkinningClasses(useStdControlsSkinningClasses);
-
- viewResources.setStyleStrategy(getInitParameterValue(context,
- InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM));
-
-
+ viewResources.initialize(context);
viewResources.processHeadResources(context);
requestMap.put(AjaxContext.HEAD_EVENTS_PARAMETER, viewResources.getHeadEvents());
@@ -277,55 +235,4 @@
ajaxRoot.broadcastAjaxEvents(context);
}
- private static String getInitParameterValue(FacesContext context, String parameterName) {
-
- String key = INIT_PARAMETER_PREFIX + parameterName;
-
- ExternalContext externalContext = context.getExternalContext();
- Map<String, Object> applicationMap = externalContext.getApplicationMap();
- Object mutex = externalContext.getRequest();
- Object parameterValue = null;
-
- synchronized (mutex) {
- parameterValue = applicationMap.get(key);
-
- if (parameterValue == null) {
-
- String initParameter = externalContext.getInitParameter(parameterName);
- if (initParameter != null) {
-
- if (ELUtils.isValueReference(initParameter)) {
- Application application = context.getApplication();
- ExpressionFactory expressionFactory = application.getExpressionFactory();
-
- parameterValue = expressionFactory.createValueExpression(context.getELContext(),
- initParameter,
- String.class);
- } else {
- parameterValue = initParameter;
- }
-
- } else {
- parameterValue = NULL;
- }
-
- applicationMap.put(key, parameterValue);
- }
- }
-
- return evaluate(context, parameterValue);
- }
-
- private static String evaluate(FacesContext context, Object parameterValue) {
- if (parameterValue == NULL || parameterValue == null) {
- return null;
- } else if (parameterValue instanceof ValueExpression) {
- ValueExpression expression = (ValueExpression) parameterValue;
-
- return (String) expression.getValue(context.getELContext());
- } else {
- return parameterValue.toString();
- }
- }
-
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2008-08-26 18:05:23 UTC (rev 10200)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/ViewResources.java 2008-08-26 18:55:35 UTC (rev 10201)
@@ -29,9 +29,13 @@
import java.util.Map;
import java.util.Set;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.RenderKit;
@@ -52,6 +56,7 @@
import org.ajax4jsf.resource.ResourceNotFoundException;
import org.ajax4jsf.resource.ResourceRenderer;
import org.ajax4jsf.resource.URIInternetResource;
+import org.ajax4jsf.util.ELUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.richfaces.skin.Skin;
@@ -64,6 +69,9 @@
public class ViewResources {
+ private static final String INIT_PARAMETER_PREFIX = "_init_parameter_";
+ private static final Object NULL = new Object();
+
private String scriptStrategy;
private String styleStrategy;
@@ -532,4 +540,99 @@
}
}
}
+
+ private static String getInitParameterValue(FacesContext context, String parameterName) {
+
+ String key = INIT_PARAMETER_PREFIX + parameterName;
+
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, Object> applicationMap = externalContext.getApplicationMap();
+ Object mutex = externalContext.getRequest();
+ Object parameterValue = null;
+
+ synchronized (mutex) {
+ parameterValue = applicationMap.get(key);
+
+ if (parameterValue == null) {
+
+ String initParameter = externalContext.getInitParameter(parameterName);
+ if (initParameter != null) {
+
+ if (ELUtils.isValueReference(initParameter)) {
+ Application application = context.getApplication();
+ ExpressionFactory expressionFactory = application.getExpressionFactory();
+
+ parameterValue = expressionFactory.createValueExpression(context.getELContext(),
+ initParameter,
+ String.class);
+ } else {
+ parameterValue = initParameter;
+ }
+
+ } else {
+ parameterValue = NULL;
+ }
+
+ applicationMap.put(key, parameterValue);
+ }
+ }
+
+ return evaluate(context, parameterValue);
+ }
+
+ private static String evaluate(FacesContext context, Object parameterValue) {
+ if (parameterValue == NULL || parameterValue == null) {
+ return null;
+ } else if (parameterValue instanceof ValueExpression) {
+ ValueExpression expression = (ValueExpression) parameterValue;
+
+ return (String) expression.getValue(context.getELContext());
+ } else {
+ return parameterValue.toString();
+ }
+ }
+
+ public void initialize(FacesContext context) {
+ boolean extendedSkinningAllowed = true;
+ String skinningLevel = getInitParameterValue(context, InternetResourceBuilder.CONTROL_SKINNING_LEVEL);
+ if (skinningLevel != null && skinningLevel.length() > 0) {
+ if (InternetResourceBuilder.BASIC.equals(skinningLevel)) {
+ extendedSkinningAllowed = false;
+ } else if (!InternetResourceBuilder.EXTENDED.equals(skinningLevel)) {
+ throw new IllegalArgumentException("Value: " + skinningLevel +
+ " of " + InternetResourceBuilder.CONTROL_SKINNING_LEVEL
+ + " init parameter is invalid! Only " + InternetResourceBuilder.EXTENDED
+ + ", " + InternetResourceBuilder.BASIC + " can be used");
+ }
+ }
+
+ this.setExtendedSkinningAllowed(extendedSkinningAllowed);
+
+ this.setScriptStrategy(getInitParameterValue(context,
+ InternetResourceBuilder.LOAD_SCRIPT_STRATEGY_PARAM));
+
+ boolean useStdControlsSkinning = false;
+
+ String stdControlsSkinning = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_PARAM);
+ if (stdControlsSkinning != null) {
+ useStdControlsSkinning = InternetResourceBuilder.ENABLE.equals(stdControlsSkinning);
+ }
+
+ this.setUseStdControlsSkinning(useStdControlsSkinning);
+
+ boolean useStdControlsSkinningClasses = true;
+
+ String stdControlsSkinningClasses = getInitParameterValue(context, InternetResourceBuilder.STD_CONTROLS_SKINNING_CLASSES_PARAM);
+ if (stdControlsSkinningClasses != null) {
+ useStdControlsSkinningClasses = InternetResourceBuilder.ENABLE.equals(stdControlsSkinningClasses);
+ }
+
+ this.setUseStdControlsSkinningClasses(useStdControlsSkinningClasses);
+
+ this.setStyleStrategy(getInitParameterValue(context,
+ InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM));
+
+
+ }
+
}
16 years, 4 months
JBoss Rich Faces SVN: r10200 - in trunk/ui/tree/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-08-26 14:05:23 -0400 (Tue, 26 Aug 2008)
New Revision: 10200
Modified:
trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js
Log:
https://jira.jboss.org/jira/browse/RF-4256
Modified: trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2008-08-26 17:40:27 UTC (rev 10199)
+++ trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2008-08-26 18:05:23 UTC (rev 10200)
@@ -66,12 +66,12 @@
String id = treeNode.getClientId(context);
StringBuilder script = new StringBuilder();
- script.append("$(this).up('TABLE').object.");
+ script.append("Tree.");
boolean expanded = tree.isExpanded();
if (expanded) {
- script.append("fireCollapsionEvent();");
+ script.append("fireCollapsionEvent(this);");
} else {
- script.append("fireExpansionEvent();");
+ script.append("fireExpansionEvent(this);");
}
if (UITree.SWITCH_AJAX.equals(tree.getSwitchType())) {
Modified: trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js
===================================================================
--- trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js 2008-08-26 17:40:27 UTC (rev 10199)
+++ trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/scripts/tree.js 2008-08-26 18:05:23 UTC (rev 10200)
@@ -19,6 +19,22 @@
Tree.CLASS_ITEM_COLLAPSED = "dr-tree-h-ic-line-clp";
Tree.CLASS_AJAX_SELECTED_LISTENER_FLAG = "ajax_selected_listener_flag";
+Tree.findComponent = function(elt) {
+ while (elt && (!elt.tagName || elt.tagName.toLowerCase() != 'table')) {
+ elt = elt.parentNode;
+ }
+
+ return elt.object;
+};
+
+Tree.fireCollapsionEvent = function(elt) {
+ return Tree.findComponent(elt).fireCollapsionEvent();
+};
+
+Tree.fireExpansionEvent = function(elt) {
+ return Tree.findComponent(elt).fireExpansionEvent();
+};
+
Tree.prototype = {
initialize: function(id, input, switchType, events, onAjaxSelect, toggleOnClick, showConnectingLines) {
this.childs = [];
16 years, 4 months
JBoss Rich Faces SVN: r10199 - in trunk/ui/tree/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-08-26 13:40:27 -0400 (Tue, 26 Aug 2008)
New Revision: 10199
Modified:
trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss
trunk/ui/tree/src/main/templates/htmlTree.jspx
Log:
Script DIV made invisible in tree
Modified: trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss
===================================================================
--- trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss 2008-08-26 16:14:08 UTC (rev 10198)
+++ trunk/ui/tree/src/main/resources/org/richfaces/renderkit/html/css/tree.xcss 2008-08-26 17:40:27 UTC (rev 10199)
@@ -15,7 +15,7 @@
zoom: 1;
}
-.dr-tree-h-input {
+.dr-tree-h-input, .dr-tree-h-script {
display: none;
}
Modified: trunk/ui/tree/src/main/templates/htmlTree.jspx
===================================================================
--- trunk/ui/tree/src/main/templates/htmlTree.jspx 2008-08-26 16:14:08 UTC (rev 10198)
+++ trunk/ui/tree/src/main/templates/htmlTree.jspx 2008-08-26 17:40:27 UTC (rev 10199)
@@ -65,7 +65,7 @@
);
#{this:getScriptContributions(context, component)}
</script>
- <div id="#{clientId}:script">
+ <div id="#{clientId}:script" class="dr-tree-h-script">
<script type="text/javascript">
</script>
</div>
16 years, 4 months
JBoss Rich Faces SVN: r10198 - trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2008-08-26 12:14:08 -0400 (Tue, 26 Aug 2008)
New Revision: 10198
Modified:
trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss
Log:
Bug fixing(RF-4176)
Modified: trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss
===================================================================
--- trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss 2008-08-26 16:11:56 UTC (rev 10197)
+++ trunk/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/css/menucomponents.xcss 2008-08-26 16:14:08 UTC (rev 10198)
@@ -108,7 +108,7 @@
<u:style name="border-top-color" skin="panelBorderColor" />
</u:selector>
-<u:selector name=".dr-menu-item, .dr-menu-item a">
+<u:selector name=".dr-menu-item, .dr-menu-item a, .dr-menu-item a:hover, .dr-menu-item a:visited">
<u:style name="color" skin="generalTextColor" />
<u:style name="font-family" skin="generalFamilyFont" />
<u:style name="font-size" skin="generalSizeFont" />
16 years, 4 months
JBoss Rich Faces SVN: r10197 - trunk/test-applications/facelets/src/main/webapp/DragAndDrop.
by richfaces-svn-commits@lists.jboss.org
Author: mvitenkov
Date: 2008-08-26 12:11:56 -0400 (Tue, 26 Aug 2008)
New Revision: 10197
Modified:
trunk/test-applications/facelets/src/main/webapp/DragAndDrop/DragAndDrop.xhtml
Log:
+cursors styles
Modified: trunk/test-applications/facelets/src/main/webapp/DragAndDrop/DragAndDrop.xhtml
===================================================================
--- trunk/test-applications/facelets/src/main/webapp/DragAndDrop/DragAndDrop.xhtml 2008-08-26 15:43:11 UTC (rev 10196)
+++ trunk/test-applications/facelets/src/main/webapp/DragAndDrop/DragAndDrop.xhtml 2008-08-26 16:11:56 UTC (rev 10197)
@@ -41,6 +41,8 @@
<h:panelGrid styleClass="dropzoneDecoration" id="drop2">
<h:outputText value="#{type} - drop" />
<rich:dropSupport reRender="dragValueText" id="dropSupportID"
+ rejectCursors="not-allowed"
+ acceptCursors="help"
actionListener="#{dndBean.actListenerDrop}"
action="#{dndBean.dropAction}" acceptedTypes="#{type}"
dropListener="#{dndBean.processDrop}" dropValue="#{type} - value"
16 years, 4 months
JBoss Rich Faces SVN: r10196 - in trunk/ui/inplaceInput/src/main: java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-08-26 11:43:11 -0400 (Tue, 26 Aug 2008)
New Revision: 10196
Modified:
trunk/ui/inplaceInput/src/main/config/component/inplaceinput.xml
trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
trunk/ui/inplaceInput/src/main/templates/inplaceinput.jspx
Log:
https://jira.jboss.org/jira/browse/RF-3895
Modified: trunk/ui/inplaceInput/src/main/config/component/inplaceinput.xml
===================================================================
--- trunk/ui/inplaceInput/src/main/config/component/inplaceinput.xml 2008-08-26 15:42:18 UTC (rev 10195)
+++ trunk/ui/inplaceInput/src/main/config/component/inplaceinput.xml 2008-08-26 15:43:11 UTC (rev 10196)
@@ -60,7 +60,7 @@
<name>defaultLabel</name>
<classname>java.lang.String</classname>
<description>The attribute is used to display text while value is undefined</description>
- <defaultvalue>"   "</defaultvalue>
+ <defaultvalue>"\u00a0\u00a0\u00a0"</defaultvalue>
</property>
<property>
<name>showControls</name>
Modified: trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
===================================================================
--- trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2008-08-26 15:42:18 UTC (rev 10195)
+++ trunk/ui/inplaceInput/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2008-08-26 15:43:11 UTC (rev 10196)
@@ -50,7 +50,7 @@
private static final String INPLACE_CSS_HOVER = "hover";
- private static final String EMPTY_DEFAULT_LABEL = "   ";
+ private static final String EMPTY_DEFAULT_LABEL = "\u00a0\u00a0\u00a0";
private static enum States {
NORMAL {String createCss(UIComponent component, String suffix){
Modified: trunk/ui/inplaceInput/src/main/templates/inplaceinput.jspx
===================================================================
--- trunk/ui/inplaceInput/src/main/templates/inplaceinput.jspx 2008-08-26 15:42:18 UTC (rev 10195)
+++ trunk/ui/inplaceInput/src/main/templates/inplaceinput.jspx 2008-08-26 15:43:11 UTC (rev 10196)
@@ -37,7 +37,7 @@
fieldValue = "";
String defaultValue = (String)component.getAttributes().get("defaultLabel");
if(defaultValue == null || defaultValue.equals("")) {
- defaultValue = "   ";
+ defaultValue = "\u00a0\u00a0\u00a0";
}
value = defaultValue;
}
16 years, 4 months
JBoss Rich Faces SVN: r10195 - in trunk/ui/inplaceSelect/src/main: java/org/richfaces/renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-08-26 11:42:18 -0400 (Tue, 26 Aug 2008)
New Revision: 10195
Modified:
trunk/ui/inplaceSelect/src/main/config/component/inplaceselect.xml
trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
Log:
https://jira.jboss.org/jira/browse/RF-4244
Modified: trunk/ui/inplaceSelect/src/main/config/component/inplaceselect.xml
===================================================================
--- trunk/ui/inplaceSelect/src/main/config/component/inplaceselect.xml 2008-08-26 15:11:46 UTC (rev 10194)
+++ trunk/ui/inplaceSelect/src/main/config/component/inplaceselect.xml 2008-08-26 15:42:18 UTC (rev 10195)
@@ -67,7 +67,7 @@
<name>defaultLabel</name>
<classname>java.lang.String</classname>
<description>The attribute is used to display text while value is undefined</description>
- <defaultvalue>"   "</defaultvalue>
+ <defaultvalue>"\u00a0\u00a0\u00a0"</defaultvalue>
</property>
<property>
<name>showControls</name>
Modified: trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
===================================================================
--- trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2008-08-26 15:11:46 UTC (rev 10194)
+++ trunk/ui/inplaceSelect/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2008-08-26 15:42:18 UTC (rev 10195)
@@ -30,7 +30,7 @@
//TODO: move duplicate constants to superclass
private static final String RICH_INPLACE_SELECT_CLASSES = "rich-inplace-select-item rich-inplace-select-font";
private static final String CONTROLS_FACET = "controls";
- private static final String EMPTY_DEFAULT_LABEL = "   ";
+ private static final String EMPTY_DEFAULT_LABEL = "\u00a0\u00a0\u00a0";
@Override
protected void doDecode(FacesContext context, UIComponent component) {
16 years, 4 months