JBoss Rich Faces SVN: r7048 - trunk/framework/test/src/test/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-21 09:47:32 -0400 (Fri, 21 Mar 2008)
New Revision: 7048
Modified:
trunk/framework/test/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java
Log:
Reverted changes from version reverted changes in BaseXMLFilter
Modified: trunk/framework/test/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java 2008-03-21 13:47:23 UTC (rev 7047)
+++ trunk/framework/test/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java 2008-03-21 13:47:32 UTC (rev 7048)
@@ -23,13 +23,8 @@
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
-import javax.faces.context.FacesContext;
-import org.ajax4jsf.io.parser.FastHtmlParser;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.ajax4jsf.webapp.BaseXMLFilter;
-import org.ajax4jsf.webapp.HtmlParser;
-import org.ajax4jsf.webapp.ParserFacade;
/**
* Created 26.10.2007
@@ -52,22 +47,6 @@
protected Class<? extends UIComponent> getComponentClass() {
return UIOutput.class;
}
-
- @Override
- protected ParserFacade getParserFacade(FacesContext context) {
- return new ParserFacade(context) {
- @Override
- protected HtmlParser getParser(FacesContext context,
- BaseXMLFilter filter) {
- return new FastHtmlParser();
- }
- @Override
- protected void reuseParser() {
-
- }
- };
- }
-
};
UIOutput output = new UIOutput();
16 years, 10 months
JBoss Rich Faces SVN: r7047 - in trunk/framework/impl/src/main/java/org: ajax4jsf/webapp/nekko and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-21 09:47:23 -0400 (Fri, 21 Mar 2008)
New Revision: 7047
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserFacade.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
Log:
Reverted changes from version reverted changes in BaseXMLFilter
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2008-03-21 13:35:56 UTC (rev 7046)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2008-03-21 13:47:23 UTC (rev 7047)
@@ -79,19 +79,12 @@
public static final String APPLICATION_XHTML_XML = "application/xhtml+xml";
- private static BaseXMLFilter INSTANCE;
-
public BaseFilter filter;
public void setFilter(BaseFilter filter) {
this.filter = filter;
}
- static BaseXMLFilter getInstance(FacesContext context) {
- return INSTANCE;//(BaseXMLFilter) context.getExternalContext().getApplicationMap().get(APPLICATION_SCOPE_KEY);
- }
-
-
public void init(FilterConfig config) throws ServletException {
if (log.isDebugEnabled()) {
log.debug("init XML filter service with class "
@@ -112,9 +105,6 @@
setNamespace((String) nz(config.getInitParameter(NAMESPACE_PARAMETER),
getNamespace()));
-
- INSTANCE = this;
-
}
/**
@@ -375,7 +365,7 @@
protected abstract void reuseParser(HtmlParser parser);
- public abstract HtmlParser getParser(String mimetype, boolean isAjax,
+ protected abstract HtmlParser getParser(String mimetype, boolean isAjax,
String viewId);
/**
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java 2008-03-21 13:35:56 UTC (rev 7046)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java 2008-03-21 13:47:23 UTC (rev 7047)
@@ -103,7 +103,7 @@
* @see org.ajax4jsf.webapp.BaseXMLFilter#getParser(java.lang.String,
* boolean, java.lang.String)
*/
- public HtmlParser getParser(String mimetype, boolean isAjax,
+ protected HtmlParser getParser(String mimetype, boolean isAjax,
String viewId) {
HtmlParser parser = null;
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserFacade.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserFacade.java 2008-03-21 13:35:56 UTC (rev 7046)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserFacade.java 2008-03-21 13:47:23 UTC (rev 7047)
@@ -1,49 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.webapp;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ParserFacade {
-
- private HtmlParser parser;
-
- private BaseXMLFilter filter;
-
- public static ParserFacade newInstance(FacesContext context) {
- return new ParserFacade(context);
- }
-
- public ParserFacade(FacesContext context) {
- super();
- this.filter = BaseXMLFilter.getInstance(context);
- this.parser = getParser(context, filter);
-
- }
-
- public void parseHtml(Reader input, Writer output) throws IOException {
- parser.parseHtml(input, output);
- reuseParser();
- }
-
- protected HtmlParser getParser(FacesContext context, BaseXMLFilter filter) {
- UIViewRoot viewRoot = context.getViewRoot();
- HtmlParser parser = filter.getParser(filter.getMimetype(), true, viewRoot.getViewId());
- return parser;
- }
-
- protected void reuseParser() {
- filter.reuseParser(parser);
- }
-
-}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java 2008-03-21 13:35:56 UTC (rev 7046)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java 2008-03-21 13:47:23 UTC (rev 7047)
@@ -36,7 +36,7 @@
public NekkoXMLFilter() {}
- public HtmlParser getParser(String mimetype, boolean isAjax, String viewId) {
+ protected HtmlParser getParser(String mimetype, boolean isAjax, String viewId) {
HtmlParser parser = null;
if( isAjax ){
parser = getXmlParser();
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java 2008-03-21 13:35:56 UTC (rev 7046)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java 2008-03-21 13:47:23 UTC (rev 7047)
@@ -67,7 +67,7 @@
* @param string Encodings for parser
* @return
*/
- public HtmlParser getParser(String mime, boolean isAjax, String viewId) {
+ protected HtmlParser getParser(String mime, boolean isAjax, String viewId) {
// For non-ajax, parse only html types !
if (isAjax || mime.startsWith(TEXT_HTML) || mime.startsWith(APPLICATION_XHTML_XML)) {
if(isAjax || isForcexml()){
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2008-03-21 13:35:56 UTC (rev 7046)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2008-03-21 13:47:23 UTC (rev 7047)
@@ -5,18 +5,17 @@
import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
+import java.util.Properties;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
@@ -28,15 +27,15 @@
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
-import org.ajax4jsf.webapp.ParserFacade;
+import org.ajax4jsf.resource.util.URLToStreamHelper;
+import org.ajax4jsf.webapp.tidy.TidyParser;
+import org.ajax4jsf.webapp.tidy.TidyXMLFilter;
import org.richfaces.component.TemplateComponent;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
/**
* @author Nick Belaevski - mailto:nbelaevski@exadel.com
@@ -60,88 +59,68 @@
return true;
}
- protected ParserFacade getParserFacade(FacesContext context) {
- return ParserFacade.newInstance(context);
- }
-
public void writeScriptBody(Writer writer, String string) throws IOException {
- ParserFacade parserFacade = getParserFacade(FacesContext.getCurrentInstance());
- StringReader stringReader = new StringReader(string);
- StringWriter stringWriter = new StringWriter();
- parserFacade.parseHtml(stringReader, stringWriter);
+ Properties tidyProperties = new Properties();
+ InputStream propertiesStream = null;
+ try {
+ propertiesStream = URLToStreamHelper.urlToStreamSafe(
+ TidyXMLFilter.class.getResource("tidy.properties"));
+ tidyProperties.load(propertiesStream);
+ } finally {
+ if (propertiesStream != null) {
+ propertiesStream.close();
+ }
+ }
- boolean wroteAnything = false;
- String wellFormed = stringWriter.toString();
- if (wellFormed != null && wellFormed.length() > 0) {
- Document document = parse(wellFormed);
+ TidyParser tidyParser = new TidyParser(tidyProperties);
+ Document parsedHtml = tidyParser.parseHtmlByTidy(new StringReader(string), null);
- Element documentElement = null;
+ Element documentElement = null;
+
+ if (parsedHtml != null) {
+ documentElement = parsedHtml.getDocumentElement();
+ }
+
+ if (documentElement != null) {
+ writer.write("[");
- if (document != null) {
- documentElement = document.getDocumentElement();
- }
-
- if (documentElement != null) {
- writer.write("[");
-
- NodeList nodeList = documentElement.getChildNodes();
- Node bodyNode = nodeList.item(nodeList.getLength() - 1);
- NodeList bodyChildren = bodyNode.getChildNodes();
- int bodyChildrenLength = bodyChildren.getLength();
+ NodeList nodeList = documentElement.getChildNodes();
+ Node bodyNode = nodeList.item(nodeList.getLength() - 1);
+ NodeList bodyChildren = bodyNode.getChildNodes();
+ int bodyChildrenLength = bodyChildren.getLength();
- try {
- Transformer transformer;
+ try {
+ Transformer transformer;
- TransformerFactory factory = getTransformerFactory();
-
- synchronized (factory) {
- transformer = factory.newTransformer();
- }
+ TransformerFactory factory = getTransformerFactory();
+
+ synchronized (factory) {
+ transformer = factory.newTransformer();
+ }
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- ContentHandler contentHandler = createContentHandler(writer);
- Result result = new SAXResult(contentHandler);
+ ContentHandler contentHandler = createContentHandler(writer);
+ Result result = new SAXResult(contentHandler);
- for (int i = 0; i < bodyChildrenLength; i++) {
- if (i != 0) {
- writer.write(", ");
- }
- transformer.transform(new DOMSource(bodyChildren.item(i)), result);
+ for (int i = 0; i < bodyChildrenLength; i++) {
+ if (i != 0) {
+ writer.write(", ");
}
-
-
- } catch (TransformerException e) {
- throw new IOException(e.getMessage());
+ transformer.transform(new DOMSource(bodyChildren.item(i)), result);
}
-
- writer.write("]");
-
- wroteAnything = true;
-
+ } catch (TransformerException e) {
+ throw new IOException(e.getMessage());
}
- }
+
+ writer.write("]");
-
- if (!wroteAnything) {
+ } else {
writer.write(ScriptUtils.toScript(JSReference.NULL));
}
}
- private Document parse(String xml) throws IOException {
- try {
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder();
- Document document = documentBuilder.parse(new InputSource(new StringReader(xml)));
- return document;
- } catch (ParserConfigurationException e) {
- throw new IOException(e.getMessage());
- } catch (SAXException e) {
- throw new IOException(e.getMessage());
- }
- }
-
protected void writeScriptBody(FacesContext context, UIComponent component, boolean children)
throws IOException {
ResponseWriter writer = context.getResponseWriter();
16 years, 10 months
JBoss Rich Faces SVN: r7046 - in trunk/ui/modal-panel/src/main: java/org/richfaces/renderkit and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-03-21 09:35:56 -0400 (Fri, 21 Mar 2008)
New Revision: 7046
Modified:
trunk/ui/modal-panel/src/main/config/component/modalPanel.xml
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
Log:
http://jira.jboss.com/jira/browse/RF-2201?page=comments
also onbeforeshow/onbeforehide cancelable events are added
Modified: trunk/ui/modal-panel/src/main/config/component/modalPanel.xml
===================================================================
--- trunk/ui/modal-panel/src/main/config/component/modalPanel.xml 2008-03-21 13:20:24 UTC (rev 7045)
+++ trunk/ui/modal-panel/src/main/config/component/modalPanel.xml 2008-03-21 13:35:56 UTC (rev 7046)
@@ -132,6 +132,20 @@
</property>
<property>
+ <name>onbeforeshow</name>
+ <classname>java.lang.String</classname>
+ <description> Event must occurs before panel is opening </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+
+ <property>
+ <name>onbeforehide</name>
+ <classname>java.lang.String</classname>
+ <description> Event must occurs before panel is hiding </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+
+ <property>
<name>onresize</name>
<classname>java.lang.String</classname>
<description>Event must occurs than panel is resizing </description>
Modified: trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
===================================================================
--- trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2008-03-21 13:20:24 UTC (rev 7045)
+++ trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2008-03-21 13:35:56 UTC (rev 7046)
@@ -124,6 +124,8 @@
variables.setVariable("onhide", onhide);
String onbeforeshow = ScriptUtils.toScript(panel.getAttributes().get("onbeforeshow"));
variables.setVariable("onbeforeshow", onbeforeshow);
+ String onbeforehide = ScriptUtils.toScript(panel.getAttributes().get("onbeforehide"));
+ variables.setVariable("onbeforehide", onbeforehide);
String onmove = ScriptUtils.toScript(panel.getAttributes().get("onmove"));
variables.setVariable("onmove", onmove);
}
Modified: trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js
===================================================================
--- trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-03-21 13:20:24 UTC (rev 7045)
+++ trunk/ui/modal-panel/src/main/resources/org/richfaces/renderkit/html/scripts/modalPanel.js 2008-03-21 13:35:56 UTC (rev 7046)
@@ -422,7 +422,7 @@
show: function(event, opts) {
var element = this.id;
- if(this.invokeEvent("show",event,null,element)){
+ if(this.invokeEvent("beforeshow",event,null,element)){
this.preventFocus();
if (!this.floatedToBody) {
@@ -620,6 +620,7 @@
var event = {};
event.parameters = opts || {};
this.shown = true;
+ this.invokeEvent("show",event,null,element);
}
},
@@ -639,57 +640,60 @@
},
hide: function(event, opts) {
- this.restoreFocus();
-
- this.traverseSelects(true);
-
- var eDiv = $(this.div);
- var eCdiv = $(this.cdiv);
-
- if (eDiv.style.removeExpression) {
- eDiv.style.removeExpression("width");
- eDiv.style.removeExpression("height");
-
- eDiv.style.removeExpression("left");
- eDiv.style.removeExpression("top");
-
- var eCursorDiv = $(this.cursorDiv);
- eCursorDiv.style.removeExpression("width");
- eCursorDiv.style.removeExpression("height");
-
- eCursorDiv.style.removeExpression("left");
- eCursorDiv.style.removeExpression("top");
-
- eCdiv.style.removeExpression("left");
- eCdiv.style.removeExpression("top");
- }
-
- var element = $(this.id);
- Element.hide(element);
-
- if (this.floatedToBody && this.parent) {
-
- document.body.removeChild(element);
- this.parent.appendChild(element);
- this.floatedToBody = false;
- }
- var event = {};
- event.parameters = opts || {};
- if (this.eventOnHide) this.eventOnHide(event);
- var forms = eCdiv.getElementsByTagName("form");
- if (this.options.keepVisualState && forms) {
- for (var i = 0; i < forms.length; i++) {
- Event.stopObserving(forms[i], "submit", this.formOnsubmit);
+ if (this.invokeEvent("beforehide",event,null,element)) {
+ this.restoreFocus();
+ this.traverseSelects(true);
+
+ var eDiv = $(this.div);
+ var eCdiv = $(this.cdiv);
+
+ if (eDiv.style.removeExpression) {
+ eDiv.style.removeExpression("width");
+ eDiv.style.removeExpression("height");
+
+ eDiv.style.removeExpression("left");
+ eDiv.style.removeExpression("top");
+
+ var eCursorDiv = $(this.cursorDiv);
+ eCursorDiv.style.removeExpression("width");
+ eCursorDiv.style.removeExpression("height");
+
+ eCursorDiv.style.removeExpression("left");
+ eCursorDiv.style.removeExpression("top");
+
+ eCdiv.style.removeExpression("left");
+ eCdiv.style.removeExpression("top");
}
+
+ var element = $(this.id);
+ Element.hide(element);
+
+ if (this.floatedToBody && this.parent) {
+
+ document.body.removeChild(element);
+ this.parent.appendChild(element);
+ this.floatedToBody = false;
+ }
+
+ var event = {};
+ event.parameters = opts || {};
+ if (this.eventOnHide) this.eventOnHide(event);
+
+ var forms = eCdiv.getElementsByTagName("form");
+ if (this.options.keepVisualState && forms) {
+ for (var i = 0; i < forms.length; i++) {
+ Event.stopObserving(forms[i], "submit", this.formOnsubmit);
+ }
+ }
+
+ this.shown = false;
+
+ if (this.options.autosized) {
+ window.clearInterval(this.observerSize);
+ }
}
-
- this.shown = false;
-
- if (this.options.autosized) {
- window.clearInterval(this.observerSize);
- }
},
_getStyle: function(elt, name) {
@@ -884,20 +888,15 @@
var eventFunction = this.options['on'+eventName];
var result;
- if (eventFunction)
- {
+ if (eventFunction) {
var eventObj;
-
- if (event)
- {
+ if (event) {
eventObj = event;
}
- else if( document.createEventObject )
- {
+ else if(document.createEventObject) {
eventObj = document.createEventObject();
}
- else if( document.createEvent )
- {
+ else if( document.createEvent ) {
eventObj = document.createEvent('Events');
eventObj.initEvent( eventName, true, false );
}
@@ -905,16 +904,15 @@
eventObj.rich = {component:this};
eventObj.rich.value = value;
- try
- {
+ try {
result = eventFunction.call(element, eventObj);
}
catch (e) { LOG.warn("Exception: "+e.Message + "\n[on"+eventName + "]"); }
-
}
- if (result!=false) result = true;
-
+ if (result!=false) {
+ result = true;
+ }
return result;
}
}
Modified: trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx
===================================================================
--- trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2008-03-21 13:20:24 UTC (rev 7045)
+++ trunk/ui/modal-panel/src/main/templates/org/richfaces/htmlModalPanel.jspx 2008-03-21 13:35:56 UTC (rev 7046)
@@ -176,6 +176,8 @@
<f:call name="writeEventHandlerFunction"><f:parameter value="onresize" /></f:call>,
<f:call name="writeEventHandlerFunction"><f:parameter value="onmove" /></f:call>,
<f:call name="writeEventHandlerFunction"><f:parameter value="onshow" /></f:call>,
+ <f:call name="writeEventHandlerFunction"><f:parameter value="onbeforeshow"/></f:call>,
+ <f:call name="writeEventHandlerFunction"><f:parameter value="onbeforehide" /></f:call>,
keepVisualState: #{component.keepVisualState},
showWhenRendered: #{component.showWhenRendered},
16 years, 10 months
JBoss Rich Faces SVN: r7045 - trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: vmolotkov
Date: 2008-03-21 09:20:24 -0400 (Fri, 21 Mar 2008)
New Revision: 7045
Modified:
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
Log:
http://jira.jboss.com/jira/browse/RF-2655
Modified: trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
===================================================================
--- trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-03-21 12:29:59 UTC (rev 7044)
+++ trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-03-21 13:20:24 UTC (rev 7045)
@@ -183,6 +183,7 @@
this.comboList.moveActiveItem(event);
break;
case Event.KEY_ESC :
+ this.field.value = this.field.value; //field must lose focus
this.comboList.hideWithDelay();
break;
}
16 years, 10 months
JBoss Rich Faces SVN: r7042 - in trunk/samples/richfaces-demo/src/main: webapp/richfaces and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2008-03-21 08:23:15 -0400 (Fri, 21 Mar 2008)
New Revision: 7042
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/pickList/PickListBean.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/fileUpload/examples/fileUpload.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/externalSortingUsage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/sortingUsage.xhtml
Log:
refactoring according to Sergey's proposal (split filtering and sorting)
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/pickList/PickListBean.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/pickList/PickListBean.java 2008-03-21 11:44:22 UTC (rev 7041)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/pickList/PickListBean.java 2008-03-21 12:23:15 UTC (rev 7042)
@@ -3,42 +3,24 @@
*/
package org.richfaces.demo.pickList;
-import java.util.ArrayList;
+import java.util.List;
-import javax.faces.model.SelectItem;
-
/**
* @author Ilya Shaikovsky
*
*/
public class PickListBean {
- private ArrayList<String> result;
+ private List<String> result;
- private SelectItem[] optionsAvailable;
-
- public SelectItem[] getOptionsAvailable() {
- return optionsAvailable;
- }
-
- public void setOptionsAvailable(SelectItem[] optionsAvailable) {
- this.optionsAvailable = optionsAvailable;
- }
-
public PickListBean() {
- optionsAvailable = new SelectItem[5];
- for (int i = 0; i < optionsAvailable.length; i++) {
- optionsAvailable[i] = new SelectItem();
- optionsAvailable[i].setLabel("Generated Option " + i);
- optionsAvailable[i].setValue("Value " + i);
- }
}
- public ArrayList<String> getResult() {
+ public List<String> getResult() {
return result;
}
- public void setResult(ArrayList<String> result) {
+ public void setResult(List<String> result) {
this.result = result;
}
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/fileUpload/examples/fileUpload.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/fileUpload/examples/fileUpload.xhtml 2008-03-21 11:44:22 UTC (rev 7041)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/fileUpload/examples/fileUpload.xhtml 2008-03-21 12:23:15 UTC (rev 7042)
@@ -1,10 +1,11 @@
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich">
- <h:form>
- <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}" maxFilesQuantity="10"/>
- </h:form>
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+ <h:form>
+ <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
+ maxFilesQuantity="10" />
+ </h:form>
</ui:composition>
\ No newline at end of file
Copied: trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature (from rev 7036, trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFilteringFeatures)
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/externalSortingUsage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFilteringFeatures/externalSortingUsage.xhtml 2008-03-20 23:36:16 UTC (rev 7036)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/externalSortingUsage.xhtml 2008-03-21 12:23:15 UTC (rev 7042)
@@ -13,9 +13,9 @@
<div class="sample-container" >
- <ui:include src="/richfaces/sortingFilteringFeatures/examples/externalMultipleSorting.xhtml"/>
+ <ui:include src="/richfaces/sortingFeatures/examples/externalMultipleSorting.xhtml"/>
<ui:include src="/templates/include/sourceview.xhtml">
- <ui:param name="sourcepath" value="/richfaces/sortingFilteringFeatures/examples/externalMultipleSorting.xhtml"/>
+ <ui:param name="sourcepath" value="/richfaces/sortingFeature/examples/externalMultipleSorting.xhtml"/>
</ui:include>
</div>
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/sortingUsage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFilteringFeatures/sortingUsage.xhtml 2008-03-20 23:36:16 UTC (rev 7036)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/sortingUsage.xhtml 2008-03-21 12:23:15 UTC (rev 7042)
@@ -13,9 +13,9 @@
<div class="sample-container" >
- <ui:include src="/richfaces/sortingFilteringFeatures/examples/simpleSingleSorting.xhtml"/>
+ <ui:include src="/richfaces/sortingFeature/examples/simpleSingleSorting.xhtml"/>
<ui:include src="/templates/include/sourceview.xhtml">
- <ui:param name="sourcepath" value="/richfaces/sortingFilteringFeatures/examples/simpleSingleSorting.xhtml"/>
+ <ui:param name="sourcepath" value="/richfaces/sortingFeature/examples/simpleSingleSorting.xhtml"/>
</ui:include>
</div>
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature.xhtml 2008-03-21 11:44:22 UTC (rev 7041)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature.xhtml 2008-03-21 12:23:15 UTC (rev 7042)
@@ -9,10 +9,10 @@
<ui:define name="body">
<rich:tabPanel switchType="server" styleClass="top_tab" contentClass="content_tab" headerClass="header_tabs_class" inactiveTabClass="inactive_tab" activeTabClass="active_tab">
<rich:tab label="Built-in Sorting Feature">
- <ui:include src="/richfaces/sortingFilteringFeatures/sortingUsage.xhtml"/>
+ <ui:include src="/richfaces/sortingFeature/sortingUsage.xhtml"/>
</rich:tab>
<rich:tab label="External Sorting">
- <ui:include src="/richfaces/sortingFilteringFeatures/externalSortingUsage.xhtml"/>
+ <ui:include src="/richfaces/sortingFeature/externalSortingUsage.xhtml"/>
</rich:tab>
</rich:tabPanel>
</ui:define>
16 years, 10 months
JBoss Rich Faces SVN: r7040 - in trunk/framework/test/src: test/java/org/richfaces/renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-21 07:38:25 -0400 (Fri, 21 Mar 2008)
New Revision: 7040
Modified:
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
trunk/framework/test/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java
Log:
fixed TemplateEncoder
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2008-03-21 11:38:14 UTC (rev 7039)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2008-03-21 11:38:25 UTC (rev 7040)
@@ -55,6 +55,7 @@
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.tests.org.apache.shale.test.config.ConfigParser;
+import org.ajax4jsf.webapp.ConfigurableXMLFilter;
import org.ajax4jsf.webapp.WebXml;
import org.apache.shale.test.base.AbstractJsfTestCase;
import org.apache.shale.test.mock.MockApplication;
@@ -127,20 +128,12 @@
//e.printStackTrace();
//We cannot set private field
}
- /*
- * Don't know yet how to support enums
- *
- * expressionFactory = new EnumSupportExpressionFactoryWrapper(application.getExpressionFactory());
- application = new MockApplication12() {
- @Override
- public ExpressionFactory getExpressionFactory() {
- return expressionFactory;
- }
- };
- facesContext.setApplication(application);
- */
+
// Setup FacesContext with necessary init parameters.
this.servletContext.addInitParameter(SkinFactory.SKIN_PARAMETER, getSkinName());
+
+
+
// setup VCP renderKit, create renderers.
RenderKitFactory vcpRenderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
vcpRenderKit = new ChameleonRenderKitImpl();
@@ -227,6 +220,9 @@
facesContext.setExternalContext(externalContext);
elContext = facesContext.getELContext();
expressionFactory = application.getExpressionFactory();
+
+
+
}
protected WebClient createWebClient() {
Modified: trunk/framework/test/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java 2008-03-21 11:38:14 UTC (rev 7039)
+++ trunk/framework/test/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java 2008-03-21 11:38:25 UTC (rev 7040)
@@ -21,9 +21,15 @@
package org.richfaces.renderkit;
+import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
+import javax.faces.context.FacesContext;
+import org.ajax4jsf.io.parser.FastHtmlParser;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.webapp.BaseXMLFilter;
+import org.ajax4jsf.webapp.HtmlParser;
+import org.ajax4jsf.webapp.ParserFacade;
/**
* Created 26.10.2007
@@ -43,10 +49,25 @@
TemplateEncoderRendererBase rendererBase = new TemplateEncoderRendererBase() {
@Override
- protected Class getComponentClass() {
+ protected Class<? extends UIComponent> getComponentClass() {
return UIOutput.class;
}
+ @Override
+ protected ParserFacade getParserFacade(FacesContext context) {
+ return new ParserFacade(context) {
+ @Override
+ protected HtmlParser getParser(FacesContext context,
+ BaseXMLFilter filter) {
+ return new FastHtmlParser();
+ }
+ @Override
+ protected void reuseParser() {
+
+ }
+ };
+ }
+
};
UIOutput output = new UIOutput();
16 years, 10 months
JBoss Rich Faces SVN: r7039 - in trunk/framework/impl/src/main/java/org: richfaces/renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-03-21 07:38:14 -0400 (Fri, 21 Mar 2008)
New Revision: 7039
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserFacade.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
Log:
fixed TemplateEncoder
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserFacade.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserFacade.java 2008-03-21 08:57:58 UTC (rev 7038)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserFacade.java 2008-03-21 11:38:14 UTC (rev 7039)
@@ -16,24 +16,33 @@
*/
public class ParserFacade {
+ private HtmlParser parser;
+
private BaseXMLFilter filter;
- private FacesContext context;
-
public static ParserFacade newInstance(FacesContext context) {
return new ParserFacade(context);
}
- private ParserFacade(FacesContext context) {
+ public ParserFacade(FacesContext context) {
super();
- this.context = context;
this.filter = BaseXMLFilter.getInstance(context);
+ this.parser = getParser(context, filter);
+
}
public void parseHtml(Reader input, Writer output) throws IOException {
+ parser.parseHtml(input, output);
+ reuseParser();
+ }
+
+ protected HtmlParser getParser(FacesContext context, BaseXMLFilter filter) {
UIViewRoot viewRoot = context.getViewRoot();
HtmlParser parser = filter.getParser(filter.getMimetype(), true, viewRoot.getViewId());
- parser.parseHtml(input, output);
+ return parser;
+ }
+
+ protected void reuseParser() {
filter.reuseParser(parser);
}
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2008-03-21 08:57:58 UTC (rev 7038)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2008-03-21 11:38:14 UTC (rev 7039)
@@ -5,13 +5,11 @@
import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
-import java.util.Properties;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -30,10 +28,7 @@
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
import org.ajax4jsf.webapp.ParserFacade;
-import org.ajax4jsf.webapp.tidy.TidyParser;
-import org.ajax4jsf.webapp.tidy.TidyXMLFilter;
import org.richfaces.component.TemplateComponent;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -65,57 +60,71 @@
return true;
}
+ protected ParserFacade getParserFacade(FacesContext context) {
+ return ParserFacade.newInstance(context);
+ }
+
public void writeScriptBody(Writer writer, String string) throws IOException {
- ParserFacade parserFacade = ParserFacade.newInstance(FacesContext.getCurrentInstance());
+ ParserFacade parserFacade = getParserFacade(FacesContext.getCurrentInstance());
StringReader stringReader = new StringReader(string);
StringWriter stringWriter = new StringWriter();
parserFacade.parseHtml(stringReader, stringWriter);
-
- Document document = parse(stringWriter.toString());
+ boolean wroteAnything = false;
+ String wellFormed = stringWriter.toString();
+ if (wellFormed != null && wellFormed.length() > 0) {
+ Document document = parse(wellFormed);
- Element documentElement = null;
-
- if (document != null) {
- documentElement = document.getDocumentElement();
- }
-
- if (documentElement != null) {
- writer.write("[");
+ Element documentElement = null;
- NodeList nodeList = documentElement.getChildNodes();
- Node bodyNode = nodeList.item(nodeList.getLength() - 1);
- NodeList bodyChildren = bodyNode.getChildNodes();
- int bodyChildrenLength = bodyChildren.getLength();
+ if (document != null) {
+ documentElement = document.getDocumentElement();
+ }
+
+ if (documentElement != null) {
+ writer.write("[");
+
+ NodeList nodeList = documentElement.getChildNodes();
+ Node bodyNode = nodeList.item(nodeList.getLength() - 1);
+ NodeList bodyChildren = bodyNode.getChildNodes();
+ int bodyChildrenLength = bodyChildren.getLength();
- try {
- Transformer transformer;
+ try {
+ Transformer transformer;
- TransformerFactory factory = getTransformerFactory();
-
- synchronized (factory) {
- transformer = factory.newTransformer();
- }
+ TransformerFactory factory = getTransformerFactory();
+
+ synchronized (factory) {
+ transformer = factory.newTransformer();
+ }
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- ContentHandler contentHandler = createContentHandler(writer);
- Result result = new SAXResult(contentHandler);
+ ContentHandler contentHandler = createContentHandler(writer);
+ Result result = new SAXResult(contentHandler);
- for (int i = 0; i < bodyChildrenLength; i++) {
- if (i != 0) {
- writer.write(", ");
+ for (int i = 0; i < bodyChildrenLength; i++) {
+ if (i != 0) {
+ writer.write(", ");
+ }
+ transformer.transform(new DOMSource(bodyChildren.item(i)), result);
}
- transformer.transform(new DOMSource(bodyChildren.item(i)), result);
+
+
+ } catch (TransformerException e) {
+ throw new IOException(e.getMessage());
}
- } catch (TransformerException e) {
- throw new IOException(e.getMessage());
+
+ writer.write("]");
+
+ wroteAnything = true;
+
}
-
- writer.write("]");
+ }
- } else {
+
+ if (!wroteAnything) {
writer.write(ScriptUtils.toScript(JSReference.NULL));
}
}
16 years, 10 months