JBoss Rich Faces SVN: r7750 - trunk/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: cluts
Date: 2008-04-11 05:21:26 -0400 (Fri, 11 Apr 2008)
New Revision: 7750
Modified:
trunk/docs/userguide/en/src/main/docbook/included/comboBox.xml
trunk/docs/userguide/en/src/main/docbook/included/contextMenu.xml
trunk/docs/userguide/en/src/main/docbook/included/fileUpload.xml
Log:
RF-925 - Done for comboBox, contextMenu, fileUpload (JavaScript API)
Modified: trunk/docs/userguide/en/src/main/docbook/included/comboBox.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/comboBox.xml 2008-04-11 01:19:44 UTC (rev 7749)
+++ trunk/docs/userguide/en/src/main/docbook/included/comboBox.xml 2008-04-11 09:21:26 UTC (rev 7750)
@@ -234,6 +234,17 @@
</listitem>
</itemizedlist>
</para>
+ <para>It's possible to program events for comboBox from JavaScript code. A simplest example of usage JavaScript API is placed below:</para>
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="XML"><![CDATA[...
+ <rich:comboBox defaultLabel="Enter some value" id="comboBoxID">
+ ...
+ </rich:comboBox>
+...
+<h:commandButton value="Enable" onclick="#{rich:component('comboBoxID')}.enable(event)"/>
+...]]></programlisting>
</section>
<section>
Modified: trunk/docs/userguide/en/src/main/docbook/included/contextMenu.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/contextMenu.xml 2008-04-11 01:19:44 UTC (rev 7749)
+++ trunk/docs/userguide/en/src/main/docbook/included/contextMenu.xml 2008-04-11 09:21:26 UTC (rev 7750)
@@ -297,8 +297,18 @@
<property></h:form></property>
</emphasis> tags.</para></note>
+ <para>It's possible to program events for contextMenu from JavaScript code. A simplest example of usage JavaScript API is placed below:</para>
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="XML"><![CDATA[...
+ <rich:contextMenu ... id="cmID">
+ ...
+ </rich:contextMenu>
+ ...
+<h:commandButton value="Show" onclick="#{rich:component('cmID')}.show(event)"/>
+...]]></programlisting>
-
<!-- Will be done for latest version -->
<!--para> It's possible to define the direction for list appear in the <emphasis>
<property>"direction"</property>
Modified: trunk/docs/userguide/en/src/main/docbook/included/fileUpload.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/fileUpload.xml 2008-04-11 01:19:44 UTC (rev 7749)
+++ trunk/docs/userguide/en/src/main/docbook/included/fileUpload.xml 2008-04-11 09:21:26 UTC (rev 7750)
@@ -357,7 +357,17 @@
</imageobject>
</mediaobject>
</figure>
-
+ <para>It's possible to program events for fileUpload from JavaScript code. A simplest example of usage JavaScript API is placed below:</para>
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="XML"><![CDATA[...
+ <rich:fileUpload ... id="upload">
+ ...
+ </rich:fileUpload>
+ ...
+<h:commandButton value="Click me" onclick="#{rich:component('upload')}.enable(event)"/>
+...]]></programlisting>
<para>The <emphasis role="bold"><property><rich:fileUpload></property></emphasis> component allows to use internationalization method
to redefine and localize the labels. You could use application resource bundle and define
<property>RICH_FILE_UPLOAD_CANCEL_LABEL</property>,
16 years, 9 months
JBoss Rich Faces SVN: r7749 - in trunk: framework/impl/src/main/java/org/ajax4jsf/webapp/nekko and 35 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2008-04-10 21:19:44 -0400 (Thu, 10 Apr 2008)
New Revision: 7749
Added:
trunk/framework/test/src/main/java/META-INF/
trunk/framework/test/src/main/java/META-INF/MANIFEST.MF
trunk/samples/seamEAR/primary-source/src/main/java/org/
trunk/samples/seamEAR/primary-source/src/main/java/org/richfaces/
trunk/samples/seamEAR/primary-source/src/main/java/org/richfaces/demo/
trunk/samples/seamEAR/primary-source/src/main/java/org/richfaces/demo/SeamUtil.java
trunk/samples/seamEAR/projects/logging/java/
trunk/samples/seamEAR/projects/logging/java/META-INF/
trunk/samples/seamEAR/projects/logging/java/META-INF/MANIFEST.MF
trunk/samples/seamEAR/projects/logging/java/org/
trunk/samples/seamEAR/projects/logging/java/org/richfaces/
trunk/samples/seamEAR/projects/logging/java/org/richfaces/demo/
trunk/samples/seamEAR/projects/logging/java/org/richfaces/demo/Log.java
trunk/samples/seamEAR/projects/logging/src/
trunk/samples/seamEAR/projects/logging/src/main/
trunk/test-applications/qa/Performance
trunk/test-applications/qa/Test
trunk/ui/columns/src/main/java/META-INF/
trunk/ui/columns/src/main/java/META-INF/MANIFEST.MF
trunk/ui/combobox/src/main/java/META-INF/
trunk/ui/combobox/src/main/java/META-INF/MANIFEST.MF
trunk/ui/componentControl/src/main/java/META-INF/
trunk/ui/componentControl/src/main/java/META-INF/MANIFEST.MF
trunk/ui/contextMenu/src/main/java/META-INF/
trunk/ui/contextMenu/src/main/java/META-INF/MANIFEST.MF
trunk/ui/fileUpload/src/main/java/META-INF/
trunk/ui/fileUpload/src/main/java/META-INF/MANIFEST.MF
trunk/ui/functions/src/main/java/META-INF/
trunk/ui/functions/src/main/java/META-INF/MANIFEST.MF
trunk/ui/inplaceInput/src/main/java/META-INF/
trunk/ui/inplaceInput/src/main/java/META-INF/MANIFEST.MF
trunk/ui/inplaceSelect/src/main/java/META-INF/
trunk/ui/inplaceSelect/src/main/java/META-INF/MANIFEST.MF
trunk/ui/pickList/src/main/java/META-INF/
trunk/ui/pickList/src/main/java/META-INF/MANIFEST.MF
trunk/ui/progressBAR/src/main/java/META-INF/
trunk/ui/progressBAR/src/main/java/META-INF/MANIFEST.MF
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/NamespaceMappings.java
trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java
Log:
Fix problem in the NEKO filter with two or more parameters in URL
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java 2008-04-10 23:36:53 UTC (rev 7748)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java 2008-04-11 01:19:44 UTC (rev 7749)
@@ -136,24 +136,25 @@
private class NekoParserConfig extends ParserConfig {
protected HtmlParser createParser(String mime) {
- NekkoParser parser;
- try {
- synchronized (_xhtmlParsersPool) {
- parser = (NekkoParser) _xhtmlParsersPool.pop();
+ NekkoParser parser;
+ try {
+ synchronized (_xhtmlParsersPool) {
+ parser = (NekkoParser) _xhtmlParsersPool.pop();
+ }
+ } catch (EmptyStackException e) {
+ parser = new NekkoParser();
+ parser.setPublicId(getPublicid());
+ parser.setSystemid(getSystemid());
+ parser.setNamespace(getNamespace());
+ // If tidy not handle all requests, disable reorganising
+ // of html
+ // parser.setMoveElements(isForcexml());
+ parser.init();
+ }
+ parser.setMime(mime);
+ // TODO - set header scripts/styles filter.
+ return parser;
}
- } catch (EmptyStackException e) {
- parser = new NekkoParser();
- parser.setPublicId(getPublicid());
- parser.setSystemid(getSystemid());
- parser.setNamespace(getNamespace());
- // If tidy not handle all requests, disable reorganising
- // of html
- // parser.setMoveElements(isForcexml());
- parser.init();
- }
- // TODO - set header scripts/styles filter.
- return parser;
- }
boolean storeParser(HtmlParser parser) {
if (null != parser && parser instanceof NekkoParser) {
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java 2008-04-10 23:36:53 UTC (rev 7748)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java 2008-04-11 01:19:44 UTC (rev 7749)
@@ -36,6 +36,7 @@
import javax.xml.parsers.ParserConfigurationException;
import org.ajax4jsf.application.AjaxViewHandler;
+import org.ajax4jsf.webapp.BaseXMLFilter;
import org.ajax4jsf.webapp.HtmlParser;
import org.ajax4jsf.xml.serializer.Method;
import org.ajax4jsf.xml.serializer.OutputPropertiesFactory;
@@ -108,6 +109,12 @@
private String _outputEncoding;
+ private Serializer _XHTMLserializer;
+
+ private Serializer _XMLserialiser;
+
+ private Serializer _HTMLserialiser;
+
/**
*
*/
@@ -121,10 +128,12 @@
_parser = new HtmlSAXParser(getHtmlConfig());
Properties properties = OutputPropertiesFactory
.getDefaultMethodProperties(Method.XHTML);
- // Properties properties =
- // OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
- // properties.put("encoding",_encoding);
- _serializer = SerializerFactory.getSerializer(properties);
+ _XHTMLserializer = SerializerFactory.getSerializer(properties);
+ properties = OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
+ _XMLserialiser = SerializerFactory.getSerializer(properties);
+ properties = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
+ _HTMLserialiser = SerializerFactory.getSerializer(properties);
+ _serializer = _HTMLserialiser;
// serializer.setOutputStream(output);
// _parser.setContentHandler(serializer.asContentHandler());
viewStateParser = new DOMFragmentParser();
@@ -168,7 +177,10 @@
_userStyles = null;
_viewState = null;
_parser.reset();
- _serializer.reset();
+ _XMLserialiser.reset();
+ _HTMLserialiser.reset();
+ _XHTMLserializer.reset();
+ _serializer = _HTMLserialiser;
}
/*
@@ -772,6 +784,18 @@
}
public boolean setMime(String mimeType) {
+ if(null != mimeType) {
+ if(mimeType.startsWith(BaseXMLFilter.TEXT_HTML)){
+ _serializer = _HTMLserialiser;
+ } else if (mimeType.startsWith(BaseXMLFilter.APPLICATION_XHTML_XML)) {
+ _serializer = _XHTMLserializer;
+ } else if (mimeType.startsWith("text/xml")) {
+ _serializer = _XMLserialiser;
+ } else {
+ return false;
+ }
+ return true;
+ }
return false;
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/NamespaceMappings.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/NamespaceMappings.java 2008-04-10 23:36:53 UTC (rev 7748)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/NamespaceMappings.java 2008-04-11 01:19:44 UTC (rev 7749)
@@ -221,8 +221,10 @@
Stack stack;
if ((stack = (Stack) m_namespaces.get(prefix)) != null)
{
- stack.pop();
- return true;
+ if (!stack.isEmpty()) {
+ stack.pop();
+ }
+ return true;
}
return false;
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java 2008-04-10 23:36:53 UTC (rev 7748)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java 2008-04-11 01:19:44 UTC (rev 7749)
@@ -1326,7 +1326,7 @@
// Since http://www.ietf.org/rfc/rfc2396.txt refers to the URI grammar as
// not allowing quotes in the URI proper syntax, nor in the fragment
// identifier, we believe that it's OK to double escape quotes.
- else if (ch == '"')
+ else if (ch == '"' || ch == '<' || ch == '>' || ch == '&')
{
// If the character is a '%' number number, try to avoid double-escaping.
// There is a question if this is legal behavior.
@@ -1346,11 +1346,18 @@
// Mike Kay encodes this as ", so he may know something I don't?
- if (doURLEscaping)
- writer.write("%22");
- else
- writer.write("""); // we have to escape this, I guess.
+ if (doURLEscaping){
+ writer.write('%');
+ writer.write(makeHHString(ch));
+ } else {
+ int pos = accumDefaultEntity(writer, ch, i, chars, end, false, true);
+ if (i != pos)
+ {
+ i = pos - 1;
+ }
+// writer.write("""); // we have to escape this, I guess.
+ }
// We have written out any clean characters, then the escaped '%' and now we
// We now we reset the next possible clean character.
cleanStart = i + 1;
Added: trunk/framework/test/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/framework/test/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/framework/test/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/framework/test/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/samples/seamEAR/primary-source/src/main/java/org/richfaces/demo/SeamUtil.java
===================================================================
--- trunk/samples/seamEAR/primary-source/src/main/java/org/richfaces/demo/SeamUtil.java (rev 0)
+++ trunk/samples/seamEAR/primary-source/src/main/java/org/richfaces/demo/SeamUtil.java 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,5 @@
+package org.richfaces.demo;
+
+public class SeamUtil {
+
+}
Property changes on: trunk/samples/seamEAR/primary-source/src/main/java/org/richfaces/demo/SeamUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/samples/seamEAR/projects/logging/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/samples/seamEAR/projects/logging/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/samples/seamEAR/projects/logging/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
Property changes on: trunk/samples/seamEAR/projects/logging/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/samples/seamEAR/projects/logging/java/org/richfaces/demo/Log.java
===================================================================
--- trunk/samples/seamEAR/projects/logging/java/org/richfaces/demo/Log.java (rev 0)
+++ trunk/samples/seamEAR/projects/logging/java/org/richfaces/demo/Log.java 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,5 @@
+package org.richfaces.demo;
+
+public class Log {
+
+}
Property changes on: trunk/samples/seamEAR/projects/logging/java/org/richfaces/demo/Log.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-applications/qa/Performance
===================================================================
Added: trunk/test-applications/qa/Test
===================================================================
Added: trunk/ui/columns/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/columns/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/columns/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/columns/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/combobox/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/combobox/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/combobox/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/combobox/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/componentControl/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/componentControl/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/componentControl/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/componentControl/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/contextMenu/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/contextMenu/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/contextMenu/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/contextMenu/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/fileUpload/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/fileUpload/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/fileUpload/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/fileUpload/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/functions/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/functions/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/functions/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/functions/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/inplaceInput/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/inplaceInput/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/inplaceInput/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/inplaceInput/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/inplaceSelect/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/inplaceSelect/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/inplaceSelect/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/inplaceSelect/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/pickList/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/pickList/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/pickList/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/pickList/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/progressBAR/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/progressBAR/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/progressBAR/src/main/java/META-INF/MANIFEST.MF 2008-04-11 01:19:44 UTC (rev 7749)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/progressBAR/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 9 months
JBoss Rich Faces SVN: r7748 - branches/3.2.x/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-04-10 19:36:53 -0400 (Thu, 10 Apr 2008)
New Revision: 7748
Modified:
branches/3.2.x/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js
Log:
http://jira.jboss.com/jira/browse/RF-2953
Modified: branches/3.2.x/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js
===================================================================
--- branches/3.2.x/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js 2008-04-10 23:33:32 UTC (rev 7747)
+++ branches/3.2.x/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js 2008-04-10 23:36:53 UTC (rev 7748)
@@ -218,6 +218,9 @@
this.scrollBox.setWidth(width);
this.scrollBox.setHeight(height);
+ this.defaultRowHeight = this._calcDefaultRowHeight();
+ this.sizeBox.setHeight(this.defaultRowHeight * this.grid.dataModel.getCount() + fixH);
+
height = this.scrollBox.getElement().clientHeight;
this.contentBox.setHeight(height - fixH);
@@ -225,9 +228,10 @@
this.frozenContentBox.setHeight(height - fixH);
this.container.setHeight(height - fixH);
- this.defaultRowHeight = this._calcDefaultRowHeight();
+ //http://jira.jboss.com/jira/browse/RF-2953
+ //this.defaultRowHeight = this._calcDefaultRowHeight();
this.scrollBox.hide();
- this.sizeBox.setHeight(this.defaultRowHeight * this.grid.dataModel.getCount() + fixH);
+ //this.sizeBox.setHeight(this.defaultRowHeight * this.grid.dataModel.getCount() + fixH);
this.helpObject1.moveToY(this.sizeBox.element.offsetHeight+ this.defaultRowHeight + 5);
this.helpObject2.moveToY(this.sizeBox.element.offsetHeight+ this.defaultRowHeight + 5);
16 years, 9 months
JBoss Rich Faces SVN: r7747 - branches/3.2.x/cdk/generator/src/main/resources/META-INF/templates12.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-04-10 19:33:32 -0400 (Thu, 10 Apr 2008)
New Revision: 7747
Modified:
branches/3.2.x/cdk/generator/src/main/resources/META-INF/templates12/taghandler.vm
Log:
http://jira.jboss.com/jira/browse/RF-2952
Modified: branches/3.2.x/cdk/generator/src/main/resources/META-INF/templates12/taghandler.vm
===================================================================
--- branches/3.2.x/cdk/generator/src/main/resources/META-INF/templates12/taghandler.vm 2008-04-10 23:21:06 UTC (rev 7746)
+++ branches/3.2.x/cdk/generator/src/main/resources/META-INF/templates12/taghandler.vm 2008-04-10 23:33:32 UTC (rev 7747)
@@ -54,11 +54,18 @@
if (meta.isTargetInstanceOf(${component.simpleClassName}.class)) {
#foreach($prop in $component.properties)
#if( !$prop.existintag )
- #if( $prop.isInstanceof("javax.faces.el.MethodBinding") )
+ #if( $prop.isInstanceof("javax.faces.el.MethodBinding") || $prop.isInstanceof("javax.el.MethodExpression") )
+ #if ( $prop.name != "actionExpression" )
+
if ("${prop.name}".equals(name)) {
return new ${prop.name}Mapper(attribute);
}
-
+
+ #else
+
+ //skip $prop.name
+
+ #end
#end
#end
#end
@@ -71,7 +78,8 @@
#foreach($prop in $component.properties)
#if( !$prop.existintag )
- #if( $prop.isInstanceof("javax.faces.el.MethodBinding") )
+ #if( $prop.isInstanceof("javax.faces.el.MethodBinding") || $prop.isInstanceof("javax.el.MethodExpression") )
+ #if ( $prop.name != "actionExpression" )
static class ${prop.name}Mapper extends Metadata {
@@ -90,13 +98,21 @@
*/
public void applyMetadata(FaceletContext ctx, Object instance) {
((${component.simpleClassName}) instance)
- .${prop.setterName}(new LegacyMethodBinding(this._action
- .getMethodExpression(ctx, null,
+ .${prop.setterName}
+ #if( $prop.isInstanceof("javax.faces.el.MethodBinding"))
+ (new LegacyMethodBinding(this._action.getMethodExpression(ctx, null,
SIGNATURE)));
+ #else
+ (this._action.getMethodExpression(ctx, null,
+ SIGNATURE));
+ #end
}
}
+
#end
+
+ #end
#end
#end
}
16 years, 9 months
JBoss Rich Faces SVN: r7746 - trunk/cdk/generator/src/main/resources/META-INF/templates12.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-04-10 19:21:06 -0400 (Thu, 10 Apr 2008)
New Revision: 7746
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates12/taghandler.vm
Log:
http://jira.jboss.com/jira/browse/RF-2952
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/taghandler.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/taghandler.vm 2008-04-10 22:45:54 UTC (rev 7745)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/taghandler.vm 2008-04-10 23:21:06 UTC (rev 7746)
@@ -54,11 +54,18 @@
if (meta.isTargetInstanceOf(${component.simpleClassName}.class)) {
#foreach($prop in $component.properties)
#if( !$prop.existintag )
- #if( $prop.isInstanceof("javax.faces.el.MethodBinding") )
+ #if( $prop.isInstanceof("javax.faces.el.MethodBinding") || $prop.isInstanceof("javax.el.MethodExpression") )
+ #if ( $prop.name != "actionExpression" )
+
if ("${prop.name}".equals(name)) {
return new ${prop.name}Mapper(attribute);
}
-
+
+ #else
+
+ //skip $prop.name
+
+ #end
#end
#end
#end
@@ -71,7 +78,8 @@
#foreach($prop in $component.properties)
#if( !$prop.existintag )
- #if( $prop.isInstanceof("javax.faces.el.MethodBinding") )
+ #if( $prop.isInstanceof("javax.faces.el.MethodBinding") || $prop.isInstanceof("javax.el.MethodExpression") )
+ #if ( $prop.name != "actionExpression" )
static class ${prop.name}Mapper extends Metadata {
@@ -90,13 +98,21 @@
*/
public void applyMetadata(FaceletContext ctx, Object instance) {
((${component.simpleClassName}) instance)
- .${prop.setterName}(new LegacyMethodBinding(this._action
- .getMethodExpression(ctx, null,
+ .${prop.setterName}
+ #if( $prop.isInstanceof("javax.faces.el.MethodBinding"))
+ (new LegacyMethodBinding(this._action.getMethodExpression(ctx, null,
SIGNATURE)));
+ #else
+ (this._action.getMethodExpression(ctx, null,
+ SIGNATURE));
+ #end
}
}
+
#end
+
+ #end
#end
#end
}
16 years, 9 months
JBoss Rich Faces SVN: r7745 - in trunk: samples/seamEAR and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2008-04-10 18:45:54 -0400 (Thu, 10 Apr 2008)
New Revision: 7745
Modified:
trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/seamEAR/pom.xml
trunk/ui/assembly/pom.xml
trunk/ui/fileUpload/src/main/java/org/richfaces/component/UIFileUpload.java
trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
trunk/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java
trunk/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
Log:
fix http://jira.jboss.com/jira/browse/RF-3031
Modified: trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2008-04-10 18:11:42 UTC (rev 7744)
+++ trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2008-04-10 22:45:54 UTC (rev 7745)
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
-<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
- "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
-<faces-config>
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+ version="1.2">
<converter>
<converter-id>listShuttleconverter</converter-id>
<converter-class>org.richfaces.demo.listShuttle.Converter</converter-class>
Modified: trunk/samples/seamEAR/pom.xml
===================================================================
--- trunk/samples/seamEAR/pom.xml 2008-04-10 18:11:42 UTC (rev 7744)
+++ trunk/samples/seamEAR/pom.xml 2008-04-10 22:45:54 UTC (rev 7745)
@@ -13,7 +13,7 @@
<packaging>pom</packaging>
<name>seam EAR project</name>
<properties>
- <seam>2.0.1.GA</seam>
+ <seam>2.0.2-SNAPSHOT</seam>
</properties>
<modules>
<module>projects</module>
Modified: trunk/ui/assembly/pom.xml
===================================================================
--- trunk/ui/assembly/pom.xml 2008-04-10 18:11:42 UTC (rev 7744)
+++ trunk/ui/assembly/pom.xml 2008-04-10 22:45:54 UTC (rev 7745)
@@ -94,121 +94,6 @@
</executions>
</plugin>
<plugin>
- <groupId>net.sourceforge.maven-taglib</groupId>
- <artifactId>maven-taglib-plugin</artifactId>
- <configuration>
- <taglib.src.dir>
- ${project.build.outputDirectory}/META-INF
- </taglib.src.dir>
- <tldDocDir>
- ${project.build.directory}/tlddoc
- </tldDocDir>
- </configuration>
-
- <executions>
- <execution>
- <id>attach-javadoc</id>
- <phase>process-resources</phase>
- <goals>
- <goal>taglibdocjar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>2.2</version>
- <executions>
- <execution>
- <id>attach-javadoc</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <javadocVersion>1.5</javadocVersion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>
- org.richfaces.docs.userguide
- </groupId>
- <artifactId>en</artifactId>
- <version>
- ${project.version}
- </version>
- <type>war</type>
- <classifier>pdf</classifier>
- <outputDirectory>
- ${project.build.directory}/docs/userguide/en
- </outputDirectory>
- </artifactItem>
- <artifactItem>
- <groupId>
- org.richfaces.docs.faq
- </groupId>
- <artifactId>en</artifactId>
- <version>
- ${project.version}
- </version>
- <type>war</type>
- <classifier>pdf</classifier>
- <outputDirectory>
- ${project.build.directory}/docs/faq/en
- </outputDirectory>
- </artifactItem>
- </artifactItems>
- <outputDirectory>
- ${project.build.directory}/docs
- </outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>
- true
- </overWriteSnapshots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <outputDirectory>
- ${project.build.directory}/dist
- </outputDirectory>
- <descriptors>
- <descriptor>
- ${basedir}/src/main/assembly/richfaces.xml
- </descriptor>
- <descriptor>
- ${basedir}/src/main/assembly/src.xml
- </descriptor>
- </descriptors>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id>
- <phase>package</phase>
- <goals>
- <goal>attached</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<outputDirectory>
@@ -339,5 +224,132 @@
</plugin>
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>release</id>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>net.sourceforge.maven-taglib</groupId>
+ <artifactId>maven-taglib-plugin</artifactId>
+ <configuration>
+ <taglib.src.dir>
+ ${project.build.outputDirectory}/META-INF
+ </taglib.src.dir>
+ <tldDocDir>
+ ${project.build.directory}/tlddoc
+ </tldDocDir>
+ </configuration>
+
+ <executions>
+ <execution>
+ <id>attach-javadoc</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>taglibdocjar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.2</version>
+ <executions>
+ <execution>
+ <id>attach-javadoc</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <javadocVersion>1.5</javadocVersion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>
+ org.richfaces.docs.userguide
+ </groupId>
+ <artifactId>en</artifactId>
+ <version>
+ ${project.version}
+ </version>
+ <type>war</type>
+ <classifier>pdf</classifier>
+ <outputDirectory>
+ ${project.build.directory}/docs/userguide/en
+ </outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>
+ org.richfaces.docs.faq
+ </groupId>
+ <artifactId>en</artifactId>
+ <version>
+ ${project.version}
+ </version>
+ <type>war</type>
+ <classifier>pdf</classifier>
+ <outputDirectory>
+ ${project.build.directory}/docs/faq/en
+ </outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>
+ ${project.build.directory}/docs
+ </outputDirectory>
+ <overWriteReleases>
+ false
+ </overWriteReleases>
+ <overWriteSnapshots>
+ true
+ </overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <outputDirectory>
+ ${project.build.directory}/dist
+ </outputDirectory>
+ <descriptors>
+ <descriptor>
+ ${basedir}/src/main/assembly/richfaces.xml
+ </descriptor>
+ <descriptor>
+ ${basedir}/src/main/assembly/src.xml
+ </descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
<dependencies />
</project>
\ No newline at end of file
Modified: trunk/ui/fileUpload/src/main/java/org/richfaces/component/UIFileUpload.java
===================================================================
--- trunk/ui/fileUpload/src/main/java/org/richfaces/component/UIFileUpload.java 2008-04-10 18:11:42 UTC (rev 7744)
+++ trunk/ui/fileUpload/src/main/java/org/richfaces/component/UIFileUpload.java 2008-04-10 22:45:54 UTC (rev 7745)
@@ -14,7 +14,6 @@
import javax.faces.convert.Converter;
import javax.faces.el.MethodBinding;
import javax.faces.event.FacesEvent;
-import javax.servlet.http.HttpServletRequest;
import org.ajax4jsf.Filter;
import org.ajax4jsf.context.AjaxContext;
@@ -162,12 +161,12 @@
} else {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
- HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
- if ("progress".equals(request.getParameter("action"))
- && request.getParameterMap().containsKey(
+ Map<String, String> requestParameterMap = externalContext.getRequestParameterMap();
+ if ("progress".equals(requestParameterMap.get("action"))
+ && requestParameterMap.containsKey(
this.getClientId(facesContext))) {
AjaxContext ajaxContext = AjaxContextImpl.getCurrentInstance(facesContext);
- String uid = request.getParameter(Filter.UPLOAD_FILES_ID);
+ String uid = requestParameterMap.get(Filter.UPLOAD_FILES_ID);
Map<String, Object> sessionMap = externalContext.getSessionMap();
Modified: trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
===================================================================
--- trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2008-04-10 18:11:42 UTC (rev 7744)
+++ trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2008-04-10 22:45:54 UTC (rev 7745)
@@ -14,13 +14,11 @@
import javax.faces.FactoryFinder;
import javax.faces.component.UIComponent;
import javax.faces.component.UIParameter;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
import org.ajax4jsf.Filter;
import org.ajax4jsf.context.AjaxContext;
@@ -91,23 +89,21 @@
@Override
@SuppressWarnings("unchecked")
protected void doDecode(FacesContext context, UIComponent component) {
- ServletRequest request = (ServletRequest) context.getExternalContext()
- .getRequest();
new AjaxEvent(component).queue();
- String fileUploadIndicator = request.getParameter(Filter.FILE_UPLOAD_INDICATOR);
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, String> requestParameterMap = externalContext.getRequestParameterMap();
+ String fileUploadIndicator = requestParameterMap.get(Filter.FILE_UPLOAD_INDICATOR);
if (fileUploadIndicator != null && Boolean.TRUE.toString().equals(fileUploadIndicator)) {
String clientId = component.getClientId(context);
UIFileUpload fileUpload = (UIFileUpload) component;
- HttpSession session = (HttpSession) context.getExternalContext()
- .getSession(false);
- String uid = request.getParameter(Filter.UPLOAD_FILES_ID);
- String id = request.getParameter("id");
- decreaseFileCounter(session, id);
- Map<String, MultipartRequest> map = (Map<String, MultipartRequest>) session
- .getAttribute(Filter.REQUESTS_SESSIONS_BEAN_NAME);
+ String uid = requestParameterMap.get(Filter.UPLOAD_FILES_ID);
+ String id = requestParameterMap.get("id");
+ decreaseFileCounter(context, id);
+ Map<String, MultipartRequest> map = (Map<String, MultipartRequest>) externalContext.getSessionMap()
+ .get(Filter.REQUESTS_SESSIONS_BEAN_NAME);
MultipartRequest multipartRequest = map.get(uid);
@@ -133,11 +129,10 @@
UIComponent component, String clientId) {
Integer max = (Integer) component.getAttributes().get(
"maxFilesQuantity");
- HttpSession session = (HttpSession) context.getExternalContext()
+ Object session = context.getExternalContext()
.getSession(false);
synchronized (session) {
- Map<String, Integer> map = (Map<String, Integer>) session
- .getAttribute(Filter.UPLOADED_COUNTER);
+ Map<String, Integer> map = (Map<String, Integer>) context.getExternalContext().getSessionMap().get(Filter.UPLOADED_COUNTER);
if (map == null) {
map = Collections
.synchronizedMap(new HashMap<String, Integer>());
@@ -215,9 +210,7 @@
String messageBundle = context.getApplication().getMessageBundle();
Object locale = fileUpload.getLocale();
if (locale == null) {
- HttpServletRequest request = (HttpServletRequest) context
- .getExternalContext().getRequest();
- locale = request.getLocale();
+ locale = context.getExternalContext().getRequestLocale();
}
if (null != messageBundle) {
bundle1 = ResourceBundle.getBundle(messageBundle, fileUpload
@@ -315,13 +308,13 @@
/**
* Method decrease file counter
*
- * @param session
+ * @param context
* @param id
*/
@SuppressWarnings("unchecked")
- private void decreaseFileCounter(HttpSession session, String id) {
- Map<String, Integer> map = (Map<String, Integer>) session
- .getAttribute(Filter.UPLOADED_COUNTER);
+ private void decreaseFileCounter(FacesContext context, String id) {
+ Map<String, Integer> map = (Map<String, Integer>) context.getExternalContext().getSessionMap()
+ .get(Filter.UPLOADED_COUNTER);
if (map != null) {
Integer i = map.get(id);
if (i == null) {
Modified: trunk/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java
===================================================================
--- trunk/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java 2008-04-10 18:11:42 UTC (rev 7744)
+++ trunk/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java 2008-04-10 22:45:54 UTC (rev 7745)
@@ -18,7 +18,6 @@
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
import javax.faces.event.FacesEvent;
-import javax.servlet.http.HttpServletRequest;
import org.ajax4jsf.component.UIPoll;
import org.ajax4jsf.context.AjaxContext;
@@ -94,9 +93,7 @@
FacesContext facesContext = FacesContext.getCurrentInstance();
AjaxContext ajaxContext = AjaxContextImpl
.getCurrentInstance(facesContext);
- HttpServletRequest request = (HttpServletRequest) facesContext
- .getExternalContext().getRequest();
- Map params = request.getParameterMap();
+ Map<String, String> params = facesContext.getExternalContext().getRequestParameterMap();
String clientId = this.getClientId(facesContext);
if (!params.containsKey(clientId)) {
@@ -125,7 +122,7 @@
+ this.getClientId(facesContext));
}
ajaxContext.addComponentToAjaxRender(this);
- String forcedState = request.getParameter(FORCE_PERCENT_PARAM);
+ String forcedState = params.get(FORCE_PERCENT_PARAM);
if ("complete".equals(forcedState)) {
Object reRender = this.getAttributes().get("reRenderAfterComplete");
Set<String> ajaxRegions = AjaxRendererUtils.asSet(reRender);
Modified: trunk/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
===================================================================
--- trunk/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java 2008-04-10 18:11:42 UTC (rev 7744)
+++ trunk/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java 2008-04-10 22:45:54 UTC (rev 7745)
@@ -19,7 +19,6 @@
import javax.faces.event.ActionEvent;
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
-import javax.servlet.http.HttpServletRequest;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.event.AjaxEvent;
@@ -85,9 +84,7 @@
*/
public String getForcedState(FacesContext context, UIComponent component) {
String forcedState = null;
- HttpServletRequest request = (HttpServletRequest) context
- .getExternalContext().getRequest();
- Map params = request.getParameterMap();
+ Map params = context.getExternalContext().getRequestParameterMap();
if (params.containsKey(UIProgressBar.FORCE_PERCENT_PARAM)) {
String[] str = (String[]) params
.get(UIProgressBar.FORCE_PERCENT_PARAM);
16 years, 9 months
JBoss Rich Faces SVN: r7744 - trunk/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: vsukhov
Date: 2008-04-10 14:11:42 -0400 (Thu, 10 Apr 2008)
New Revision: 7744
Modified:
trunk/docs/userguide/en/src/main/docbook/included/support.xml
Log:
http://jira.jboss.com/jira/browse/RF-2994 I've described process attribute for <a4j:support>
Modified: trunk/docs/userguide/en/src/main/docbook/included/support.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/support.xml 2008-04-10 17:54:32 UTC (rev 7743)
+++ trunk/docs/userguide/en/src/main/docbook/included/support.xml 2008-04-10 18:11:42 UTC (rev 7744)
@@ -104,6 +104,41 @@
{form.reset(); return false;}" oncomplete="alert('Value succesfully stored')"/>
</h:selectOneMenu>]]></programlisting>
<para>In example there is the condition checking (confirm) is used before request sending and message printing after the request processing is over. </para>
+ <para>
+ <emphasis >
+ <property>"process"</property></emphasis> attribute defines the component to be processed together with the component which contains this attribute.
+ In order to define processed components you could set theirs ids into the value of <emphasis >
+ <property>"process"</property></emphasis> attribute. </para>
+ <para>
+ <emphasis >
+ <property>"process"</property></emphasis> attribute attribute has two limitations:
+ <itemizedlist>
+ <listitem>
+ <para>it works only if <emphasis >
+ <property>"ajaxSingle"</property></emphasis> equals to "true" for given command component</para>
+ </listitem>
+ <listitem>
+ <para>you do not have to point this attribute to one of the own parent components to avoid processing of command component twice.</para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para><emphasis role="bold">Example:</emphasis></para>
+ <programlisting role="XML"><![CDATA[...
+<h:form>
+ <h:inputText id="oneA" value="#{bean.width}"/>
+ <br/>
+ <h:inputText id="oneB" value="#{bean.text}"/>
+ <br/>
+ <a4j:commandButton value="Submit2" process="oneB" ajaxSingle="true" reRender=":three1, :three2"/>
+</h:form>
+ <h:outputText id="three1" value="#{bean.width}"/>
+ <br/>
+ <h:outputText id="three2" value="#{bean.text}"/>
+...]]></programlisting>
+ <para>
+ In the example above only <emphasis role="bold"><property><h:inputText></property></emphasis> with "oneB" id process.
+ After you click on the button- the value of this component appears into the <emphasis role="bold"><property><h:outputText></property></emphasis> with "three2" id.
+ </para>
<para>The components allows different Ajax request managing ways for its various optimization in particular conditions such as:
<itemizedlist>
<listitem>
16 years, 9 months
JBoss Rich Faces SVN: r7743 - in branches/3.1.x: samples/datascroller-sample/src/main/webapp/pages and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-04-10 13:54:32 -0400 (Thu, 10 Apr 2008)
New Revision: 7743
Added:
branches/3.1.x/framework/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java
Modified:
branches/3.1.x/samples/datascroller-sample/src/main/webapp/pages/index.jsp
branches/3.1.x/ui/datascroller/src/main/config/component/datascroller.xml
branches/3.1.x/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java
branches/3.1.x/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
Log:
http://jira.jboss.com/jira/browse/RF-2714
http://jira.jboss.com/jira/browse/RF-2233
Added: branches/3.1.x/framework/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java
===================================================================
--- branches/3.1.x/framework/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java (rev 0)
+++ branches/3.1.x/framework/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java 2008-04-10 17:54:32 UTC (rev 7743)
@@ -0,0 +1,58 @@
+/*
+ * JSLiteral.java Date created: 29.01.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.ajax4jsf.javascript;
+
+/**
+ * Class provides creation of simple literal javascript to be set in ajax response data
+ * @author Andrey Markavtsov
+ *
+ */
+public class JSLiteral extends ScriptStringBase {
+
+ /** Javascript literal text */
+ private String literal;
+
+
+ /**
+ * Default constructor
+ */
+ public JSLiteral() {
+ super();
+ }
+
+ /**
+ * Constructor using literal parameter
+ * @param literal
+ */
+ public JSLiteral(String literal) {
+ super();
+ this.literal = literal;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.javascript.ScriptString#appendScript(java.lang.StringBuffer)
+ */
+ public void appendScript(StringBuffer jsString) {
+ jsString.append(literal);
+
+ }
+
+ /**
+ * @return the literal
+ */
+ public String getLiteral() {
+ return literal;
+ }
+
+ /**
+ * @param literal the literal to set
+ */
+ public void setLiteral(String literal) {
+ this.literal = literal;
+ }
+
+}
Modified: branches/3.1.x/samples/datascroller-sample/src/main/webapp/pages/index.jsp
===================================================================
--- branches/3.1.x/samples/datascroller-sample/src/main/webapp/pages/index.jsp 2008-04-10 16:39:51 UTC (rev 7742)
+++ branches/3.1.x/samples/datascroller-sample/src/main/webapp/pages/index.jsp 2008-04-10 17:54:32 UTC (rev 7743)
@@ -23,9 +23,6 @@
<h:outputText value="Data Table test" />
<br />
-
-
-
<h:dataTable rows="#{testBean.rows}" id="master" border="1" value="#{testBean.data}" var="data">
<f:facet name="header">
<h:outputText value="My table" />
@@ -58,7 +55,7 @@
</f:facet>
</h:column>
<f:facet name="footer">
- <ds:datascroller for="master" reRender="actionCount, eventCount" rendered="true" fastStep="2" actionListener="#{testBean.onAction}" renderIfSinglePage="#{testBean.renderIfSinglePage}" scrollerListener="#{testBean.doScroll}" maxPages="#{testBean.maxpage}"/>
+ <ds:datascroller for="master" reRender="actionCount, eventCount" rendered="true" fastStep="2" actionListener="#{testBean.onAction}" renderIfSinglePage="#{testBean.renderIfSinglePage}" scrollerListener="#{testBean.doScroll}" maxPages="#{testBean.maxpage}" onpagechange="return confirm('Do you want to go to: ' + event.memo.page + '?')" />
</f:facet>
</h:dataTable>
Modified: branches/3.1.x/ui/datascroller/src/main/config/component/datascroller.xml
===================================================================
--- branches/3.1.x/ui/datascroller/src/main/config/component/datascroller.xml 2008-04-10 16:39:51 UTC (rev 7742)
+++ branches/3.1.x/ui/datascroller/src/main/config/component/datascroller.xml 2008-04-10 17:54:32 UTC (rev 7743)
@@ -284,6 +284,10 @@
<description>Name of variable in request scope containing number of pages</description>
</property>
+ <property>
+ <name>onpagechange</name>
+ <classname>java.lang.String</classname>
+ </property>
</component>
&listeners;
</components>
Modified: branches/3.1.x/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java
===================================================================
--- branches/3.1.x/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2008-04-10 16:39:51 UTC (rev 7742)
+++ branches/3.1.x/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2008-04-10 17:54:32 UTC (rev 7743)
@@ -36,6 +36,8 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.JSLiteral;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.richfaces.component.UIDatascroller;
@@ -217,8 +219,7 @@
} else {
out.writeAttribute("class", "dr-dscr-inact rich-datascr-inact "+
styleClass, null);
- out.writeAttribute("onclick", getOnClick(context, component,
- Integer.toString(i + 1)), null);
+ out.writeAttribute("onclick", getOnClick(Integer.toString(i + 1)), null);
}
if (null != style) out.writeAttribute("style", style, null);
out.writeText(Integer.toString(i + 1), null);
@@ -228,6 +229,10 @@
}
+ public Object getOnClick(String string) {
+ return "Event.fire(this, 'rich:datascroller:onscroll', {'page': '" + string + "'});";
+ }
+
public void renderPages(FacesContext context, UIComponent component, UIData data)
throws IOException {
UIDatascroller scroller = (UIDatascroller) component;
@@ -275,28 +280,44 @@
return parameters;
}
- public String getOnClick(FacesContext context, UIComponent component,
- String value) {
-
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(component,
+ public String getSubmitFunction(FacesContext context, UIComponent component) {
+ JSFunctionDefinition definition = new JSFunctionDefinition("event");
+
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(component,
context);
UIDatascroller scroller = (UIDatascroller) component;
Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
component);
Map parameters = (Map) eventOptions.get("parameters");
- parameters.put(scroller.getClientId(context), value);
Map params = getParameters(context,component);
if(!params.isEmpty()){
parameters.putAll(params);
}
+ parameters.put(component.getClientId(context), new JSLiteral("event.memo.page"));
+
function.addParameter(eventOptions);
StringBuffer buffer = new StringBuffer();
function.appendScript(buffer);
buffer.append("; return false;");
- String script = buffer.toString();
- return script;
+
+ String onPageChange = (String) component.getAttributes().get("onpagechange");
+ if (onPageChange != null && onPageChange.length() != 0) {
+ JSFunctionDefinition onPageChangeDef = new JSFunctionDefinition("event");
+ onPageChangeDef.addToBody(onPageChange);
+ onPageChangeDef.addToBody("; return true;");
+
+ definition.addToBody("if (");
+ definition.addToBody(onPageChangeDef.toScript());
+ definition.addToBody("(event)) {");
+ definition.addToBody(buffer.toString());
+ definition.addToBody("}");
+ } else {
+ definition.addToBody(buffer.toString());
+ }
+
+ return definition.toScript();
}
Modified: branches/3.1.x/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
===================================================================
--- branches/3.1.x/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2008-04-10 16:39:51 UTC (rev 7742)
+++ branches/3.1.x/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2008-04-10 17:54:32 UTC (rev 7743)
@@ -13,7 +13,7 @@
<h:scripts>
new org.ajax4jsf.javascript.PrototypeScript(),
- new org.ajax4jsf.javascript.AjaxScript(),
+ new org.ajax4jsf.javascript.AjaxScript()
</h:scripts>
<f:clientid var="clientId"/>
@@ -57,7 +57,7 @@
if (controlsState.isFirstRendered()){
if (controlsState.isFirstEnabled()){
variables.setVariable("buttonClass", "");
- variables.setVariable("onclick", getOnClick(context,component,component.FIRST_FACET_NAME));
+ variables.setVariable("onclick", getOnClick(component.FIRST_FACET_NAME));
variables.setVariable("facet", component.FIRST_FACET_NAME);
facet=component.FIRST_FACET_NAME;
}else{
@@ -103,7 +103,7 @@
if (controlsState.isFastRewindRendered()){
if (controlsState.isFastRewindEnabled()){
variables.setVariable("buttonClass", "");
- variables.setVariable("onclick", getOnClick(context,component,component.FAST_REWIND_FACET_NAME));
+ variables.setVariable("onclick", getOnClick(component.FAST_REWIND_FACET_NAME));
variables.setVariable("facet", component.FAST_REWIND_FACET_NAME);
facet=component.FAST_REWIND_FACET_NAME;
}else{
@@ -150,7 +150,7 @@
if (controlsState.isPreviousRendered()){
if (controlsState.isPreviousEnabled()){
variables.setVariable("buttonClass", "");
- variables.setVariable("onclick", getOnClick(context,component,component.PREVIOUS_FACET_NAME));
+ variables.setVariable("onclick", getOnClick(component.PREVIOUS_FACET_NAME));
variables.setVariable("facet", component.PREVIOUS_FACET_NAME);
facet=component.PREVIOUS_FACET_NAME;
}else{
@@ -203,7 +203,7 @@
<jsp:scriptlet><![CDATA[
if (controlsState.isNextRendered()){
if (controlsState.isNextEnabled()){
- variables.setVariable("onclick", getOnClick(context,component,component.NEXT_FACET_NAME));
+ variables.setVariable("onclick", getOnClick(component.NEXT_FACET_NAME));
variables.setVariable("buttonClass", "");
variables.setVariable("facet", component.NEXT_FACET_NAME);
facet=component.NEXT_FACET_NAME;
@@ -249,7 +249,7 @@
<jsp:scriptlet><![CDATA[
if (controlsState.isFastForwardRendered()){
if (controlsState.isFastForwardEnabled()){
- variables.setVariable("onclick", getOnClick(context,component,component.FAST_FORWARD_FACET_NAME));
+ variables.setVariable("onclick", getOnClick(component.FAST_FORWARD_FACET_NAME));
variables.setVariable("buttonClass", "");
variables.setVariable("facet", component.FAST_FORWARD_FACET_NAME);
facet=component.FAST_FORWARD_FACET_NAME;
@@ -297,7 +297,7 @@
<jsp:scriptlet><![CDATA[
if (controlsState.isLastRendered()){
if (controlsState.isLastEnabled()){
- variables.setVariable("onclick", getOnClick(context,component,component.LAST_FACET_NAME));
+ variables.setVariable("onclick", getOnClick(component.LAST_FACET_NAME));
variables.setVariable("buttonClass", "");
variables.setVariable("facet", component.LAST_FACET_NAME);
facet=component.LAST_FACET_NAME;
@@ -342,5 +342,8 @@
}
]]>
</jsp:scriptlet>
+ <script type="text/javascript">
+ Event.observe('#{clientId}', 'rich:datascroller:onscroll', #{this:getSubmitFunction(context,component)});
+ </script>
</div>
</f:root>
\ No newline at end of file
16 years, 9 months
JBoss Rich Faces SVN: r7742 - in branches/3.1.x/cdk/generator/src: test/java/org/ajax4jsf/builder/xml and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-04-10 12:39:51 -0400 (Thu, 10 Apr 2008)
New Revision: 7742
Added:
branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java
branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java
branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java
branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java
branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java
branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java
Modified:
branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java
branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java
Log:
http://jira.jboss.com/jira/browse/RF-2526
Modified: branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java
===================================================================
--- branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java 2008-04-10 16:39:44 UTC (rev 7741)
+++ branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java 2008-04-10 16:39:51 UTC (rev 7742)
@@ -24,19 +24,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
-import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.ErrorListener;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
@@ -44,7 +37,6 @@
import org.ajax4jsf.builder.config.ParsingException;
import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -87,14 +79,14 @@
// Create Document Builder Factory
DocumentBuilderFactory docFactory = DocumentBuilderFactory
.newInstance();
-
+ docFactory.setIgnoringElementContentWhitespace(true);
docFactory.setValidating(false);
docFactory.setNamespaceAware(namespaceAware);
// Create Document Builder
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ //docBuilder.
+ //docBuilder.isValidating();
- docBuilder.isValidating();
-
// Disable loading of external Entityes
docBuilder.setEntityResolver(new EntityResolver() {
// Dummi resolver - alvays do nothing
@@ -152,66 +144,36 @@
}
private String serializeNodes(NodeList childNodes) throws ParsingException {
- DocumentFragment fragment = xmlDocument.createDocumentFragment();
- for (int i = 0; i < childNodes.getLength(); i++) {
- fragment.appendChild(childNodes.item(i).cloneNode(true));
- }
try {
- TransformerFactory transformerFactory = TransformerFactory
- .newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- transformer.setErrorListener(new ErrorListener(){
-
- public void error(TransformerException exception)
- throws TransformerException {
- // TODO Auto-generated method stub
-
- }
-
- public void fatalError(TransformerException exception)
- throws TransformerException {
- // TODO Auto-generated method stub
-
- }
-
- public void warning(TransformerException exception)
- throws TransformerException {
- // TODO Auto-generated method stub
-
- }
-
- });
- transformer.setOutputProperty("omit-xml-declaration", "yes");
- StringWriter out = new StringWriter();
- StreamResult result = new StreamResult(out);
- transformer.transform(new DOMSource(fragment), result);
- return out.toString();
-
+ return new XMLBodySerializer().serialize(childNodes, xmlDocument);
} catch (Exception e) {
throw new ParsingException(e);
}
}
public String getContent(String xpath) throws ParsingException{
+ return serializeNodes(getByXpath(xpath));
+ }
+
+ public NodeList getByXpath(String xpath) throws ParsingException {
XPath path = XPathFactory.newInstance().newXPath();
NodeList childNodes;
try {
- childNodes = (NodeList) path.evaluate(xpath, xmlDocument,XPathConstants.NODESET);
+ childNodes = (NodeList) path.evaluate(xpath, xmlDocument, XPathConstants.NODESET);
} catch (XPathExpressionException e) {
throw new ParsingException("Error evaluate xpath",e);
}
- return serializeNodes(childNodes);
+ return childNodes;
}
-
- public String getContentUnique(String xpath, String keyXPath, Set<String> keySet) throws ParsingException{
+
+ public NodeList getByXpathUnique(String xpath, String keyXPath, Set<String> keySet) throws ParsingException {
if (keyXPath == null) {
- return getContent(xpath);
+ return getByXpath(xpath);
} else {
-
XPath path = XPathFactory.newInstance().newXPath();
NodeList childNodes;
try {
- childNodes = (NodeList) path.evaluate(xpath, xmlDocument,XPathConstants.NODESET);
+ childNodes = getByXpath(xpath);
List<Node> nodeSet = new ArrayList<Node>();
@@ -224,14 +186,16 @@
nodeSet.add(node);
}
}
-
- return serializeNodes(new ArrayNodeList(nodeSet.toArray(new Node[nodeSet.size()])));
-
+ return new ArrayNodeList(nodeSet.toArray(new Node[nodeSet.size()]));
} catch (XPathExpressionException e) {
throw new ParsingException("Error evaluate xpath",e);
}
+
}
}
+ public String getContentUnique(String xpath, String keyXPath, Set<String> keySet) throws ParsingException{
+ return serializeNodes(getByXpathUnique(xpath, keyXPath, keySet));
+ }
}
class ArrayNodeList implements NodeList {
Added: branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java
===================================================================
--- branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java (rev 0)
+++ branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java 2008-04-10 16:39:51 UTC (rev 7742)
@@ -0,0 +1,130 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.ajax4jsf.builder.config.ParsingException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodyMerge implements NodeList{
+
+ private String xpath;
+
+ private List<Node> nodes = new ArrayList<Node>();
+
+ private Document document = null;
+
+ private XPathExpression keyXpath = null;
+
+ private StringBuffer content = new StringBuffer();
+
+ private Set<String> keys = new HashSet<String>();
+
+
+
+ public XMLBodyMerge(String xpath) {
+ super();
+ this.xpath = xpath;
+ }
+
+ public XMLBodyMerge(String xpath, String keyXpath) {
+ this(xpath);
+ if (keyXpath != null) {
+ try {
+ XPath newXPath = XPathFactory.newInstance().newXPath();
+ this.keyXpath = newXPath.compile(keyXpath);
+ } catch (XPathExpressionException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void add(Node node) {
+
+ if (keyXpath != null) {
+ String key = getKey(node);
+ if (key == null || keys.contains(key)) {
+ return;
+ }
+ }
+
+ if (document == null) {
+ document = node.getOwnerDocument();
+ } else {
+ node = document.importNode(node, true);
+ }
+ nodes.add(node);
+ }
+
+ public void add(XMLBody xmlBody) throws ParsingException {
+
+ if (xpath != null) {
+ NodeList nodeList = xmlBody.getByXpath(xpath);
+ if (nodeList != null) {
+ for(int i = 0; i < nodeList.getLength(); i++) {
+ add(nodeList.item(i));
+ }
+ }
+ } else {
+ content.append(xmlBody.getContent());
+ }
+
+ }
+
+ public int getLength() {
+ return nodes.size();
+ }
+
+ public Node item(int index) {
+ if (index < nodes.size()) {
+ return nodes.get(index);
+ }
+ return null;
+ }
+
+
+ public void sort(Comparator<Node> comparator) {
+ Collections.sort(nodes, comparator);
+ }
+
+ public String getContent() throws Exception{
+ StringBuilder buf = new StringBuilder();
+ if (content != null) {
+ buf.append(content);
+ }
+ if (document != null) {
+ buf.append(new XMLBodySerializer().serialize(this, document));
+ }
+
+ return buf.toString();
+ }
+
+ private String getKey(Node node) {
+ try {
+ NodeList list = (NodeList) keyXpath.evaluate(node, XPathConstants.NODESET);
+ return new XMLBodySerializer().serialize(list, node.getOwnerDocument());
+ } catch (Exception e) {
+ }
+ return null;
+ }
+}
Added: branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java
===================================================================
--- branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java (rev 0)
+++ branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java 2008-04-10 16:39:51 UTC (rev 7742)
@@ -0,0 +1,60 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import java.io.StringWriter;
+
+import javax.xml.transform.ErrorListener;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.ajax4jsf.builder.config.ParsingException;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodySerializer {
+ public String serialize(NodeList childNodes, Document xmlDocument) throws ParsingException {
+ try {
+ StringWriter out;
+ DocumentFragment fragment = xmlDocument.createDocumentFragment();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ fragment.appendChild(childNodes.item(i).cloneNode(true));
+ }
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setErrorListener(new ErrorListener(){
+
+ public void error(TransformerException exception)
+ throws TransformerException {
+ }
+
+ public void fatalError(TransformerException exception)
+ throws TransformerException {
+ }
+
+ public void warning(TransformerException exception)
+ throws TransformerException {
+ }
+
+ });
+ transformer.setOutputProperty("indent", "yes");
+ transformer.setOutputProperty("omit-xml-declaration", "yes");
+ out = new StringWriter();
+ StreamResult result = new StreamResult(out);
+ transformer.transform(new DOMSource(fragment), result);
+ return out.toString();
+ } catch (Exception e) {
+ throw new ParsingException(e);
+ }
+ }
+}
Added: branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java
===================================================================
--- branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java (rev 0)
+++ branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java 2008-04-10 16:39:51 UTC (rev 7742)
@@ -0,0 +1,79 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import java.util.Comparator;
+
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Node;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XPathComparator implements Comparator<Node> {
+
+ class XPathCompatorCriterion {
+ private XPathExpression expression = null;
+
+ public XPathCompatorCriterion(String xPath){
+ try {
+ expression = XPathFactory.newInstance().newXPath().compile(xPath);
+ } catch (XPathExpressionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public String getValue(Object node) throws XPathExpressionException {
+ return expression == null ? null : expression.evaluate(node);
+ }
+ }
+
+ private XPathCompatorCriterion [] criteria;
+
+ public XPathComparator(String ... criteria) {
+ this.criteria = new XPathCompatorCriterion[criteria.length];
+ for(int i = 0; i < criteria.length; i++) {
+ this.criteria[i] = new XPathCompatorCriterion(criteria[i]);
+ }
+ }
+
+ public int compare(Node o1, Node o2) {
+ int result = 0;
+
+ for(int i = 0; i < criteria.length && result == 0; i++) {
+ String s1 = null;
+ String s2 = null;
+ try {
+ s1 = this.criteria[i].getValue(o1);
+ } catch (XPathExpressionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ s2 = this.criteria[i].getValue(o2);
+ } catch (XPathExpressionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (s1 != null) {
+ if (s2 != null) {
+ result = s1.compareTo(s2);
+ } else {
+ result = 1;
+ }
+ } else if (s2 != null) {
+ result = -1;
+ }
+ }
+
+ return result;
+ }
+
+}
Added: branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java
===================================================================
--- branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java (rev 0)
+++ branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java 2008-04-10 16:39:51 UTC (rev 7742)
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodyMergeTest extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#add(org.w3c.dom.Node)}.
+ */
+ public void testAddNode() {
+ XMLBodyMerge merge = new XMLBodyMerge("//node()");
+
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#add(org.ajax4jsf.builder.xml.XMLBody)}.
+ */
+ public void testAddXMLBody() {
+ //fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#getLength()}.
+ */
+ public void testGetLength() {
+ //fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#item(int)}.
+ */
+ public void testItem() {
+ //fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#getContent()}.
+ */
+ public void testGetContent() {
+ //fail("Not yet implemented");
+ }
+
+}
Added: branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java
===================================================================
--- branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java (rev 0)
+++ branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java 2008-04-10 16:39:51 UTC (rev 7742)
@@ -0,0 +1,73 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.ajax4jsf.builder.config.ParsingException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodySerializerTest extends TestCase {
+
+ private XMLBodySerializer serializer;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ serializer = new XMLBodySerializer();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ serializer = null;
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.builder.xml.XMLBodySerializer#serialize(org.w3c.dom.NodeList, org.w3c.dom.Document)}.
+ */
+ public void testSerialize() throws ParsingException{
+ String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + " <component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
+ + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+ body.loadXML(in);
+
+ NodeList singleElementList = body.getByXpath("/faces-config");
+ assertEquals(1, singleElementList.getLength());
+ Node node = singleElementList.item(0);
+ assertNotNull(node);
+ assertEquals("faces-config", node.getNodeName());
+ String actual = serializer.serialize(singleElementList, node.getOwnerDocument()).replaceAll("\\s", "");
+ String expected = "<faces-config><component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component></faces-config>";
+ assertEquals(expected, actual);
+
+ NodeList children = node.getChildNodes();
+ actual = serializer.serialize(children, node.getOwnerDocument()).replaceAll("\\s", "");
+ expected = "<component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>";
+ assertEquals(expected, actual);
+
+
+ }
+
+}
Modified: branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java
===================================================================
--- branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java 2008-04-10 16:39:44 UTC (rev 7741)
+++ branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java 2008-04-10 16:39:51 UTC (rev 7742)
@@ -25,12 +25,10 @@
import java.io.InputStream;
import java.util.HashSet;
-import javax.xml.xpath.XPathExpressionException;
+import junit.framework.TestCase;
import org.ajax4jsf.builder.config.ParsingException;
-import junit.framework.TestCase;
-
/**
* @author shura
*
@@ -145,7 +143,7 @@
InputStream in = new ByteArrayInputStream(xml.getBytes());
XMLBody body = new XMLBody();
body.loadXML(in);
- assertEquals("<modelVersion>4.0.0</modelVersion>", body.getContent());
+ assertEquals("<modelVersion>4.0.0</modelVersion>", body.getContent().trim());
}
public void testGetContentXpath() throws ParsingException {
@@ -160,7 +158,7 @@
try {
assertEquals(
"<component>blabla</component>",
- body.getContent("/faces-config/component"));
+ body.getContent("/faces-config/component").trim());
} catch (ParsingException e) {
e.printStackTrace();
assertTrue(e.getMessage(),false);
@@ -177,9 +175,12 @@
XMLBody body = new XMLBody();
body.loadXML(in);
try {
+ String expected = "<component><test>blabla</test></component><component><test>blabla2</test></component>";
+ String actual = body.getContentUnique("/faces-config/component", "test/text()", new HashSet<String>()).replaceAll("\\s", "");
+
assertEquals(
- "<component><test>blabla</test></component><component><test>blabla2</test></component>",
- body.getContentUnique("/faces-config/component", "test/text()", new HashSet<String>()));
+ expected,
+ actual);
} catch (ParsingException e) {
e.printStackTrace();
assertTrue(e.getMessage(),false);
Added: branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java
===================================================================
--- branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java (rev 0)
+++ branches/3.1.x/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java 2008-04-10 16:39:51 UTC (rev 7742)
@@ -0,0 +1,75 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XPathComparatorTest extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testCompare() throws Exception{
+ String xml = "<faces-config>" +
+ "<component><test>blabla1</test></component>" +
+ "<component><test>blabla</test></component>" +
+ "<renderer><foo>blabla2</foo></renderer>" +
+ "<component><test>blabla2</test></component>"
+ + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+ body.loadXML(in);
+ NodeList list = body.getByXpath("//component|//renderer");
+ assertEquals(4, list.getLength());
+ Node node0 = list.item(0);
+ Node node1 = list.item(1);
+ Node node2 = list.item(2);
+ Node node3 = list.item(3);
+
+ XPathComparator dummyComparator = new XPathComparator();
+ assertEquals(0, dummyComparator.compare(node0, node1));
+ assertEquals(0, dummyComparator.compare(node1, node2));
+ assertEquals(0, dummyComparator.compare(node0, node2));
+ assertEquals(0, dummyComparator.compare(node0, node3));
+ assertEquals(0, dummyComparator.compare(node2, node3));
+ assertEquals(0, dummyComparator.compare(node1, node0));
+ assertEquals(0, dummyComparator.compare(node2, node1));
+ assertEquals(0, dummyComparator.compare(node2, node0));
+
+ XPathComparator simpleComparator = new XPathComparator("local-name()");
+ assertEquals(0, simpleComparator.compare(node0, node1));
+ assertEquals(0, simpleComparator.compare(node0, node3));
+ assertTrue(simpleComparator.compare(node0, node2) < 0);
+ assertTrue(simpleComparator.compare(node2, node1) > 0);
+
+ XPathComparator advancedComparator = new XPathComparator("local-name()", "test/text()", "foo/text()");
+ assertTrue(advancedComparator.compare(node0, node2) < 0);
+ assertTrue(advancedComparator.compare(node2, node1) > 0);
+ assertTrue(advancedComparator.compare(node0, node1) > 0);
+ assertTrue(advancedComparator.compare(node1, node0) < 0);
+
+
+ }
+}
16 years, 9 months
JBoss Rich Faces SVN: r7741 - in branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder: mojo and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2008-04-10 12:39:44 -0400 (Thu, 10 Apr 2008)
New Revision: 7741
Added:
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java
Modified:
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
Log:
http://jira.jboss.com/jira/browse/RF-2526
Added: branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java (rev 0)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java 2008-04-10 16:39:44 UTC (rev 7741)
@@ -0,0 +1,120 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.maven;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ajax4jsf.builder.config.ParsingException;
+import org.ajax4jsf.builder.xml.XMLBody;
+import org.ajax4jsf.builder.xml.XMLBodyMerge;
+import org.ajax4jsf.builder.xml.XPathComparator;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.DirectoryScanner;
+
+/**
+ * Class is used to locate and merge several xml files
+ * @author Maksim Kaszynski
+ *
+ */
+public class MavenXMLMerge {
+
+ class DirectoryItem {
+ private File baseDir;
+ private String [] includes;
+ public DirectoryItem(File baseDir, String[] includes) {
+ super();
+ this.baseDir = baseDir;
+ this.includes = includes;
+ }
+
+ }
+
+ private boolean namespaceAware = false;
+
+ private Log log;
+
+ private String xPath;
+
+ private String keyXPath;
+
+ private String [] sortBy = {};
+
+ private List<DirectoryItem> directories = new ArrayList<DirectoryItem>();
+
+ public MavenXMLMerge() {
+ }
+
+ public void addDirectory(File dir, String [] includes) {
+ directories.add(new DirectoryItem(dir, includes));
+ }
+
+ public void setSortBy(String ... sortBy) {
+ this.sortBy = sortBy;
+ }
+
+ public void performMerge(XMLMergeCallback callback) throws MojoExecutionException {
+ XMLBodyMerge merge = new XMLBodyMerge(xPath, keyXPath);
+
+ for (DirectoryItem item : directories) {
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setFollowSymlinks(true);
+ ds.setBasedir(item.baseDir);
+ ds.setIncludes(item.includes);
+ ds.addDefaultExcludes();
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
+ for (String file : files) {
+ File sourceFile = new File(item.baseDir, file);
+ if (log != null){
+ log.info("Process file " + sourceFile.getPath());
+ }
+ try {
+ XMLBody configBody = new XMLBody();
+ configBody.loadXML(new FileInputStream(sourceFile), namespaceAware);
+ merge.add(configBody);
+
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException("Could't read file "
+ + sourceFile.getPath(), e);
+ } catch (ParsingException e) {
+ throw new MojoExecutionException(
+ "Error parsing config file "
+ + sourceFile.getPath(), e);
+ }
+
+ }
+ }
+
+ if (sortBy != null) {
+ merge.sort(new XPathComparator(sortBy));
+ }
+
+ try {
+ callback.onMergeComplete(merge.getContent());
+ } catch (Exception e) {
+ throw new MojoExecutionException("Exception uring XML merge", e);
+ }
+ }
+
+ public void setNamespaceAware(boolean namespaceAware) {
+ this.namespaceAware = namespaceAware;
+ }
+
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
+ public void setXPath(String path) {
+ xPath = path;
+ }
+
+ public void setKeyXPath(String keyXPath) {
+ this.keyXPath = keyXPath;
+ }
+}
Added: branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java (rev 0)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java 2008-04-10 16:39:44 UTC (rev 7741)
@@ -0,0 +1,56 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.maven;
+
+import java.io.File;
+import java.io.FileWriter;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.codehaus.plexus.velocity.VelocityComponent;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class VelocityTaglibMergeCallBack implements XMLMergeCallback {
+
+ private File target;
+
+ private String template;
+
+ private VelocityComponent velocity;
+
+ private VelocityContext initialContext;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.maven.XMLMergeCallback#onMergeComplete(java.lang.String)
+ */
+ public void onMergeComplete(String mergedContent) throws Exception{
+
+ VelocityContext velocityContext;
+
+ if (initialContext != null) {
+ velocityContext = new VelocityContext(initialContext);
+ } else {
+ velocityContext = new VelocityContext();
+ }
+
+ VelocityEngine velocityEngine = velocity.getEngine();
+ Template template2 = velocityEngine.getTemplate(template);
+
+ File parentFile = target.getParentFile();
+ if (!parentFile.exists()) {
+ parentFile.mkdirs();
+ }
+
+ FileWriter fileWriter = new FileWriter(target);
+
+ template2.merge(velocityContext, fileWriter);
+ fileWriter.flush();
+ fileWriter.close();
+ }
+
+}
Added: branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java (rev 0)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java 2008-04-10 16:39:44 UTC (rev 7741)
@@ -0,0 +1,13 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.maven;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface XMLMergeCallback {
+ void onMergeComplete(String mergedContent) throws Exception;
+
+}
Modified: branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java 2008-04-10 16:34:25 UTC (rev 7740)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java 2008-04-10 16:39:44 UTC (rev 7741)
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -39,6 +40,8 @@
import org.ajax4jsf.builder.config.ParsingException;
import org.ajax4jsf.builder.xml.XMLBody;
+import org.ajax4jsf.builder.xml.XMLBodyMerge;
+import org.ajax4jsf.builder.xml.XPathComparator;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -55,15 +58,11 @@
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.MavenProjectHelper;
import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.shared.io.scan.ResourceInclusionScanner;
-import org.apache.maven.shared.io.scan.SimpleResourceInclusionScanner;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.util.DirectoryScanner;
+import org.w3c.dom.Node;
/**
* This plugin assembly full components library from modules, included in parent
@@ -357,17 +356,17 @@
"META-INF/resources-config.xml");
mergeXML(models, "META-INF/resources-config.xml",
RESOURCES_CONFIG_TEMPLATE, "/resource-config/resource", "name/text()",
- new VelocityContext(), resourcesConfig);
+ new VelocityContext(), resourcesConfig, null);
File tld = new File(outputDirectory, "META-INF/"
+ library.getTaglib().getShortName() + ".tld");
mergeXML(models, includeTld, TLD_TEMPLATE,
"/taglib/tag | /taglib/listener",
- null, new VelocityContext(), tld);
+ null, new VelocityContext(), tld, new XPathComparator("local-name()", "name/text()", "listener-class/text()"));
File taglib = new File(outputDirectory, "META-INF/"
+ library.getTaglib().getShortName() + ".taglib.xml");
mergeXML(models, includeTaglib, TAGLIB_TEMPLATE,
"/facelet-taglib/tag | /facelet-taglib/function",
- null, new VelocityContext(), taglib);
+ null, new VelocityContext(), taglib, new XPathComparator("local-name()", "tag-name/text()", "function-name/text()"));
}else {
throw new MojoFailureException("Components library project must have parent pom with components modules");
}
@@ -447,15 +446,15 @@
* Velocity context for template processing.
* @throws MojoExecutionException
*/
- private void mergeXML(List models, String filename, String templateName,
- String commonXpath, String keyXPath, VelocityContext context, File target)
+ private void mergeXML(List<Model> models, String filename, String templateName,
+ String commonXpath, String keyXPath, VelocityContext context, File target, Comparator<Node> comparator)
throws MojoExecutionException {
- Set<String> keySet = new HashSet<String>();
- StringBuffer content = new StringBuffer();
+ StringBuilder content = new StringBuilder();
+ XMLBodyMerge bodyMerge = new XMLBodyMerge(commonXpath, keyXPath);
List<XMLBody> xmls = new ArrayList<XMLBody>(models.size());
String[] split = filename.split(",");
- for (Iterator iter = models.iterator(); iter.hasNext();) {
- Model model = (Model) iter.next();
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = iter.next();
File moduleDir = new File(buildDirectory, model.getArtifactId());
DirectoryScanner ds = new DirectoryScanner();
ds.setFollowSymlinks(true);
@@ -473,15 +472,7 @@
try {
configBody.loadXML(new FileInputStream(moduleFacesConfig));
xmls.add(configBody);
- if (commonXpath != null) {
- if (keyXPath == null) {
- content.append(configBody.getContent(commonXpath));
- } else {
- content.append(configBody.getContentUnique(commonXpath, keyXPath, keySet));
- }
- } else {
- content.append(configBody.getContent());
- }
+ bodyMerge.add(configBody);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Could't read file "
+ moduleFacesConfig.getPath(), e);
@@ -490,10 +481,22 @@
"Error parsing config file "
+ moduleFacesConfig.getPath(), e);
}
+
+
}
}
+ if (comparator != null) {
+ bodyMerge.sort(comparator);
+ }
+
+ try {
+ content.append(bodyMerge.getContent());
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+
if (xmls.size() > 0) {
- context.put("content", content.toString());
+ context.put("content", content);
context.put("library", library);
context.put("models", models);
context.put("xmls", xmls);
Modified: branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2008-04-10 16:34:25 UTC (rev 7740)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2008-04-10 16:39:44 UTC (rev 7741)
@@ -40,6 +40,8 @@
import org.ajax4jsf.builder.config.ParsingException;
import org.ajax4jsf.builder.xml.XMLBody;
+import org.ajax4jsf.builder.xml.XMLBodyMerge;
+import org.ajax4jsf.builder.xml.XPathComparator;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -55,15 +57,11 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.shared.io.scan.ResourceInclusionScanner;
-import org.apache.maven.shared.io.scan.SimpleResourceInclusionScanner;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.util.DirectoryScanner;
+import org.w3c.dom.Node;
/**
* This plugin assembly full components library from modules, included in parent
@@ -97,6 +95,10 @@
private static final String TAGLIB_TEMPLATE = "taglib.vm";
+ private static final Comparator<Node> TLD_COMPARATOR = new XPathComparator("local-name()", "listener-class/text()", "name/text()");
+ private static final Comparator<Node> FACELET_COMPARATOR = new XPathComparator("local-name()", "function-name/text()", "tag-name/text()");
+
+
/**
* Used to look up Artifacts in the remote repository.
*
@@ -236,23 +238,23 @@
templates = Library.JSF12.equals(library.getJsfVersion()) ? TEMPLATES12_PREFIX
: TEMPLATES_PREFIX;
}
- List models = extractModules();
+ List<Model> models = extractModules();
mergeFacesConfig(models);
File resourcesConfig = new File(outputDirectory,
"META-INF/resources-config.xml");
mergeXML(models, "META-INF/resources-config.xml",
RESOURCES_CONFIG_TEMPLATE, "/resource-config/resource",
- "name/text()", new VelocityContext(), resourcesConfig, false);
+ "name/text()", new VelocityContext(), resourcesConfig, false, null);
if (null != commonStyle) {
File commonXcss = new File(outputDirectory, commonStyle);
mergeXML(models, includeXcss, XCSS_TEMPLATE, templateXpath, null,
- new VelocityContext(), commonXcss, true);
+ new VelocityContext(), commonXcss, true, null);
}
if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
for (int i = 0; i < library.getTaglibs().length; i++) {
Taglib taglib = library.getTaglibs()[i];
- List taglibModels;
+ List<Model> taglibModels;
if (taglib.getIncludeModules() == null
&& taglib.getExcludeModules() == null) {
taglibModels = models;
@@ -267,7 +269,7 @@
excludeModules = taglib.getExcludeModules().split(",");
Arrays.sort(excludeModules);
}
- taglibModels = new ArrayList();
+ taglibModels = new ArrayList<Model>();
for (Iterator iterator = models.iterator(); iterator
.hasNext();) {
Model model = (Model) iterator.next();
@@ -280,33 +282,6 @@
}
}
}
- // sort taglib models by artifactIds in ASC order
- Collections.sort(taglibModels, new Comparator() {
- /**
- * Compares two <code>Model</code> objects by artifactIds
- * for sorting in ASC order
- * @param m1 - model object
- * @param m2 - model object
- * @return result of comparing
- */
- public int compare(Object o1, Object o2) {
- // cast incoming parameters to Model objects
- if(!(o1 instanceof Model) || !(o2 instanceof Model)) {
- throw new IllegalArgumentException("Only Model objects should be compared!");
- }
- Model m1 = (Model) o1;
- Model m2 = (Model) o2;
- // check incoming parameters for null
- if ((m1 == null) || (m1.getArtifactId() == null)) {
- return -1;
- } else
- if ((m2 == null) || (m2.getArtifactId() == null)) {
- return 1;
- }
-
- return m1.getArtifactId().compareTo(m2.getArtifactId());
- }
- });
generateTaglib(taglibModels, taglib);
}
} else {
@@ -318,7 +293,7 @@
* @param models
* @throws MojoExecutionException
*/
- private void generateTaglib(List models, Taglib taglib)
+ private void generateTaglib(List<Model> models, Taglib taglib)
throws MojoExecutionException {
getLog().debug(
"Assembly taglib for uri " + taglib.getUri()
@@ -331,15 +306,21 @@
File tld = new File(outputDirectory, "META-INF/" + taglib.getTaglib()
+ ".tld");
getLog().debug("Write JSP taglib " + tld.getPath());
- mergeXML(models, includeTld, TLD_TEMPLATE, "/taglib/tag"
- + createTagCondition(taglib, "name") + " | /taglib/listener",
- null, new VelocityContext(taglibContext), tld, false);
+ String commonXPath = "/taglib/tag"
+ + createTagCondition(taglib, "name") + " | /taglib/listener";
+
+ mergeXML(models, includeTld, TLD_TEMPLATE, commonXPath,
+ "listener-class/text() | name/text()", new VelocityContext(taglibContext), tld, false, TLD_COMPARATOR);
+
+
File faceletsTaglib = new File(outputDirectory, "META-INF/"
+ taglib.getTaglib() + ".taglib.xml");
- mergeXML(models, includeTaglib, TAGLIB_TEMPLATE, "/facelet-taglib/tag"
- + createTagCondition(taglib, "tag-name")
- + " | /facelet-taglib/function", null, new VelocityContext(
- taglibContext), faceletsTaglib, false);
+ commonXPath = "/facelet-taglib/tag"
+ + createTagCondition(taglib, "tag-name")
+ + " | /facelet-taglib/function";
+
+ mergeXML(models, includeTaglib, TAGLIB_TEMPLATE, commonXPath, "tag-name/text() | function-name/text()", new VelocityContext(
+ taglibContext), faceletsTaglib, false, FACELET_COMPARATOR);
getLog().debug("Write Facelets taglib " + faceletsTaglib.getPath());
}
@@ -390,12 +371,12 @@
* @return
* @throws MojoExecutionException
*/
- private List extractModules() throws MojoExecutionException {
- List modules = parentProject.getModules();
- List models = new ArrayList(modules.size());
+ private List<Model> extractModules() throws MojoExecutionException {
+ List<String> modules = parentProject.getModules();
+ List<Model> models = new ArrayList<Model>(modules.size());
Map<String, Dependency> projectsDependencies = new HashMap<String, Dependency>();
- for (Iterator iter = modules.iterator(); iter.hasNext();) {
- String moduleName = (String) iter.next();
+ for (Iterator<String> iter = modules.iterator(); iter.hasNext();) {
+ String moduleName = iter.next();
getLog().info("Parent project have module " + moduleName);
Model model;
File f = new File(parentProject.getBasedir(), moduleName
@@ -422,10 +403,10 @@
getLog().debug(
"Project " + model.getName()
+ " included to library set");
- List dependencies = model.getDependencies();
- for (Iterator iterator = dependencies.iterator(); iterator
+ List<Dependency> dependencies = model.getDependencies();
+ for (Iterator<Dependency> iterator = dependencies.iterator(); iterator
.hasNext();) {
- Dependency dependency = (Dependency) iterator.next();
+ Dependency dependency = iterator.next();
getLog().debug(
dependency.getClass().getName() + " : "
+ dependency + " with key: "
@@ -441,9 +422,9 @@
}
// Remove modules projects from dependencise
Set<String> unwanted = new HashSet<String>(projectsDependencies.size());
- for (Iterator iter = models.iterator(); iter.hasNext();) {
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
Model model = (Model) iter.next();
- for (Iterator iterator = projectsDependencies.values().iterator(); iterator
+ for (Iterator<Dependency> iterator = projectsDependencies.values().iterator(); iterator
.hasNext();) {
Dependency dependency = (Dependency) iterator.next();
if (model.getGroupId().equals(dependency.getGroupId())
@@ -625,28 +606,33 @@
* {@link Set} to check for duplicate keys. Must not be null
* @throws MojoExecutionException
*/
- private void mergeXML(List models, String filename, String templateName,
+ private void mergeXML(List<Model> models, String filename, String templateName,
String commonXpath, String keyXPath, VelocityContext context,
- File target, boolean namespaceAware) throws MojoExecutionException {
- Set<String> keySet = new HashSet<String>();
+ File target, boolean namespaceAware, Comparator<Node> comparator) throws MojoExecutionException {
StringBuffer content = new StringBuffer();
- List<XMLBody> xmls = new ArrayList<XMLBody>(models.size());
String[] split = filename.split(",");
- for (Iterator iter = models.iterator(); iter.hasNext();) {
- Model model = (Model) iter.next();
+ XMLBodyMerge xBodyMerge = new XMLBodyMerge(commonXpath, keyXPath);
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = iter.next();
File moduleDir = new File(modulesDirectory, model.getArtifactId());
- mergeXMLdir(moduleDir, commonXpath, keyXPath, namespaceAware,
- keySet, content, xmls, split);
+ mergeXMLdir(moduleDir, namespaceAware, split, xBodyMerge);
}
if(null!=config){
- mergeXMLdir(config, commonXpath, keyXPath, namespaceAware,
- keySet, content, xmls, split);
+ mergeXMLdir(config, namespaceAware, split, xBodyMerge);
}
- if (xmls.size() > 0) {
+
+ if (comparator != null) {
+ xBodyMerge.sort(comparator);
+ }
+ try {
+ content.append(xBodyMerge.getContent());
+ } catch (Exception e1) {
+ throw new MojoExecutionException("XML Merge Exception Occured", e1);
+ }
+ if (content.length() > 0) {
context.put("content", content.toString());
context.put("library", library);
context.put("models", models);
- context.put("xmls", xmls);
try {
writeParsedTemplate(templates + templateName, context, target);
} catch (Exception e) {
@@ -669,9 +655,7 @@
* @throws IllegalStateException
* @throws MojoExecutionException
*/
- private void mergeXMLdir(File moduleDir, String commonXpath,
- String keyXPath, boolean namespaceAware, Set<String> keySet,
- StringBuffer content, List<XMLBody> xmls, String[] split)
+ private void mergeXMLdir(File moduleDir, boolean namespaceAware, String[] split, XMLBodyMerge xBodyMerge)
throws IllegalStateException, MojoExecutionException {
DirectoryScanner ds = new DirectoryScanner();
ds.setFollowSymlinks(true);
@@ -687,17 +671,7 @@
XMLBody configBody = new XMLBody();
try {
configBody.loadXML(new FileInputStream(moduleFacesConfig),namespaceAware);
- xmls.add(configBody);
- if (commonXpath != null) {
- if (keyXPath == null) {
- content.append(configBody.getContent(commonXpath));
- } else {
- content.append(configBody.getContentUnique(
- commonXpath, keyXPath, keySet));
- }
- } else {
- content.append(configBody.getContent());
- }
+ xBodyMerge.add(configBody);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Could't read file "
+ moduleFacesConfig.getPath(), e);
16 years, 9 months