JBoss Rich Faces SVN: r1565 - trunk/docs/ajaxguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2007-07-10 04:25:13 -0400 (Tue, 10 Jul 2007)
New Revision: 1565
Modified:
trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGusingAJAX.xml
Log:
http://jira.jboss.com/jira/browse/RF-436
Modified: trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGusingAJAX.xml
===================================================================
--- trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGusingAJAX.xml 2007-07-10 08:23:47 UTC (rev 1564)
+++ trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGusingAJAX.xml 2007-07-10 08:25:13 UTC (rev 1565)
@@ -112,7 +112,7 @@
<para>In order to create AJAX4JSF applications properly, keep the following points in mind:</para>
<itemizedlist>
<listitem>
- The AJAX framework should not append or delete, but only replace elements on the page. For successful updates, an element with the same ID as in the response must exist on the page. If you'd like to append any code to a page, put in a placeholder for it (any empty element). For the same reason, it's recommended to place messages in the<emphasis role="italic">
+ The AJAX framework should not append or delete, but only replace elements on the page. For successful updates, an element with the same ID as in the response must exist on the page. If you'd like to append any code to a page, put in a placeholder for it (any empty element). For the same reason, it's recommended to place messages in the<emphasis >
<property>"AjaxOutput"</property>
</emphasis> component (as no messages is also a message).
</listitem>
@@ -167,14 +167,14 @@
<para>Most important attributes of components that provide AJAX request calling features are:</para>
<itemizedlist>
<listitem>
- <emphasis role="italic">
+ <emphasis >
<property>"reRender"</property>
</emphasis>attribute as it was mentioned <link linkend="SendAnAJAXRequest">before</link> specifies components to be reRendered
after AJAX response. The attribute can be specified using EL expression and formed dynamicaly on the
server side (see <ulink url="index.html#FAQ">FAQ chapter</ulink>).
</listitem>
<listitem>
- <emphasis role="italic">
+ <emphasis >
<property>"RequestDelay"</property>
</emphasis> attribute is used for a requests frequency regulation.
</listitem>
@@ -187,18 +187,18 @@
</para>
<itemizedlist>
<listitem>
- <emphasis role="italic">
+ <emphasis >
<property>"EventsQueue"</property>
</emphasis> is a queue that stores the next request.
</listitem>
<listitem>
- <emphasis role="italic">
+ <emphasis >
<property>"LimitToList"</property>
</emphasis> attribute is used to regulate updatable regions. Setting
it to true limits the updatable areas only to ones specified in a
reRender list, in other case all Output Panels of the region are updated.
</listitem>
- <listitem> <emphasis role="italic">
+ <listitem> <emphasis >
<property>"ajaxSingle"</property>
</emphasis> attributes specify regions to be sent with a request,
if "false" it is a full region, in other case it's is only a control caused
@@ -288,9 +288,9 @@
<section id="SessionExpiredHandling">
<?dbhtml filename="SessionExpiredHandling.html"?>
<title>Session Expired Handling</title>
- <para>Beginning with Ajax4jsf version 1.0.5 it's possible to redefine also the <emphasis role="italic">
+ <para>Beginning with Ajax4jsf version 1.0.5 it's possible to redefine also the <emphasis >
<property>"onExpired"</property>
- </emphasis> framework method that is called on the <emphasis role="italic">
+ </emphasis> framework method that is called on the <emphasis >
<property>"Session Expiration"</property>
</emphasis> event.</para>
<programlisting role="JAVA"><![CDATA[A4J.AJAX.onExpired = function(loc,expiredMsg){
@@ -301,16 +301,22 @@
<para>Here the function receives in params:</para>
<itemizedlist>
<listitem>loc - URL of the current page (on demand can be updated) </listitem>
- <listitem>expiredMsg - a default message on <emphasis role="italic">
+ <listitem>expiredMsg - a default message on <emphasis >
<property>"Session Expiration"</property>
</emphasis>event.</listitem>
</itemizedlist>
<note>
<title>Note:</title>
-Until the version 1.0.5 the method can't be redefined on <emphasis role="italic">
+Until the version 1.0.5 the method can't be redefined on <emphasis >
<property>"Session Expiration"</property>,
</emphasis> a confirmation dialog with a request for view reloading was always called.
</note>
</section>
</section>
-&FAQ;</chapter>
+&FAQ;
+<section id="OtherRelevantResources">
+ <title>Other Relevant Resources</title>
+ <para><ulink url="http://jsf.javabeat.net/articles/2007/06/introduction-to-ajax4jsf/">Introduction to Ajax4Jsf</ulink> by Shunmuga Raja</para>
+
+</section>
+</chapter>
17 years, 6 months
JBoss Rich Faces SVN: r1564 - trunk/docs/ajaxguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2007-07-10 04:23:47 -0400 (Tue, 10 Jul 2007)
New Revision: 1564
Modified:
trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGstart.xml
Log:
http://jira.jboss.com/jira/browse/RF-436
Modified: trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGstart.xml
===================================================================
--- trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGstart.xml 2007-07-10 08:21:05 UTC (rev 1563)
+++ trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGstart.xml 2007-07-10 08:23:47 UTC (rev 1564)
@@ -35,14 +35,14 @@
<itemizedlist>
<listitem>
- Unzip <emphasis role="italic">
+ Unzip <emphasis >
<property>"ajax4jsf.zip"</property>
</emphasis> file to the chosen folder.
</listitem>
<listitem>
- Copy <emphasis role="italic"><property>"ajax4jsf.jar"</property></emphasis> and <emphasis role="italic"><property>"oscache-2.3.2.jar"</property></emphasis> files into the <emphasis role="italic">
+ Copy <emphasis ><property>"ajax4jsf.jar"</property></emphasis> and <emphasis ><property>"oscache-2.3.2.jar"</property></emphasis> files into the <emphasis >
<property>"WEB-INF/lib"</property>
</emphasis> folder of your application.
@@ -53,7 +53,7 @@
</para>
</note>
<listitem>
- Add the following content into the <emphasis role="italic">
+ Add the following content into the <emphasis >
<property>"WEB-INF/web.xml"</property>
</emphasis> file of your application:
@@ -71,7 +71,7 @@
</filter-mapping>]]></programlisting>
<note>
<title>Note:</title>
- <para>You can copy and paste the above text from the <emphasis role="italic">
+ <para>You can copy and paste the above text from the <emphasis >
<property>"README.txt"</property>
</emphasis> file.</para>
</note>
@@ -135,15 +135,15 @@
text field pointed to our managed bean property contains up-to-date value of our input.
</para>
<para>
- The value of <emphasis role="italic"><property>"reRender"</property></emphasis> attribute of the <emphasis role="bold">
+ The value of <emphasis ><property>"reRender"</property></emphasis> attribute of the <emphasis role="bold">
<property><a4j:support></property>
</emphasis> tag defines which part(s) of our
page is (are) to be updated. In this case, the only part of the page to
update is the <emphasis role="bold">
<property><h:outputText></property>
- </emphasis> tag because its ID value matches to the value of <emphasis role="italic"><property>"reRender"</property></emphasis>
+ </emphasis> tag because its ID value matches to the value of <emphasis ><property>"reRender"</property></emphasis>
attribute. As you see, it's not difficult to update multiple elements on the page, only list their IDs
- as the value of <emphasis role="italic"><property>"reRender"</property></emphasis>.
+ as the value of <emphasis ><property>"reRender"</property></emphasis>.
</para>
</section>
<section id="DataBean">
@@ -251,4 +251,8 @@
</para>
</section>
</section>
+ <section id="Relevant_src">
+ <title>Other Relevant Resources</title>
+ <para><ulink url="http://jsf.javabeat.net/articles/2007/06/introduction-to-ajax4jsf/3">Introduction to Ajax4Jsf - Sample Application</ulink> by Shunmuga Raja</para>
+ </section>
</chapter>
17 years, 6 months
JBoss Rich Faces SVN: r1563 - trunk/docs/ajaxguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2007-07-10 04:21:05 -0400 (Tue, 10 Jul 2007)
New Revision: 1563
Modified:
trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGintro.xml
Log:
http://jira.jboss.com/jira/browse/RF-436
Modified: trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGintro.xml
===================================================================
--- trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGintro.xml 2007-07-10 08:20:19 UTC (rev 1562)
+++ trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGintro.xml 2007-07-10 08:21:05 UTC (rev 1563)
@@ -52,7 +52,7 @@
<title>Easily generate images on-the-fly</title>
<para>Resource framework can generate images on-the-fly so that it becomes possible to
create images using the familiar approach of the
- <emphasis role="italic"><property>"Java Graphics2D"</property></emphasis> library.</para>
+ <emphasis ><property>"Java Graphics2D"</property></emphasis> library.</para>
</formalpara>
<formalpara>
<title>Create a modern rich user interface look-and-feel with skins-based technology</title>
17 years, 6 months
JBoss Rich Faces SVN: r1562 - trunk/docs/ajaxguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2007-07-10 04:20:19 -0400 (Tue, 10 Jul 2007)
New Revision: 1562
Modified:
trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGfaq.xml
Log:
http://jira.jboss.com/jira/browse/RF-436
Modified: trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGfaq.xml
===================================================================
--- trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGfaq.xml 2007-07-10 01:19:57 UTC (rev 1561)
+++ trunk/docs/ajaxguide/en/src/main/docbook/modules/a4jUGfaq.xml 2007-07-10 08:20:19 UTC (rev 1562)
@@ -28,7 +28,7 @@
<title>How to check sending request conditions? Custom JavaScript before request
"OnSubmit" attribute.</title>
- <para> To check on the client some terms of request sending, the <emphasis role="italic">
+ <para> To check on the client some terms of request sending, the <emphasis >
<property>"onSubmit</property>
</emphasis>" attribute is added to all components, which may cause the request. </para>
<para>
@@ -37,17 +37,17 @@
<programlisting role="XML"><![CDATA[<h:inputText id="i" value="#{beanText.kennung}">
<a4j:support event="onfocus" onsubmit="doSomething();" reRender="panelToReRender"/>
</h:inputText>]]></programlisting>
- <para> So in this case "<emphasis role="italic"
+ <para> So in this case "<emphasis
><property>doSomething()</property>"</emphasis> function is executed before
the AJAX request. </para>
<para> Besides, if this function returns "false", AJAX request
isn't fired. </para>
<note>
<title>Note:</title>
- <para>Behavior of our <emphasis role="italic">
+ <para>Behavior of our <emphasis >
<property>"onsubmit"</property>
</emphasis>slightly differs from the standard one. Do not return <emphasis
- role="italic">
+ >
<property>"true"</property>
</emphasis> if you want to fire the request - because <emphasis role="bold">
<property><xxx><a4j:support
@@ -56,7 +56,7 @@
</emphasis> is transformed into <xxx onclick="return true;
A4J.Submit(.... );" > and the request isn't fired also in
this case (but the standard event processing fired). You must only return <emphasis
- role="italic">
+ >
<property>"false"</property>
</emphasis> if your conditions weren't completed or perform some actions
(if needed) without any returns in case you need to fire it. </para>
@@ -70,15 +70,15 @@
(..oncomplete :anotherFunction(this)..), it places (oncomplete:
function(){anotherFunction(this);}..) in anonymous function, to allow put
"chain" of statements in attribute. </para>
- <para> Since, <emphasis role="italic">
+ <para> Since, <emphasis >
<property>"this"</property>
</emphasis> keyword will point to a parameters map instead of a control element as it
- was before. You may use <emphasis role="italic">
+ was before. You may use <emphasis >
<property>document.findElementById()</property>
</emphasis>to get references to this object after a request is processed as when a page
is updated in AJAX you will have reference to a control, removed from a DOM tree. </para>
<para> Or, if you are sure that your element is not updated, you can add <emphasis
- role="italic">
+ >
<property>"onsubmit"</property>
</emphasis> in <emphasis role="bold">
<property><a4j:support></property>
@@ -103,13 +103,13 @@
<section id="InvokeOnComponentUsingWithJSF1.2">
<?dbhtml filename="InvokeOnComponentUsingWithJSF1.2.html"?>
<title>Is it possible to use InvokeOnComponent with JSF 1.2?</title>
- <para> Ajax4jsf currently does not use <emphasis role="italic">invokeOnComponent</emphasis>
+ <para> Ajax4jsf currently does not use <emphasis >invokeOnComponent</emphasis>
because of the 2 reasons: </para>
<itemizedlist>
<listitem> Compatibility with JSF 1.1 and MyFaces applications is kept, due to a big
amount of code used in corporate applications. </listitem>
<listitem>
- <emphasis role="italic"> InvokeOnComponent</emphasis> works with already known
+ <emphasis > InvokeOnComponent</emphasis> works with already known
clientId, and works fine for communication between widget and backed component, or
updates content of already rendered component. But there are some troubles to use
this method for more complex use-cases implemented in Ajax4jsf, as there is a choice
@@ -216,14 +216,14 @@
<?dbhtml filename="IgnoreDupResponsesAndRequestDelay.html"?>
<title>How to use IgnoreDupResponses and requestDelay?</title>
- <para>The <emphasis role="italic">
+ <para>The <emphasis >
<property>"IgnoreDupResponses"</property>
</emphasis> attribute appeared from 1.0.4 RC1 version and is used on the client for
response ignoring after an AJAX request if a newer request has been already sent. <para>
- The additional information could be found on the<ulink
+ The additional information could be found <ulink
url="http://jboss.com/index.html?module=bb&op=viewtopic&t=105766"
>here</ulink>. </para>
- <emphasis role="italic">
+ <emphasis >
<property>"RequestDelay"</property>
</emphasis> attribute also defines the client behavior. It sets the time delay, after
which another request could be sent, all other requests are taken away from a queue
@@ -245,7 +245,7 @@
<section id="EventQueueUsage">
<?dbhtml filename="EventQueueUsage.html"?>
<title>How to use "EventQueue" attribute?</title>
- <para>The <emphasis role="italic">
+ <para>The <emphasis >
<property>"EventQueue"</property>
</emphasis> attribute defines the query name where the requests are saved before their
sending to the server. The queue is created for redundant requests deleting during
@@ -282,7 +282,7 @@
<emphasis role="bold"><a4j:region></emphasis> can't work inside
iteration components like <emphasis role="bold"><h:dataTable></emphasis>
and <emphasis role="bold"><a4j:repeat></emphasis>. </para>
- <para>The details could be found on the <ulink
+ <para>The details could be found <ulink
url="http://jboss.com/index.html?module=bb&op=viewtopic&t=109080"
>here. </ulink>
</para>
17 years, 6 months
JBoss Rich Faces SVN: r1561 - in trunk: framework/impl/src/main/java/org/ajax4jsf/framework/renderer and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-09 21:19:57 -0400 (Mon, 09 Jul 2007)
New Revision: 1561
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java
trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
Log:
packages and classes refactor in the "impl" project
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java 2007-07-10 01:10:15 UTC (rev 1560)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,34 +0,0 @@
-package org.ajax4jsf.ajax;
-
-import java.io.Serializable;
-import java.util.EventObject;
-
-import org.ajax4jsf.event.PushEventListener;
-
-public class PushEventsCounter implements PushEventListener,Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 4060284352186710009L;
- private volatile boolean performed = false;
-
- public void onEvent(EventObject event) {
- performed = true;
- }
-
- /**
- * @return the performed
- */
- public boolean isPerformed() {
- return performed;
- }
-
- /**
- */
- public void processed() {
- this.performed = false;
- }
-
-
-}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2007-07-10 01:10:15 UTC (rev 1560)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -39,8 +39,8 @@
import javax.faces.convert.Converter;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.Java2Dresource;
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler)
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/AttributeElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,122 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-
-import org.ajax4jsf.Messages;
-import org.xml.sax.SAXException;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
- *
- */
-public class AttributeElement extends ElementBase {
-
- private String name;
- private boolean mandatory = true;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(TemplateContext context) throws IOException {
- String attributeValue = getString(context);
- if(attributeValue.length()>0 || isMandatory()){
- context.getWriter().writeAttribute(getName(),attributeValue,null);
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- throw new FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_INSIDE_ATTRIBUTE_ERROR, getName(), context.getComponent().getId()));
- }
-
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
- /**
- * @param name The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
- /**
- * @return Returns the notNull.
- */
- public boolean isMandatory() {
- return mandatory;
- }
- /**
- * Alias ( due to typo error ) for Mandatory property.
- * @param notNull The notNull to set.
- */
- public void setMantadory(boolean notNull) {
- this.mandatory = notNull;
- }
-
- /**
- * @param notNull The notNull to set.
- */
- public void setMandatory(boolean notNull) {
- this.mandatory = notNull;
- }
-
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.ATTRIBUTE_TAG;
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- super.setParent(parent);
- if (getName()==null) {
- throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // TODO Auto-generated method stub
- return new Class[]{
- MethodCallElement.class,
- TextElement.class,
- ResourceElement.class,
- ClassElement.class
- };
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/AttributeElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/AttributeElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,122 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+
+import org.ajax4jsf.Messages;
+import org.xml.sax.SAXException;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
+ *
+ */
+public class AttributeElement extends ElementBase {
+
+ private String name;
+ private boolean mandatory = true;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ String attributeValue = getString(context);
+ if(attributeValue.length()>0 || isMandatory()){
+ context.getWriter().writeAttribute(getName(),attributeValue,null);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ throw new FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_INSIDE_ATTRIBUTE_ERROR, getName(), context.getComponent().getId()));
+ }
+
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ /**
+ * @return Returns the notNull.
+ */
+ public boolean isMandatory() {
+ return mandatory;
+ }
+ /**
+ * Alias ( due to typo error ) for Mandatory property.
+ * @param notNull The notNull to set.
+ */
+ public void setMantadory(boolean notNull) {
+ this.mandatory = notNull;
+ }
+
+ /**
+ * @param notNull The notNull to set.
+ */
+ public void setMandatory(boolean notNull) {
+ this.mandatory = notNull;
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.ATTRIBUTE_TAG;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ super.setParent(parent);
+ if (getName()==null) {
+ throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // TODO Auto-generated method stub
+ return new Class[]{
+ MethodCallElement.class,
+ TextElement.class,
+ ResourceElement.class,
+ ClassElement.class
+ };
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakException.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,52 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import javax.faces.FacesException;
-
-/**
- * Exception for process part of template.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:42 $
- *
- */
-public class BreakException extends FacesException {
-
- private String _name;
- /**
- * @param name
- *
- */
- public BreakException(String name) {
- super();
- _name=name;
- }
- /**
- * @return Returns the name.
- */
- public String getName() {
- return _name;
- }
-
-
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakException.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakException.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,52 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import javax.faces.FacesException;
+
+/**
+ * Exception for process part of template.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:42 $
+ *
+ */
+public class BreakException extends FacesException {
+
+ private String _name;
+ /**
+ * @param name
+ *
+ */
+ public BreakException(String name) {
+ super();
+ _name=name;
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return _name;
+ }
+
+
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakPoint.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,138 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.xml.sax.SAXException;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
- *
- */
-public class BreakPoint implements PreparedTemplate {
-
- private List childrens = new ArrayList();
-
- private PreparedTemplate _parent;
- private String name;
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name The name to set.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.RendererBase, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(RendererBase renderer, FacesContext context,
- UIComponent component) throws IOException {
- throw new BreakException(getName());
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- throw new BreakException(getName());
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint)
- throws IOException {
- if (!getName().equals(breakPoint)) {
- throw new BreakException(getName());
- } else if(getChildren().size()>0){
- // encode all childrens of this breakpoint.
- for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
- PreparedTemplate element = (PreparedTemplate) iter.next();
- element.encode(context);
- }
- // after childrens, break encoding.
- throw new BreakException(getName());
- }
- // if no childrens - continue encoding.
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getChildren()
- */
- public List getChildren() {
- // breakpoint - empty element
- return childrens;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#addChild(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void addChild(PreparedTemplate child) throws SAXException {
- child.setParent(this);
- childrens.add(child);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- if (getName()==null) {
- throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
- }
- this._parent = parent;
- if (parent instanceof ElementBase) {
- ((ElementBase) parent).addBreakPoint(getName());
- }
- }
-
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.BREAK_TAG;
- }
-
- public Object getValue(TemplateContext context) {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakPoint.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/BreakPoint.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,138 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
+ *
+ */
+public class BreakPoint implements PreparedTemplate {
+
+ private List childrens = new ArrayList();
+
+ private PreparedTemplate _parent;
+ private String name;
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.RendererBase, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(RendererBase renderer, FacesContext context,
+ UIComponent component) throws IOException {
+ throw new BreakException(getName());
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ throw new BreakException(getName());
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint)
+ throws IOException {
+ if (!getName().equals(breakPoint)) {
+ throw new BreakException(getName());
+ } else if(getChildren().size()>0){
+ // encode all childrens of this breakpoint.
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
+ PreparedTemplate element = (PreparedTemplate) iter.next();
+ element.encode(context);
+ }
+ // after childrens, break encoding.
+ throw new BreakException(getName());
+ }
+ // if no childrens - continue encoding.
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getChildren()
+ */
+ public List getChildren() {
+ // breakpoint - empty element
+ return childrens;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#addChild(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void addChild(PreparedTemplate child) throws SAXException {
+ child.setParent(this);
+ childrens.add(child);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ if (getName()==null) {
+ throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
+ }
+ this._parent = parent;
+ if (parent instanceof ElementBase) {
+ ((ElementBase) parent).addBreakPoint(getName());
+ }
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.BREAK_TAG;
+ }
+
+ public Object getValue(TemplateContext context) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ChildElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,70 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.Messages;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
- *
- */
-public class ChildElement extends ElementBase {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- throw new FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR_3));
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- UIComponent child = (UIComponent) context.getParameter(ChildrensElement.CURRENT_CHILD);
- if(null == child){
- child = (UIComponent) getValue(context);
- }
- if(null !=child && child.isRendered()){
- context.getRenderer().renderChild(context.getFacesContext(),child);
- }
- }
-
- public String getTag() {
- return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.CHILD_TAG;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // child elements not allowed
- return new Class[]{};
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ChildElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,70 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
+ *
+ */
+public class ChildElement extends ElementBase {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ throw new FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR_3));
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ UIComponent child = (UIComponent) context.getParameter(ChildrensElement.CURRENT_CHILD);
+ if(null == child){
+ child = (UIComponent) getValue(context);
+ }
+ if(null !=child && child.isRendered()){
+ context.getRenderer().renderChild(context.getFacesContext(),child);
+ }
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.CHILD_TAG;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // child elements not allowed
+ return new Class[]{};
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ChildrensElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,154 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.Messages;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
- *
- */
-public class ChildrensElement extends ElementBase {
- public static final String CURRENT_CHILD = "child_to_render";
-
- private String iteratorName;
-
-
- public String getIteratorName() {
- return iteratorName;
- }
-
- public void setIteratorName(String iteratorVar) {
- this.iteratorName = iteratorVar;
-
- }
-
- public class IteratorWrapper implements Iterator{
- private Iterator iterator;
- private int index = -1;
-
- public IteratorWrapper(Iterator iterator) {
- this.iterator = iterator;
- }
- public Iterator getIterator() {
- return iterator;
- }
- public boolean hasNext() {
- return iterator.hasNext();
- }
- public Object next() {
- Object o = iterator.next();
- index++;
- return o;
- }
- public void remove() {
- iterator.remove();
- }
- public boolean isLast(){
- return !iterator.hasNext();
- }
- public int getIndex() {
- return index;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- UIComponent stored = (UIComponent) context.getParameter(CURRENT_CHILD);
-// Collection children = context.getComponent().getChildren();
- IteratorWrapper iter =new IteratorWrapper(Collections.EMPTY_LIST.iterator());
- Object value = getValue(context);
- if(value != null){
- if (value instanceof UIComponent) {
- UIComponent comp = (UIComponent) value;
- iter = new IteratorWrapper(comp.getChildren().iterator());
- } else if (value instanceof Collection) {
- iter = new IteratorWrapper( ((Collection) value).iterator() );
- } else if (value instanceof String) {
- String componentId = (String) value;
- UIComponent comp = context.getComponent().findComponent(componentId);
- if (null != comp) {
- iter = new IteratorWrapper(comp.getChildren().iterator());
- }
- } else if (value instanceof Iterator) {
- iter = new IteratorWrapper((Iterator) value);
- }
- } else {
- iter = new IteratorWrapper(context.getComponent().getChildren().iterator());
- }
- // For all childrens, iterate over template.
-// IteratorWrapper iter = new IteratorWrapper(children.iterator());
- if(iteratorName != null){
- context.putParameter(iteratorName, iter);
- }
- while (iter.hasNext()) {
- UIComponent child = (UIComponent) iter.next();
-
- if ( child.isRendered()) {
- if (getChildren().size()>0) {
- // Store facet to render in <u:child> element.
- // TODO - create new templatecontext with current iteration component ?
- context.putParameter(CURRENT_CHILD, child);
- // In fact, render all childrens.
- super.encode(context);
- } else {
- // empty element - render children as-is
- context.getRenderer().renderChild(context.getFacesContext(),child);
- }
- }
- }
- if(iteratorName != null){
- context.removeParameter(iteratorName);
- }
- if (null != stored) {
- context.putParameter(CURRENT_CHILD, stored);
- } else {
- context.removeParameter(CURRENT_CHILD);
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // TODO Auto-generated method stub
- throw new FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR_2));
- }
-
- public String getTag() {
- return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.CHILDREN_TAG;
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ChildrensElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ChildrensElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,154 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
+ *
+ */
+public class ChildrensElement extends ElementBase {
+ public static final String CURRENT_CHILD = "child_to_render";
+
+ private String iteratorName;
+
+
+ public String getIteratorName() {
+ return iteratorName;
+ }
+
+ public void setIteratorName(String iteratorVar) {
+ this.iteratorName = iteratorVar;
+
+ }
+
+ public class IteratorWrapper implements Iterator{
+ private Iterator iterator;
+ private int index = -1;
+
+ public IteratorWrapper(Iterator iterator) {
+ this.iterator = iterator;
+ }
+ public Iterator getIterator() {
+ return iterator;
+ }
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+ public Object next() {
+ Object o = iterator.next();
+ index++;
+ return o;
+ }
+ public void remove() {
+ iterator.remove();
+ }
+ public boolean isLast(){
+ return !iterator.hasNext();
+ }
+ public int getIndex() {
+ return index;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ UIComponent stored = (UIComponent) context.getParameter(CURRENT_CHILD);
+// Collection children = context.getComponent().getChildren();
+ IteratorWrapper iter =new IteratorWrapper(Collections.EMPTY_LIST.iterator());
+ Object value = getValue(context);
+ if(value != null){
+ if (value instanceof UIComponent) {
+ UIComponent comp = (UIComponent) value;
+ iter = new IteratorWrapper(comp.getChildren().iterator());
+ } else if (value instanceof Collection) {
+ iter = new IteratorWrapper( ((Collection) value).iterator() );
+ } else if (value instanceof String) {
+ String componentId = (String) value;
+ UIComponent comp = context.getComponent().findComponent(componentId);
+ if (null != comp) {
+ iter = new IteratorWrapper(comp.getChildren().iterator());
+ }
+ } else if (value instanceof Iterator) {
+ iter = new IteratorWrapper((Iterator) value);
+ }
+ } else {
+ iter = new IteratorWrapper(context.getComponent().getChildren().iterator());
+ }
+ // For all childrens, iterate over template.
+// IteratorWrapper iter = new IteratorWrapper(children.iterator());
+ if(iteratorName != null){
+ context.putParameter(iteratorName, iter);
+ }
+ while (iter.hasNext()) {
+ UIComponent child = (UIComponent) iter.next();
+
+ if ( child.isRendered()) {
+ if (getChildren().size()>0) {
+ // Store facet to render in <u:child> element.
+ // TODO - create new templatecontext with current iteration component ?
+ context.putParameter(CURRENT_CHILD, child);
+ // In fact, render all childrens.
+ super.encode(context);
+ } else {
+ // empty element - render children as-is
+ context.getRenderer().renderChild(context.getFacesContext(),child);
+ }
+ }
+ }
+ if(iteratorName != null){
+ context.removeParameter(iteratorName);
+ }
+ if (null != stored) {
+ context.putParameter(CURRENT_CHILD, stored);
+ } else {
+ context.removeParameter(CURRENT_CHILD);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // TODO Auto-generated method stub
+ throw new FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR_2));
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.CHILDREN_TAG;
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ClassElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,148 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import javax.faces.FacesException;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.util.style.CSSFormat;
-import org.xml.sax.SAXException;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
- *
- */
-public class ClassElement extends ElementBase {
-
- private String _name;
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
- * java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint)
- throws IOException {
- encode(context);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- context.getWriter().writeText(getString(context), null);
- }
-
- /**
- * @return Returns the name.
- */
- public String getName() {
- return _name;
- }
-
- /**
- * @param name
- * The name to set.
- */
- public void setName(String name) {
- _name = name;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public String getString(TemplateContext context) throws FacesException {
- if (null == getName()) {
- throw new FacesException(Messages
- .getMessage(Messages.STYLE_ATTRIBUTE_ERROR));
- }
- String stringOrDefault = valueGetter.getStringOrDefault(context);
- StringBuffer string = new StringBuffer();
- string.append(stringOrDefault);
- for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
- Object element = iter.next();
- if (element instanceof ElementBase) {
- ElementBase stringElement = (ElementBase) element;
- String str = stringElement.getString(context);
- if (str.length() > 0) {
- string.append(" ");
- boolean isUrl = element instanceof ResourceElement;
- if (isUrl) {
- string.append(CSSFormat.url(str));
- } else {
- string.append(str);
- }
- }
- }
- }
- if (string.length() > 0) {
- string.insert(0, ":").insert(0, getName()).append(";");
- return string.toString();
- } else {
- return "";
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
- */
- public String getTag() {
- // TODO Auto-generated method stub
- return HtmlCompiler.NS_PREFIX + HtmlCompiler.STYLE_TAG;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- super.setParent(parent);
- if (getName() == null) {
- throw new SAXException(Messages.getMessage(
- Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // TODO Auto-generated method stub
- return new Class[] { MethodCallElement.class, TextElement.class,
- ResourceElement.class };
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ClassElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ClassElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,148 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.faces.FacesException;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.framework.util.style.CSSFormat;
+import org.xml.sax.SAXException;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
+ *
+ */
+public class ClassElement extends ElementBase {
+
+ private String _name;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext,
+ * java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint)
+ throws IOException {
+ encode(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ context.getWriter().writeText(getString(context), null);
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * @param name
+ * The name to set.
+ */
+ public void setName(String name) {
+ _name = name;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public String getString(TemplateContext context) throws FacesException {
+ if (null == getName()) {
+ throw new FacesException(Messages
+ .getMessage(Messages.STYLE_ATTRIBUTE_ERROR));
+ }
+ String stringOrDefault = valueGetter.getStringOrDefault(context);
+ StringBuffer string = new StringBuffer();
+ string.append(stringOrDefault);
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (element instanceof ElementBase) {
+ ElementBase stringElement = (ElementBase) element;
+ String str = stringElement.getString(context);
+ if (str.length() > 0) {
+ string.append(" ");
+ boolean isUrl = element instanceof ResourceElement;
+ if (isUrl) {
+ string.append(CSSFormat.url(str));
+ } else {
+ string.append(str);
+ }
+ }
+ }
+ }
+ if (string.length() > 0) {
+ string.insert(0, ":").insert(0, getName()).append(";");
+ return string.toString();
+ } else {
+ return "";
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
+ */
+ public String getTag() {
+ // TODO Auto-generated method stub
+ return HtmlCompiler.NS_PREFIX + HtmlCompiler.STYLE_TAG;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ super.setParent(parent);
+ if (getName() == null) {
+ throw new SAXException(Messages.getMessage(
+ Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // TODO Auto-generated method stub
+ return new Class[] { MethodCallElement.class, TextElement.class,
+ ResourceElement.class };
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ElementBase.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,438 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.apache.commons.beanutils.MethodUtils;
-import org.richfaces.skin.SkinFactory;
-import org.xml.sax.SAXException;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
- *
- */
-public abstract class ElementBase implements PreparedTemplate {
-
- private List childrens = new ArrayList();
- private Map breaks = new HashMap();
-
- protected ValueGetter valueGetter = new ValueGetter();
- private Object _value = null;
- private Object _default = null;
- private Object _context = null;
- private String _property = null;
- private String _skin ;
-// private String _skinConfiguration ;
- private String _call = null;
- private PreparedTemplate parent;
- private ValueBinding _valueBinding;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(RendererBase renderer, FacesContext context,
- UIComponent component) throws IOException {
- encode(new TemplateContext(renderer,context,component));
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- if (breaks.containsKey(breakPoint)) {
- // start after last breakpoint.
- int start = ((Integer)breaks.get(breakPoint)).intValue();
- Iterator iter = getChildren().listIterator(start);
- ((PreparedTemplate) iter.next()).encode(context,breakPoint);
- // perform childrens - other not contain this breakpoint !
- while ( iter.hasNext()) {
- PreparedTemplate element = (PreparedTemplate) iter.next();
- element.encode(context);
- }
- encodeEnd(context);
- } else {
- throw new FacesException(Messages.getMessage(Messages.BREAKPOINT_NOT_REGISTERED_ERROR, breakPoint));
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- // perform childrens.
- encodeBegin(context);
- for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
- PreparedTemplate element = (PreparedTemplate) iter.next();
- element.encode(context);
- }
- encodeEnd(context);
- }
-
- protected void encodeBegin(TemplateContext context) throws IOException {
-
- }
-
- protected void encodeEnd(TemplateContext context) throws IOException {
-
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.CompiledXML#getChildren()
- */
- public List getChildren() {
- // TODO Auto-generated method stub
- return childrens;
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.CompiledXML#addChild(org.ajax4jsf.renderkit.compiler.CompiledXML)
- */
- public void addChild(PreparedTemplate child) throws SAXException {
- Class[] allowedClasses = getAllowedClasses();
- for (int i = 0; i < allowedClasses.length; i++) {
- if(allowedClasses[i].isInstance(child)){
- child.setParent(this);
- getChildren().add(child);
- return;
- }
- }
- // element don't allowed as child for this.
- throw new SAXException(Messages.getMessage(Messages.CHILD_NOT_ALLOWED_ERROR, child.getTag(), getTag()));
- }
-
- /**
- *
- * @return array of classes, allowed as childs for this element.
- */
- protected Class[] getAllowedClasses(){
- return new Class[]{PreparedTemplate.class};
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- this.parent = parent;
- // Translate all registered breakpoints to parent
- if (parent instanceof ElementBase ) {
- for (Iterator iter = breaks.keySet().iterator(); iter.hasNext();) {
- ((ElementBase) parent).addBreakPoint((String) iter.next());
- }
- }
- }
-
- public void addBreakPoint(String name){
- Integer num = new Integer(getChildren().size());
- breaks.put(name,num);
-// if (null != parent && parent instanceof ElementBase) {
-// ((ElementBase) parent).addBreakPoint(name);
-// }
- }
-
-
-
- /* (non-Javadoc)
- * Build this class name with childrens.
- * @see java.lang.Object#toString()
- */
- public String toString() {
- //
- StringBuffer buf = new StringBuffer(this.getClass().getName());
- buf.append(" [\n");
- for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
- Object child = (Object) iter.next();
- buf.append(" ").append(child.toString()).append(" ;\n");
- }
- buf.append("]\n");
- return buf.toString();
- }
-
- /**
- * @return Returns the value. If is EL expression valueBinding - evaluate in.
- */
- public Object getValue(TemplateContext context) {
- return valueGetter.getValue(context);
- }
-
- public String getString(TemplateContext context) throws FacesException {
- StringBuffer string = new StringBuffer();
- string.append(valueGetter.getStringOrDefault(context));
- for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
- Object element = iter.next();
- if (element instanceof ElementBase) {
- ElementBase stringElement = (ElementBase) element;
- string.append(stringElement.getString(context));
- }
- }
- return string.toString();
- }
- /**
- * @param value The value to set. if EL-expression ( #{...} ) - compile it.
- */
- public void setValue(Object value) {
- if (value instanceof String) {
- String stringValue = (String) value;
- if(isValueReference(stringValue)){
- _value = value;
- try {
- Application app = ((ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
- _valueBinding = app.createValueBinding(stringValue);
- } catch (Exception e) {
- // Do nothing - create at first call
- }
- this.valueGetter = new ValueGetter(){
-
- public /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- // TODO Auto-generated method stub
- if(null==_valueBinding) {
- Application app = context.getFacesContext().getApplication();
- _valueBinding = app.createValueBinding((String) _value);
- }
- return _valueBinding.getValue(context.getFacesContext());
- }
-
- };
- return;
- }
- }
- this._value = value;
- this.valueGetter = new ValueGetter(){
-
- public /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- // TODO Auto-generated method stub
- return _value;
- }
-
- };
- }
-
- /**
- * @return Returns the default.
- */
- public Object getDefault() {
- return _default;
- }
-
- /**
- * @param default1 The default to set.
- */
- public void setDefault(Object default1) {
- _default = default1;
- }
-
- /**
- * @param property The property to set.
- */
- public void setProperty(String property) {
- _property = property;
- valueGetter = new ValueGetter(){
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- Object value = context.getComponent().getAttributes().get(_property);
- if (context.getRenderer().getUtils().isValidProperty(value)) {
- return value;
- } else {
- return null;
- }
- }
-
- };
- }
-
- /**
- * @param skin The skin to set.
- */
- public void setSkin(String skin) {
- _skin = skin;
-// if( null == _skinConfiguration ){
- // Only Skin parameter is used.
- valueGetter = new ValueGetter(){
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- FacesContext facesContext = context.getFacesContext();
- Object parameter = SkinFactory.getInstance().getSkin(facesContext).getParameter(facesContext,_skin,_default);
- return parameter;
- }
-
- };
-// } else {
-// valueGetter = new ConfigurationAndSkinValueGetter();
-// }
- }
-
- /**
- * Set name of skin parameter in "mandatory" list ( default value for fine-tuning parameter ).
- * @param mandatorySkin
- */
-// public void setSkinConfiguration(String mandatorySkin) {
-// _skinConfiguration = mandatorySkin;
-// if(null == _skin){
-// valueGetter = new ConfigurationValueGetter();
-// } else {
-// valueGetter = new ConfigurationAndSkinValueGetter();
-// }
-// }
-
- /**
- * @param context The context to set.
- */
- public void setContext(Object context) {
- _context = context;
- //System.out.println("CTX:" + context);
- valueGetter = new ValueGetter(){
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- // TODO Auto-generated method stub
- return context.getParameter(_context);
- }
-
- };
- }
-
- /**
- * @param call The call to set.
- */
- public void setCall(String call) {
- this._call = call;
- valueGetter = new ValueGetter(){
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- Object getValue(TemplateContext context) {
- try {
- return MethodUtils.invokeMethod(context
- .getRenderer(), _call, new Object[]{context});
- } catch (Exception e) {
- throw new FacesException(Messages.getMessage(Messages.INVOKE_RENDERER_METHOD_ERROR, this.getClass().getName()), e);
- }
- }
-
- };
- }
-
- /**
- * Get EL-enabled value. Return same string, if not el-expression.
- * Otherthise, return parsed and evaluated expression.
- * @param context - current Faces Context.
- * @param value - string to parse.
- * @return - interpreted el or unmodified value.
- */
- protected boolean isValueReference( String value) {
- if (value == null)
- return false;
-
- int start = value.indexOf("#{");
- if (start >= 0) {
- int end = value.lastIndexOf('}');
- if (end >= 0 && start < end) {
- return true;
- }
- }
- return false;
- }
-
-// private final class ConfigurationValueGetter extends ValueGetter {
-// /* (non-Javadoc)
-// * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
-// */
-// Object getValue(TemplateContext context) {
-// FacesContext facesContext = context.getFacesContext();
-// Object parameter = SkinFactory.getInstance().getSkinConfiguration(facesContext).getParameter(facesContext,_skinConfiguration);
-// if(null == parameter){
-// parameter = _default;
-// }
-// return parameter;
-// }
-// }
-//
-// private final class ConfigurationAndSkinValueGetter extends ValueGetter {
-// /* (non-Javadoc)
-// * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
-// */
-// Object getValue(TemplateContext context) {
-// FacesContext facesContext = context.getFacesContext();
-// return SkinFactory.getInstance().getSkinConfiguration(facesContext).getParameter(facesContext,_skinConfiguration,_skin,_default);
-// }
-// }
-
-
- protected class ValueGetter {
- Object getValue(TemplateContext context) {
- return null;
- }
-
- Object getValueOrDefault(TemplateContext context){
- Object result = getValue(context);
- if (null == result) {
- result = getDefault();
- }
- return result;
- }
-
- String getStringOrDefault(TemplateContext context){
- Object result = getValue(context);
- if (null == result || result.toString().length()==0) {
- result = getDefault();
- if (null == result) {
- result = "";
- }
- }
- return result.toString();
-
- }
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ElementBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ElementBase.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,438 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.apache.commons.beanutils.MethodUtils;
+import org.richfaces.skin.SkinFactory;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
+ *
+ */
+public abstract class ElementBase implements PreparedTemplate {
+
+ private List childrens = new ArrayList();
+ private Map breaks = new HashMap();
+
+ protected ValueGetter valueGetter = new ValueGetter();
+ private Object _value = null;
+ private Object _default = null;
+ private Object _context = null;
+ private String _property = null;
+ private String _skin ;
+// private String _skinConfiguration ;
+ private String _call = null;
+ private PreparedTemplate parent;
+ private ValueBinding _valueBinding;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(RendererBase renderer, FacesContext context,
+ UIComponent component) throws IOException {
+ encode(new TemplateContext(renderer,context,component));
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ if (breaks.containsKey(breakPoint)) {
+ // start after last breakpoint.
+ int start = ((Integer)breaks.get(breakPoint)).intValue();
+ Iterator iter = getChildren().listIterator(start);
+ ((PreparedTemplate) iter.next()).encode(context,breakPoint);
+ // perform childrens - other not contain this breakpoint !
+ while ( iter.hasNext()) {
+ PreparedTemplate element = (PreparedTemplate) iter.next();
+ element.encode(context);
+ }
+ encodeEnd(context);
+ } else {
+ throw new FacesException(Messages.getMessage(Messages.BREAKPOINT_NOT_REGISTERED_ERROR, breakPoint));
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ // perform childrens.
+ encodeBegin(context);
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
+ PreparedTemplate element = (PreparedTemplate) iter.next();
+ element.encode(context);
+ }
+ encodeEnd(context);
+ }
+
+ protected void encodeBegin(TemplateContext context) throws IOException {
+
+ }
+
+ protected void encodeEnd(TemplateContext context) throws IOException {
+
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.CompiledXML#getChildren()
+ */
+ public List getChildren() {
+ // TODO Auto-generated method stub
+ return childrens;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.CompiledXML#addChild(org.ajax4jsf.renderkit.compiler.CompiledXML)
+ */
+ public void addChild(PreparedTemplate child) throws SAXException {
+ Class[] allowedClasses = getAllowedClasses();
+ for (int i = 0; i < allowedClasses.length; i++) {
+ if(allowedClasses[i].isInstance(child)){
+ child.setParent(this);
+ getChildren().add(child);
+ return;
+ }
+ }
+ // element don't allowed as child for this.
+ throw new SAXException(Messages.getMessage(Messages.CHILD_NOT_ALLOWED_ERROR, child.getTag(), getTag()));
+ }
+
+ /**
+ *
+ * @return array of classes, allowed as childs for this element.
+ */
+ protected Class[] getAllowedClasses(){
+ return new Class[]{PreparedTemplate.class};
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ this.parent = parent;
+ // Translate all registered breakpoints to parent
+ if (parent instanceof ElementBase ) {
+ for (Iterator iter = breaks.keySet().iterator(); iter.hasNext();) {
+ ((ElementBase) parent).addBreakPoint((String) iter.next());
+ }
+ }
+ }
+
+ public void addBreakPoint(String name){
+ Integer num = new Integer(getChildren().size());
+ breaks.put(name,num);
+// if (null != parent && parent instanceof ElementBase) {
+// ((ElementBase) parent).addBreakPoint(name);
+// }
+ }
+
+
+
+ /* (non-Javadoc)
+ * Build this class name with childrens.
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ //
+ StringBuffer buf = new StringBuffer(this.getClass().getName());
+ buf.append(" [\n");
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
+ Object child = (Object) iter.next();
+ buf.append(" ").append(child.toString()).append(" ;\n");
+ }
+ buf.append("]\n");
+ return buf.toString();
+ }
+
+ /**
+ * @return Returns the value. If is EL expression valueBinding - evaluate in.
+ */
+ public Object getValue(TemplateContext context) {
+ return valueGetter.getValue(context);
+ }
+
+ public String getString(TemplateContext context) throws FacesException {
+ StringBuffer string = new StringBuffer();
+ string.append(valueGetter.getStringOrDefault(context));
+ for (Iterator iter = getChildren().iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (element instanceof ElementBase) {
+ ElementBase stringElement = (ElementBase) element;
+ string.append(stringElement.getString(context));
+ }
+ }
+ return string.toString();
+ }
+ /**
+ * @param value The value to set. if EL-expression ( #{...} ) - compile it.
+ */
+ public void setValue(Object value) {
+ if (value instanceof String) {
+ String stringValue = (String) value;
+ if(isValueReference(stringValue)){
+ _value = value;
+ try {
+ Application app = ((ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+ _valueBinding = app.createValueBinding(stringValue);
+ } catch (Exception e) {
+ // Do nothing - create at first call
+ }
+ this.valueGetter = new ValueGetter(){
+
+ public /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ // TODO Auto-generated method stub
+ if(null==_valueBinding) {
+ Application app = context.getFacesContext().getApplication();
+ _valueBinding = app.createValueBinding((String) _value);
+ }
+ return _valueBinding.getValue(context.getFacesContext());
+ }
+
+ };
+ return;
+ }
+ }
+ this._value = value;
+ this.valueGetter = new ValueGetter(){
+
+ public /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ // TODO Auto-generated method stub
+ return _value;
+ }
+
+ };
+ }
+
+ /**
+ * @return Returns the default.
+ */
+ public Object getDefault() {
+ return _default;
+ }
+
+ /**
+ * @param default1 The default to set.
+ */
+ public void setDefault(Object default1) {
+ _default = default1;
+ }
+
+ /**
+ * @param property The property to set.
+ */
+ public void setProperty(String property) {
+ _property = property;
+ valueGetter = new ValueGetter(){
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ Object value = context.getComponent().getAttributes().get(_property);
+ if (context.getRenderer().getUtils().isValidProperty(value)) {
+ return value;
+ } else {
+ return null;
+ }
+ }
+
+ };
+ }
+
+ /**
+ * @param skin The skin to set.
+ */
+ public void setSkin(String skin) {
+ _skin = skin;
+// if( null == _skinConfiguration ){
+ // Only Skin parameter is used.
+ valueGetter = new ValueGetter(){
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ FacesContext facesContext = context.getFacesContext();
+ Object parameter = SkinFactory.getInstance().getSkin(facesContext).getParameter(facesContext,_skin,_default);
+ return parameter;
+ }
+
+ };
+// } else {
+// valueGetter = new ConfigurationAndSkinValueGetter();
+// }
+ }
+
+ /**
+ * Set name of skin parameter in "mandatory" list ( default value for fine-tuning parameter ).
+ * @param mandatorySkin
+ */
+// public void setSkinConfiguration(String mandatorySkin) {
+// _skinConfiguration = mandatorySkin;
+// if(null == _skin){
+// valueGetter = new ConfigurationValueGetter();
+// } else {
+// valueGetter = new ConfigurationAndSkinValueGetter();
+// }
+// }
+
+ /**
+ * @param context The context to set.
+ */
+ public void setContext(Object context) {
+ _context = context;
+ //System.out.println("CTX:" + context);
+ valueGetter = new ValueGetter(){
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ // TODO Auto-generated method stub
+ return context.getParameter(_context);
+ }
+
+ };
+ }
+
+ /**
+ * @param call The call to set.
+ */
+ public void setCall(String call) {
+ this._call = call;
+ valueGetter = new ValueGetter(){
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ Object getValue(TemplateContext context) {
+ try {
+ return MethodUtils.invokeMethod(context
+ .getRenderer(), _call, new Object[]{context});
+ } catch (Exception e) {
+ throw new FacesException(Messages.getMessage(Messages.INVOKE_RENDERER_METHOD_ERROR, this.getClass().getName()), e);
+ }
+ }
+
+ };
+ }
+
+ /**
+ * Get EL-enabled value. Return same string, if not el-expression.
+ * Otherthise, return parsed and evaluated expression.
+ * @param context - current Faces Context.
+ * @param value - string to parse.
+ * @return - interpreted el or unmodified value.
+ */
+ protected boolean isValueReference( String value) {
+ if (value == null)
+ return false;
+
+ int start = value.indexOf("#{");
+ if (start >= 0) {
+ int end = value.lastIndexOf('}');
+ if (end >= 0 && start < end) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+// private final class ConfigurationValueGetter extends ValueGetter {
+// /* (non-Javadoc)
+// * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+// */
+// Object getValue(TemplateContext context) {
+// FacesContext facesContext = context.getFacesContext();
+// Object parameter = SkinFactory.getInstance().getSkinConfiguration(facesContext).getParameter(facesContext,_skinConfiguration);
+// if(null == parameter){
+// parameter = _default;
+// }
+// return parameter;
+// }
+// }
+//
+// private final class ConfigurationAndSkinValueGetter extends ValueGetter {
+// /* (non-Javadoc)
+// * @see org.ajax4jsf.renderkit.compiler.RootElement.ValueGetter#getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+// */
+// Object getValue(TemplateContext context) {
+// FacesContext facesContext = context.getFacesContext();
+// return SkinFactory.getInstance().getSkinConfiguration(facesContext).getParameter(facesContext,_skinConfiguration,_skin,_default);
+// }
+// }
+
+
+ protected class ValueGetter {
+ Object getValue(TemplateContext context) {
+ return null;
+ }
+
+ Object getValueOrDefault(TemplateContext context){
+ Object result = getValue(context);
+ if (null == result) {
+ result = getDefault();
+ }
+ return result;
+ }
+
+ String getStringOrDefault(TemplateContext context){
+ Object result = getValue(context);
+ if (null == result || result.toString().length()==0) {
+ result = getDefault();
+ if (null == result) {
+ result = "";
+ }
+ }
+ return result.toString();
+
+ }
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/FacetElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,88 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.Messages;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
- *
- */
-public class FacetElement extends ElementBase {
-
- public static final String CURRENT_FACET = "child_to_render";
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- String facetName = getValue(context).toString();
- if (null == facetName) {
- throw new FacesException(Messages.getMessage(Messages.NO_FACET_NAME_ATTRIBUTE, getTag()));
- }
- UIComponent stored = (UIComponent) context
- .getParameter(CURRENT_FACET);
- // if inside childrens loop - render facet from current iteration component.
- // TODO - use cloned context
- UIComponent facet = null == stored?context.getComponent().getFacet(facetName):stored.getFacet(facetName);
- if (null != facet && facet.isRendered()) {
- if (getChildren().size()>0) {
- // Store facet to render in <u:child> element.
- // TODO - use cloned context.
- context.putParameter(CURRENT_FACET, facet);
- // In fact, render all childrens.
- super.encode(context);
- if (null != stored) {
- context.putParameter(CURRENT_FACET, stored);
- } else {
- context.removeParameter(CURRENT_FACET);
- }
- } else {
- // empty element - render facet as-is.
- context.getRenderer().renderChild(context.getFacesContext(),facet);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // TODO Auto-generated method stub
- throw new FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR, getValue(context)));
- }
-
- public void setName(Object name) {
- setValue(name);
- }
-
- public String getTag() {
- return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.FACET_TAG;
- }
-
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/FacetElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/FacetElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,88 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
+ *
+ */
+public class FacetElement extends ElementBase {
+
+ public static final String CURRENT_FACET = "child_to_render";
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ String facetName = getValue(context).toString();
+ if (null == facetName) {
+ throw new FacesException(Messages.getMessage(Messages.NO_FACET_NAME_ATTRIBUTE, getTag()));
+ }
+ UIComponent stored = (UIComponent) context
+ .getParameter(CURRENT_FACET);
+ // if inside childrens loop - render facet from current iteration component.
+ // TODO - use cloned context
+ UIComponent facet = null == stored?context.getComponent().getFacet(facetName):stored.getFacet(facetName);
+ if (null != facet && facet.isRendered()) {
+ if (getChildren().size()>0) {
+ // Store facet to render in <u:child> element.
+ // TODO - use cloned context.
+ context.putParameter(CURRENT_FACET, facet);
+ // In fact, render all childrens.
+ super.encode(context);
+ if (null != stored) {
+ context.putParameter(CURRENT_FACET, stored);
+ } else {
+ context.removeParameter(CURRENT_FACET);
+ }
+ } else {
+ // empty element - render facet as-is.
+ context.getRenderer().renderChild(context.getFacesContext(),facet);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // TODO Auto-generated method stub
+ throw new FacesException(Messages.getMessage(Messages.BREAKPOINTS_UNSUPPORTED_ERROR, getValue(context)));
+ }
+
+ public void setName(Object name) {
+ setValue(name);
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_UTIL_PREFIX+HtmlCompiler.FACET_TAG;
+ }
+
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/HtmlCompiler.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,422 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.Rule;
-import org.apache.commons.digester.RulesBase;
-import org.apache.commons.digester.SetNextRule;
-import org.apache.commons.digester.SetPropertiesRule;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.LocatorImpl;
-
-
-/**
- * Compiler for XML string or stream for creation of {@link javax.faces.render.Renderer} internal
- * interpretator. Use Apache Digitester for parse .
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
- *
- */
-public class HtmlCompiler {
-
- public static final String NS_PREFIX = "f:";
- public static final String NS_UTIL_PREFIX = "u:";
- public static final String ROOT_TAG = "template";
- public static final String CALL_TAG = "call";
- public static final String VALUE_CALL_TAG = "valueCall";
- public static final String CALL_PARAM_TAG = "parameter";
- public static final String VERBATUM_TAG = "verbatim";
- public static final String BREAK_TAG = "break";
- public static final String FACET_TAG = "insertFacet";
- public static final String CHILDREN_TAG = "insertChildren";
- public static final String IF_TAG = "if";
- public static final String CHILD_TAG = "insertChild";
- public static final String STYLE_TAG = "style";
- public static final String CHILD_METHOD = "addChild";
- public static final String RESOURCE_TAG = "resource";
- public static final String ATTRIBUTE_TAG = "attribute";
- public static final String CHILD_PARAM_METHOD = "addParameter";
- public static final String ANY_PARENT = "*/";
- public static final String SELECTOR_TAG = "selector";
-
-
- private static final Log log = LogFactory.getLog(HtmlCompiler.class);
-
- private Digester digestr = new Digester();
-
-
- /**
- * Constructor with initialisation.
- */
- public HtmlCompiler(){
- WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper(new RulesBase());
- // Add default rules to process plain tags.
- rules.addDefault(new PlainElementCreateRule());
- rules.addDefault(new SetNextRule(CHILD_METHOD));
- digestr.setDocumentLocator(new LocatorImpl());
- digestr.setRules(rules);
- digestr.setValidating(false);
- digestr.setNamespaceAware(false);
- digestr.setUseContextClassLoader(true);
- // Concrete renderer method call rules.
- setCustomRules(digestr);
- }
-
- /**
- * Build custom rules for parse special tags and attributes.
- * For most tags, value can be in next forms ( for resource, preffixed with f: ):
- * <ul>
- * <li><b>value</b> as string or EL-expression</li>
- * <li><b>property</b> name for property of current component</li>
- * <li><b>skin</b> name for property of current skin</li>
- * <li><b>context</b> name for property of {@link TemplateContext} for trmplate encoding</li>
- * <li><b>default</b> use as value if main property <code>null</code></li>
- * </ul>
- * Supported :
- * <ul>
- * <li>Call renderer or utils method <f:call name='xxx' /></li>
- * <li>Call method parameter <f:parameter name='xxx' (value='....' | property='style' | skin='paramName' | context='propertyName ) /></li>
- * <li>Encode plain text <f:verbatim [value='....' | property='style' | skin='paramName' | context='propertyName ] >Some Text</f:text></li>
- * <li>Encode as text in HTML CSS parameter format <u:style name='background' (value='....' | property='style' | skin='paramName' | context='propertyName )/></li>
- * <li>Get and encode resource <f:resource f:key='images/spacer.gif' [ ... any attributes ... ] /></li>
- * <li>Encode custom attribute <f:attribute name='style' (value='....' | property='style' | skin='paramName' | context='propertyName ) [endorsed='true'] /></li>
- * <li>Template breakpoint <f:break name='xxxxx' /></li>
- * <li>Encode named facet <u:facet ( name='head | property='style' | skin='paramName' | context='propertyName )' /></li>
- * <li>Encode children components for current <u:children /></li>
- * <li>Encode one child component for enclosed u:facet or u:children <u:child /'></li>
- * </ul>
- * @param digestr
- */
- protected void setCustomRules( Digester digestr){
- // Root element. not instantiate - already set by compile method.
- String pattern = NS_PREFIX+ROOT_TAG;
- digestr.addSetProperties(pattern);
- // call renderer method <f:call methodName='xxx' [methodParam='yyy'] />
- pattern = ANY_PARENT+NS_PREFIX+CALL_TAG;
- digestr.addObjectCreate(pattern,MethodCallElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
- digestr.addSetProperties(pattern);
- // for value of parent call renderer method <f:valueCall methodName='xxx' [methodParam='yyy'] />
- pattern = ANY_PARENT+NS_PREFIX+VALUE_CALL_TAG;
- digestr.addObjectCreate(pattern,ValueMethodCallElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
- digestr.addSetProperties(pattern);
- // call parameter <f:parapeter methodName='xxx' [methodParam='yyy'] />
-// pattern = ANY_PARENT+NS_PREFIX+CALL_TAG+"/"+NS_PREFIX+CALL_PARAM_TAG;
- pattern = ANY_PARENT+NS_PREFIX+CALL_PARAM_TAG;
- digestr.addObjectCreate(pattern,MethodParameterElement.class);
- digestr.addSetNext(pattern,CHILD_PARAM_METHOD);
- digestr.addSetProperties(pattern);
- // Encode plain text <f:text>Some Text</f:text>
- pattern = ANY_PARENT+NS_PREFIX+VERBATUM_TAG;
- digestr.addObjectCreate(pattern,TextElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
- digestr.addSetProperties(pattern);
- digestr.addBeanPropertySetter(pattern,"text");
- // resource <f:resource f:key='images/spacer.gif' [f:data='...'] [ ... any attributes ... ] />
- pattern =ANY_PARENT+NS_PREFIX+RESOURCE_TAG;
- digestr.addObjectCreate(pattern,ResourceElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
- {
- Rule rule = new PutAttributesRule(digestr,new String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"});
- digestr.addRule(pattern,rule);
- }
- {
- SetPropertiesRule rule = new SetPropertiesRule(new String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"},new String[]{"value","property","skin","context"});
- digestr.addRule(pattern,rule);
- }
- // custom attribute <f:attribute name='style' (value='....' | property='style' | skin='paramName' | call='methodName' | utilCall='methodName') [notNull='true'] />
- pattern = ANY_PARENT+NS_PREFIX+ATTRIBUTE_TAG;
- digestr.addObjectCreate(pattern,AttributeElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
- digestr.addSetProperties(pattern);
- // component clientId <f:id [f:required='true'] />
- // breakpoint <f:break name="name">
- pattern = ANY_PARENT+NS_PREFIX+BREAK_TAG;
- digestr.addObjectCreate(pattern,BreakPoint.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
- // conditional rendering <f:if then="true">
- pattern = ANY_PARENT+NS_PREFIX+IF_TAG;
- digestr.addObjectCreate(pattern,IfElement.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
- // facet <u:insertFacet name="name">
- pattern = ANY_PARENT+NS_UTIL_PREFIX+FACET_TAG;
- digestr.addObjectCreate(pattern,FacetElement.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
-
- // childrens <u:insertChildren>
- pattern = ANY_PARENT+NS_UTIL_PREFIX+CHILDREN_TAG;
- digestr.addObjectCreate(pattern,ChildrensElement.class);
- digestr.addSetNext(pattern,CHILD_METHOD);
-// {
-// Rule rule = new PutAttributesRule(digestr,new String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"});
-// digestr.addRule(pattern,rule);
-// }
- {
- SetPropertiesRule rule = new SetPropertiesRule(new String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"},new String[]{"value","property","skin","context"});
- digestr.addRule(pattern,rule);
- }
-
-
-
- // style(sheet) property <u:style>
- pattern = ANY_PARENT+NS_UTIL_PREFIX+STYLE_TAG;
- digestr.addObjectCreate(pattern,ClassElement.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
- // breakpoint <f:break name="name">
- pattern = ANY_PARENT+NS_UTIL_PREFIX+CHILD_TAG;
- digestr.addObjectCreate(pattern,ChildElement.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
-
- //Selector element <u:selector></u:selector>
- pattern = ANY_PARENT+NS_UTIL_PREFIX+SELECTOR_TAG;
- digestr.addObjectCreate(pattern,SelectorElement.class);
- digestr.addSetProperties(pattern);
- digestr.addSetNext(pattern,CHILD_METHOD);
- }
-
-
- /**
- * Compile template for XML from simple string.
- * @param xml - String with template code
- * @return compiled template, ready for rendering.
- */
- public PreparedTemplate compile(String xml){
- Reader input = new StringReader(xml);
- return compile(input);
- }
-
- /**
- * Compile set of templates at time. Templates gets from resources in
- * classpath relative to base class. Used for initialisation set of templates in {@link RendererBase} subclasses constructor
- * @param base - base class for resources paths
- * @param templates - array with templates names.
- * @return {@link Map } , with keys - templates name, value - compiled template.
- */
- public Map compileResources(Class base,String[] templates) {
- Map result = new HashMap(templates.length);
- for (int i = 0; i < templates.length; i++) {
- String template = templates[i];
- result.put(template,compileResource(base,template));
- }
- return result;
- }
- /**
- * Compile XML from resource in classpath. Resource always readed
- * as UTF-8 text , to avoid xml declarations.
- * @param base - class of base object.
- * @param resource - path to resource ( if not start with / , relative to base object )
- * @return compiled XML, or Exception-generated stub, if parsing error occurs.
- */
- public static PreparedTemplate compileResource(Class base, String resource) {
- String path;
- if (resource.startsWith("/")) {
- path = base.getPackage().getName().replace('.','/')+resource;
- } else {
- path = base.getPackage().getName().replace('.','/')+"/"+resource;
- }
- return compileResource(path);
- }
-
-
- /**
- * Compile XML from resource in classpath. Resource always readed
- * as UTF-8 text , to avoid xml declarations.
- * @param resource - absolute path to resource
- * @return compiled XML, or Exception-generated stub, if parsing error occurs.
- */
- public static PreparedTemplate compileResource(String resource) {
- HtmlCompiler compiler = new HtmlCompiler();
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- InputStream input = loader.getResourceAsStream(resource);
- // Since parsing exceptions handled by compiler, we can not check parameter.
- PreparedTemplate compile = compiler.compile(input, resource);
- if(null != input){
- try {
- input.close();
- } catch (IOException e) {
- // can be ignored
- }
- }
- return compile;
- }
-
- public PreparedTemplate compile(Reader input){
- // By default - empty result. we not throw any exceptions in compile phase -
- // since it can be in static class initialization.
- PreparedTemplate result = null;
- try {
- digestr.clear();
- digestr.push(new RootElement());
- result = (PreparedTemplate) digestr.parse(input);
- } catch (SAXParseException e) {
-// TODO - locate compilation error. How get name ?
- String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR, new Object[]{"" + e.getLineNumber(), "" + e.getColumnNumber(), e.toString()});
-// errorstr.append(digestr.getDocumentLocator().getLineNumber()).append(" and position ").append(digestr.getDocumentLocator().getColumnNumber());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- } catch (IOException e) {
- String errorstr = Messages.getMessage(Messages.TEMPLATE_IO_ERROR, e.toString());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- } catch (SAXException e) {
- String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_2, e.toString());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- }
- return result;
- }
-
- /**
- * Compile input {@link InputStream} to {@link PreparedTemplate} - set of Java classes to encode as JSF output.
- * @param input stream with template XML text.
- * @param sourcename ( optional ) name of resource, for debug purposes.
- * @return compiled template.
- */
- public PreparedTemplate compile(InputStream input, String sourcename){
- // By default - empty result. we not throw any exceptions in compile phase -
- // since it can be in static class initialization.
- PreparedTemplate result = null;
- try {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.START_COMPILE_TEMPLATE_INFO, sourcename));
- }
- digestr.clear();
- RootElement root = new RootElement();
- root.setTemplateName(sourcename);
- digestr.push(root);
- result = (PreparedTemplate) digestr.parse(input);
- } catch (SAXParseException e) {
-// TODO - locate compilation error. How get name ?
- String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_a, new Object[]{sourcename, "" + e.getLineNumber(), "" + e.getColumnNumber(), e.toString()});
-// errorstr.append(digestr.getDocumentLocator().getLineNumber()).append(" and position ").append(digestr.getDocumentLocator().getColumnNumber());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- } catch (IOException e) {
- String errorstr = Messages.getMessage(Messages.TEMPLATE_IO_ERROR_a, sourcename, e.toString());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- } catch (SAXException e) {
- String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_2a, sourcename, e.toString());
- log.error(errorstr, e);
- result = new CompiledError(errorstr.toString(),e);
- }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.FINISH_COMPILE_TEMPLATE_INFO, sourcename));
- }
- return result;
- }
-
- /**
- * Incapsulate parsing - compilation errors to throw at encoding.
- * Allow static / constructor initialisation, all errors will be
- * see in page at request time. For debugging purposes.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
- *
- */
- private static class CompiledError implements PreparedTemplate {
- private Exception cause = null;
- private String message = Messages.getMessage(Messages.TEMPLATE_NOT_COMPILED_ERROR);
-
- /**
- * @param cause
- * @param message
- */
- public CompiledError(String message,Exception cause) {
- super();
- this.cause = cause;
- this.message = message;
- }
-
- /**
- * @param cause
- */
- CompiledError(Exception cause) {
- this.cause = cause;
- }
-
- public void encode(RendererBase renderer, FacesContext context, UIComponent component) throws IOException {
- // TODO - concrete compilation error.
- throw new FacesException(message,cause);
- }
-
- public List getChildren() {
- return Collections.EMPTY_LIST;
- }
-
- public void addChild(PreparedTemplate child) throws SAXException {
- // DO Nothing.
- throw new SAXException(Messages.getMessage(Messages.NO_CHILD_ALLOWED));
- }
-
- public void encode(TemplateContext context) throws IOException {
- throw new FacesException(message,cause);
-
- }
-
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- throw new FacesException(message,cause);
-
- }
-
- public void setParent(PreparedTemplate parent) {
- // DO Nothing.
- }
-
- public String getTag() {
- // TODO Auto-generated method stub
- return "f:error";
- }
-
- public Object getValue(TemplateContext context) {
- // error don't have value
- return null;
- }
-
- };
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/HtmlCompiler.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/HtmlCompiler.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,422 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.Rule;
+import org.apache.commons.digester.RulesBase;
+import org.apache.commons.digester.SetNextRule;
+import org.apache.commons.digester.SetPropertiesRule;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.LocatorImpl;
+
+
+/**
+ * Compiler for XML string or stream for creation of {@link javax.faces.render.Renderer} internal
+ * interpretator. Use Apache Digitester for parse .
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
+ *
+ */
+public class HtmlCompiler {
+
+ public static final String NS_PREFIX = "f:";
+ public static final String NS_UTIL_PREFIX = "u:";
+ public static final String ROOT_TAG = "template";
+ public static final String CALL_TAG = "call";
+ public static final String VALUE_CALL_TAG = "valueCall";
+ public static final String CALL_PARAM_TAG = "parameter";
+ public static final String VERBATUM_TAG = "verbatim";
+ public static final String BREAK_TAG = "break";
+ public static final String FACET_TAG = "insertFacet";
+ public static final String CHILDREN_TAG = "insertChildren";
+ public static final String IF_TAG = "if";
+ public static final String CHILD_TAG = "insertChild";
+ public static final String STYLE_TAG = "style";
+ public static final String CHILD_METHOD = "addChild";
+ public static final String RESOURCE_TAG = "resource";
+ public static final String ATTRIBUTE_TAG = "attribute";
+ public static final String CHILD_PARAM_METHOD = "addParameter";
+ public static final String ANY_PARENT = "*/";
+ public static final String SELECTOR_TAG = "selector";
+
+
+ private static final Log log = LogFactory.getLog(HtmlCompiler.class);
+
+ private Digester digestr = new Digester();
+
+
+ /**
+ * Constructor with initialisation.
+ */
+ public HtmlCompiler(){
+ WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper(new RulesBase());
+ // Add default rules to process plain tags.
+ rules.addDefault(new PlainElementCreateRule());
+ rules.addDefault(new SetNextRule(CHILD_METHOD));
+ digestr.setDocumentLocator(new LocatorImpl());
+ digestr.setRules(rules);
+ digestr.setValidating(false);
+ digestr.setNamespaceAware(false);
+ digestr.setUseContextClassLoader(true);
+ // Concrete renderer method call rules.
+ setCustomRules(digestr);
+ }
+
+ /**
+ * Build custom rules for parse special tags and attributes.
+ * For most tags, value can be in next forms ( for resource, preffixed with f: ):
+ * <ul>
+ * <li><b>value</b> as string or EL-expression</li>
+ * <li><b>property</b> name for property of current component</li>
+ * <li><b>skin</b> name for property of current skin</li>
+ * <li><b>context</b> name for property of {@link TemplateContext} for trmplate encoding</li>
+ * <li><b>default</b> use as value if main property <code>null</code></li>
+ * </ul>
+ * Supported :
+ * <ul>
+ * <li>Call renderer or utils method <f:call name='xxx' /></li>
+ * <li>Call method parameter <f:parameter name='xxx' (value='....' | property='style' | skin='paramName' | context='propertyName ) /></li>
+ * <li>Encode plain text <f:verbatim [value='....' | property='style' | skin='paramName' | context='propertyName ] >Some Text</f:text></li>
+ * <li>Encode as text in HTML CSS parameter format <u:style name='background' (value='....' | property='style' | skin='paramName' | context='propertyName )/></li>
+ * <li>Get and encode resource <f:resource f:key='images/spacer.gif' [ ... any attributes ... ] /></li>
+ * <li>Encode custom attribute <f:attribute name='style' (value='....' | property='style' | skin='paramName' | context='propertyName ) [endorsed='true'] /></li>
+ * <li>Template breakpoint <f:break name='xxxxx' /></li>
+ * <li>Encode named facet <u:facet ( name='head | property='style' | skin='paramName' | context='propertyName )' /></li>
+ * <li>Encode children components for current <u:children /></li>
+ * <li>Encode one child component for enclosed u:facet or u:children <u:child /'></li>
+ * </ul>
+ * @param digestr
+ */
+ protected void setCustomRules( Digester digestr){
+ // Root element. not instantiate - already set by compile method.
+ String pattern = NS_PREFIX+ROOT_TAG;
+ digestr.addSetProperties(pattern);
+ // call renderer method <f:call methodName='xxx' [methodParam='yyy'] />
+ pattern = ANY_PARENT+NS_PREFIX+CALL_TAG;
+ digestr.addObjectCreate(pattern,MethodCallElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ digestr.addSetProperties(pattern);
+ // for value of parent call renderer method <f:valueCall methodName='xxx' [methodParam='yyy'] />
+ pattern = ANY_PARENT+NS_PREFIX+VALUE_CALL_TAG;
+ digestr.addObjectCreate(pattern,ValueMethodCallElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ digestr.addSetProperties(pattern);
+ // call parameter <f:parapeter methodName='xxx' [methodParam='yyy'] />
+// pattern = ANY_PARENT+NS_PREFIX+CALL_TAG+"/"+NS_PREFIX+CALL_PARAM_TAG;
+ pattern = ANY_PARENT+NS_PREFIX+CALL_PARAM_TAG;
+ digestr.addObjectCreate(pattern,MethodParameterElement.class);
+ digestr.addSetNext(pattern,CHILD_PARAM_METHOD);
+ digestr.addSetProperties(pattern);
+ // Encode plain text <f:text>Some Text</f:text>
+ pattern = ANY_PARENT+NS_PREFIX+VERBATUM_TAG;
+ digestr.addObjectCreate(pattern,TextElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ digestr.addSetProperties(pattern);
+ digestr.addBeanPropertySetter(pattern,"text");
+ // resource <f:resource f:key='images/spacer.gif' [f:data='...'] [ ... any attributes ... ] />
+ pattern =ANY_PARENT+NS_PREFIX+RESOURCE_TAG;
+ digestr.addObjectCreate(pattern,ResourceElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ {
+ Rule rule = new PutAttributesRule(digestr,new String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"});
+ digestr.addRule(pattern,rule);
+ }
+ {
+ SetPropertiesRule rule = new SetPropertiesRule(new String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"},new String[]{"value","property","skin","context"});
+ digestr.addRule(pattern,rule);
+ }
+ // custom attribute <f:attribute name='style' (value='....' | property='style' | skin='paramName' | call='methodName' | utilCall='methodName') [notNull='true'] />
+ pattern = ANY_PARENT+NS_PREFIX+ATTRIBUTE_TAG;
+ digestr.addObjectCreate(pattern,AttributeElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ digestr.addSetProperties(pattern);
+ // component clientId <f:id [f:required='true'] />
+ // breakpoint <f:break name="name">
+ pattern = ANY_PARENT+NS_PREFIX+BREAK_TAG;
+ digestr.addObjectCreate(pattern,BreakPoint.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ // conditional rendering <f:if then="true">
+ pattern = ANY_PARENT+NS_PREFIX+IF_TAG;
+ digestr.addObjectCreate(pattern,IfElement.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ // facet <u:insertFacet name="name">
+ pattern = ANY_PARENT+NS_UTIL_PREFIX+FACET_TAG;
+ digestr.addObjectCreate(pattern,FacetElement.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+
+ // childrens <u:insertChildren>
+ pattern = ANY_PARENT+NS_UTIL_PREFIX+CHILDREN_TAG;
+ digestr.addObjectCreate(pattern,ChildrensElement.class);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+// {
+// Rule rule = new PutAttributesRule(digestr,new String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"});
+// digestr.addRule(pattern,rule);
+// }
+ {
+ SetPropertiesRule rule = new SetPropertiesRule(new String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"skin",NS_PREFIX+"context"},new String[]{"value","property","skin","context"});
+ digestr.addRule(pattern,rule);
+ }
+
+
+
+ // style(sheet) property <u:style>
+ pattern = ANY_PARENT+NS_UTIL_PREFIX+STYLE_TAG;
+ digestr.addObjectCreate(pattern,ClassElement.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ // breakpoint <f:break name="name">
+ pattern = ANY_PARENT+NS_UTIL_PREFIX+CHILD_TAG;
+ digestr.addObjectCreate(pattern,ChildElement.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+
+ //Selector element <u:selector></u:selector>
+ pattern = ANY_PARENT+NS_UTIL_PREFIX+SELECTOR_TAG;
+ digestr.addObjectCreate(pattern,SelectorElement.class);
+ digestr.addSetProperties(pattern);
+ digestr.addSetNext(pattern,CHILD_METHOD);
+ }
+
+
+ /**
+ * Compile template for XML from simple string.
+ * @param xml - String with template code
+ * @return compiled template, ready for rendering.
+ */
+ public PreparedTemplate compile(String xml){
+ Reader input = new StringReader(xml);
+ return compile(input);
+ }
+
+ /**
+ * Compile set of templates at time. Templates gets from resources in
+ * classpath relative to base class. Used for initialisation set of templates in {@link RendererBase} subclasses constructor
+ * @param base - base class for resources paths
+ * @param templates - array with templates names.
+ * @return {@link Map } , with keys - templates name, value - compiled template.
+ */
+ public Map compileResources(Class base,String[] templates) {
+ Map result = new HashMap(templates.length);
+ for (int i = 0; i < templates.length; i++) {
+ String template = templates[i];
+ result.put(template,compileResource(base,template));
+ }
+ return result;
+ }
+ /**
+ * Compile XML from resource in classpath. Resource always readed
+ * as UTF-8 text , to avoid xml declarations.
+ * @param base - class of base object.
+ * @param resource - path to resource ( if not start with / , relative to base object )
+ * @return compiled XML, or Exception-generated stub, if parsing error occurs.
+ */
+ public static PreparedTemplate compileResource(Class base, String resource) {
+ String path;
+ if (resource.startsWith("/")) {
+ path = base.getPackage().getName().replace('.','/')+resource;
+ } else {
+ path = base.getPackage().getName().replace('.','/')+"/"+resource;
+ }
+ return compileResource(path);
+ }
+
+
+ /**
+ * Compile XML from resource in classpath. Resource always readed
+ * as UTF-8 text , to avoid xml declarations.
+ * @param resource - absolute path to resource
+ * @return compiled XML, or Exception-generated stub, if parsing error occurs.
+ */
+ public static PreparedTemplate compileResource(String resource) {
+ HtmlCompiler compiler = new HtmlCompiler();
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ InputStream input = loader.getResourceAsStream(resource);
+ // Since parsing exceptions handled by compiler, we can not check parameter.
+ PreparedTemplate compile = compiler.compile(input, resource);
+ if(null != input){
+ try {
+ input.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+ }
+ return compile;
+ }
+
+ public PreparedTemplate compile(Reader input){
+ // By default - empty result. we not throw any exceptions in compile phase -
+ // since it can be in static class initialization.
+ PreparedTemplate result = null;
+ try {
+ digestr.clear();
+ digestr.push(new RootElement());
+ result = (PreparedTemplate) digestr.parse(input);
+ } catch (SAXParseException e) {
+// TODO - locate compilation error. How get name ?
+ String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR, new Object[]{"" + e.getLineNumber(), "" + e.getColumnNumber(), e.toString()});
+// errorstr.append(digestr.getDocumentLocator().getLineNumber()).append(" and position ").append(digestr.getDocumentLocator().getColumnNumber());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ } catch (IOException e) {
+ String errorstr = Messages.getMessage(Messages.TEMPLATE_IO_ERROR, e.toString());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ } catch (SAXException e) {
+ String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_2, e.toString());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ }
+ return result;
+ }
+
+ /**
+ * Compile input {@link InputStream} to {@link PreparedTemplate} - set of Java classes to encode as JSF output.
+ * @param input stream with template XML text.
+ * @param sourcename ( optional ) name of resource, for debug purposes.
+ * @return compiled template.
+ */
+ public PreparedTemplate compile(InputStream input, String sourcename){
+ // By default - empty result. we not throw any exceptions in compile phase -
+ // since it can be in static class initialization.
+ PreparedTemplate result = null;
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.START_COMPILE_TEMPLATE_INFO, sourcename));
+ }
+ digestr.clear();
+ RootElement root = new RootElement();
+ root.setTemplateName(sourcename);
+ digestr.push(root);
+ result = (PreparedTemplate) digestr.parse(input);
+ } catch (SAXParseException e) {
+// TODO - locate compilation error. How get name ?
+ String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_a, new Object[]{sourcename, "" + e.getLineNumber(), "" + e.getColumnNumber(), e.toString()});
+// errorstr.append(digestr.getDocumentLocator().getLineNumber()).append(" and position ").append(digestr.getDocumentLocator().getColumnNumber());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ } catch (IOException e) {
+ String errorstr = Messages.getMessage(Messages.TEMPLATE_IO_ERROR_a, sourcename, e.toString());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ } catch (SAXException e) {
+ String errorstr = Messages.getMessage(Messages.PARSING_TEMPLATE_ERROR_2a, sourcename, e.toString());
+ log.error(errorstr, e);
+ result = new CompiledError(errorstr.toString(),e);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.FINISH_COMPILE_TEMPLATE_INFO, sourcename));
+ }
+ return result;
+ }
+
+ /**
+ * Incapsulate parsing - compilation errors to throw at encoding.
+ * Allow static / constructor initialisation, all errors will be
+ * see in page at request time. For debugging purposes.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
+ *
+ */
+ private static class CompiledError implements PreparedTemplate {
+ private Exception cause = null;
+ private String message = Messages.getMessage(Messages.TEMPLATE_NOT_COMPILED_ERROR);
+
+ /**
+ * @param cause
+ * @param message
+ */
+ public CompiledError(String message,Exception cause) {
+ super();
+ this.cause = cause;
+ this.message = message;
+ }
+
+ /**
+ * @param cause
+ */
+ CompiledError(Exception cause) {
+ this.cause = cause;
+ }
+
+ public void encode(RendererBase renderer, FacesContext context, UIComponent component) throws IOException {
+ // TODO - concrete compilation error.
+ throw new FacesException(message,cause);
+ }
+
+ public List getChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ public void addChild(PreparedTemplate child) throws SAXException {
+ // DO Nothing.
+ throw new SAXException(Messages.getMessage(Messages.NO_CHILD_ALLOWED));
+ }
+
+ public void encode(TemplateContext context) throws IOException {
+ throw new FacesException(message,cause);
+
+ }
+
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ throw new FacesException(message,cause);
+
+ }
+
+ public void setParent(PreparedTemplate parent) {
+ // DO Nothing.
+ }
+
+ public String getTag() {
+ // TODO Auto-generated method stub
+ return "f:error";
+ }
+
+ public Object getValue(TemplateContext context) {
+ // error don't have value
+ return null;
+ }
+
+ };
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/IfElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,66 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
- *
- */
-public class IfElement extends ElementBase {
-
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // Condition will not contain breakpoints.
- encode(context);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- Object condition = getValue(context);
- if (null != condition) {
- if ( (!(condition instanceof Boolean)) || ((Boolean)condition).booleanValue()) {
- super.encode(context);
- }
- }
- }
-
- public void setWhen(String condition){
- setValue(condition);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
- */
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.IF_TAG;
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/IfElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/IfElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
+ *
+ */
+public class IfElement extends ElementBase {
+
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // Condition will not contain breakpoints.
+ encode(context);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ Object condition = getValue(context);
+ if (null != condition) {
+ if ( (!(condition instanceof Boolean)) || ((Boolean)condition).booleanValue()) {
+ super.encode(context);
+ }
+ }
+ }
+
+ public void setWhen(String condition){
+ setValue(condition);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
+ */
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.IF_TAG;
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodCallElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,505 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.el.MethodNotFoundException;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.SAXException;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:47 $
- *
- */
-public class MethodCallElement extends ElementBase {
-
- public static final String UTILS_PREFIX = "utils.";
-
- static final Log _log = LogFactory.getLog(MethodCallElement.class);
-
- private String _name = null;
-
- private List parameters = new ArrayList();
-
- private Invoker invoker = new Invoker();
-
- private MethodCacheState state = new MethodCacheState();
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(TemplateContext context ) throws IOException {
- getValue(context);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // Text not contain breakpoints.
- encode(context);
- }
-
-
- public Object getValue(TemplateContext context) throws FacesException {
- // prepare method params. we attempt to call 3 signatures :
- // a) name(FacesContext,UIComponent [, param0...])
- // b) name(TempalateContext [,param0...])
- // c) name([param0...])
- state.init(parameters);
- Object[] values = state.computeParameterValues(context);
-
- InvokeData data = null;
- synchronized (state) {
- state.update(context, values, invoker);
- data = invoker.invokeMethod(context, state);
- }
- return invoker.invokeMethod(data);
- // perform childrens.
- // super.encode(renderer,context,component);
- }
-
-
-
- public void addParameter(MethodParameterElement parameter){
- parameters.add(parameter);
- }
- /**
- * @return Returns the methodName.
- */
- public String getName() {
- return _name;
- }
-
- /**
- * @param methodName The methodName to set.
- */
- public void setName(String methodName) {
- if(methodName.startsWith(UTILS_PREFIX)){
- this._name = methodName.substring(UTILS_PREFIX.length());
- this.invoker = getRendererUtilsInvoker(_name);
- } else if(methodName.indexOf('.') >= 0) {
- this._name = methodName;
- this.invoker = getStaticInvoker(_name);
- } else {
- this._name = methodName;
- this.invoker = getRendererInvoker(_name);
- }
- }
-
- static Map staticInvokers = new HashMap();
-
- public StaticInvoker getStaticInvoker(String methodName) {
- StaticInvoker invoker = (StaticInvoker)staticInvokers.get(methodName);
- if(invoker == null) {
- invoker = new StaticInvoker(methodName);
- staticInvokers.put(methodName, invoker);
- }
- return invoker;
- }
-
- static Map rendererInvokers = new HashMap();
-
- public RendererInvoker getRendererInvoker(String methodName) {
- RendererInvoker invoker = (RendererInvoker)rendererInvokers.get(methodName);
- if(invoker == null) {
- invoker = new RendererInvoker(false, methodName);
- rendererInvokers.put(methodName, invoker);
- }
- return invoker;
- }
-
- static Map utilsInvokers = new HashMap();
-
- public RendererInvoker getRendererUtilsInvoker(String methodName) {
- RendererInvoker invoker = (RendererInvoker)utilsInvokers.get(methodName);
- if(invoker == null) {
- invoker = new RendererInvoker(true, methodName);
- utilsInvokers.put(methodName, invoker);
- }
- return invoker;
- }
-
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.CALL_TAG;
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- super.setParent(parent);
- if (getName()==null) {
- throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
- }
- }
-
-
-/* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public String getString(TemplateContext context) throws FacesException {
- Object result = getValue(context);
- if (null == result || result.toString().length()==0) {
- result = "";
- }
- return result.toString();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // TODO Auto-generated method stub
- return new Class[]{
- MethodParameterElement.class,
- ResourceElement.class
- };
- }
-
-}
-
-class InvokeData {
- TemplateContext context;
- Method method;
- Object object;
- Object[] arguments;
- InvokeData(TemplateContext context, Method method, Object object, Object[] arguments) {
- this.context = context;
- this.method = method;
- this.object = object;
- this.arguments = (Object[]) arguments.clone();
- }
-}
-
-class Invoker {
- String methodName;
-
- InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
- throw new FacesException(Messages.getMessage(Messages.RENDERER_METHOD_NOT_SET_ERROR));
- }
-
- void handleInvocationTargetException(TemplateContext context, InvocationTargetException e) {}
- void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {}
- void handleMethodNotFoundException(TemplateContext context) throws MethodNotFoundException {}
-
- InvokeData invokeMethod(TemplateContext context, Map methods, Class cls, Object object, MethodCacheState state) {
- Method method = provideMethod(methods, cls, object, state);
- return new InvokeData(context, method, object, state.current.arguments);
- }
-
- Object invokeMethod(InvokeData data) {
- if(data.method != null) {
- try {
- return data.method.invoke(data.object, data.arguments);
- } catch (InvocationTargetException e) {
- handleInvocationTargetException(data.context, e);
- } catch (IllegalAccessException e) {
- handleIllegalAccessException(data.context, e);
- }
- }
- handleMethodNotFoundException(data.context);
- return null;
- }
-
- public Class getInvokedClass(TemplateContext context) {
- return null;
- }
-
- private Method provideMethod(Map methods, Class cls, Object object, MethodCacheState state) {
- if(state.method != null) return state.method;
-
- if(methods.size() > 0) {
- for (int i = 0; i < state.signatures.length; i++) {
- state.method = (Method)methods.get(getClassesKey(state.signatures[i].arguments));
- if(state.method != null) {
- state.current = state.signatures[i];
- return state.method;
- }
- }
- }
-
- if(cls == null && object != null) cls = object.getClass();
- Method[] ms = cls.getMethods();
- for (int m = 0; m < ms.length; m++) {
- if(!ms[m].getName().equals(methodName)) continue;
- if(object == null && !Modifier.isStatic(ms[m].getModifiers())) continue;
- Class[] cs = ms[m].getParameterTypes();
- Signature s = getMatchingArguments(cs, state.signatures);
- if(s == null) continue;
- state.current = s;
- state.method = ms[m];
- methods.put(getClassesKey(s.arguments), ms[m]);
- return state.method;
- }
-
- return null;
- }
-
- private String getClassesKey(Object[] args) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < args.length; i++) {
- String dk = args[i] == null ? "null" : args[i].getClass().getName();
- sb.append(";").append(dk);
- }
- return sb.toString();
- }
-
- private Signature getMatchingArguments(Class[] cs, Signature[] sgs) {
- for (int i = 0; i < sgs.length; i++) {
- if(isMatching(cs, sgs[i].arguments)) return sgs[i];
- }
- return null;
- }
-
- static boolean isMatching(Class[] cs, Object[] args) {
- if(cs.length != args.length) return false;
- for (int i = 0; i < cs.length; i++) {
- if(args[i] != null && !cs[i].isAssignableFrom(args[i].getClass())) return false;
- }
- return true;
- }
-}
-
-class RendererInvoker extends Invoker {
- boolean utils = false;
- Map renderers = new HashMap();
-
- public RendererInvoker(boolean utils, String methodName) {
- this.utils = utils;
- this.methodName = methodName;
- }
-
- public Class getInvokedClass(TemplateContext context) {
- Object object = getInvokedObject(context);
- return (object != null) ? object.getClass() : null;
- }
-
- private Object getInvokedObject(TemplateContext context) {
- if(utils) {
- return context.getRenderer().getUtils();
- } else {
- return context.getRenderer();
- }
- }
-
- InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
- Object object = getInvokedObject(context);
- Map methods = getMethods(object);
- return invokeMethod(context, methods, null, object, state);
- }
-
- private Map getMethods(Object object) {
- if(object == null) return null;
- Map methods = (Map)renderers.get(object);
- if(methods == null) {
- methods = new HashMap();
- renderers.put(object, methods);
- }
- return methods;
- }
-
- void handleInvocationTargetException(TemplateContext context, InvocationTargetException e) {
- String logMessage = (utils)
- ? Messages.getMessage(Messages.METHOD_CALL_ERROR_1, methodName, context.getComponent().getId())
- : Messages.getMessage(Messages.METHOD_CALL_ERROR_1a, methodName, context.getComponent().getId());
- String excMessage = (utils)
- ? Messages.getMessage(Messages.METHOD_CALL_ERROR_2, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()})
- : Messages.getMessage(Messages.METHOD_CALL_ERROR_2a, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()});
- MethodCallElement._log.error(logMessage, e);
- throw new FacesException(excMessage, e);
- }
- void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {
- String logMessage = (utils)
- ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_3, methodName, context.getComponent().getId()))
- : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_3a, methodName, context.getComponent().getId()));
- String excMessage = (utils)
- ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_4, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}))
- : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_4a, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}));
- MethodCallElement._log.error(logMessage, e);
- throw new FacesException(excMessage, e);
- }
-
- void handleMethodNotFoundException(TemplateContext context) throws MethodNotFoundException {
- String logMessage = (utils)
- ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_5, methodName, context.getComponent().getId()))
- : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_5a, methodName, context.getComponent().getId()));
- String excMessage = (utils)
- ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_6, methodName))
- : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_6a, methodName));
- MethodCallElement._log.error(logMessage);
- throw new FacesException(excMessage);
- }
-}
-
-class StaticInvoker extends Invoker {
- String className;
- Class cls;
- Map methods = new HashMap();
-
- StaticInvoker(String methodName) {
- this.methodName = methodName;
- int i = methodName.lastIndexOf('.');
- className = methodName.substring(0, i);
- this.methodName = methodName.substring(i + 1);
- try {
- cls = Thread.currentThread().getContextClassLoader().loadClass(className);
- } catch (ClassNotFoundException e) {
- //ignore, throw exception when invoking
- }
- }
-
- InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
- if(cls == null) throw new FacesException(className, new ClassNotFoundException(className));
- return invokeMethod(context, methods, cls, null, state);
- }
-
- void handleInvocationTargetException(TemplateContext context, InvocationTargetException e) {
- MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_1a, methodName, context.getComponent().getId()), e);
- throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_2a, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}), e);
- }
- void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {
- MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_3a, methodName, context.getComponent().getId()), e);
- throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_4a, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}), e);
- }
- void handleMethodNotFoundException(TemplateContext context) throws MethodNotFoundException {
- MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_5a, methodName, context.getComponent().getId()));
- throw new MethodNotFoundException(Messages.getMessage(Messages.METHOD_CALL_ERROR_6a, methodName));
- }
-}
-
-class MethodCacheState {
- private MethodParameterElement[] elements;
- private Class[] parameterClasses;
- private Object[] parameterValues;
- private Class lastCallingClass = null;
- public Method method;
- public Signature current;
- public Signature[] signatures;
-
- public void init(List parameters) {
- if(elements != null) return;
- synchronized (this) {
- if(elements != null) return;
- int size = parameters.size();
- parameterClasses = new Class[size];
- parameterValues = new Object[size];
- signatures = new Signature[3];
- signatures[0] = new Signature2(size);
- signatures[1] = new Signature1(size);
- signatures[2] = new Signature0(size);
- elements = (MethodParameterElement[])parameters.toArray(new MethodParameterElement[0]);
- }
- }
-
- public Object[] computeParameterValues(TemplateContext context) {
- Object[] ps = new Object[elements.length];
- for (int i = 0; i < elements.length; i++) {
- ps[i] = elements[i].valueGetter.getValueOrDefault(context);
- }
- return ps;
- }
-
- public void update(TemplateContext context, Object[] values, Invoker invoker) {
- boolean changed = false;
- for (int i = 0; i < elements.length; i++) {
- Object parametr = values[i];
- Class c = (parametr == null) ? null : parametr.getClass();
- if(c != parameterClasses[i]) {
- parameterClasses[i] = c;
- changed = true;
- }
- parameterValues[i] = parametr;
- }
- if(method != null && !changed && lastCallingClass != invoker.getInvokedClass(context)) {
- lastCallingClass = invoker.getInvokedClass(context);
- changed = true;
- }
- if(changed || current == null) {
- for (int i = 0; i < signatures.length; i++) {
- signatures[i].update(context, parameterValues);
- }
- method = null;
- current = null;
- } else {
- current.update(context, parameterValues);
- }
- }
-
-}
-
-abstract class Signature {
- Object[] arguments;
-
- Signature() {}
-
- void update(TemplateContext context, Object[] parameters) {}
-}
-
-class Signature0 extends Signature {
- Signature0(int size) {
- arguments = new Object[size];
- }
-
- void update(TemplateContext context, Object[] parameters) {
- System.arraycopy(parameters, 0, arguments, 0, parameters.length);
- }
-
-}
-
-class Signature1 extends Signature {
- Signature1(int size) {
- arguments = new Object[size + 1];
- }
- void update(TemplateContext context, Object[] parameters) {
- arguments[0] = context;
- System.arraycopy(parameters, 0, arguments, 1, parameters.length);
- }
-
-}
-
-class Signature2 extends Signature {
- Signature2(int size) {
- arguments = new Object[size + 2];
- }
- void update(TemplateContext context, Object[] parameters) {
- arguments[0] = context.getFacesContext();
- arguments[1] = context.getComponent();
- System.arraycopy(parameters, 0, arguments, 2, parameters.length);
- }
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodCallElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodCallElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,505 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.el.MethodNotFoundException;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.SAXException;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:47 $
+ *
+ */
+public class MethodCallElement extends ElementBase {
+
+ public static final String UTILS_PREFIX = "utils.";
+
+ static final Log _log = LogFactory.getLog(MethodCallElement.class);
+
+ private String _name = null;
+
+ private List parameters = new ArrayList();
+
+ private Invoker invoker = new Invoker();
+
+ private MethodCacheState state = new MethodCacheState();
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(TemplateContext context ) throws IOException {
+ getValue(context);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // Text not contain breakpoints.
+ encode(context);
+ }
+
+
+ public Object getValue(TemplateContext context) throws FacesException {
+ // prepare method params. we attempt to call 3 signatures :
+ // a) name(FacesContext,UIComponent [, param0...])
+ // b) name(TempalateContext [,param0...])
+ // c) name([param0...])
+ state.init(parameters);
+ Object[] values = state.computeParameterValues(context);
+
+ InvokeData data = null;
+ synchronized (state) {
+ state.update(context, values, invoker);
+ data = invoker.invokeMethod(context, state);
+ }
+ return invoker.invokeMethod(data);
+ // perform childrens.
+ // super.encode(renderer,context,component);
+ }
+
+
+
+ public void addParameter(MethodParameterElement parameter){
+ parameters.add(parameter);
+ }
+ /**
+ * @return Returns the methodName.
+ */
+ public String getName() {
+ return _name;
+ }
+
+ /**
+ * @param methodName The methodName to set.
+ */
+ public void setName(String methodName) {
+ if(methodName.startsWith(UTILS_PREFIX)){
+ this._name = methodName.substring(UTILS_PREFIX.length());
+ this.invoker = getRendererUtilsInvoker(_name);
+ } else if(methodName.indexOf('.') >= 0) {
+ this._name = methodName;
+ this.invoker = getStaticInvoker(_name);
+ } else {
+ this._name = methodName;
+ this.invoker = getRendererInvoker(_name);
+ }
+ }
+
+ static Map staticInvokers = new HashMap();
+
+ public StaticInvoker getStaticInvoker(String methodName) {
+ StaticInvoker invoker = (StaticInvoker)staticInvokers.get(methodName);
+ if(invoker == null) {
+ invoker = new StaticInvoker(methodName);
+ staticInvokers.put(methodName, invoker);
+ }
+ return invoker;
+ }
+
+ static Map rendererInvokers = new HashMap();
+
+ public RendererInvoker getRendererInvoker(String methodName) {
+ RendererInvoker invoker = (RendererInvoker)rendererInvokers.get(methodName);
+ if(invoker == null) {
+ invoker = new RendererInvoker(false, methodName);
+ rendererInvokers.put(methodName, invoker);
+ }
+ return invoker;
+ }
+
+ static Map utilsInvokers = new HashMap();
+
+ public RendererInvoker getRendererUtilsInvoker(String methodName) {
+ RendererInvoker invoker = (RendererInvoker)utilsInvokers.get(methodName);
+ if(invoker == null) {
+ invoker = new RendererInvoker(true, methodName);
+ utilsInvokers.put(methodName, invoker);
+ }
+ return invoker;
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.CALL_TAG;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ super.setParent(parent);
+ if (getName()==null) {
+ throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
+ }
+ }
+
+
+/* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public String getString(TemplateContext context) throws FacesException {
+ Object result = getValue(context);
+ if (null == result || result.toString().length()==0) {
+ result = "";
+ }
+ return result.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // TODO Auto-generated method stub
+ return new Class[]{
+ MethodParameterElement.class,
+ ResourceElement.class
+ };
+ }
+
+}
+
+class InvokeData {
+ TemplateContext context;
+ Method method;
+ Object object;
+ Object[] arguments;
+ InvokeData(TemplateContext context, Method method, Object object, Object[] arguments) {
+ this.context = context;
+ this.method = method;
+ this.object = object;
+ this.arguments = (Object[]) arguments.clone();
+ }
+}
+
+class Invoker {
+ String methodName;
+
+ InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
+ throw new FacesException(Messages.getMessage(Messages.RENDERER_METHOD_NOT_SET_ERROR));
+ }
+
+ void handleInvocationTargetException(TemplateContext context, InvocationTargetException e) {}
+ void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {}
+ void handleMethodNotFoundException(TemplateContext context) throws MethodNotFoundException {}
+
+ InvokeData invokeMethod(TemplateContext context, Map methods, Class cls, Object object, MethodCacheState state) {
+ Method method = provideMethod(methods, cls, object, state);
+ return new InvokeData(context, method, object, state.current.arguments);
+ }
+
+ Object invokeMethod(InvokeData data) {
+ if(data.method != null) {
+ try {
+ return data.method.invoke(data.object, data.arguments);
+ } catch (InvocationTargetException e) {
+ handleInvocationTargetException(data.context, e);
+ } catch (IllegalAccessException e) {
+ handleIllegalAccessException(data.context, e);
+ }
+ }
+ handleMethodNotFoundException(data.context);
+ return null;
+ }
+
+ public Class getInvokedClass(TemplateContext context) {
+ return null;
+ }
+
+ private Method provideMethod(Map methods, Class cls, Object object, MethodCacheState state) {
+ if(state.method != null) return state.method;
+
+ if(methods.size() > 0) {
+ for (int i = 0; i < state.signatures.length; i++) {
+ state.method = (Method)methods.get(getClassesKey(state.signatures[i].arguments));
+ if(state.method != null) {
+ state.current = state.signatures[i];
+ return state.method;
+ }
+ }
+ }
+
+ if(cls == null && object != null) cls = object.getClass();
+ Method[] ms = cls.getMethods();
+ for (int m = 0; m < ms.length; m++) {
+ if(!ms[m].getName().equals(methodName)) continue;
+ if(object == null && !Modifier.isStatic(ms[m].getModifiers())) continue;
+ Class[] cs = ms[m].getParameterTypes();
+ Signature s = getMatchingArguments(cs, state.signatures);
+ if(s == null) continue;
+ state.current = s;
+ state.method = ms[m];
+ methods.put(getClassesKey(s.arguments), ms[m]);
+ return state.method;
+ }
+
+ return null;
+ }
+
+ private String getClassesKey(Object[] args) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < args.length; i++) {
+ String dk = args[i] == null ? "null" : args[i].getClass().getName();
+ sb.append(";").append(dk);
+ }
+ return sb.toString();
+ }
+
+ private Signature getMatchingArguments(Class[] cs, Signature[] sgs) {
+ for (int i = 0; i < sgs.length; i++) {
+ if(isMatching(cs, sgs[i].arguments)) return sgs[i];
+ }
+ return null;
+ }
+
+ static boolean isMatching(Class[] cs, Object[] args) {
+ if(cs.length != args.length) return false;
+ for (int i = 0; i < cs.length; i++) {
+ if(args[i] != null && !cs[i].isAssignableFrom(args[i].getClass())) return false;
+ }
+ return true;
+ }
+}
+
+class RendererInvoker extends Invoker {
+ boolean utils = false;
+ Map renderers = new HashMap();
+
+ public RendererInvoker(boolean utils, String methodName) {
+ this.utils = utils;
+ this.methodName = methodName;
+ }
+
+ public Class getInvokedClass(TemplateContext context) {
+ Object object = getInvokedObject(context);
+ return (object != null) ? object.getClass() : null;
+ }
+
+ private Object getInvokedObject(TemplateContext context) {
+ if(utils) {
+ return context.getRenderer().getUtils();
+ } else {
+ return context.getRenderer();
+ }
+ }
+
+ InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
+ Object object = getInvokedObject(context);
+ Map methods = getMethods(object);
+ return invokeMethod(context, methods, null, object, state);
+ }
+
+ private Map getMethods(Object object) {
+ if(object == null) return null;
+ Map methods = (Map)renderers.get(object);
+ if(methods == null) {
+ methods = new HashMap();
+ renderers.put(object, methods);
+ }
+ return methods;
+ }
+
+ void handleInvocationTargetException(TemplateContext context, InvocationTargetException e) {
+ String logMessage = (utils)
+ ? Messages.getMessage(Messages.METHOD_CALL_ERROR_1, methodName, context.getComponent().getId())
+ : Messages.getMessage(Messages.METHOD_CALL_ERROR_1a, methodName, context.getComponent().getId());
+ String excMessage = (utils)
+ ? Messages.getMessage(Messages.METHOD_CALL_ERROR_2, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()})
+ : Messages.getMessage(Messages.METHOD_CALL_ERROR_2a, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()});
+ MethodCallElement._log.error(logMessage, e);
+ throw new FacesException(excMessage, e);
+ }
+ void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {
+ String logMessage = (utils)
+ ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_3, methodName, context.getComponent().getId()))
+ : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_3a, methodName, context.getComponent().getId()));
+ String excMessage = (utils)
+ ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_4, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}))
+ : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_4a, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}));
+ MethodCallElement._log.error(logMessage, e);
+ throw new FacesException(excMessage, e);
+ }
+
+ void handleMethodNotFoundException(TemplateContext context) throws MethodNotFoundException {
+ String logMessage = (utils)
+ ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_5, methodName, context.getComponent().getId()))
+ : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_5a, methodName, context.getComponent().getId()));
+ String excMessage = (utils)
+ ? Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_6, methodName))
+ : Messages.getMessage(Messages.getMessage(Messages.METHOD_CALL_ERROR_6a, methodName));
+ MethodCallElement._log.error(logMessage);
+ throw new FacesException(excMessage);
+ }
+}
+
+class StaticInvoker extends Invoker {
+ String className;
+ Class cls;
+ Map methods = new HashMap();
+
+ StaticInvoker(String methodName) {
+ this.methodName = methodName;
+ int i = methodName.lastIndexOf('.');
+ className = methodName.substring(0, i);
+ this.methodName = methodName.substring(i + 1);
+ try {
+ cls = Thread.currentThread().getContextClassLoader().loadClass(className);
+ } catch (ClassNotFoundException e) {
+ //ignore, throw exception when invoking
+ }
+ }
+
+ InvokeData invokeMethod(TemplateContext context, MethodCacheState state) {
+ if(cls == null) throw new FacesException(className, new ClassNotFoundException(className));
+ return invokeMethod(context, methods, cls, null, state);
+ }
+
+ void handleInvocationTargetException(TemplateContext context, InvocationTargetException e) {
+ MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_1a, methodName, context.getComponent().getId()), e);
+ throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_2a, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}), e);
+ }
+ void handleIllegalAccessException(TemplateContext context, IllegalAccessException e) {
+ MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_3a, methodName, context.getComponent().getId()), e);
+ throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_4a, new Object[]{methodName, context.getComponent().getId(), e.getCause().getMessage()}), e);
+ }
+ void handleMethodNotFoundException(TemplateContext context) throws MethodNotFoundException {
+ MethodCallElement._log.error(Messages.getMessage(Messages.METHOD_CALL_ERROR_5a, methodName, context.getComponent().getId()));
+ throw new MethodNotFoundException(Messages.getMessage(Messages.METHOD_CALL_ERROR_6a, methodName));
+ }
+}
+
+class MethodCacheState {
+ private MethodParameterElement[] elements;
+ private Class[] parameterClasses;
+ private Object[] parameterValues;
+ private Class lastCallingClass = null;
+ public Method method;
+ public Signature current;
+ public Signature[] signatures;
+
+ public void init(List parameters) {
+ if(elements != null) return;
+ synchronized (this) {
+ if(elements != null) return;
+ int size = parameters.size();
+ parameterClasses = new Class[size];
+ parameterValues = new Object[size];
+ signatures = new Signature[3];
+ signatures[0] = new Signature2(size);
+ signatures[1] = new Signature1(size);
+ signatures[2] = new Signature0(size);
+ elements = (MethodParameterElement[])parameters.toArray(new MethodParameterElement[0]);
+ }
+ }
+
+ public Object[] computeParameterValues(TemplateContext context) {
+ Object[] ps = new Object[elements.length];
+ for (int i = 0; i < elements.length; i++) {
+ ps[i] = elements[i].valueGetter.getValueOrDefault(context);
+ }
+ return ps;
+ }
+
+ public void update(TemplateContext context, Object[] values, Invoker invoker) {
+ boolean changed = false;
+ for (int i = 0; i < elements.length; i++) {
+ Object parametr = values[i];
+ Class c = (parametr == null) ? null : parametr.getClass();
+ if(c != parameterClasses[i]) {
+ parameterClasses[i] = c;
+ changed = true;
+ }
+ parameterValues[i] = parametr;
+ }
+ if(method != null && !changed && lastCallingClass != invoker.getInvokedClass(context)) {
+ lastCallingClass = invoker.getInvokedClass(context);
+ changed = true;
+ }
+ if(changed || current == null) {
+ for (int i = 0; i < signatures.length; i++) {
+ signatures[i].update(context, parameterValues);
+ }
+ method = null;
+ current = null;
+ } else {
+ current.update(context, parameterValues);
+ }
+ }
+
+}
+
+abstract class Signature {
+ Object[] arguments;
+
+ Signature() {}
+
+ void update(TemplateContext context, Object[] parameters) {}
+}
+
+class Signature0 extends Signature {
+ Signature0(int size) {
+ arguments = new Object[size];
+ }
+
+ void update(TemplateContext context, Object[] parameters) {
+ System.arraycopy(parameters, 0, arguments, 0, parameters.length);
+ }
+
+}
+
+class Signature1 extends Signature {
+ Signature1(int size) {
+ arguments = new Object[size + 1];
+ }
+ void update(TemplateContext context, Object[] parameters) {
+ arguments[0] = context;
+ System.arraycopy(parameters, 0, arguments, 1, parameters.length);
+ }
+
+}
+
+class Signature2 extends Signature {
+ Signature2(int size) {
+ arguments = new Object[size + 2];
+ }
+ void update(TemplateContext context, Object[] parameters) {
+ arguments[0] = context.getFacesContext();
+ arguments[1] = context.getComponent();
+ System.arraycopy(parameters, 0, arguments, 2, parameters.length);
+ }
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodParameterElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,99 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.xml.sax.SAXException;
-
-
-public class MethodParameterElement extends ElementBase {
-
- /**
- *
- */
- public MethodParameterElement() {
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(RendererBase renderer, FacesContext context, UIComponent component) throws IOException {
- // DO Nothing !
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // DO Nothing !
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- // DO Nothing !
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#addChild(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void addChild(PreparedTemplate child) throws SAXException {
- // TODO Auto-generated method stub
- super.addChild(child);
- if (child instanceof ResourceElement) {
- final ResourceElement res = (ResourceElement) child;
- this.valueGetter = new ValueGetter(){
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase.ValueGetter#getValue(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- Object getValue(TemplateContext context) {
- return context.getRenderer().getResource(res.getValue(context).toString());
- }
-
- };
- }
- }
-
- public String getTag() {
- // TODO Auto-generated method stub
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.CALL_PARAM_TAG;
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // TODO Auto-generated method stub
- return new Class[]{
- ResourceElement.class
- };
- }
-
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodParameterElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/MethodParameterElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,99 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.RendererBase;
+import org.xml.sax.SAXException;
+
+
+public class MethodParameterElement extends ElementBase {
+
+ /**
+ *
+ */
+ public MethodParameterElement() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(RendererBase renderer, FacesContext context, UIComponent component) throws IOException {
+ // DO Nothing !
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // DO Nothing !
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ // DO Nothing !
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#addChild(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void addChild(PreparedTemplate child) throws SAXException {
+ // TODO Auto-generated method stub
+ super.addChild(child);
+ if (child instanceof ResourceElement) {
+ final ResourceElement res = (ResourceElement) child;
+ this.valueGetter = new ValueGetter(){
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase.ValueGetter#getValue(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ Object getValue(TemplateContext context) {
+ return context.getRenderer().getResource(res.getValue(context).toString());
+ }
+
+ };
+ }
+ }
+
+ public String getTag() {
+ // TODO Auto-generated method stub
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.CALL_PARAM_TAG;
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // TODO Auto-generated method stub
+ return new Class[]{
+ ResourceElement.class
+ };
+ }
+
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PlainElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,157 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.context.ResponseWriter;
-
-import org.xml.sax.Attributes;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
- *
- */
-public class PlainElement extends ElementBase {
-
-
- private String namespace = "";
- private String tag = null;
-
- private String[][] attrs = null;
-
- private boolean encodeStart = true;
-
- private boolean encodeEnd = true;
- /**
- * @param attrs
- */
- public PlainElement(String namespace, String tag, Attributes attrs) {
- // Set modifable attributes implementation to ability of
- // modifications.
- this.attrs = new String[attrs.getLength()][2];
- this.namespace = namespace;
- this.tag = tag;
- int currentAttribute = 0;
- // remove non-passed attributes, parse special.
- for (int i = 0; i < attrs.getLength(); i++) {
- String qName = attrs.getQName(i);
- String value = attrs.getValue(i);
- if (qName.equals(HtmlCompiler.NS_PREFIX+"start")) {
- this.encodeStart = "true".equals(value);
- } else if (qName.equals(HtmlCompiler.NS_PREFIX+"end")) {
- this.encodeEnd = "true".equals(value);
- } else {
- this.attrs[currentAttribute][0]=qName;
- this.attrs[currentAttribute++][1]=value;
- }
-
- }
- // squize array if nessesary.
- if (currentAttribute < attrs.getLength()) {
- String[][] newattrs = new String[currentAttribute][2];
- System.arraycopy(this.attrs,0,newattrs,0,currentAttribute);
- this.attrs = newattrs;
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encodeBegin(TemplateContext context) throws IOException {
- ResponseWriter writer = context.getWriter();
- if (this.encodeStart) {
- writer.startElement(getTag(), context.getComponent());
- // write attributes
- for (int i = 0; i < attrs.length; i++) {
- writer.writeAttribute(attrs[i][0], attrs[i][1], null);
- }
- }
- }
-
- public void encodeEnd(TemplateContext context) throws IOException {
- ResponseWriter writer = context.getWriter();
-
- if (this.encodeEnd) {
- writer.endElement(getTag());
- }
-
- }
-
- /**
- * @return Returns the tag.
- */
- public String getTag() {
- return tag;
- }
-
- /**
- * @param tag The tag to set.
- */
- public void setTag(String tag) {
- this.tag = tag;
- }
-
- /**
- * @return Returns the attrs.
- */
- public String[][] getAttrs() {
- return attrs;
- }
-
- /**
- * @return Returns the encodeEnd.
- */
- public boolean isEncodeEnd() {
- return encodeEnd;
- }
-
- /**
- * @param encodeEnd The encodeEnd to set.
- */
- public void setEncodeEnd(boolean encodeEnd) {
- this.encodeEnd = encodeEnd;
- }
-
- /**
- * @return Returns the encodeStart.
- */
- public boolean isEncodeStart() {
- return encodeStart;
- }
-
- /**
- * @param encodeStart The encodeStart to set.
- */
- public void setEncodeStart(boolean encodeStart) {
- this.encodeStart = encodeStart;
- }
-
- /**
- * @return Returns the namespace.
- */
- public String getNamespace() {
- return namespace;
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PlainElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,157 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.context.ResponseWriter;
+
+import org.xml.sax.Attributes;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
+ *
+ */
+public class PlainElement extends ElementBase {
+
+
+ private String namespace = "";
+ private String tag = null;
+
+ private String[][] attrs = null;
+
+ private boolean encodeStart = true;
+
+ private boolean encodeEnd = true;
+ /**
+ * @param attrs
+ */
+ public PlainElement(String namespace, String tag, Attributes attrs) {
+ // Set modifable attributes implementation to ability of
+ // modifications.
+ this.attrs = new String[attrs.getLength()][2];
+ this.namespace = namespace;
+ this.tag = tag;
+ int currentAttribute = 0;
+ // remove non-passed attributes, parse special.
+ for (int i = 0; i < attrs.getLength(); i++) {
+ String qName = attrs.getQName(i);
+ String value = attrs.getValue(i);
+ if (qName.equals(HtmlCompiler.NS_PREFIX+"start")) {
+ this.encodeStart = "true".equals(value);
+ } else if (qName.equals(HtmlCompiler.NS_PREFIX+"end")) {
+ this.encodeEnd = "true".equals(value);
+ } else {
+ this.attrs[currentAttribute][0]=qName;
+ this.attrs[currentAttribute++][1]=value;
+ }
+
+ }
+ // squize array if nessesary.
+ if (currentAttribute < attrs.getLength()) {
+ String[][] newattrs = new String[currentAttribute][2];
+ System.arraycopy(this.attrs,0,newattrs,0,currentAttribute);
+ this.attrs = newattrs;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.CompiledXML#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeBegin(TemplateContext context) throws IOException {
+ ResponseWriter writer = context.getWriter();
+ if (this.encodeStart) {
+ writer.startElement(getTag(), context.getComponent());
+ // write attributes
+ for (int i = 0; i < attrs.length; i++) {
+ writer.writeAttribute(attrs[i][0], attrs[i][1], null);
+ }
+ }
+ }
+
+ public void encodeEnd(TemplateContext context) throws IOException {
+ ResponseWriter writer = context.getWriter();
+
+ if (this.encodeEnd) {
+ writer.endElement(getTag());
+ }
+
+ }
+
+ /**
+ * @return Returns the tag.
+ */
+ public String getTag() {
+ return tag;
+ }
+
+ /**
+ * @param tag The tag to set.
+ */
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ /**
+ * @return Returns the attrs.
+ */
+ public String[][] getAttrs() {
+ return attrs;
+ }
+
+ /**
+ * @return Returns the encodeEnd.
+ */
+ public boolean isEncodeEnd() {
+ return encodeEnd;
+ }
+
+ /**
+ * @param encodeEnd The encodeEnd to set.
+ */
+ public void setEncodeEnd(boolean encodeEnd) {
+ this.encodeEnd = encodeEnd;
+ }
+
+ /**
+ * @return Returns the encodeStart.
+ */
+ public boolean isEncodeStart() {
+ return encodeStart;
+ }
+
+ /**
+ * @param encodeStart The encodeStart to set.
+ */
+ public void setEncodeStart(boolean encodeStart) {
+ this.encodeStart = encodeStart;
+ }
+
+ /**
+ * @return Returns the namespace.
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PlainElementCreateRule.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,64 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.digester.Rule;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:47 $
- *
- */
-public class PlainElementCreateRule extends Rule {
-
- /* (non-Javadoc)
- * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String, org.xml.sax.Attributes)
- */
- public void begin(String namespace, String name, Attributes attrs) throws Exception {
- if (name.startsWith(HtmlCompiler.NS_PREFIX)) {
- throw new SAXException(Messages.getMessage(Messages.NAMESPACE_NOT_RECOGNIZED_ERROR, name));
- }
- digester.push(new PlainElement(namespace,name,attrs));
- }
-
- /* (non-Javadoc)
- * @see org.apache.commons.digester.Rule#body(java.lang.String, java.lang.String, java.lang.String)
- */
- public void body(String arg0, String arg1, String arg2) throws Exception {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.commons.digester.Rule#end(java.lang.String, java.lang.String)
- */
- public void end(String arg0, String arg1) throws Exception {
- // TODO Auto-generated method stub
- digester.pop();
- }
-
-
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PlainElementCreateRule.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PlainElementCreateRule.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,64 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.digester.Rule;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:47 $
+ *
+ */
+public class PlainElementCreateRule extends Rule {
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ public void begin(String namespace, String name, Attributes attrs) throws Exception {
+ if (name.startsWith(HtmlCompiler.NS_PREFIX)) {
+ throw new SAXException(Messages.getMessage(Messages.NAMESPACE_NOT_RECOGNIZED_ERROR, name));
+ }
+ digester.push(new PlainElement(namespace,name,attrs));
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.digester.Rule#body(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void body(String arg0, String arg1, String arg2) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.commons.digester.Rule#end(java.lang.String, java.lang.String)
+ */
+ public void end(String arg0, String arg1) throws Exception {
+ // TODO Auto-generated method stub
+ digester.pop();
+ }
+
+
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PreparedTemplate.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,87 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.xml.sax.SAXException;
-
-
-/**
- * Public interface for compiled XML rendered template.
- * {@link javax.faces.render.Renderer} must simple call xml.encode(this,context,component);
- * for produce {@link javax.faces.context.ResponseWriter} events.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
- *
- */
-public interface PreparedTemplate {
-
- /**
- * Encode this XML component. May be simple send element and attributes,
- * call specified Renderer or RendererUtils method etc. Can encode children
- * elements ( if exist ).
- * @param renderer
- * @param context
- * @param component
- * @throws IOException
- */
- public void encode(RendererBase renderer, FacesContext context, UIComponent component) throws IOException;
-
- public void encode(TemplateContext context) throws IOException;
-
- public void encode(TemplateContext context,String breakPoint) throws IOException;
- /**
- * @return List of childrens of this component.
- */
- public List getChildren();
-
- /**
- * Append child element to current.
- * @param child
- * @throws SAXException
- */
- public void addChild(PreparedTemplate child) throws SAXException;
-
- /**
- * Set parent element in compiled tree for template.
- * @param parent
- * @throws SAXException
- */
- public void setParent(PreparedTemplate parent) throws SAXException;
-
- /**
- * @return tag name for element.
- */
- public String getTag();
-
- /**
- * @return Returns the value. If is EL expression valueBinding - evaluate in.
- */
- public Object getValue(TemplateContext context);
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PreparedTemplate.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PreparedTemplate.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,87 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.RendererBase;
+import org.xml.sax.SAXException;
+
+
+/**
+ * Public interface for compiled XML rendered template.
+ * {@link javax.faces.render.Renderer} must simple call xml.encode(this,context,component);
+ * for produce {@link javax.faces.context.ResponseWriter} events.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:49 $
+ *
+ */
+public interface PreparedTemplate {
+
+ /**
+ * Encode this XML component. May be simple send element and attributes,
+ * call specified Renderer or RendererUtils method etc. Can encode children
+ * elements ( if exist ).
+ * @param renderer
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encode(RendererBase renderer, FacesContext context, UIComponent component) throws IOException;
+
+ public void encode(TemplateContext context) throws IOException;
+
+ public void encode(TemplateContext context,String breakPoint) throws IOException;
+ /**
+ * @return List of childrens of this component.
+ */
+ public List getChildren();
+
+ /**
+ * Append child element to current.
+ * @param child
+ * @throws SAXException
+ */
+ public void addChild(PreparedTemplate child) throws SAXException;
+
+ /**
+ * Set parent element in compiled tree for template.
+ * @param parent
+ * @throws SAXException
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException;
+
+ /**
+ * @return tag name for element.
+ */
+ public String getTag();
+
+ /**
+ * @return Returns the value. If is EL expression valueBinding - evaluate in.
+ */
+ public Object getValue(TemplateContext context);
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PutAttributesRule.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,92 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.Rule;
-import org.xml.sax.Attributes;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
- *
- */
-public class PutAttributesRule extends Rule {
-
- private List toSkip = Collections.EMPTY_LIST;
- private String methodName = "put";
- /**
- * @param digestr
- * @param toSkip
- */
- public PutAttributesRule(Digester digestr, String[] toSkip) {
- // TODO Auto-generated constructor stub
- this.digester = digestr;
-// Arrays.asList(toSkip);
- this.toSkip = Arrays.asList(toSkip);
- }
-
- /**
- * @param digestr
- * @param methodName
- */
- public PutAttributesRule(Digester digestr, String methodName) {
- // TODO Auto-generated constructor stub
- this.digester = digestr;
-// Arrays.asList(toSkip);
- this.methodName = methodName;
- }
-
- /**
- * @param digestr
- * @param methodName
- * @param toSkip
- */
- public PutAttributesRule(Digester digestr, String methodName, String[] toSkip) {
- // TODO Auto-generated constructor stub
- this.digester = digestr;
- this.methodName = methodName;
- this.toSkip = Arrays.asList(toSkip);
- }
- /* (non-Javadoc)
- * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String, org.xml.sax.Attributes)
- */
- public void begin(String namespace, String element, Attributes attrs) throws Exception {
- Object top = digester.peek();
- if(null != top){
- Method put = top.getClass().getDeclaredMethod(methodName,new Class[]{Object.class,Object.class});
- for (int i = 0; i < attrs.getLength(); i++) {
- String qName = attrs.getQName(i);
- String value = attrs.getValue(i);
- if (!toSkip.contains(qName)) {
- put.invoke(top,new Object[]{qName,value});
- }
- }
- }
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PutAttributesRule.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/PutAttributesRule.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,92 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.Rule;
+import org.xml.sax.Attributes;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
+ *
+ */
+public class PutAttributesRule extends Rule {
+
+ private List toSkip = Collections.EMPTY_LIST;
+ private String methodName = "put";
+ /**
+ * @param digestr
+ * @param toSkip
+ */
+ public PutAttributesRule(Digester digestr, String[] toSkip) {
+ // TODO Auto-generated constructor stub
+ this.digester = digestr;
+// Arrays.asList(toSkip);
+ this.toSkip = Arrays.asList(toSkip);
+ }
+
+ /**
+ * @param digestr
+ * @param methodName
+ */
+ public PutAttributesRule(Digester digestr, String methodName) {
+ // TODO Auto-generated constructor stub
+ this.digester = digestr;
+// Arrays.asList(toSkip);
+ this.methodName = methodName;
+ }
+
+ /**
+ * @param digestr
+ * @param methodName
+ * @param toSkip
+ */
+ public PutAttributesRule(Digester digestr, String methodName, String[] toSkip) {
+ // TODO Auto-generated constructor stub
+ this.digester = digestr;
+ this.methodName = methodName;
+ this.toSkip = Arrays.asList(toSkip);
+ }
+ /* (non-Javadoc)
+ * @see org.apache.commons.digester.Rule#begin(java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ public void begin(String namespace, String element, Attributes attrs) throws Exception {
+ Object top = digester.peek();
+ if(null != top){
+ Method put = top.getClass().getDeclaredMethod(methodName,new Class[]{Object.class,Object.class});
+ for (int i = 0; i < attrs.getLength(); i++) {
+ String qName = attrs.getQName(i);
+ String value = attrs.getValue(i);
+ if (!toSkip.contains(qName)) {
+ put.invoke(top,new Object[]{qName,value});
+ }
+ }
+ }
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ResourceElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,105 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.FacesException;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
- *
- */
-public class ResourceElement extends ElementBase {
-
- private Map attrs = new HashMap();
- /* (non-Javadoc)
- * @see java.util.Map#put(java.lang.Object, java.lang.Object)
- */
- public Object put(Object key, Object value) {
- return attrs.put(key, value);
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#get(java.lang.Object)
- */
- public Object get(Object key) {
- return attrs.get(key);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encodeBegin(TemplateContext context) throws IOException {
- InternetResource resource = findResource(context);
- if(null !=resource){
- resource.encodeBegin(context.getFacesContext(),context.getComponent(),attrs);
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encodeEnd(TemplateContext context) throws IOException {
- InternetResource resource = findResource(context);
- if(null !=resource){
- resource.encodeEnd(context.getFacesContext(),context.getComponent());
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#getString(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public String getString(TemplateContext context) throws FacesException {
- InternetResource resource = findResource(context);
- if(null !=resource){
- return resource.getUri(context.getFacesContext(),context.getComponent());
- }
- return "";
- }
-
- private InternetResource findResource(TemplateContext context) {
- InternetResource resource;
- String path = (String) getValue(context);
- RendererBase renderer = context.getRenderer();
- if (renderer != null) {
- resource = renderer.getResource(path);
- } else {
- resource = InternetResourceBuilder.getInstance().createResource(null, path);
- }
-
- return resource;
- }
-
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.RESOURCE_TAG;
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ResourceElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ResourceElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,105 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.FacesException;
+
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:43 $
+ *
+ */
+public class ResourceElement extends ElementBase {
+
+ private Map attrs = new HashMap();
+ /* (non-Javadoc)
+ * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+ */
+ public Object put(Object key, Object value) {
+ return attrs.put(key, value);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#get(java.lang.Object)
+ */
+ public Object get(Object key) {
+ return attrs.get(key);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeBegin(TemplateContext context) throws IOException {
+ InternetResource resource = findResource(context);
+ if(null !=resource){
+ resource.encodeBegin(context.getFacesContext(),context.getComponent(),attrs);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeEnd(TemplateContext context) throws IOException {
+ InternetResource resource = findResource(context);
+ if(null !=resource){
+ resource.encodeEnd(context.getFacesContext(),context.getComponent());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#getString(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public String getString(TemplateContext context) throws FacesException {
+ InternetResource resource = findResource(context);
+ if(null !=resource){
+ return resource.getUri(context.getFacesContext(),context.getComponent());
+ }
+ return "";
+ }
+
+ private InternetResource findResource(TemplateContext context) {
+ InternetResource resource;
+ String path = (String) getValue(context);
+ RendererBase renderer = context.getRenderer();
+ if (renderer != null) {
+ resource = renderer.getResource(path);
+ } else {
+ resource = InternetResourceBuilder.getInstance().createResource(null, path);
+ }
+
+ return resource;
+ }
+
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.RESOURCE_TAG;
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/RootElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,92 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
- *
- */
-public class RootElement extends ElementBase {
- private static final Log log = LogFactory.getLog(RootElement.class);
-
- private String templateName="unset";
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_COMPILED_TEMPLATE_INFO, getTemplateName(), breakPoint));
- }
- try {
- super.encode(context, breakPoint);
- } catch (BreakException e) {
- // encoding terminated by break
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODING_TEMPLATE_TERMINATED_INFO, getTemplateName(), e.getName()));
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_COMPILED_TEMPLATE_INFO2, getTemplateName()));
- }
- try {
- super.encode(context);
- } catch (BreakException e) {
- // encoding terminated by break
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODING_TEMPLATE_TERMINATED_INFO, getTemplateName(), e.getName()));
- }
- }
- }
-
- public String getTag() {
- // TODO Auto-generated method stub
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.ROOT_TAG;
- }
-
- /**
- * @return Returns the templateName.
- */
- public String getTemplateName() {
- return templateName;
- }
-
- /**
- * @param templateName The templateName to set.
- */
- public void setTemplateName(String templateName) {
- this.templateName = templateName;
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/RootElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/RootElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,92 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
+ *
+ */
+public class RootElement extends ElementBase {
+ private static final Log log = LogFactory.getLog(RootElement.class);
+
+ private String templateName="unset";
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_COMPILED_TEMPLATE_INFO, getTemplateName(), breakPoint));
+ }
+ try {
+ super.encode(context, breakPoint);
+ } catch (BreakException e) {
+ // encoding terminated by break
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODING_TEMPLATE_TERMINATED_INFO, getTemplateName(), e.getName()));
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_COMPILED_TEMPLATE_INFO2, getTemplateName()));
+ }
+ try {
+ super.encode(context);
+ } catch (BreakException e) {
+ // encoding terminated by break
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODING_TEMPLATE_TERMINATED_INFO, getTemplateName(), e.getName()));
+ }
+ }
+ }
+
+ public String getTag() {
+ // TODO Auto-generated method stub
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.ROOT_TAG;
+ }
+
+ /**
+ * @return Returns the templateName.
+ */
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ /**
+ * @param templateName The templateName to set.
+ */
+ public void setTemplateName(String templateName) {
+ this.templateName = templateName;
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/SelectorElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,87 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import org.ajax4jsf.Messages;
-import org.xml.sax.SAXException;
-
-/**
- * @author Maksim Kaszynski (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
- * CSS selector tag.
- * Works this way
- * <code>
- * <u:selector name=".X">
- * a bunch of <u:style>
- * </u:selector>
- * </code>
- * renders like this
- * <code>
- * .X{
- * styles...
- * }
- * </code>
- *
- */
-public class SelectorElement extends ElementBase {
-
- private String name ;
-
- protected void encodeBegin(TemplateContext context) throws IOException {
- context.getWriter().write("\n" + getName() + "{\n");
- }
-
- protected void encodeEnd(TemplateContext context) throws IOException {
- context.getWriter().write("}");
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
- */
- public String getTag() {
- // TODO Auto-generated method stub
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.SELECTOR_TAG;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- super.setParent(parent);
- if (getName()==null) {
- throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
- }
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/SelectorElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/SelectorElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,87 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import org.ajax4jsf.Messages;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Maksim Kaszynski (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:46 $
+ * CSS selector tag.
+ * Works this way
+ * <code>
+ * <u:selector name=".X">
+ * a bunch of <u:style>
+ * </u:selector>
+ * </code>
+ * renders like this
+ * <code>
+ * .X{
+ * styles...
+ * }
+ * </code>
+ *
+ */
+public class SelectorElement extends ElementBase {
+
+ private String name ;
+
+ protected void encodeBegin(TemplateContext context) throws IOException {
+ context.getWriter().write("\n" + getName() + "{\n");
+ }
+
+ protected void encodeEnd(TemplateContext context) throws IOException {
+ context.getWriter().write("}");
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
+ */
+ public String getTag() {
+ // TODO Auto-generated method stub
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.SELECTOR_TAG;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ super.setParent(parent);
+ if (getName()==null) {
+ throw new SAXException(Messages.getMessage(Messages.NO_NAME_ATTRIBUTE_ERROR, getTag()));
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TemplateContext.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,108 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-
-
-/**
- * Incapsulate all current parameters for encoding template.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
- *
- */
-public class TemplateContext {
- FacesContext facesContext;
- RendererBase renderer;
- UIComponent component;
- Map parameters = new HashMap();
- /**
- * @param renderer
- * @param facesContext
- * @param component
- */
- public TemplateContext(RendererBase renderer, FacesContext facesContext, UIComponent component) {
- // TODO Auto-generated constructor stub
- this.facesContext = facesContext;
- this.renderer = renderer;
- this.component = component;
- }
- /**
- * @return Returns the component.
- */
- public UIComponent getComponent() {
- return component;
- }
- /**
- * @return Returns the facesContext.
- */
- public FacesContext getFacesContext() {
- return facesContext;
- }
- /**
- * @return Returns the renderer.
- */
- public RendererBase getRenderer() {
- return renderer;
- }
-
- public void putParameter(Object key,Object value) {
- parameters.put(key,value);
- }
-
- public Object getParameter(Object key) {
- return parameters.get(key);
- }
- public void removeParameter(Object key) {
- parameters.remove(key);
-
- }
- public ResponseWriter getWriter() {
- return facesContext.getResponseWriter();
- }
-
- /**
- * Create copy of this context for other child component.
- * Used in iterations and facets for render template on current child
- * @param child - component for template
- * @return - new copy of component, with same parameters.
- */
- public TemplateContext clone(UIComponent child){
- TemplateContext cloned = new TemplateContext(this.renderer,this.facesContext,child);
- cloned.parameters.putAll(this.parameters);
- return cloned;
- }
-
- /**
- * Return a mutable Map representing the parameters associated wth this TemplateContext
- */
- public Map getParameters() {
- return parameters;
- }
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TemplateContext.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TemplateContext.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,108 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererBase;
+
+
+/**
+ * Incapsulate all current parameters for encoding template.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:48 $
+ *
+ */
+public class TemplateContext {
+ FacesContext facesContext;
+ RendererBase renderer;
+ UIComponent component;
+ Map parameters = new HashMap();
+ /**
+ * @param renderer
+ * @param facesContext
+ * @param component
+ */
+ public TemplateContext(RendererBase renderer, FacesContext facesContext, UIComponent component) {
+ // TODO Auto-generated constructor stub
+ this.facesContext = facesContext;
+ this.renderer = renderer;
+ this.component = component;
+ }
+ /**
+ * @return Returns the component.
+ */
+ public UIComponent getComponent() {
+ return component;
+ }
+ /**
+ * @return Returns the facesContext.
+ */
+ public FacesContext getFacesContext() {
+ return facesContext;
+ }
+ /**
+ * @return Returns the renderer.
+ */
+ public RendererBase getRenderer() {
+ return renderer;
+ }
+
+ public void putParameter(Object key,Object value) {
+ parameters.put(key,value);
+ }
+
+ public Object getParameter(Object key) {
+ return parameters.get(key);
+ }
+ public void removeParameter(Object key) {
+ parameters.remove(key);
+
+ }
+ public ResponseWriter getWriter() {
+ return facesContext.getResponseWriter();
+ }
+
+ /**
+ * Create copy of this context for other child component.
+ * Used in iterations and facets for render template on current child
+ * @param child - component for template
+ * @return - new copy of component, with same parameters.
+ */
+ public TemplateContext clone(UIComponent child){
+ TemplateContext cloned = new TemplateContext(this.renderer,this.facesContext,child);
+ cloned.parameters.putAll(this.parameters);
+ return cloned;
+ }
+
+ /**
+ * Return a mutable Map representing the parameters associated wth this TemplateContext
+ */
+ public Map getParameters() {
+ return parameters;
+ }
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TextElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,123 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
- *
- */
-public class TextElement extends ElementBase {
-
- private String text = null;
-
- private boolean escape = false;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encode(TemplateContext context) throws IOException {
- // TODO Auto-generated method stub
- String textValue = getString(context);
-
- if (isEscape()) {
- context.getWriter().writeText(textValue, null);
- } else {
- context.getWriter().write(textValue.toString());
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
- */
- public void encode(TemplateContext context, String breakPoint) throws IOException {
- // Text not contain breakpoints.
- encode(context);
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public String getString(TemplateContext context) throws FacesException {
-
- String textValue = super.getString(context);
- // If value not set - return element body.
- if (textValue.length()==0 && null != getText()) {
- textValue = getText();
- }
- return textValue;
- }
-
-
- /**
- * @return Returns the text.
- */
- public String getText() {
- return text;
- }
-
- /**
- * @param text The text to set.
- */
- public void setText(String text) {
- this.text = text;
- }
-
- /**
- * @return Returns the escape.
- */
- public boolean isEscape() {
- return escape;
- }
-
- /**
- * @param escape The escape to set.
- */
- public void setEscape(boolean escape) {
- this.escape = escape;
- }
-
-
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.VERBATUM_TAG;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
- */
- protected Class[] getAllowedClasses() {
- // TODO Auto-generated method stub
- return new Class[]{
- MethodCallElement.class,
- ResourceElement.class,
- ClassElement.class
- };
- }
-
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TextElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/TextElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,123 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:44 $
+ *
+ */
+public class TextElement extends ElementBase {
+
+ private String text = null;
+
+ private boolean escape = false;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.RootElement#encode(javax.faces.render.Renderer, javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ // TODO Auto-generated method stub
+ String textValue = getString(context);
+
+ if (isEscape()) {
+ context.getWriter().writeText(textValue, null);
+ } else {
+ context.getWriter().write(textValue.toString());
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#encode(org.ajax4jsf.renderkit.compiler.TemplateContext, java.lang.String)
+ */
+ public void encode(TemplateContext context, String breakPoint) throws IOException {
+ // Text not contain breakpoints.
+ encode(context);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getString(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public String getString(TemplateContext context) throws FacesException {
+
+ String textValue = super.getString(context);
+ // If value not set - return element body.
+ if (textValue.length()==0 && null != getText()) {
+ textValue = getText();
+ }
+ return textValue;
+ }
+
+
+ /**
+ * @return Returns the text.
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text The text to set.
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ /**
+ * @return Returns the escape.
+ */
+ public boolean isEscape() {
+ return escape;
+ }
+
+ /**
+ * @param escape The escape to set.
+ */
+ public void setEscape(boolean escape) {
+ this.escape = escape;
+ }
+
+
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.VERBATUM_TAG;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase#getAllowedClasses()
+ */
+ protected Class[] getAllowedClasses() {
+ // TODO Auto-generated method stub
+ return new Class[]{
+ MethodCallElement.class,
+ ResourceElement.class,
+ ClassElement.class
+ };
+ }
+
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ValueMethodCallElement.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,68 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.io.IOException;
-
-import org.xml.sax.SAXException;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
- *
- */
-public class ValueMethodCallElement extends MethodCallElement {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.MethodCallElement#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- public void encode(TemplateContext context) throws IOException {
- // do nothing
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.MethodCallElement#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
- */
- public void setParent(PreparedTemplate parent) throws SAXException {
- // TODO Auto-generated method stub
- super.setParent(parent);
- if (parent instanceof ElementBase) {
- ElementBase base = (ElementBase) parent;
- base.valueGetter = new ElementBase.ValueGetter(){
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.ElementBase.ValueGetter#getValue(org.ajax4jsf.renderkit.compiler.TemplateContext)
- */
- Object getValue(TemplateContext context) {
- // TODO Auto-generated method stub
- return ValueMethodCallElement.this.getValue(context);
- }
- };
- }
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
- */
- public String getTag() {
- return HtmlCompiler.NS_PREFIX+HtmlCompiler.VALUE_CALL_TAG;
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ValueMethodCallElement.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/ValueMethodCallElement.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,68 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.io.IOException;
+
+import org.xml.sax.SAXException;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:45 $
+ *
+ */
+public class ValueMethodCallElement extends MethodCallElement {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.MethodCallElement#encode(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ public void encode(TemplateContext context) throws IOException {
+ // do nothing
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.MethodCallElement#setParent(org.ajax4jsf.renderkit.compiler.PreparedTemplate)
+ */
+ public void setParent(PreparedTemplate parent) throws SAXException {
+ // TODO Auto-generated method stub
+ super.setParent(parent);
+ if (parent instanceof ElementBase) {
+ ElementBase base = (ElementBase) parent;
+ base.valueGetter = new ElementBase.ValueGetter(){
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.ElementBase.ValueGetter#getValue(org.ajax4jsf.renderkit.compiler.TemplateContext)
+ */
+ Object getValue(TemplateContext context) {
+ // TODO Auto-generated method stub
+ return ValueMethodCallElement.this.getValue(context);
+ }
+ };
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.compiler.PreparedTemplate#getTag()
+ */
+ public String getTag() {
+ return HtmlCompiler.NS_PREFIX+HtmlCompiler.VALUE_CALL_TAG;
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/WithDefaultsRulesWrapper.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,190 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* $Id: WithDefaultsRulesWrapper.java,v 1.1.2.1 2007/01/09 18:57:42 alexsmirnov Exp $
- *
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.ajax4jsf.framework.renderer.compiler;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.Rule;
-import org.apache.commons.digester.Rules;
-
-/**
- * <h2>Imported from digitester 1.7 , since JSF RI used version 1.5 by default.</h2>
- * <p><code>Rules</code> <em>Decorator</em> that returns default rules
- * when no matches are returned by the wrapped implementation.</p>
- *
- * <p>This allows default <code>Rule</code> instances to be added to any
- * existing <code>Rules</code> implementation. These default <code>Rule</code>
- * instances will be returned for any match for which the wrapped
- * implementation does not return any matches.</p>
- * <p> For example,
- * <pre>
- * Rule alpha;
- * ...
- * WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper(new BaseRules());
- * rules.addDefault(alpha);
- * ...
- * digester.setRules(rules);
- * ...
- * </pre>
- * when a pattern does not match any other rule, then rule alpha will be called.
- * </p>
- * <p><code>WithDefaultsRulesWrapper</code> follows the <em>Decorator</em> pattern.</p>
- *
- * @since 1.6
- */
-
-public class WithDefaultsRulesWrapper implements Rules {
-
- // --------------------------------------------------------- Fields
-
- /** The Rules implementation that this class wraps. */
- private Rules wrappedRules;
- /** Rules to be fired when the wrapped implementations returns none. */
- private List defaultRules = new ArrayList();
- /** All rules (preserves order in which they were originally added) */
- private List allRules = new ArrayList();
-
- // --------------------------------------------------------- Constructor
-
- /**
- * Base constructor.
- *
- * @param wrappedRules the wrapped <code>Rules</code> implementation, not null
- * @throws IllegalArgumentException when <code>wrappedRules</code> is null
- */
- public WithDefaultsRulesWrapper(Rules wrappedRules) {
- if (wrappedRules == null) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.WRAPPED_RULES_NULL_ERROR));
- }
- this.wrappedRules = wrappedRules;
- }
-
- // --------------------------------------------------------- Properties
-
- /** Gets digester using these Rules */
- public Digester getDigester() {
- return wrappedRules.getDigester();
- }
-
- /** Sets digeseter using these Rules */
- public void setDigester(Digester digester) {
- wrappedRules.setDigester(digester);
- Iterator it = defaultRules.iterator();
- while (it.hasNext()) {
- Rule rule = (Rule) it.next();
- rule.setDigester(digester);
- }
- }
-
- /** Gets namespace to apply to Rule's added */
- public String getNamespaceURI() {
- return wrappedRules.getNamespaceURI();
- }
-
- /** Sets namespace to apply to Rule's added subsequently */
- public void setNamespaceURI(String namespaceURI) {
- wrappedRules.setNamespaceURI(namespaceURI);
- }
-
- /** Gets Rule's which will be fired when the wrapped implementation returns no matches */
- public List getDefaults() {
- return defaultRules;
- }
-
- // --------------------------------------------------------- Public Methods
-
- public List match(String pattern) {
- return match("", pattern);
- }
-
- /**
- * Return list of rules matching given pattern.
- * If wrapped implementation returns any matches return those.
- * Otherwise, return default matches.
- */
- public List match(String namespaceURI, String pattern) {
- List matches = wrappedRules.match(namespaceURI, pattern);
- if (matches == null || matches.isEmpty()) {
- // a little bit of defensive programming
- return new ArrayList(defaultRules);
- }
- // otherwise
- return matches;
- }
-
- /** Adds a rule to be fired when wrapped implementation returns no matches */
- public void addDefault(Rule rule) {
- // set up rule
- if (wrappedRules.getDigester() != null) {
- rule.setDigester(wrappedRules.getDigester());
- }
-
- if (wrappedRules.getNamespaceURI() != null) {
- rule.setNamespaceURI(wrappedRules.getNamespaceURI());
- }
-
- defaultRules.add(rule);
- allRules.add(rule);
- }
-
- /** Gets all rules */
- public List rules() {
- return allRules;
- }
-
- /** Clears all Rule's */
- public void clear() {
- wrappedRules.clear();
- allRules.clear();
- defaultRules.clear();
- }
-
- /**
- * Adds a Rule to be fired on given pattern.
- * Pattern matching is delegated to wrapped implementation.
- */
- public void add(String pattern, Rule rule) {
- wrappedRules.add(pattern, rule);
- allRules.add(rule);
- }
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/WithDefaultsRulesWrapper.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/WithDefaultsRulesWrapper.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,190 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* $Id: WithDefaultsRulesWrapper.java,v 1.1.2.1 2007/01/09 18:57:42 alexsmirnov Exp $
+ *
+ * Copyright 2003-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.ajax4jsf.renderkit.compiler;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.Rule;
+import org.apache.commons.digester.Rules;
+
+/**
+ * <h2>Imported from digitester 1.7 , since JSF RI used version 1.5 by default.</h2>
+ * <p><code>Rules</code> <em>Decorator</em> that returns default rules
+ * when no matches are returned by the wrapped implementation.</p>
+ *
+ * <p>This allows default <code>Rule</code> instances to be added to any
+ * existing <code>Rules</code> implementation. These default <code>Rule</code>
+ * instances will be returned for any match for which the wrapped
+ * implementation does not return any matches.</p>
+ * <p> For example,
+ * <pre>
+ * Rule alpha;
+ * ...
+ * WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper(new BaseRules());
+ * rules.addDefault(alpha);
+ * ...
+ * digester.setRules(rules);
+ * ...
+ * </pre>
+ * when a pattern does not match any other rule, then rule alpha will be called.
+ * </p>
+ * <p><code>WithDefaultsRulesWrapper</code> follows the <em>Decorator</em> pattern.</p>
+ *
+ * @since 1.6
+ */
+
+public class WithDefaultsRulesWrapper implements Rules {
+
+ // --------------------------------------------------------- Fields
+
+ /** The Rules implementation that this class wraps. */
+ private Rules wrappedRules;
+ /** Rules to be fired when the wrapped implementations returns none. */
+ private List defaultRules = new ArrayList();
+ /** All rules (preserves order in which they were originally added) */
+ private List allRules = new ArrayList();
+
+ // --------------------------------------------------------- Constructor
+
+ /**
+ * Base constructor.
+ *
+ * @param wrappedRules the wrapped <code>Rules</code> implementation, not null
+ * @throws IllegalArgumentException when <code>wrappedRules</code> is null
+ */
+ public WithDefaultsRulesWrapper(Rules wrappedRules) {
+ if (wrappedRules == null) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.WRAPPED_RULES_NULL_ERROR));
+ }
+ this.wrappedRules = wrappedRules;
+ }
+
+ // --------------------------------------------------------- Properties
+
+ /** Gets digester using these Rules */
+ public Digester getDigester() {
+ return wrappedRules.getDigester();
+ }
+
+ /** Sets digeseter using these Rules */
+ public void setDigester(Digester digester) {
+ wrappedRules.setDigester(digester);
+ Iterator it = defaultRules.iterator();
+ while (it.hasNext()) {
+ Rule rule = (Rule) it.next();
+ rule.setDigester(digester);
+ }
+ }
+
+ /** Gets namespace to apply to Rule's added */
+ public String getNamespaceURI() {
+ return wrappedRules.getNamespaceURI();
+ }
+
+ /** Sets namespace to apply to Rule's added subsequently */
+ public void setNamespaceURI(String namespaceURI) {
+ wrappedRules.setNamespaceURI(namespaceURI);
+ }
+
+ /** Gets Rule's which will be fired when the wrapped implementation returns no matches */
+ public List getDefaults() {
+ return defaultRules;
+ }
+
+ // --------------------------------------------------------- Public Methods
+
+ public List match(String pattern) {
+ return match("", pattern);
+ }
+
+ /**
+ * Return list of rules matching given pattern.
+ * If wrapped implementation returns any matches return those.
+ * Otherwise, return default matches.
+ */
+ public List match(String namespaceURI, String pattern) {
+ List matches = wrappedRules.match(namespaceURI, pattern);
+ if (matches == null || matches.isEmpty()) {
+ // a little bit of defensive programming
+ return new ArrayList(defaultRules);
+ }
+ // otherwise
+ return matches;
+ }
+
+ /** Adds a rule to be fired when wrapped implementation returns no matches */
+ public void addDefault(Rule rule) {
+ // set up rule
+ if (wrappedRules.getDigester() != null) {
+ rule.setDigester(wrappedRules.getDigester());
+ }
+
+ if (wrappedRules.getNamespaceURI() != null) {
+ rule.setNamespaceURI(wrappedRules.getNamespaceURI());
+ }
+
+ defaultRules.add(rule);
+ allRules.add(rule);
+ }
+
+ /** Gets all rules */
+ public List rules() {
+ return allRules;
+ }
+
+ /** Clears all Rule's */
+ public void clear() {
+ wrappedRules.clear();
+ allRules.clear();
+ defaultRules.clear();
+ }
+
+ /**
+ * Adds a Rule to be fired on given pattern.
+ * Pattern matching is delegated to wrapped implementation.
+ */
+ public void add(String pattern, Rule rule) {
+ wrappedRules.add(pattern, rule);
+ allRules.add(rule);
+ }
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/package.html 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html 2007-07-10 01:19:57 UTC (rev 1561)
@@ -1,10 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>Insert title here</title>
-</head>
-<body>
-
-</body>
-</html>
\ No newline at end of file
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html (from rev 1560, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/package.html)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/compiler/package.html 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,10 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Insert title here</title>
+</head>
+<body>
+
+</body>
+</html>
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -33,10 +33,10 @@
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
-import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
-import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.compiler.HtmlCompiler;
+import org.ajax4jsf.renderkit.compiler.PreparedTemplate;
+import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.skin.SkinFactory;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java 2007-07-10 01:10:15 UTC (rev 1560)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -39,7 +39,6 @@
import javax.servlet.http.HttpSession;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.ajax.PushEventsCounter;
import org.ajax4jsf.renderkit.AjaxContainerRenderer;
import org.ajax4jsf.resource.InternetResourceService;
import org.apache.commons.logging.Log;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java 2007-07-10 01:10:15 UTC (rev 1560)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -10,7 +10,6 @@
import javax.faces.FacesException;
import javax.servlet.ServletContext;
-import org.ajax4jsf.ajax.PushEventsCounter;
import org.ajax4jsf.cache.Cache;
import org.ajax4jsf.cache.CacheConfigurationLoader;
import org.ajax4jsf.cache.CacheException;
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/PushEventsCounter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -0,0 +1,34 @@
+package org.ajax4jsf.webapp;
+
+import java.io.Serializable;
+import java.util.EventObject;
+
+import org.ajax4jsf.event.PushEventListener;
+
+public class PushEventsCounter implements PushEventListener,Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4060284352186710009L;
+ private volatile boolean performed = false;
+
+ public void onEvent(EventObject event) {
+ performed = true;
+ }
+
+ /**
+ * @return the performed
+ */
+ public boolean isPerformed() {
+ return performed;
+ }
+
+ /**
+ */
+ public void processed() {
+ this.performed = false;
+ }
+
+
+}
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java 2007-07-10 01:10:15 UTC (rev 1560)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/resource/CSSTemplateTestCase.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -24,8 +24,8 @@
import java.io.IOException;
import java.io.InputStream;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.resource.FacesResourceContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java 2007-07-10 01:10:15 UTC (rev 1560)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -28,8 +28,8 @@
import javax.faces.el.MethodBinding;
import javax.servlet.http.HttpSession;
-import org.ajax4jsf.ajax.PushEventsCounter;
import org.ajax4jsf.webapp.PollEventsManager;
+import org.ajax4jsf.webapp.PushEventsCounter;
/**
* Component for periodically call AJAX events on server ( poll actions )
Modified: trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
--- trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
+++ trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-10 01:19:57 UTC (rev 1561)
@@ -22,15 +22,15 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
-import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.compiler.HtmlCompiler;
+import org.ajax4jsf.renderkit.compiler.PreparedTemplate;
+import org.ajax4jsf.renderkit.compiler.TemplateContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.TemplateCSSResource;
import org.richfaces.component.AjaxSuggestionEvent;
17 years, 6 months
JBoss Rich Faces SVN: r1560 - in trunk: framework/impl/src/main/java/org/ajax4jsf/component and 45 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-09 21:10:15 -0400 (Mon, 09 Jul 2007)
New Revision: 1560
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxContainerRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxPhaseListener.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxViewRootRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKit.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitFactory.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentVariables.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentsVariableResolver.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/PrototypeBasedRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/taglib/DropSourceMetaRule.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AJAXDataSerializer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxComponentRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxPhaseListener.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxViewRootRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKit.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKitFactory.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKitImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentVariables.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentsVariableResolver.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourcesRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakPoint.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ElementBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/HtmlCompiler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodParameterElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PreparedTemplate.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ResourceElement.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TemplateContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/HtmlComponentTagBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
trunk/framework/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java
trunk/framework/impl/src/main/java/org/richfaces/component/util/FormUtil.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
trunk/framework/impl/src/main/resources/META-INF/faces-config.xml
trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/EventValueBinding.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxStatus.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UISelector.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java
trunk/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/log.jspx
trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractCellRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractDefinitionListRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractGridRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractListRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java
trunk/ui/dataTable/src/main/templates/org/richfaces/htmlSubTable.jspx
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DnDValidator.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java
trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
trunk/ui/gmap/src/main/templates/gmap.jspx
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuSeparator.jspx
trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DRenderer.java
trunk/ui/panel/src/main/templates/panel.jspx
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java
trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java
trunk/ui/spacer/src/main/templates/spacer.jspx
trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITab.java
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabRendererBase.java
trunk/ui/togglePanel/src/main/java/org/richfaces/component/UIToggleControl.java
trunk/ui/togglePanel/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java
trunk/ui/togglePanel/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java
trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java
trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
trunk/ui/tree/src/main/java/org/richfaces/component/UITreeNode.java
trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
Log:
packages and classes refactor in the "impl" project
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -27,7 +27,7 @@
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.renderer.AjaxPhaseListener;
+import org.ajax4jsf.renderkit.AjaxPhaseListener;
/**
* @author shura
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -37,9 +37,9 @@
import org.ajax4jsf.component.AjaxViewRoot;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.context.ViewIdHolder;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.apache.commons.logging.Log;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -40,7 +40,7 @@
import org.ajax4jsf.context.InvokerCallback;
import org.ajax4jsf.context.ViewIdHolder;
import org.ajax4jsf.event.AjaxListener;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
import org.apache.commons.collections.Buffer;
import org.apache.commons.collections.BufferUnderflowException;
import org.apache.commons.collections.UnboundedFifoBuffer;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -58,10 +58,10 @@
import org.ajax4jsf.component.AjaxViewRoot;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.context.ViewIdHolder;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.HeaderResourceProducer;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.webapp.BaseFilter;
import org.ajax4jsf.webapp.FilterServletResponseWrapper;
import org.apache.commons.logging.Log;
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/taglib/DropSourceMetaRule.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/taglib/DropSourceMetaRule.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/taglib/DropSourceMetaRule.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,77 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs/ajax4jsf/framework/src/main/java/org/ajax4jsf/dnd/taglib/Attic/DropSourceMetaRule.java,v $
- * $Revision: 1.1.2.1 $
- */
-
-package org.ajax4jsf.dnd.taglib;
-
-import javax.faces.el.MethodBinding;
-
-import org.richfaces.event.DropEvent;
-import org.richfaces.event.DropSource;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class DropSourceMetaRule extends MetaRule {
-
- public static final DropSourceMetaRule INSTANCE = new DropSourceMetaRule();
- private static final Class [] SIGNATURE = {DropEvent.class};
-
- private class DropListenerMetaData extends Metadata {
-
- private TagAttribute tagAttribute;
-
- public DropListenerMetaData(TagAttribute attribute) {
- tagAttribute = attribute;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- MethodBinding binding = ctx.getFacesContext().getApplication().createMethodBinding(tagAttribute.getValue(), SIGNATURE);
- ((DropSource) instance).setDropListener(binding);
- }
- }
-
-
- public Metadata applyRule(String name, TagAttribute attribute,
- MetadataTarget meta) {
- if ("dropListener".equals(name)) {
- return new DropListenerMetaData(attribute);
- }
- return null;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AJAXDataSerializer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AJAXDataSerializer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AJAXDataSerializer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,45 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-
-
-import org.ajax4jsf.javascript.ScriptUtils;
-
-/**
- * @author shura
- *
- */
-public class AJAXDataSerializer {
-
- public static final String SERVICE = AJAXDataSerializer.class.getName();
-
- public String asString(Object data) {
- StringBuffer result = new StringBuffer();
- if(null != data){
- result.append("<![CDATA[ ");
- result.append(ScriptUtils.toScript(data));
- result.append(" ]]>");
- }
- return result.toString();
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,189 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.AjaxChildrenEncoder;
-import org.ajax4jsf.component.AjaxOutput;
-import org.ajax4jsf.renderkit.AjaxRenderer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura
- *
- */
-public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase implements AjaxRenderer {
-
- public static final Log log = LogFactory.getLog(AjaxChildrenRenderer.class);
-
- public static final String[] SPECIAL_COMPONENTS_TYPES = {
- "org.ajax4jsf.Bundle"/*UILoadBundle.COMPONENT_TYPE*/, "org.apache.myfaces.AliasBean",
- "org.apache.myfaces.AliasBeansScope" };
- private static final String SPECIAL_TYPES_PARAMETER = "org.ajax4jsf.CONTROL_COMPONENTS";
-
- /**
- * Iterate over all childs of components. If component id contains in list ,
- * or, if list is empty, compotents is submitted form - render it. TODO -
- * Instead of calculate full path for every component, build current Path
- * for componet and send as parameter.
- *
- * @param context -
- * current context
- * @param component -
- * curent faces component.
- * @param ids -
- * list of Id to render.
- * @throws IOException
- * @deprecated Use {@link #encodeAjaxChildren(FacesContext,UIComponent,String,Set,Set)} instead
- */
- public void encodeAjaxChild(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
- encodeAjaxChildren(context, component, path, ids, renderedAreas);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String, java.util.Set, java.util.Set)
- */
- public void encodeAjaxChildren(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_CHILD_AJAX_INFO,
- path, component.getId()));
- }
- String currentPath = path;
- if (component instanceof NamingContainer) {
- currentPath += component.getId() + NamingContainer.SEPARATOR_CHAR;
- }
- for (Iterator it = component.getFacetsAndChildren(); it.hasNext();) {
- UIComponent element = (UIComponent) it.next();
- encodeAjaxComponent(context, element, currentPath, ids, renderedAreas);
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxComponent(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String, java.util.Set, java.util.Set)
- */
- public void encodeAjaxComponent(FacesContext context, UIComponent component, String currentPath, Set ids, Set renderedAreas) throws IOException {
- if (component.isRendered()) { // skip not-rendered components.
- boolean found = false;
- if (!ids.isEmpty()) {
- // list for rendering may contains absolute id ( best ),
- // component Id or client ID
- String elementId = component.getId();
- String absoluteId = currentPath + elementId;
- // String clientId = element.getClientId(context);
- if (ids.contains(absoluteId) || ids.contains(elementId)) {
- if (log.isDebugEnabled()) {
- log
- .debug(Messages.getMessage(
- Messages.RENDER_AJAX_AREA_INFO,
- absoluteId));
- }
- // renderChild(context, element);
- found = true;
- }
- }
- if (!found && component instanceof AjaxOutput) {
- if (((AjaxOutput) component).isAjaxRendered()) {
- // renderChild(context, element);
- found = true;
- }
-
- }
-
- if (!found) {
- if (component instanceof AjaxChildrenEncoder) {
- ((AjaxChildrenEncoder) component).encodeAjaxChild(
- context, currentPath, ids, renderedAreas);
- } else {
- // Special case - for control components, not produced
- // html code - such as message bundles loaders,
- // MyFaces aliases etc. we call encodeBegin/end methods
- // even if components not in rendered areas.
- boolean special = isSpecialElement(context, component);
- if (special) {
- component.encodeBegin(context);
- }
- encodeAjaxChildren(context, component, currentPath, ids,
- renderedAreas);
- if (special) {
- component.encodeEnd(context);
- }
-
- }
- } else {
- renderedAreas.add(component.getClientId(context));
- renderChild(context, component);
- }
- }
- }
-
- private Set _specialComponentTypes = null;
-
- /**
- * Detect component as special control case - such as messages bundle
- * loader, alias bean components etc. Type of component get by reflection
- * from static field COMPONENT_TYPE
- *
- * @param context
- * @param component
- * @return true if encode methods must be called for this component even in
- * not-rendered parts.
- */
- private boolean isSpecialElement(FacesContext context, UIComponent component) {
- if (_specialComponentTypes == null) {
- _specialComponentTypes = new HashSet(10);
- for (int i = 0; i < SPECIAL_COMPONENTS_TYPES.length; i++) {
- _specialComponentTypes.add(SPECIAL_COMPONENTS_TYPES[i]);
- }
- String special = context.getExternalContext().getInitParameter(
- SPECIAL_TYPES_PARAMETER);
- if (null != special) {
- String[] split = special.split(",");
- for (int i = 0; i < split.length; i++) {
- _specialComponentTypes.add(split[i]);
- }
- }
- }
- boolean result;
- try {
- String componentType = (String) component.getClass().getField(
- "COMPONENT_TYPE").get(null);
- result = _specialComponentTypes.contains(componentType);
- } catch (Exception e) {
- // exception occurs if component not have accesible COMPONENT_TYPE
- // constant
- // we assume that component not in special types.
- result = false;
- }
- return result;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxComponentRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxComponentRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxComponentRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,93 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import org.ajax4jsf.javascript.AjaxScript;
-import org.ajax4jsf.renderkit.HeaderResourceProducer;
-import org.ajax4jsf.resource.InternetResource;
-
-
-/**
- * Base class for all Ajax enabled components. Perform common task -
- * output javasript for component.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:49 $
- *
- */
-public abstract class AjaxComponentRendererBase extends HeaderResourcesRendererBase implements HeaderResourceProducer {
-
-// private InternetResource ajaxScript = getResource("/com/exadel/vcp/framework/ajax/scripts/AJAX.js");
- private static final String AJAX_SCRIPT = AjaxScript.class.getName();
-
- private InternetResource[] scripts = null;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderScripts(javax.faces.context.FacesContext)
- */
-// public LinkedHashSet getHeaderScripts(FacesContext context, UIComponent component) {
-// LinkedHashSet scripts = new LinkedHashSet() ; // Collections.singleton(ajaxScript.getUri(context, null));
-// scripts.add(ajaxScript.getUri(context, component));
-// String[] additionalScripts = getAdditionalScripts();
-// if (null != additionalScripts) {
-// for (int i = 0; i < additionalScripts.length; i++) {
-// String resource = additionalScripts[i];
-// scripts.add(getResource(resource).getUri(context, component));
-// }
-// }
-// return scripts;
-// }
-
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.HeaderResourcesRendererBase#getScripts()
- */
- protected InternetResource[] getScripts() {
- // Lazy create
- if (scripts == null) {
- InternetResource[] additionalScripts = getAdditionalScripts();
- // Custom scripts
- if (null != additionalScripts) {
- scripts = new InternetResource[additionalScripts.length+1];
- System.arraycopy(additionalScripts,0,scripts,1,additionalScripts.length);
- } else {
- scripts = new InternetResource[1];
- }
- // Ajax script
- scripts[0] = getResource(AJAX_SCRIPT);
- }
-
- return scripts;
- }
-
-
-
- /**
- * Hoock method for append custom ajax scripts
- * @return
- */
- protected InternetResource[] getAdditionalScripts() {
- return null;
- }
-
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,166 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.AjaxContainer;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.event.AjaxEvent;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base renderer for all AJAX - subview components.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/08 15:02:02 $
- *
- */
-public class AjaxContainerRenderer extends AjaxChildrenRenderer {
-
- public static final String AJAX_PARAMETER_NAME = "AJAXREQUEST";
-
- public static final String AJAX_JSF_SCRIPT = "AJAX.js";
-
- public static final String SARISSA_SCRIPT = "sarissa.js";
-
- public static final String JSDOM_SCRIPT = "JSDOM_sarissa.js";
-
- public static final String AJAX_VIEW_STATE_TAG = "span";
-
- public static final String AJAX_VIEW_STATE_ID = "ajax-update-ids";
-
- public static final String AJAX_RESULT_GROUP_TAG = "meta";
-
- public static final String AJAX_RESULT_GROUP_ATTR = "content";
-
- public static final String AJAX_RESULT_STYLE = "display: none";
-
- public static final String AJAX_UPDATE_HEADER = "Ajax-Update-Ids";
-
- static final Log log = LogFactory
- .getLog(AjaxContainerRenderer.class);
-
- public static final String AJAX_FLAG_HEADER = "Ajax-Response";
-
- public static final String AJAX_LOCATION_HEADER = "Location";
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return AjaxContainer.class;
- }
-
- /**
- *
- *
- * @see javax.faces.component.UIComponent#encodeChildren(javax.faces.context.FacesContext)
- * Since main function of component - render subset of components, for
- * update on page,don't delegate this for renderer.
- *
- */
- public void encodeChildren(FacesContext context, UIComponent component)
- throws IOException {
- // Normal request - render all ...
- log.debug(Messages.getMessage(Messages.RENDER_CHILDREN_NON_AJAX_INFO));
- renderChildren(context, component);
- }
-
- /**
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeAjax(FacesContext context, UIComponent component)
- throws IOException {
- UIComponent root ;
- // Iterate over all childrens, render it if nessesary...
- log.debug(Messages.getMessage(Messages.RENDER_CHILDREN_AJAX_INFO));
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- Set ids = ajaxContext.getAjaxAreasToRender();
- Set renderedAreas = ajaxContext.getAjaxRenderedAreas();
- if (((AjaxContainer) component).isRenderRegionOnly()) {
- root = component;
- } else {
- root = context.getViewRoot();
- }
- String path = AjaxRendererUtils.getAbsoluteId(root);
- // if(! (component instanceof NamingContainer)){
- path = path.substring(0, path
- .lastIndexOf(NamingContainer.SEPARATOR_CHAR) + 1);
- encodeAjaxComponent(context, root, path, ids, renderedAreas);
- // Write information about encoded areas after submission.
- AjaxRendererUtils.encodeAreas(context, component);
- }
-
-
-
- /*
- * always return true, since component must maintain set of rendered
- * components.
- *
- * @see javax.faces.component.UIComponent#getRendersChildren()
- */
- public boolean getRendersChildren() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.RendererBase#doDecode(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- protected void doDecode(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
- Map paramMap = context.getExternalContext().getRequestParameterMap();
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.DECODE_AJAX_REQUEST_STATUS_INFO, clientId));
- log.debug(Messages.getMessage(Messages.REQUEST_PARAMETERS_MAP,
- paramMap.toString()));
- }
- Object ajaxParameter = paramMap.get(AJAX_PARAMETER_NAME);
- AjaxContainer ajaxContainer = (AjaxContainer) component;
- if (null != ajaxParameter && ajaxParameter.equals(clientId)) {
- ajaxContainer.setSubmitted(true);
- AjaxEvent event = new AjaxEvent(component);
- component.queueEvent(event);
- } else {
- ajaxContainer.setSubmitted(false);
- }
-
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxPhaseListener.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxPhaseListener.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxPhaseListener.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,169 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.event.PhaseListener;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.context.AjaxContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * Listener for act before Render phase to set RenderKit Id for current skin.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:19 $
- *
- */
-public class AjaxPhaseListener implements PhaseListener {
-
- /**
- *
- */
- private static final long serialVersionUID = -4087936963051339868L;
-
- public static final String VIEW_BEAN_PREFIX = "org.ajax4jsf.viewbean:";
-
- public static final String VIEW_STATE_SAVED_PARAM = "org.ajax4jsf.VIEW_STATE_SAVED";
-
- private static final Log log = LogFactory
- .getLog(AjaxPhaseListener.class);
-
- public static final String AJAX_BEAN_PREFIX = "org.ajax4jsf.ajaxviewbean:";
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
- */
- public void afterPhase(PhaseEvent event) {
- PhaseId phaseId = event.getPhaseId();
- if(log.isDebugEnabled()){
- log.debug("Process after phase "+phaseId.toString());
- }
- FacesContext context = event.getFacesContext();
- Map requestMap = context.getExternalContext().getRequestMap();
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if (phaseId == PhaseId.RENDER_RESPONSE) {
- if (ajaxContext.isAjaxRequest()) {
- // JSF RI 1.1 hack - view state not saved in <f:view> tag.
- if(null == requestMap.get(VIEW_STATE_SAVED_PARAM)){
- try {
- ajaxContext.saveViewState(context);
- } catch (IOException e) {
- throw new FacesException(e);
- }
- }
- }
-// ajaxContext.processHeadResources(context);
- } else if (phaseId == PhaseId.RESTORE_VIEW) {
-
- UIViewRoot viewRoot = context.getViewRoot();
- if(null != viewRoot){
- boolean isAjax = ajaxContext.isAjaxRequest();
- Map attributes = viewRoot.getAttributes();
- for (Iterator it = attributes.keySet().iterator(); it.hasNext();) {
- Object key = it.next();
- if (key instanceof String) {
- String stringKey = (String) key;
- if(stringKey.startsWith(VIEW_BEAN_PREFIX)){
- requestMap.put(stringKey.substring(VIEW_BEAN_PREFIX.length()), attributes.get(key));
- } else if(isAjax && stringKey.startsWith(AJAX_BEAN_PREFIX)){
- requestMap.put(stringKey.substring(AJAX_BEAN_PREFIX.length()), attributes.get(key));
- }
-
- }
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.event.PhaseListener#beforePhase(javax.faces.event.PhaseEvent)
- */
- public void beforePhase(PhaseEvent event) {
- PhaseId phaseId = event.getPhaseId();
- if(log.isDebugEnabled()){
- log.debug("Process before phase "+phaseId.toString());
- }
- FacesContext context = event.getFacesContext();
- if (phaseId == PhaseId.RENDER_RESPONSE) {
- // Clear ViewId replacement, to avoid incorrect rendering of forms URI.
- AjaxContext.getCurrentInstance(context).setViewIdHolder(null);
-
- UIViewRoot root = context.getViewRoot();
- log.debug(Messages.getMessage(
- Messages.ENTER_BEFORE_RENDER_VIEW_PHASE, root.getViewId(),
- root.getRenderKitId()));
-
- // TODO - create special skin-config.xml configuration.
- String renderKitId = null;
- try {
- renderKitId = SkinFactory.getInstance().getSkin(context)
- .getRenderKitId(context);
- } catch (Exception e) {
- log.error("Exception on get current Skin ", e);
- }
- if (null != renderKitId) {
- log.debug(Messages.getMessage(Messages.SET_RENDER_KIT_ID_INFO,
- renderKitId));
- root.setRenderKitId(renderKitId);
- }
- } else if (phaseId == PhaseId.RESTORE_VIEW) {
-
- }
- }
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.event.PhaseListener#getPhaseId()
- */
- public PhaseId getPhaseId() {
- return PhaseId.ANY_PHASE;
- }
-
- protected boolean isValueReference(String value) {
- if (value == null)
- throw new NullPointerException("value");
-
- int start = value.indexOf("#{");
- if (start < 0)
- return false;
-
- int end = value.lastIndexOf('}');
- return (end >= 0 && start < end);
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,934 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.component.ActionSource;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIParameter;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.component.AjaxContainer;
-import org.ajax4jsf.component.AjaxLoadBundleComponent;
-import org.ajax4jsf.component.AjaxSupport;
-import org.ajax4jsf.component.AjaxViewRoot;
-import org.ajax4jsf.component.JavaScriptParameter;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.util.ServicesUtils;
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.JSReference;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura
- *
- * Some utilites for render AJAX components.
- */
-public class AjaxRendererUtils {
-
- /**
- * Name Javasript function for submit AJAX request
- */
- public static final String AJAX_FUNCTION_NAME = "A4J.AJAX.Submit";
-
- /**
- * Attribute for keep clientId of status component
- */
- public static final String STATUS_ATTR_NAME = "status";
-
- /**
- * Attribute for keep JavaScript funtion name for call after complete
- * request.
- */
- public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
-
- /**
- * Attribute to keep
- */
- public static final String LIMITTOLIST_ATTR_NAME = "limitToList";
-
- private static Log log = LogFactory.getLog(AjaxRendererUtils.class);
-
- public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
-
- private static final Class OBJECT_ARRAY_CLASS = (new Object[0]).getClass();
-
- public static final String SEQUENCE_PARAM = "jsf_sequence";
-
- private static final String VALUE_ATTR = "value";
-
- public static final String AJAX_AREAS_RENDERED = "org.ajax4jsf.areas.rendered";
-
- private static final String AJAX_SINGLE_ATTR = "ajaxSingle";
-
- public static final String AJAX_QUEUE_ATTR = "eventsQueue";
-
- public static final String AJAX_DELAY_ATTR = "requestDelay";
-
- private static final Object AJAX_ABORT_ATTR = "ignoreDupResponses";
-
- /**
- * Static class - protect constructor TODO - make as subclass of chameleon
- * RendererUtils.
- *
- */
- private AjaxRendererUtils() {
-
- }
-
- /**
- * Build JavaScript onclick event for given component
- *
- * @param uiComponent -
- * component for build event
- * @param facesContext
- * @return <code>StringBuffer</code> with Javascript code
- */
- public static StringBuffer buildOnClick(UIComponent uiComponent,
- FacesContext facesContext) {
- return buildOnEvent(uiComponent, facesContext, HTML.onclick_ATTRIBUTE);
- }
-
- /**
- * Build JavaScript event for component
- *
- * @param uiComponent -
- * component for build event
- * @param facesContext
- * @param eventName -
- * name of event
- * @return <code>StringBuffer</code> with Javascript code TODO - for
- * key-based events build list of supported keys
- */
- public static StringBuffer buildOnEvent(UIComponent uiComponent,
- FacesContext facesContext, String eventName) {
- StringBuffer onEvent = new StringBuffer();
- if (null != eventName) {
- String commandOnEvent = (String) uiComponent.getAttributes().get(
- eventName);
- if (commandOnEvent != null) {
- onEvent.append(commandOnEvent);
- onEvent.append(';');
- }
- }
- JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext);
- // Create formal parameter for non-input elements ???
- // Link Control pseudo-object
- // Options map. Possible options for function call :
- // control - name of form control for submit.
- // name - name for link control \
- // value - value of control. - possible replace by parameters ?
- // single true/false - submit all form or only one control.
- // affected - array of element's ID for update on responce.
- // oncomplete - function for call after complete request.
- // status - id of request status component.
- // parameters - map of parameters name/value for append on request.
- // TODO
- // sync true/false - run script in sync mode.
- // ..........
- ajaxFunction.addParameter(buildEventOptions(facesContext, uiComponent));
-
- // appendAjaxSubmitParameters(facesContext, uiComponent, onEvent);
- ajaxFunction.appendScript(onEvent);
- if (uiComponent instanceof AjaxSupport) {
- AjaxSupport support = (AjaxSupport) uiComponent;
- if (support.isDisableDefault()) {
- onEvent.append("; return false;");
- }
- }
- log.debug(Messages.getMessage(Messages.BUILD_ONCLICK_INFO, uiComponent
- .getId(), onEvent.toString()));
- return onEvent;
-
- }
-
- /**
- * @param facesContext
- * @param uiComponent
- * @return
- */
- public static Map buildEventOptions(FacesContext facesContext,
- UIComponent uiComponent) {
- String clientId = uiComponent.getClientId(facesContext);
- Map componentAttributes = uiComponent.getAttributes();
- Map options = new HashMap();
- Map parameters = new HashMap();
- // UIForm form = getNestingForm(uiComponent);
- // "input" - if assigned to html input element.
- boolean input = (uiComponent instanceof AjaxSupport && uiComponent
- .getParent() instanceof EditableValueHolder)
- || uiComponent instanceof EditableValueHolder;
- // Action component - button etc.
- boolean action = (uiComponent instanceof AjaxSupport && uiComponent
- .getParent() instanceof ActionSource)
- || uiComponent instanceof ActionSource;
- // TODO - disable ( or not ? ) submission of action for disabled default
- // ?
- // if ( action && uiComponent instanceof AjaxSupport) {
- // AjaxSupport support = (AjaxSupport) uiComponent;
- // if (support.isDisableDefault()) {
- // action = false;
- // }
- // }
-
- boolean ajaxSingle = Boolean.TRUE.equals(componentAttributes
- .get(AJAX_SINGLE_ATTR));
- // For input components in single mode or without form submit input
- // control )
- if (ajaxSingle && input) { // || action
- // TODO - inside form, put reference :
- // document.forms['form'].controls['control']
- options.put("control", JSReference.THIS);
- }
- // Control value for submit
- String controlName;
- Object controlValue;
- // TODO - make compatible with JSF RI/MyFaces ? use submittedValue ( if
- // any ) for UIInput, converted value for ValueHolder.
- controlName = clientId;
- controlValue = clientId;
- parameters.put(controlName, controlValue);
- // Move processing of a 'single' attribute to a server-side.
-// if (ajaxSingle) {
-// options.put("single", JSReference.TRUE);
-// }
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
- // Setup action URL. For portlet environment, it will be different from
- // page.
- options.put("actionUrl", ajaxContext.getAjaxActionURL(facesContext));
- // Add application-wide Ajax parameters
- parameters.putAll(ajaxContext.getCommonAjaxParameters());
- // add child parameters
- for (Iterator it = uiComponent.getChildren().iterator(); it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
- if (child instanceof UIParameter) {
- String name = ((UIParameter) child).getName();
- Object value = ((UIParameter) child).getValue();
- if (null == name) {
- throw new IllegalArgumentException(Messages.getMessage(
- Messages.UNNAMED_PARAMETER_ERROR, uiComponent
- .getClientId(facesContext)));
- }
- boolean escape = true;
- if (child instanceof JavaScriptParameter) {
- JavaScriptParameter actionParam = (JavaScriptParameter) child;
- escape = !actionParam.isNoEscape();
- }
- if (escape) {
- parameters.put(name, value);
- } else {
- parameters.put(name, new JSReference(value.toString()));
- // if(it.hasNext()){onEvent.append(',');};
- // renderAjaxLinkParameter( name,
- // value, onClick, jsForm, nestingForm);
- }
- }
- }
- if (!parameters.isEmpty()) {
- options.put("parameters", parameters);
- }
- // parameter to render only current list of areas.
- if (isAjaxLimitToList(uiComponent)) {
- Set ajaxAreas = getAjaxAreas(uiComponent);
- Set areasIds = new HashSet();
- if (null != ajaxAreas) {
- for (Iterator iter = ajaxAreas.iterator(); iter.hasNext();) {
- String id = (String) iter.next();
- UIComponent comp = uiComponent.findComponent(id);
- if (null != comp) {
- areasIds.add(comp.getClientId(facesContext));
- } else {
- areasIds.add(id);
- }
- }
- }
- options.put("affected", areasIds);
- }
- String oncomplete = getAjaxOncomplete(uiComponent);
- if (null != oncomplete) {
- JSFunctionDefinition function = new JSFunctionDefinition();
- function.addParameter("request");
- function.addParameter("event");
- function.addParameter("data");
- function.addToBody(oncomplete);
-
- options.put("oncomplete", function);
- }
- String status = getAjaxStatus(uiComponent);
- if (null != status) {
- options.put("status", status);
- }
- String queue = (String) componentAttributes.get(AJAX_QUEUE_ATTR);
- Integer requestDelay = (Integer) componentAttributes
- .get(AJAX_DELAY_ATTR);
- if (null != requestDelay && requestDelay.intValue() > 0) {
- options.put(AJAX_DELAY_ATTR, requestDelay);
- if (null == queue) {
- queue = clientId;
- }
- }
- Boolean ignoreDupResponses = (Boolean) componentAttributes
- .get(AJAX_ABORT_ATTR);
- if (null != ignoreDupResponses && ignoreDupResponses.booleanValue()) {
- options.put(AJAX_ABORT_ATTR, JSReference.TRUE);
- if (null == queue) {
- queue = clientId;
- }
- }
- if (null != queue) {
- options.put(AJAX_QUEUE_ATTR, queue);
- }
- // request timeout.
- Integer timeout = (Integer) componentAttributes.get("timeout");
- if (null != timeout && timeout.intValue() > 0) {
- options.put("timeout", timeout);
- }
- // Encoding for requests
- String encoding = (String) componentAttributes.get("encoding");
- if (null != encoding) {
- options.put("encoding", encoding);
- }
- return options;
- }
-
- /**
- * Create call to Ajax Submit function with first two parameters
- *
- * @param uiComponent
- * @param facesContext
- * @param functionName
- * TODO
- * @return
- */
- public static JSFunction buildAjaxFunction(UIComponent uiComponent,
- FacesContext facesContext) {
- JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext,
- AJAX_FUNCTION_NAME);
- // client-side script must have reference to event-enabled object.
- ajaxFunction.addParameter(new JSReference("event"));
- return ajaxFunction;
- }
-
- /**
- * Create call to Ajax Submit function with first two parameters
- *
- * @param uiComponent
- * @param facesContext
- * @param functionName
- * TODO
- * @return
- */
- public static JSFunction buildAjaxFunction(UIComponent uiComponent,
- FacesContext facesContext, String functionName) {
- JSFunction ajaxFunction = new JSFunction(functionName);
- UIComponent nestingContainer = (UIComponent) findAjaxContainer(
- facesContext, uiComponent);
- ajaxFunction.addParameter(nestingContainer.getClientId(facesContext));
- // build form name or ActionUrl for script
- UIComponent nestingForm = getNestingForm(uiComponent);
- if (null == nestingForm) {
- ajaxFunction.addParameter(JSReference.NULL);
- } else {
- ajaxFunction.addParameter(nestingForm.getClientId(facesContext));
- }
- return ajaxFunction;
- }
-
- /**
- * Append common parameters ( array of affected areas, status area id, on
- * complete function ) to JavaScript event string.
- *
- * @param uiComponent
- * @param onClick -
- * buffer with JavaScript code eg... AJAX.Submit(form,this
- */
- // public static void appendAjaxSubmitParameters(FacesContext facesContext,
- // UIComponent uiComponent, StringBuffer onClick)
- // {
- // Set ajaxAreas = getAjaxAreas(uiComponent);
- // onClick.append(',');
- // // parameter to render only current list of areas.
- // if (isAjaxLimitToList(uiComponent) && ajaxAreas != null &&
- // ajaxAreas.size() > 0)
- // {
- // onClick.append('[');
- // Iterator areas = ajaxAreas.iterator();
- // boolean first = true;
- // while (areas.hasNext())
- // {
- // String element = (String) areas.next();
- // UIComponent component = uiComponent.findComponent(element);
- // if (null != component)
- // {
- // if (!first)
- // {
- // onClick.append(',');
- // }
- // else
- // {
- // first = false;
- // }
- // onClick.append('\'');
- // onClick.append(component.getClientId(facesContext));
- // onClick.append('\'');
- // }
- // }
- // onClick.append("]");
- // }
- // else
- // {
- // onClick.append("null");
- // }
- // // insert id of request status element.
- // onClick.append(',');
- // String status = getAjaxStatus(uiComponent);
- // if (null != status)
- // {
- // onClick.append('\'').append(status).append('\'');
- // }
- // else
- // {
- // onClick.append("null");
- // }
- // // insert function name for call after completed request
- // onClick.append(',');
- // String oncomplete = getAjaxOncomplete(uiComponent);
- // if (null != oncomplete)
- // {
- // onClick.append(oncomplete);
- // }
- // else
- // {
- // onClick.append("null");
- // }
- //
- // }
- /**
- * Get list of clientId's for given component
- *
- * @param uiComponent
- * @return List of areas Id's , updated by this component.
- */
- public static Set getAjaxAreas(UIComponent uiComponent) {
- Object areas;
- if (uiComponent instanceof AjaxComponent) {
- areas = ((AjaxComponent) uiComponent).getReRender();
-
- } else {
- areas = uiComponent.getAttributes().get(
- AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE);
- }
- return asSet(areas);
- }
-
- /**
- * Convert parameter ( Collection, List, array, String, comma-separated
- * String ) to list of srings. TODO - when move to JDK 5, change to
- * List<String>
- *
- * @param valueToSet -
- * obect for convert to List.
- * @return - list of strings.
- */
- public static Set asSet(Object valueToSet) {
-
- if (null != valueToSet) {
- // Simplest case - set.
- if (valueToSet instanceof Set) {
- return (Set) valueToSet;
- }
- // Other collections.
- else if (valueToSet instanceof Collection) {
- return new HashSet((Collection) valueToSet);
- }
- // Array
- else if (OBJECT_ARRAY_CLASS.isAssignableFrom(valueToSet.getClass())) {
- return new HashSet(Arrays.asList((Object[]) valueToSet));
- }
- // Tokenize string.
- else if (valueToSet instanceof String) {
- String areasString = (String) valueToSet;
- if (areasString.indexOf(",") > 0) {
- return new HashSet(Arrays.asList(areasString.trim().split(
- "(\\s)*,(\\s)*")));
- } else {
- Set areasSet = new HashSet(5);
- areasSet.add(areasString.trim());
- return areasSet;
- }
-
- }
- }
- return null;
- }
-
- /**
- * Get status area Id for given component.
- *
- * @param component
- * @return clientId of status area, or <code>null</code>
- */
- public static String getAjaxStatus(UIComponent component) {
- String statusId;
- if (component instanceof AjaxComponent) {
- statusId = ((AjaxComponent) component).getStatus();
-
- } else {
- statusId = (String) component.getAttributes().get(STATUS_ATTR_NAME);
- }
- if (null != statusId) {
- UIComponent status = null;
- UIComponent currentParent = component;
- try {
- // Check the naming container of the current
- // component for component identified by
- // 'forComponent'
- while (currentParent != null) {
- // If the current component is a NamingContainer,
- // see if it contains what we're looking for.
- status = currentParent.findComponent(statusId);
- if (status != null)
- break;
- // if not, start checking further up in the view
- currentParent = currentParent.getParent();
- }
- } catch (Exception e) {
- // ignore - log the warning
- }
- if (null != status) {
- statusId = status
- .getClientId(FacesContext.getCurrentInstance());
- } else {
- log.warn(Messages.getMessage(
- Messages.AJAX_STATUS_COMPONENT_NOT_FOWND_WARNING,
- component.getId()));
- }
- }
- return statusId;
- }
-
- /**
- * Get function name for call on completed ajax request.
- *
- * @param component
- * for wich calculate function name
- * @return name of JavaScript function or <code>null</code>
- */
- public static String getAjaxOncomplete(UIComponent component) {
- if (component instanceof AjaxComponent) {
- return ((AjaxComponent) component).getOncomplete();
-
- }
- return (String) component.getAttributes().get(ONCOMPLETE_ATTR_NAME);
- }
-
- /**
- * Calculate, must be component render only given areas, or all sended from
- * server.
- *
- * @param component
- * @return <code>true</code> if client must render ONLY given areas.
- */
- public static boolean isAjaxLimitToList(UIComponent component) {
- boolean result = false;
- if (component instanceof AjaxComponent) {
- result = ((AjaxComponent) component).isLimitToList();
-
- } else {
- try {
- result = ((Boolean) component.getAttributes().get(
- LIMITTOLIST_ATTR_NAME)).booleanValue();
- } catch (NullPointerException e) {
- // NullPointer - ignore ...
- } catch (ClassCastException e1) {
- // not Boolean - false ...
- }
- }
- return result;
- }
-
- /**
- * Replacement for buggy in MyFaces <code>RendererUtils</code>
- *
- * @param component
- * @return
- */
- public static String getAbsoluteId(UIComponent component) {
- if (component == null)
- throw new NullPointerException(Messages
- .getMessage(Messages.COMPONENT_NULL_ERROR_2));
-
- StringBuffer idBuf = new StringBuffer();
-
- idBuf.append(component.getId());
-
- UIComponent parent = component;
-
- while ((parent = parent.getParent()) != null) {
- if (parent instanceof NamingContainer) {
- idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
- idBuf.insert(0, parent.getId());
- }
- }
- idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
- log.debug(Messages.getMessage(Messages.CALCULATE_COMPONENT_ID_INFO,
- component.getId(), idBuf.toString()));
- return idBuf.toString();
- }
-
- /**
- * Find nested form for given component
- *
- * @param component
- * @return nested <code>UIForm</code> component, or <code>null</code>
- */
- public static UIComponent getNestingForm(UIComponent component) {
- UIComponent parent = component;
- // Search enclosed UIForm or ADF UIXForm component
- while (parent != null
- && !(parent instanceof UIForm)
- && !("org.apache.myfaces.trinidad.Form".equals(parent
- .getFamily()))
- && !("oracle.adf.Form".equals(parent.getFamily()))) {
- parent = parent.getParent();
- }
-
- return parent;
- }
-
- protected static String getAjaxActionUrl(FacesContext facesContext) {
- return AjaxContext.getCurrentInstance(facesContext).getAjaxActionURL(facesContext);
- }
-
- /**
- * @param facesContext
- * @param uiComponent
- * @return
- */
- public static org.ajax4jsf.component.AjaxContainer findAjaxContainer(
- FacesContext facesContext, UIComponent uiComponent) {
- UIComponent parent = uiComponent.getParent();
- while (parent != null
- && !(parent instanceof org.ajax4jsf.component.AjaxContainer)) {
- parent = parent.getParent();
- }
-
- org.ajax4jsf.component.AjaxContainer nestingContainer = null;
- if (parent != null) {
- // link is nested inside a form
- nestingContainer = (org.ajax4jsf.component.AjaxContainer) parent;
- } else if (facesContext.getViewRoot() instanceof AjaxViewRoot) {
- nestingContainer = (AjaxContainer) facesContext.getViewRoot();
- }
- return nestingContainer;
- }
-
- /**
- * For Myfaces, get current viev sequence.
- *
- * @param facescontext
- * @return
- */
- private static Integer getViewSequence(FacesContext facescontext) {
- Map map = facescontext.getExternalContext().getRequestMap();
- Integer sequence = (Integer) map.get(SEQUENCE_PARAM);
- if (sequence == null) {
- sequence = new Integer(1);
- map.put(SEQUENCE_PARAM, sequence);
- }
- return sequence;
- }
-
- /**
- * Encode rendered areas as special HTML tag ( span in current release )
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public static void encodeAreas(FacesContext context,
- UIComponent component) throws IOException {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- ExternalContext externalContext = context.getExternalContext();
- Map requestMap = externalContext.getRequestMap();
- Set rendered = ajaxContext.getAjaxRenderedAreas();
- StringBuffer senderString = new StringBuffer();
- // write special area for list of rendered elements. Client-side
- // Java
- // Script
- // read this structure for update areas of DOM tree.
- ResponseWriter out = context.getResponseWriter();
- // Create <span> element to keep list rendered aread ( in title
- // attribute )
- // More right will create special namespace for such
- // information,
- // but I want to keep simple html ( xhtml ) document - on case
- // I have troubles with microsoft XMLHTTP validations.
- out
- .startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG,
- component);
- out.writeAttribute(HTML.NAME_ATTRIBUTE,
- AjaxContainerRenderer.AJAX_UPDATE_HEADER, null);
- for (Iterator it = rendered.iterator(); it.hasNext();) {
- String id = (String) it.next();
- // out.startElement(AJAX_RESULT_TAG, component);
- // out.writeText(id,null);
- // out.endElement(AJAX_RESULT_TAG);
- senderString.append(id);
- if (it.hasNext()) {
- senderString.append(',');
- }
- }
- out.writeAttribute(AjaxContainerRenderer.AJAX_RESULT_GROUP_ATTR,
- senderString, null);
- out.endElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG);
- // For sequences and client-saved states.
-
- out.startElement(AjaxContainerRenderer.AJAX_VIEW_STATE_TAG, component);
- out.writeAttribute(HTML.id_ATTRIBUTE,
- AjaxContainerRenderer.AJAX_VIEW_STATE_ID, null);
- writeState(context);
- out.endElement(AjaxContainerRenderer.AJAX_VIEW_STATE_TAG);
- // Write rendered flag to html <meta>
- out
- .startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG,
- component);
- out.writeAttribute(HTML.id_ATTRIBUTE,
- AjaxContainerRenderer.AJAX_FLAG_HEADER, null);
- out.writeAttribute(HTML.NAME_ATTRIBUTE,
- AjaxContainerRenderer.AJAX_FLAG_HEADER, null);
- out.writeAttribute(AjaxContainerRenderer.AJAX_RESULT_GROUP_ATTR,
- "true", null);
- out.endElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG);
- // set response header with list of rendered ID's
- Object response = externalContext.getResponse();
- // Use reflection for send responce headers - we can get
- // different responces classes
- // for different environment ( portal, cocoon etc )
- if (response instanceof HttpServletResponse) {
- HttpServletResponse httpResponse = (HttpServletResponse) response;
- httpResponse.setHeader(AjaxContainerRenderer.AJAX_UPDATE_HEADER,
- senderString.toString());
- httpResponse.setHeader(AjaxContainerRenderer.AJAX_FLAG_HEADER,
- "true");
- } else {
- try {
- Method setHeadergMethod = response.getClass()
- .getMethod("setHeader",
- new Class[] { String.class, String.class });
- setHeadergMethod.invoke(response, new Object[] {
- AjaxContainerRenderer.AJAX_UPDATE_HEADER,
- senderString.toString() });
- setHeadergMethod.invoke(response, new Object[] {
- AjaxContainerRenderer.AJAX_FLAG_HEADER, "true" });
- } catch (Exception e) {
- log
- .error(Messages
- .getMessage(Messages.DETECTING_ENCODING_DISABLED_ERROR));
- log.error(Messages.getMessage(
- Messages.OBTAIN_RESPONSE_SET_HEADER_ERROR, e));
- }
- }
- Map responseDataMap = ajaxContext.getResponseDataMap();
- // Get data serializer instance
- AJAXDataSerializer serializer = (AJAXDataSerializer) ServicesUtils
- .getServiceInstance(AJAXDataSerializer.SERVICE);
- // Put data to JavaScript handlers, inside <span> elements.
- for (Iterator dataIterator = responseDataMap.keySet().iterator(); dataIterator
- .hasNext();) {
- Object dataKey = dataIterator.next();
- out.startElement(HTML.SPAN_ELEM, component);
- out.writeAttribute(HTML.id_ATTRIBUTE, dataKey, null);
- String dataString = serializer.asString(responseDataMap
- .get(dataKey));
- out.write(dataString);
- out.endElement(HTML.SPAN_ELEM);
- }
- // For self-rendered case, we use own methods for replace stateKey by
- // real value
- // in XML filter.
- // if(ajaxContext.isSelfRender()){
- // saveViewState(context, out);
- // }
- requestMap.put(AJAX_AREAS_RENDERED, "true");
- }
-
- /**
- * Write state saving markers to context, include MyFaces view sequence.
- *
- * @param context
- * @throws IOException
- */
- public static void writeState(FacesContext context) throws IOException {
- if (!context.getApplication().getStateManager().isSavingStateInClient(
- context)) {
- ResponseWriter writer = context.getResponseWriter();
- // MyFaces-specific view sequence attribute
- writer.startElement(HTML.INPUT_ELEM, null);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE,
- AjaxRendererUtils.SEQUENCE_PARAM, null);
- writer.writeAttribute(HTML.value_ATTRIBUTE, AjaxRendererUtils
- .getViewSequence(context), null);
- writer.endElement(HTML.INPUT_ELEM);
- }
- context.getApplication().getViewHandler().writeState(context);
- }
-
- /**
- * Encode declaration for AJAX response. Render <html><body>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public static void encodeAjaxBegin(FacesContext context,
- UIComponent component) throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
- out.startElement("html", component);
- // TODO - html attributes. lang - from current locale ?
- Locale locale = context.getViewRoot().getLocale();
- out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
- out.startElement("body", component);
- }
-
- /**
- * End encoding of AJAX response. Render tag with included areas and close
- * </body></html>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public static void encodeAjaxEnd(FacesContext context, UIComponent component)
- throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
-
- encodeAreas(context, component);
- out.endElement("body");
- out.endElement("html");
- }
-
- /**
- * Find all instances of {@link UILoadBundle} in view tree and load bundles
- * to request-scope map.
- *
- * @param context
- * @throws IOException
- */
- public static void loadBundles(FacesContext context) {
- // TODO - performanse improove - don't seek by all components tree.
- loadBundles(context, context.getViewRoot());
-
- }
-
- /**
- * Recursive helper for {@link #loadBundles(FacesContext)}
- *
- * @param context
- * @param component
- * @throws IOException
- */
- private static void loadBundles(FacesContext context, UIComponent component) {
- // Iterate over cildrens
- for (Iterator iter = component.getChildren().iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- loadCildBundles(context, child);
- }
- // Iterate over facets
- for (Iterator iter = component.getFacets().values().iterator(); iter
- .hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- loadCildBundles(context, child);
- }
- }
-
- /**
- * @param context
- * @param child
- */
- private static void loadCildBundles(FacesContext context, UIComponent child) {
- if (child instanceof AjaxLoadBundleComponent) {
- try {
- child.encodeBegin(context);
- } catch (IOException e) {
- // DO nothing - really, LoadBundle don't can throw exceptions.
- }
- } else {
- loadBundles(context, child);
- }
- }
-
- /**
- * @param facesContext
- * @return
- */
- public static boolean isAjaxRequest(FacesContext facesContext) {
-
- return AjaxContext.getCurrentInstance(facesContext).isAjaxRequest(facesContext);
- }
-
- /**
- * @param facesContext
- * @param component
- * @param id
- */
- public static void addRegionByName(FacesContext facesContext, UIComponent component, String id) {
-
- AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(component, id);
- }
- /**
- * @param facesContext
- * @param component
- * @param id
- */
- public static void addRegionsFromComponent(UIComponent component, FacesContext facesContext) {
-
- AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(component);
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxViewRootRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxViewRootRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxViewRootRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,108 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import org.ajax4jsf.component.AjaxViewRoot;
-import org.ajax4jsf.resource.InternetResource;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/08 15:02:03 $
- *
- */
-public class AjaxViewRootRenderer extends AjaxContainerRenderer {
-
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.AjaxComponentRendererBase#getScripts()
- */
- protected InternetResource[] getScripts() {
- // TODO Auto-generated method stub
- return null;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.RendererBase#doDecode(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
-// protected void doDecode(FacesContext context, UIComponent component) {
-// AjaxViewRoot root = (AjaxViewRoot) component;
-// if(root.isSubmitted()) {
-// // Find submitted ajax region.
-// String ajaxId = (String) context.getExternalContext().getRequestParameterMap().get(AJAX_PARAMETER_NAME);
-// String ajaxRegion = root.getAjaxRegionId(ajaxId);
-// if(null != ajaxRegion){
-// root.setSubmittedRegion(ajaxRegion);
-// }
-// }
-// }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.AjaxContainerRenderer#getComponentClass()
- */
- protected Class getComponentClass() {
- return AjaxViewRoot.class;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
-// protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
-// UIComponent submittedComponent = ((AjaxViewRoot) component).getSubmittedRegion(context);
-// if (null == submittedComponent) {
-// super.doEncodeEnd(writer,context,component);
-// } else {
-// submittedComponent.encodeEnd(context);
-// }
-// }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
-// protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
-// // Reset instance of submitted region
-// AjaxViewRoot ajaxViewRoot = ((AjaxViewRoot) component);
-// ajaxViewRoot.resetSubmittedRegionInstance();
-// UIComponent submittedComponent = ajaxViewRoot.getSubmittedRegion(context);
-// if (null == submittedComponent) {
-// super.doEncodeBegin(writer, context, component);
-// } else {
-// submittedComponent.encodeBegin(context);
-// }
-// }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKit.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKit.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKit.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,40 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import javax.faces.render.RenderKit;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:55 $
- *
- */
-public interface ChameleonRenderKit {
-
-
-
- /**
- * @param renderKit
- */
- void setDefaultRenderKit(RenderKit renderKit);
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKitFactory.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKitFactory.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKitFactory.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,131 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.util.Iterator;
-
-import javax.faces.FactoryFinder;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.context.FacesContext;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:50 $
- *
- */
-public class ChameleonRenderKitFactory extends RenderKitFactory {
- RenderKitFactory defaultFactory;
-
- // private static final String AJAX_BASE_RENDER_KIT_PARAMETER =
- // "AJAX_BASE_RENDERKIT_ID";
- // private static final String AJAX_RENDER_KIT_PARAMETER =
- // "AJAX_RENDER_KIT_ID";
-
- private static final Log _log = LogFactory
- .getLog(ChameleonRenderKitFactory.class);
-
- /**
- * @param defaultFactory
- */
- public ChameleonRenderKitFactory(RenderKitFactory defaultFactory) {
- if (_log.isDebugEnabled()) {
- _log.debug("ChameleonRenderKitFactory(RenderKitFactory) - Chameleon RenderKit factory instantiated"); //$NON-NLS-1$
- }
- this.defaultFactory = defaultFactory;
- // Init resources builder before use.
- InternetResourceBuilder.getInstance().init();
- }
-
- /**
- * @param renderKitId
- * @param renderKit
- */
- public void addRenderKit(String renderKitId, RenderKit renderKit) {
- if (_log.isDebugEnabled()) {
- _log.debug("addRenderKit(String, RenderKit) - Added RenderKit with id - renderKitId=" + renderKitId); //$NON-NLS-1$
- }
- if (renderKit instanceof ChameleonRenderKit) {
- // ChameleonRenderKit chameleonRenderKit = (ChameleonRenderKit)
- // renderKit;
- // chameleonRenderKit.setConfiguration(ConfigurationFactory.getRendererConfigurationInstance(renderKitId))
- // ;
- }
- defaultFactory.addRenderKit(renderKitId, renderKit);
- }
-
- /**
- * @param context
- * @param renderKitId
- * @return
- */
- public RenderKit getRenderKit(FacesContext context, String renderKitId) {
- RenderKit renderKit = defaultFactory.getRenderKit(context, renderKitId);
- if (renderKit instanceof ChameleonRenderKit) {
- if (_log.isDebugEnabled()) {
- _log.debug(Messages
- .getMessage(Messages.REQUEST_CHAMELEON_RENDER_KIT_INFO,
- renderKitId));
- }
- String baseRenderKitId = null;
- // TODO - get DefaultRenderKitId from ViewHandler ?
- try {
- // IN JSF-RI verifications, context may be null !
- if (null != context) {
- baseRenderKitId = context.getApplication()
- .getDefaultRenderKitId();
- } else {
- ApplicationFactory appFactory = (ApplicationFactory) FactoryFinder
- .getFactory(FactoryFinder.APPLICATION_FACTORY);
- baseRenderKitId = appFactory.getApplication()
- .getDefaultRenderKitId();
- }
- } catch (Exception e) {
- _log.warn(Messages
- .getMessage(Messages.GET_DEFAULT_RENDER_KIT_ERROR), e);
- }
- if (baseRenderKitId == null) {
- baseRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
- }
- if (_log.isDebugEnabled()) {
- _log.debug(Messages.getMessage(
- Messages.DEFAULT_RENDER_KIT_INFO, baseRenderKitId));
- }
- ((ChameleonRenderKit) renderKit).setDefaultRenderKit(defaultFactory
- .getRenderKit(context, baseRenderKitId));
- }
- return renderKit;
- }
-
- /**
- * @return
- */
- public Iterator getRenderKitIds() {
- return defaultFactory.getRenderKitIds();
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKitImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKitImpl.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKitImpl.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,163 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.FactoryFinder;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseStream;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import javax.faces.render.Renderer;
-import javax.faces.render.ResponseStateManager;
-
-/**
- * Wrapper for default applikation render kit. Only can append any
- * custom renderers , all other methods delegate to default render kit.
- *
- * @see javax.faces.render.RenderKit
- * @author shura
- *
- */
-public class ChameleonRenderKitImpl extends RenderKit implements ChameleonRenderKit {
-
- private RenderKit defaultRenderKit = null;
- public static final String RENDER_KIT_ID = "AJAX_HTML_BASIC";
-
- private Map renderers;
-
-
- //~ Constructors -------------------------------------------------------------------------------
-
- public ChameleonRenderKitImpl()
- {
- renderers = new HashMap();
- }
-
- //~ Methods ------------------------------------------------------------------------------------
-
- private String key(String componentFamily, String rendererType)
- {
- return componentFamily + "." + rendererType;
- }
- /**
- * @param family
- * @param rendererType
- * @param renderer
- */
- public void addRenderer(String family, String rendererType,
- Renderer renderer) {
- if (renderer instanceof ChameleonRenderer) {
- ChameleonRenderer chameleonRenderer = (ChameleonRenderer) renderer;
-// chameleonRenderer.setConfiguration(getConfiguration().getRendererConfiguration(family,rendererType));
-
- }
- renderers.put(key(family, rendererType), renderer);
- }
- /**
- * @param writer
- * @param contentTypeList
- * @param characterEncoding
- * @return
- */
- public ResponseWriter createResponseWriter(Writer writer,
- String contentTypeList, String characterEncoding) {
- return getDefaultRenderKit().createResponseWriter(writer, contentTypeList,
- characterEncoding);
- }
- /**
- * @param family
- * @param rendererType
- * @return
- */
- public Renderer getRenderer(String family, String rendererType) {
- Renderer renderer = (Renderer) renderers.get(key(family, rendererType));
- if (renderer != null) {
- return renderer;
- }
- return getDefaultRenderKit().getRenderer(family, rendererType);
- }
- /**
- * @return
- */
- public ResponseStateManager getResponseStateManager() {
- return getDefaultRenderKit().getResponseStateManager();
- }
-
-
- /* (non-Javadoc)
- * @see javax.faces.render.RenderKit#createResponseStream(java.io.OutputStream)
- */
- public ResponseStream createResponseStream(OutputStream out)
- {
- return getDefaultRenderKit().createResponseStream(out);
- }
-
- /**
- * TODO - create own implementation for @see javax.faces.component.UIViewRoot ,
- * and get default renderKitId as value, setted at creation time.
- * in this case, we can substitute concrete renderKit even if it pointed
- * as value for <f:view> tag on 1.2 specification.
- * @return Returns the defaultRenderer.
- */
- protected RenderKit getDefaultRenderKit() {
- if (defaultRenderKit == null)
- {
- String defaultRenderkitId = null;
- FacesContext context = null;
- RenderKitFactory rdf = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- try {
- context = FacesContext.getCurrentInstance();
- // IN JSF-RI verifications, context may be null !
- if(null != context) {
- defaultRenderkitId = context.getApplication()
- .getDefaultRenderKitId();
- } else {
- ApplicationFactory appFactory =(ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
- defaultRenderkitId = appFactory.getApplication().getDefaultRenderKitId();
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- if(defaultRenderkitId == null ){
- defaultRenderkitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
- }
- defaultRenderKit = rdf.getRenderKit(context, defaultRenderkitId);
-
- }
-
- return defaultRenderKit;
- }
-
- public void setDefaultRenderKit(RenderKit renderKit) {
- // TODO Auto-generated method stub
- this.defaultRenderKit = renderKit;
-
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,37 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import org.ajax4jsf.resource.ResourceProduser;
-
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:50 $
- *
- */
-public interface ChameleonRenderer extends ResourceProduser{
-
-
-
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,108 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.util.HashMap;
-import java.util.Stack;
-
-import javax.faces.component.UIComponent;
-
-
-
-/**
- * Components Base Renderer for all chameleon Skin's and components.
- * At most, make all common procedures and realise concrete work in "template" methods.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:52 $
- *
- */
-public abstract class ComponentRendererBase extends RendererBase{
-
- /**
- * logger for common cases.
- */
- protected static final String COMPONENT_RENDERER_BASE = ComponentRendererBase.class.getName();
-
-
- public ComponentVariables getVariables(UIComponent component) {
- HashMap components;
- Stack stackComponentsVariables;
- ComponentVariables variables;
-
-
-
- components = (HashMap)component.getAttributes().get( COMPONENT_RENDERER_BASE );
-
- if ( components == null ) {
- components = new HashMap();
- component.getAttributes().put( COMPONENT_RENDERER_BASE, components );
- }
-
- stackComponentsVariables = (Stack)components.get( this.getClass().getName() );
-
- if ( stackComponentsVariables == null ) {
- stackComponentsVariables = new Stack();
- components.put( COMPONENT_RENDERER_BASE, stackComponentsVariables );
- }
-
- if ( stackComponentsVariables.empty() ) {
- variables = new ComponentVariables();
- stackComponentsVariables.push( variables );
- } else {
- variables = (ComponentVariables)stackComponentsVariables.peek();
- }
-
- return variables;
- }
-
- public void removeVariables(UIComponent component) {
- HashMap components;
- Stack stackComponentsVariables;
- ComponentVariables variables;
-
-
-
- components = (HashMap)component.getAttributes().get( COMPONENT_RENDERER_BASE );
-
- if ( components != null ) {
-
- stackComponentsVariables = (Stack)component.getAttributes().get( this.getClass().getName() );
-
- if ( stackComponentsVariables != null ) {
- if ( !stackComponentsVariables.empty() ) {
- stackComponentsVariables.pop();
- }
-
- if ( stackComponentsVariables.empty() ) {
- components.remove( this.getClass().getName() );
- }
- }
-
- if ( components.isEmpty() ) {
- component.getAttributes().remove( COMPONENT_RENDERER_BASE );
- }
-
-
- }
-
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentUtils.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentUtils.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,134 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.MethodNotFoundException;
-
-import org.ajax4jsf.Messages;
-import org.apache.commons.beanutils.MethodUtils;
-
-/**
- * Utils for working with tempates
- * @author ayukhovich(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:52 $
- */
-public class ComponentUtils {
- private final static String UTILS_PREFIX = "util.";
- /**
- *
- * @param className
- * @param functionName
- * @param parameters
- * @return
- */
- public static Object callFunction( FacesContext context, UIComponent component, RendererBase renderer, String functionName, Object[] parameters ) {
-
- Object returnObject = null;
-
- int sizeParameters = 0;
- int sizeArrayParameters = 2;
- if ( parameters != null ) {
- sizeParameters = parameters.length;
- sizeArrayParameters = 3;
- }
-
- Object[][] arrayParameters = new Object[sizeArrayParameters][];
- arrayParameters[0] = new Object[sizeParameters+2];
- arrayParameters[1] = new Object[sizeParameters+1];
-
- if ( sizeParameters != 0 ) {
- arrayParameters[2] = new Object[sizeParameters];
- }
-
- arrayParameters[0][0] = context;
- arrayParameters[0][1] = component;
- arrayParameters[1][0] = component;
-
- if ( parameters != null ) {
- for (int iParameter=0;iParameter<parameters.length;iParameter++) {
- arrayParameters[0][iParameter+2] = parameters;
- arrayParameters[1][iParameter+1] = parameters;
- arrayParameters[2][iParameter] = parameters;
- }
- }
-
- String methodName;
- Object object;
- if(functionName.startsWith(UTILS_PREFIX)){
- methodName = functionName.substring(UTILS_PREFIX.length());
- object = renderer.getUtils();
- } else {
- object = renderer;
- methodName = functionName;
- }
-
-
- returnObject = invokeMethod(object, methodName, arrayParameters );
-
- return returnObject;
- }
-
- /**
- * Invoke a named method whose parameter type matches the object type.
- * @param objects - invoke method on this object
- * @param methodName - get method with this name
- * @param arrayParameters - use these arguments - treat null as empty array
- * @return
- */
- private static Object invokeMethod(Object object, String methodName, Object[][] arrayParameters) {
-
- try {
- for (int iParameter = 0; iParameter < arrayParameters.length; iParameter++) {
- try {
- return MethodUtils.invokeMethod(object, methodName, arrayParameters[iParameter]);
- } catch (NoSuchMethodException e) {
- continue;
- }
- }
- } catch (InvocationTargetException e) {
- throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_2b, methodName, e.getCause().getMessage()), e);
- } catch (IllegalAccessException e) {
- throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_4b, methodName, e.getMessage()), e);
- }
- throw new MethodNotFoundException(Messages.getMessage(Messages.METHOD_CALL_ERROR_6b, methodName, object));
- }
-
- /**
- * Write html-attribute
- * @param writer
- * @param attribute
- * @param value
- * @throws IOException
- */
- public static void writeAttribute(ResponseWriter writer, String attribute, Object value ) throws IOException {
- if ( (value != null) && (value.toString().length()!=0) ) {
- writer.writeAttribute(attribute, value.toString(), attribute );
- }
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentVariables.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentVariables.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentVariables.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,93 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.HashMap;
-
-/**
- * storing tempates variables
- * @author ayukhovich(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/28 17:01:01 $
- */
-public class ComponentVariables implements Serializable {
-
- private transient HashMap variablesMap = new HashMap();
-
- /**
- * setting variable
- * @param variableName
- * @param variable
- */
- public void setVariable(final String variableName, final Object variable ) {
- variablesMap.put(variableName, variable);
- }
-
- /**
- *
- * @param variableName
- * @return
- */
- public Object getVariable(final String variableName ) {
- return variablesMap.get(variableName);
- }
-
-
- /**
- *
- * @param variableName
- * @param addValue
- */
- public void addValueToVariable(final String variableName, final Object addValue) {
- Object variable = getVariable(variableName);
- if ( variable == null )
- return;
-
- if (variable instanceof Integer) {
- addToValue( variableName,(Integer) variable, addValue);
- }
- }
-
- /**
- *
- * @param variableName
- * @param variable
- * @param addValue
- */
- protected void addToValue(final String variableName, Integer variable, final Object addValue ) {
- Integer retultValue;
- if ( addValue instanceof Integer ) {
- Integer intAddValue =(Integer)addValue;
- retultValue = new Integer(variable.intValue() + intAddValue.intValue());
- } else {
- retultValue = variable;
- }
-
- setVariable(variableName, retultValue);
- }
-
- private void readObject(java.io.ObjectInputStream in)
- throws IOException, ClassNotFoundException{
- variablesMap = new HashMap();
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentsVariableResolver.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentsVariableResolver.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentsVariableResolver.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,62 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import javax.faces.component.UIComponent;
-
-/**
- * Resolve component variables
- *
- * @author ayukhovich(a)exadel.com (latest modification by $Author:
- * alexeyyukhovich $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:53 $
- */
-public class ComponentsVariableResolver {
- private static String COMPONENTS_VARIABLE_RESOLVER = ComponentsVariableResolver.class
- .getName();
-
- private static String getAttributeName(RendererBase renderer) {
- return COMPONENTS_VARIABLE_RESOLVER + ":" + (renderer != null ? renderer.getClass().getName() : null);
- }
-
- public static ComponentVariables getVariables(RendererBase renderer,
- UIComponent component) {
- ComponentVariables variables;
-
- String attributeName = getAttributeName(renderer);
-
- variables = (ComponentVariables) component.getAttributes().get(attributeName);
-
- if (variables == null) {
- variables = new ComponentVariables();
-
- component.getAttributes().put(attributeName, variables);
- }
-
- return variables;
- }
-
- public static void removeVariables(RendererBase renderer,
- UIComponent component) {
- component.getAttributes().remove(getAttributeName(renderer));
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourcesRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourcesRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourcesRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,137 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.util.LinkedHashSet;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.renderkit.HeaderResourceProducer;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.webapp.BaseFilter;
-
-/**
- * Base renderer for components used JavaScripts and Styles in header. In real
- * class override getScripts or/and getStyles methods
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:51 $
- *
- */
-public abstract class HeaderResourcesRendererBase extends RendererBase
- implements HeaderResourceProducer {
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderScripts(javax.faces.context.FacesContext)
- */
- public LinkedHashSet getHeaderScripts(FacesContext context,
- UIComponent component) {
- return getUrisSet(context, getScripts(), component);
- }
-
- /**
- * Hoock method to return array of scripts resources to store in head.
- *
- * @return
- */
- protected InternetResource[] getScripts() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderStyles(javax.faces.context.FacesContext)
- */
- public LinkedHashSet getHeaderStyles(FacesContext context,
- UIComponent component) {
- return getUrisSet(context, getStyles(), component);
- }
-
- /**
- * Hoock method to return array of styles resources to store in head
- *
- * @return
- */
- protected InternetResource[] getStyles() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * @param context
- * @param resources
- * @param component
- * TODO
- * @return
- */
- private LinkedHashSet getUrisSet(FacesContext context,
- InternetResource[] resources, UIComponent component) {
- if (null != resources) {
- LinkedHashSet uris = new LinkedHashSet(); // Collections.singleton(ajaxScript.getUri(context,
- // null));
- for (int i = 0; i < resources.length; i++) {
- InternetResource resource = resources[i];
- uris.add(resource.getUri(context, component));
- }
- return uris;
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.RendererBase#preEncodeBegin(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- protected void preEncodeBegin(FacesContext context, UIComponent component)
- throws IOException {
- if ((null == context.getExternalContext().getRequestMap().get(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE))
- /*&& (!AjaxRendererUtils.isAjaxRequest(context))*/) {
- // Filter not used - encode scripts and CSS before component.
- encodeResourcesArray(context, component, getScripts());
- encodeResourcesArray(context, component, getStyles());
- }
- }
-
- /**
- * @param context
- * @param component
- * @param scripts
- * @throws IOException
- */
- protected void encodeResourcesArray(FacesContext context, UIComponent component, InternetResource[] scripts) throws IOException {
- if (scripts != null) {
- for (int i = 0; i < scripts.length; i++) {
- scripts[i].encode(context,component);
- }
- }
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,66 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.util.LinkedHashSet;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.renderkit.HeaderResourceProducer;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.PrototypeScript;
-
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public abstract class PrototypeBasedRendererBase extends RendererBase implements HeaderResourceProducer{
-
- protected static final String[] EMPTY_ARRAY = {};
- private InternetResource prototypeScript = getResource(PrototypeScript.class.getName());
-
- public LinkedHashSet getHeaderScripts(FacesContext context, UIComponent component) {
- LinkedHashSet scripts = new LinkedHashSet() ; // Collections.singleton(ajaxScript.getUri(context, null));
- scripts.add(prototypeScript.getUri(context, null));
- String[] additionalScripts = getAdditionalScripts();
- for (int i = 0; i < additionalScripts.length; i++) {
- String resource = additionalScripts[i];
- scripts.add(getResource(resource).getUri(context, null));
- }
- return scripts;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderStyles(javax.faces.context.FacesContext)
- */
- public LinkedHashSet getHeaderStyles(FacesContext context, UIComponent component) {
- // TODO Auto-generated method stub
- return null;
- }
-
- protected String[] getAdditionalScripts() {
- return EMPTY_ARRAY;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,289 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-
-/**
- * Base Renderer for all chameleon Skin's and components.
- * At most, make all common procedures and realise concrete work in "template" methods.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:51 $
- *
- */
-public abstract class RendererBase extends Renderer implements
- ChameleonRenderer {
-
- /**
- * logger for common cases.
- */
- protected static final String JAVASCRIPT_NAMESPACE = "Exadel";
- private static final Log log = LogFactory.getLog(RendererBase.class);
- private static final RendererUtils utils = new RendererUtils();
-
- private SkinFactory skinFactory = null;
- private InternetResourceBuilder resourceBuilder = null;
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void decode(FacesContext context, UIComponent component) {
- // Test for correct parameters.
- if (context == null) throw new NullPointerException(Messages.getMessage(Messages.CONTEXT_NULL_ERROR, "decode"));
- if (component == null) throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR, "decode"));
- if (! getComponentClass().isInstance(component)) throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, "", getComponentClass().getName()));
- if(log.isDebugEnabled()){
- log.debug(Messages.getMessage(Messages.START_DECODING_COMPONENT_INFO, component.getClientId(context), component.getClass().getName()));
- }
- preDecode(context,component);
- // TODO - create set od common decoders ( UIInput, ActionSource etc. ) for process decoding.
- if (component.isRendered()) {
- doDecode(context, component);
- }
- }
-
- protected void preDecode(FacesContext context, UIComponent component) {
- }
-
- protected void preEncodeBegin(FacesContext context, UIComponent component) throws IOException {
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
- // Test for correct parameters.
- if (context == null) throw new NullPointerException(Messages.getMessage(Messages.CONTEXT_NULL_ERROR, "encodeBegin"));
- if (component == null) throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR, "encodeBegin"));
- if (! getComponentClass().isInstance(component)) throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, component.getClientId(context), getComponentClass().getName()));
- if(log.isDebugEnabled()){
- log.debug(Messages.getMessage(Messages.START_ENCODING_COMPONENT_INFO, component.getClientId(context), component.getClass().getName()));
- }
- preEncodeBegin(context,component);
- if (component.isRendered()) {
- ResponseWriter writer = context.getResponseWriter();
- doEncodeBegin(writer, context, component);
- }
- }
-
-
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- // Test for correct parameters.
- if (context == null) throw new NullPointerException(Messages.getMessage(Messages.CONTEXT_NULL_ERROR, "encodeBegin"));
- if (component == null) throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR, "encodeBegin"));
- if (! getComponentClass().isInstance(component)) throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, component.getClientId(context), getComponentClass().getName()));
- if(log.isDebugEnabled()){
- log.debug(Messages.getMessage(Messages.CHILDREN_ENCODING_COMPONENT_INFO, component.getClientId(context), component.getClass().getName()));
- }
- preEncodeBegin(context,component);
- if (component.isRendered()) {
- ResponseWriter writer = context.getResponseWriter();
- doEncodeChildren(writer, context, component);
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
- // Test for correct parameters.
- if (context == null) throw new NullPointerException(Messages.getMessage(Messages.CONTEXT_NULL_ERROR, "encodeEnd"));
- if (component == null) throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR, "encodeEnd"));
- if (! getComponentClass().isInstance(component)) throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, component.getClientId(context), getComponentClass().getName()));
- if (component.isRendered()) {
- ResponseWriter writer = context.getResponseWriter();
- doEncodeEnd(writer, context, component);
- }
- if(log.isDebugEnabled()){
- log.debug(Messages.getMessage(Messages.FINISH_ENCODING_COMPONENT_INFO, component.getClientId(context), component.getClass().getName()));
- }
- }
-
- /**
- * Base stub method for produce internet resource ( image, script ... )
- * since resources must be implemented in "lightweight" pattern, it instances
- * put in internal map to caching.
- * @param resourceURI - relative ( to renderer class ) uri to resource in jar or
- * key for generate ( in Java2D , for example ).
- * @return - resource instance for this uri.
- * @throws ResourceNotFoundException - if reqested resource not instantiated.
- */
- public InternetResource getResource(String resourceURI ) throws FacesException {
- return getResourceBuilder().createResource(this,resourceURI);
- }
-
- private InternetResourceBuilder getResourceBuilder(){
- if (resourceBuilder == null) {
- resourceBuilder = InternetResourceBuilder.getInstance();
-
- }
-
- return resourceBuilder;
- }
- //==========================================================
- // Protected common methods - for all Renderer's
-
- /**
- * Calculate current Skin for rendering.
- * @param context - current {@link FacesContext }
- * @return
- */
- protected Skin getSkin(FacesContext context) {
- if (skinFactory == null) {
- skinFactory = SkinFactory.getInstance();
-
- }
-
- return skinFactory.getSkin(context);
- }
-
-
- /**
- * Due to big number of common utility methods, base renderer divide to 2 classes - renderer and utils.
- * since use static methods of utility class breack object paradigm, we use getter for concrete util instance.
- * Developer can override any utility metod in 2 stages :
- * 1) Create subclass of {@link RendererUtils} and override utility method.
- * 2) Override this method for return instance of such subclass.
- *
- * @return Returns the utils.
- */
- public RendererUtils getUtils() {
- return utils;
- }
-
-
- /**
- * Get base component slass , targetted for this renderer. Used for check arguments in decode/encode.
- * @return
- */
- protected abstract Class getComponentClass();
-
-
- /**
- * Template method for custom decoding of concrete renderer.
- * All parameters checking if performed in original {@see decode } method.
- * @param context
- * @param component
- */
- protected void doDecode(FacesContext context, UIComponent component) {
-
- }
-
- /**
- * Template method for custom start encoding of concrete renderer.
- * All parameters checking and writer is performed in original {@link encodeBegin } method.
- * @param writer
- * @param context
- * @param component
- */
- protected void doEncodeBegin(ResponseWriter writer,FacesContext context, UIComponent component) throws IOException {
-
- }
- /**
- * @param writer
- * @param context
- * @param component
- */
- protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- // Hook method, must be overriden in renderers with special children processing
- }
-
- /**
- * Template method for custom finish encoding of concrete renderer.
- * All parameters checking and writer is performed in original {@link encodeEnd } method.
- * @param writer
- * @param context
- * @param component
- * @throws IOException
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
-
- }
- /**
- * Append new resource to renderer cache.
- * @param key
- * @param resource
- */
- protected void addResource(String key, InternetResource resource) {
- getResourceBuilder().addResource(key,resource);
- }
-
- /**
- * Render all children for given component.
- * @param facesContext
- * @param component
- * @throws IOException
- */
- public void renderChildren(FacesContext facesContext,
- UIComponent component) throws IOException {
- if (component.getChildCount() > 0) {
- for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
- renderChild(facesContext, child);
- }
- }
- }
-
-
- /**
- * Render one component and it childrens
- * @param facesContext
- * @param child
- * @throws IOException
- */
- public void renderChild(FacesContext facesContext, UIComponent child)
- throws IOException {
- if (!child.isRendered()) {
- return;
- }
-
- child.encodeBegin(facesContext);
- if (child.getRendersChildren()) {
- child.encodeChildren(facesContext);
- } else {
- renderChildren(facesContext, child);
- }
- child.encodeEnd(facesContext);
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -1,803 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.awt.Dimension;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.faces.application.ViewHandler;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIViewRoot;
-import javax.faces.component.ValueHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.convert.Converter;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
-import org.ajax4jsf.framework.util.HtmlDimensions;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.Java2Dresource;
-
-
-/**
- * Util class for common render operations - render passthru html attributes,
- * iterate over child components etc.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
- *
- */
-public class RendererUtils {
-
- public static final String DUMMY_FORM_ID = ":_form";
- /**
- * Substitutions for components properies names and HTML attributes names.
- */
- private static Map substitutions = new HashMap();
-
- static {
- substitutions.put(HTML.class_ATTRIBUTE,"styleClass");
- Arrays.sort(HTML.PASS_THRU);
- Arrays.sort(HTML.PASS_THRU_BOOLEAN);
- Arrays.sort(HTML.PASS_THRU_URI);
- }
- /**
- * Common HTML elements and attributes names.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
- *
- */
- public interface HTML {
- // elements
- public static final String BUTTON = "button";
- // attributes
- public static final String id_ATTRIBUTE = "id";
- public static final String class_ATTRIBUTE = "class";
-// public static final String STYLE_ATTRIBUTE = "style";
-// public static final String dir_ATTRIBUTE = "dir";
-// public static final String lang_ATTRIBUTE = "lang";
-// public static final String title_ATTRIBUTE = "title";
- public static final String accesskey_ATTRIBUTE = "accesskey";
- public static final String alt_ATTRIBUTE = "alt";
- public static final String cols_ATTRIBUTE = "cols";
-
- public static final String height_ATTRIBUTE = "height";
-
- public static final String lang_ATTRIBUTE = "lang";
-
- public static final String longdesc_ATTRIBUTE = "longdesc";
-
- public static final String maxlength_ATTRIBUTE = "maxlength";
-
- public static final String onblur_ATTRIBUTE = "onblur";
-
- public static final String onchange_ATTRIBUTE = "onchange";
-
- public static final String onclick_ATTRIBUTE = "onclick";
-
- public static final String ondblclick_ATTRIBUTE = "ondblclick";
-
- public static final String onfocus_ATTRIBUTE = "onfocus";
-
- public static final String onkeydown_ATTRIBUTE = "onkeydown";
-
- public static final String onkeypress_ATTRIBUTE = "onkeypress";
-
- public static final String onkeyup_ATTRIBUTE = "onkeyup";
-
- public static final String onload_ATTRIBUTE = "onload";
-
- public static final String onmousedown_ATTRIBUTE = "onmousedown";
-
- public static final String onmousemove_ATTRIBUTE = "onmousemove";
-
- public static final String onmouseout_ATTRIBUTE = "onmouseout";
-
- public static final String onmouseover_ATTRIBUTE = "onmouseover";
-
- public static final String onmouseup_ATTRIBUTE = "onmouseup";
-
- public static final String onreset_ATTRIBUTE = "onreset";
-
- public static final String onselect_ATTRIBUTE = "onselect";
-
- // public static final String onsubmit_ATTRIBUTE = "onsubmit";
- public static final String onunload_ATTRIBUTE = "onunload";
-
- public static final String rows_ATTRIBUTE = "rows";
-
- public static final String size_ATTRIBUTE = "size";
-
- public static final String tabindex_ATTRIBUTE = "tabindex";
-
- public static final String title_ATTRIBUTE = "title";
-
- public static final String style_ATTRIBUTE = "style";
-
- public static final String align_ATTRIBUTE = "align";
-
- public static final String width_ATTRIBUTE = "width";
-
- public static final String dir_ATTRIBUTE = "dir";
-
- public static final String rules_ATTRIBUTE = "rules";
-
- public static final String frame_ATTRIBUTE = "frame";
-
- public static final String border_ATTRIBUTE = "border";
-
- public static final String cellspacing_ATTRIBUTE = "cellspacing";
-
- public static final String cellpadding_ATTRIBUTE = "cellpadding";
-
- public static final String summary_ATTRIBUTE = "summary";
-
- public static final String bgcolor_ATTRIBUTE = "bgcolor";
-
- public static final String usemap_ATTRIBUTE = "usemap";
-
- public static final String enctype_ATTRIBUTE = "enctype";
-
- public static final String accept_charset_ATTRIBUTE = "accept-charset";
-
- public static final String accept_ATTRIBUTE = "accept";
-
- public static final String target_ATTRIBUTE = "target";
-
- public static final String onsubmit_ATTRIBUTE = "onsubmit";
-
- public static final String readonly_ATTRIBUTE = "readonly";
-
- public static final String nowrap_ATTRIBUTE = "nowrap";
-
- //public static final String onreset_ATTRIBUTE = "onreset";
- // attributes sets.
- public static final String[] PASS_THRU = {
-// DIR_ATTRIBUTE,
-// LANG_ATTRIBUTE,
-// STYLE_ATTRIBUTE,
-// TITLE_ATTRIBUTE
- "accesskey",
- "alt",
- "cols",
- "height",
- "lang",
- "longdesc",
- "maxlength",
- "onblur",
- "onchange",
- "onclick",
- "ondblclick",
- "onfocus",
- "onkeydown",
- "onkeypress",
- "onkeyup",
- "onload",
- "onmousedown",
- "onmousemove",
- "onmouseout",
- "onmouseover",
- "onmouseup",
- "onreset",
- "onselect",
- "onsubmit",
- "onunload",
- "rows",
- "size",
- "tabindex",
- "title",
- "width",
- "dir",
- "rules",
- "frame",
- "border",
- "cellspacing",
- "cellpadding",
- "summary",
- "bgcolor",
- "usemap",
- "enctype",
- "accept-charset",
- "accept",
- "target",
- "charset",
- "coords",
- "hreflang",
- "rel",
- "rev",
- "shape",
- "disabled",
- "readonly",
- "ismap"
-
- };
-
- /**
- * HTML attributes allowed boolean-values only
- */
- public static final String[] PASS_THRU_BOOLEAN = {
- "disabled",
- "declare",
- "readonly",
- "compact",
- "ismap",
- "selected",
- "checked",
- "nowrap",
- "noresize",
- "nohref",
- "noshade",
- "multiple"
- };
-
-
- /**
- * all HTML attributes with URI value.
- */
- public static final String[] PASS_THRU_URI = {
- "usemap",
- "background",
- "codebase",
- "cite",
- "data",
- "classid",
- "href",
- "longdesc",
- "profile",
- "src"
- };
-
- public static final String[] PASS_THRU_STYLES = {
- "style",
- "class",
- };
-
- public static final String SPAN_ELEM = "span";
- public static final String DIV_ELEM = "div";
- public static final String SCRIPT_ELEM = "script";
- public static final String STYLE_CLASS_ATTR = "styleClass";
- public static final String DISABLED_ATTR = "disabled";
- public static final String TYPE_ATTR = "type";
- public static final String CHARSET_ATTR = "charset";
- public static final String COORDS_ATTR = "coords";
- public static final String HREFLANG_ATTR = "hreflang";
- public static final String REL_ATTR = "rel";
- public static final String REV_ATTR = "rev";
- public static final String SHAPE_ATTR = "shape";
- public static final String title_ELEM = "title";
- public static final String FORM_ELEMENT = "form";
- public static final String NAME_ATTRIBUTE = "name";
- public static final String METHOD_ATTRIBUTE = "method";
- public static final String ACTION_ATTRIBUTE = "action";
- public static final String INPUT_ELEM = "input";
- public static final Object INPUT_TYPE_HIDDEN = "hidden";
- public static final String value_ATTRIBUTE = "value";
- public static final String td_ELEM = "td";
- public static final String th_ELEM = "th";
- public static final String valign_ATTRIBUTE = "valign";
- public static final String a_ELEMENT = "a";
- public static final String HTML_ELEMENT = "html";
- public static final String BODY_ELEMENT = "body";
- public static final String TR_ELEMENT = "tr";
- public static final String CAPTION_ELEMENT = "caption";
- public static final String THEAD_ELEMENT = "thead";
- public static final String TFOOT_ELEMENT = "tfoot";
- }
-
- /**
- * Encode id attribute with clientId component property
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeId(FacesContext context, UIComponent component) throws IOException {
- encodeId(context,component,HTML.id_ATTRIBUTE);
- }
-
- /**
- * Encode clientId to custom attribute ( for example, to control name )
- * @param context
- * @param component
- * @param attribute
- * @throws IOException
- */
- public void encodeId(FacesContext context,UIComponent component, String attribute) throws IOException {
- String clientId = null;
- try {
- clientId = component.getClientId(context);
- } catch(Exception e) {
- //just ignore if clientId wasn't inited yet
- }
- if (null != clientId) {
- context.getResponseWriter().writeAttribute(attribute,
- clientId,
- (String) getComponentAttributeName(attribute));
- }
- }
- /**
- * Encode id attribute with clientId component property.
- * Encoded only if id not auto generated.
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeCustomId(FacesContext context, UIComponent component) throws IOException {
- if(component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)){
- context.getResponseWriter().writeAttribute(HTML.id_ATTRIBUTE,component.getClientId(context),HTML.id_ATTRIBUTE);
- }
- }
-
- /**
- * Encode common pass-thru html attributes.
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodePassThru(FacesContext context, UIComponent component) throws IOException {
- encodeAttributesFromArray(context,component,HTML.PASS_THRU);
- }
-
- /**
- * Encode pass-through attributes except specified ones
- * @param context
- * @param component
- * @param exclusions
- * @throws IOException
- */
- public void encodePassThruWithExclusions(FacesContext context, UIComponent component,String exclusions) throws IOException{
- if (null != exclusions) {
- String[] exclusionsArray = exclusions.split(",");
- encodePassThruWithExclusionsArray(context,component,exclusionsArray);
- }
- }
-
- public void encodePassThruWithExclusionsArray(FacesContext context, UIComponent component,String[] exclusions) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- Map attributes = component.getAttributes();
- Arrays.sort(exclusions);
- for (int i = 0; i < HTML.PASS_THRU.length; i++) {
- String attribute = HTML.PASS_THRU[i];
- if(Arrays.binarySearch(exclusions, attribute) < 0){
- encodePassThruAttribute(context, attributes, writer, attribute);
- }
- }
- }
-
- /**
- * Encode one pass-thru attribute, with plain/boolean/url value, got from properly component attribute.
- * @param context
- * @param component
- * @param writer
- * @param attribute
- * @throws IOException
- */
- public void encodePassThruAttribute(FacesContext context, Map attributes, ResponseWriter writer, String attribute) throws IOException {
- Object value = attributeValue(attribute,attributes.get(getComponentAttributeName(attribute)));
- if (null != value && shouldRenderAttribute(value)) {
- if(Arrays.binarySearch(HTML.PASS_THRU_URI, attribute)>=0){
- String url = context.getApplication().getViewHandler().getResourceURL(context, value.toString());
- url = context.getExternalContext().encodeResourceURL(url);
- writer.writeURIAttribute(attribute,url,attribute);
- } else {
- writer.writeAttribute(attribute,value,attribute);
- }
- }
- }
-
-
- public void encodeAttributesFromArray(FacesContext context, UIComponent component,String[] attrs) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- Map attributes = component.getAttributes();
- for (int i = 0; i < attrs.length; i++) {
- String attribute = attrs[i];
- encodePassThruAttribute(context, attributes, writer, attribute);
- }
- }
-
-
- /**
- * Encode attributes given by comma-separated string list.
- * @param context current JSF context
- * @param component for with render attributes values
- * @param attrs comma separated list of attributes
- * @throws IOException
- */
- public void encodeAttributes(FacesContext context, UIComponent component,String attrs) throws IOException {
- if (null != attrs) {
- String[] attrsArray = attrs.split(",");
- encodeAttributesFromArray(context,component,attrsArray);
- }
- }
- /**
- * @param context
- * @param component
- * @param string
- * @param string2
- * @throws IOException
- */
- public void encodeAttribute(FacesContext context, UIComponent component, Object property, String attributeName) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- Object value = component.getAttributes().get(property);
- if (shouldRenderAttribute(value)) {
- writer.writeAttribute(attributeName,value,property.toString());
- }
-
- }
-
- public void encodeAttribute(FacesContext context, UIComponent component,String attribute) throws IOException {
- encodeAttribute(context,component,getComponentAttributeName(attribute),attribute);
- }
- /**
- * Write html-attribute
- * @param writer
- * @param attribute
- * @param value
- * @throws IOException
- */
- public void writeAttribute(ResponseWriter writer, String attribute, Object value ) throws IOException {
- if ( shouldRenderAttribute(value) ) {
- writer.writeAttribute(attribute, value.toString(), attribute );
- }
- }
-
- /**
- * @return true if and only if the argument
- * <code>attributeVal</code> is an instance of a wrapper for a
- * primitive type and its value is equal to the default value for
- * that type as given in the spec.
- */
-
- public boolean shouldRenderAttribute(Object attributeVal) {
- if(null == attributeVal){
- return false;
- } else if (attributeVal instanceof Boolean &&
- ((Boolean) attributeVal).booleanValue() ==
- Boolean.FALSE.booleanValue()) {
- return false;
- } else if(attributeVal.toString().length() == 0){
- return false;
- } else return isValidProperty(attributeVal);
- }
-
-
- /**
- * Test for valid value of property. by default, for non-setted properties with Java primitive types of
- * JSF component return appropriate MIN_VALUE .
- * @param property - value of property returned from {@link UIComponent#getAttributes()}
- * @return true for setted property, false otherthise.
- */
- public boolean isValidProperty(Object property) {
- if (null == property) {
- return false;
- } else if (property instanceof Integer
- && ((Integer) property).intValue() == Integer.MIN_VALUE) {
- return false;
- } else if (property instanceof Double
- && ((Double) property).doubleValue() == Double.MIN_VALUE) {
- return false;
- } else if (property instanceof Character
- && ((Character) property).charValue() == Character.MIN_VALUE) {
- return false;
- } else if (property instanceof Float
- && ((Float) property).floatValue() == Float.MIN_VALUE) {
- return false;
- } else if (property instanceof Short
- && ((Short) property).shortValue() == Short.MIN_VALUE) {
- return false;
- } else if (property instanceof Byte
- && ((Byte) property).byteValue() == Byte.MIN_VALUE) {
- return false;
- } else if (property instanceof Long
- && ((Long) property).longValue() == Long.MIN_VALUE) {
- return false;
- }
- return true;
- }
-
- /**
- * Convert HTML attribute name to component property name.
- *
- * @param key
- * @return
- */
- protected Object getComponentAttributeName(Object key) {
- Object converted = substitutions.get(key);
- if (null==converted) {
- return key;
- } else {
- return converted;
- }
- }
-
- /**
- * Convert attribute value to proper object. For known html boolean attributes return name
- * for true value, otherthise - null. For non-boolean attributes return same value.
- * @param name attribute name.
- * @param value
- * @return
- */
- protected Object attributeValue(String name, Object value){
- if (null != value && Arrays.binarySearch(HTML.PASS_THRU_BOOLEAN,name)>=0) {
- boolean checked = false;
- if (value instanceof Boolean) {
- checked = ((Boolean) value).booleanValue();
- } else {
- if( ! (value instanceof String) ){
- value = value.toString();
- }
- checked = (new Boolean((String) value)).booleanValue();
- }
- return checked?name:null;
- } else {
- return value;
- }
- }
-
-
- /**
- * Get boolean value of logical attribute
- * @param component
- * @param name attribute name
- * @return true if attribute is equals Boolean.TRUE or String "true" , false otherwise.
- */
- public boolean isBooleanAttribute(UIComponent component, String name){
- Object attrValue = component.getAttributes().get(name);
- boolean result = false;
- if(null != attrValue){
- if(attrValue instanceof String ){
- result = "true".equalsIgnoreCase((String) attrValue);
- } else {
- result = Boolean.TRUE.equals(attrValue);
- }
- }
- return result;
- }
-
- /**
- * Return converted value for {@link javax.faces.component.ValueHolder} as String,
- * perform nessesary convertions.
- * @param context
- * @param component
- * @return
- */
- public String getValueAsString(FacesContext context, UIComponent component) {
- // First - get submitted value for input components
- if (component instanceof EditableValueHolder) {
- EditableValueHolder input = (EditableValueHolder) component;
- String submittedValue = (String) input.getSubmittedValue();
- if(null != submittedValue) {
- return submittedValue;
- }
- }
- // If no submitted value presented - convert same for UIInput/UIOutput
- if (component instanceof ValueHolder) {
- return formatValue(context, component, ((ValueHolder) component).getValue() );
- } else {
- throw new IllegalArgumentException(Messages.getMessage(Messages.CONVERTING_NON_VALUE_HOLDER_COMPONENT_ERROR, component.getId()));
- }
- }
-
- /**
- * Convert any object value to string. If component instance of {@link ValueHolder } got {@link Converter} for formatting.
- * If not, attempt to use converter based on value type.
- * @param context
- * @param component
- * @return
- */
- public String formatValue(FacesContext context, UIComponent component,Object value) {
- if(value instanceof String) {
- return (String) value;
- }
- Converter converter = null;
- if (component instanceof ValueHolder) {
- ValueHolder holder = (ValueHolder) component;
- converter = holder.getConverter();
- }
- if(null == converter && null != value ) {
- try {
- converter = context.getApplication().createConverter(
- value.getClass());
- } catch (FacesException e) {
- // TODO - log converter exception.
- }
- }
- if(null == converter) {
- if(null != value) {
- return value.toString();
- }
- } else {
- return converter.getAsString(context, component, value);
- }
- return "";
- }
-
- public void encodeDimensions(FacesContext context, UIComponent component, InternetResource resource) throws IOException {
- if (resource instanceof Java2Dresource) {
- Java2Dresource j2d = (Java2Dresource) resource;
- Dimension dim = j2d.getDimensions(context, component);
- ResponseWriter writer = context.getResponseWriter();
- writer.writeAttribute("width", String.valueOf(dim.width), "width");
- writer.writeAttribute("height", String.valueOf(dim.height), "height");
- }
- }
- public String encodePx(String value){
- return HtmlDimensions.formatPx(HtmlDimensions.decode(value));
- }
- /**
- * formats given value to
- * @param value
- * @param pattern
- * @return
- */
- public String encodePctOrPx(String value){
- if(value.indexOf('%') > 0){
- return value;
- } else {
- return encodePx(value);
- }
- }
-
- /**
- * Find nested form for given component
- * @param component
- * @return nested <code>UIForm</code> component, or <code>null</code>
- */
- public UIForm getNestingForm(FacesContext context,UIComponent component)
- {
- UIComponent parent = component.getParent();
- while (parent != null && !(parent instanceof UIForm))
- {
- parent = parent.getParent();
- }
-
- UIForm nestingForm = null;
- if (parent != null)
- {
- //link is nested inside a form
- nestingForm = (UIForm) parent;
- }
- return nestingForm;
- }
-
- /**
- * @param context
- * @param component
- * @return
- * @throws IOException
- */
- public void encodeBeginFormIfNessesary(FacesContext context, UIComponent component) throws IOException {
- UIForm form = getNestingForm(context, component);
- if(null == form) {
- ResponseWriter writer = context.getResponseWriter();
- String clientId = component.getClientId(context)+DUMMY_FORM_ID;
- encodeBeginForm(context, component, writer, clientId);
-// writer.writeAttribute(HTML.style_ATTRIBUTE, "margin:0; padding:0;", null);
- }
- }
-
- /**
- * @param context
- * @param component
- * @param writer
- * @param clientId
- * @throws IOException
- */
- public void encodeBeginForm(FacesContext context, UIComponent component, ResponseWriter writer, String clientId) throws IOException {
- String actionURL = getActionUrl(context);
- String encodeActionURL = context.getExternalContext().encodeActionURL(actionURL);
-
- writer.startElement(HTML.FORM_ELEMENT, component);
- writer.writeAttribute(HTML.id_ATTRIBUTE, clientId, null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId, null);
- writer.writeAttribute(HTML.METHOD_ATTRIBUTE, "post", null);
- writer.writeAttribute(HTML.style_ATTRIBUTE, "margin:0; padding:0;", null);
- writer.writeURIAttribute(HTML.ACTION_ATTRIBUTE,
- encodeActionURL,
- "action");
- }
-
- /**
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeEndFormIfNessesary(FacesContext context, UIComponent component) throws IOException {
- UIForm form = getNestingForm(context, component);
- if(null == form) {
- ResponseWriter writer = context.getResponseWriter();
- // TODO - hidden form parameters ?
- encodeEndForm(context, writer);
- }
- }
-
- /**
- * @param context
- * @param writer
- * @throws IOException
- */
- public void encodeEndForm(FacesContext context, ResponseWriter writer) throws IOException {
- AjaxRendererUtils.writeState(context);
- writer.endElement(HTML.FORM_ELEMENT);
- }
-
- /**
- * @param facesContext
- * @return String A String representing the action URL
- */
- public String getActionUrl(FacesContext facesContext)
- {
- ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
- String viewId = facesContext.getViewRoot().getViewId();
- return viewHandler.getActionURL(facesContext, viewId);
- }
- /**
- *
- * @param context
- * @param value
- * @return URL of target resource (src, href, etc)
- */
- public String encodeResourceURL(TemplateContext context, Object value){
- if(value == null){
- return "";
- }
- FacesContext facesContext = context.getFacesContext();
- value = facesContext.getApplication().getViewHandler().getResourceURL(facesContext, value.toString());
- return facesContext.getExternalContext().encodeResourceURL((String)value);
- }
- /**
- * Simplified version of {@link encodeId}
- * @param context
- * @param component
- * @return client id of current component
- */
- public String clientId(FacesContext context, UIComponent component){
- String clientId = "";
- try {
- clientId = component.getClientId(context);
- } catch (Exception e) {
- //just ignore
- }
- return clientId;
- }
-
- /**
- * Wtrie JavaScript with start/end elements and type.
- * @param context
- * @param tab
- * @param string
- */
-
- public void writeScript(FacesContext context, UIComponent component, Object script) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.SCRIPT_ELEM,component);
- writer.writeAttribute(HTML.TYPE_ATTR,"text/javascript","type");
- writer.writeText(script,null);
- writer.endElement(HTML.SCRIPT_ELEM);
- }
-
-}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakPoint.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakPoint.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/BreakPoint.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -30,7 +30,7 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.xml.sax.SAXException;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ElementBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ElementBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ElementBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -37,7 +37,7 @@
import javax.faces.el.ValueBinding;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.apache.commons.beanutils.MethodUtils;
import org.richfaces.skin.SkinFactory;
import org.xml.sax.SAXException;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/HtmlCompiler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/HtmlCompiler.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/HtmlCompiler.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -35,7 +35,7 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.Rule;
import org.apache.commons.digester.RulesBase;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodParameterElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodParameterElement.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/MethodParameterElement.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -26,7 +26,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.xml.sax.SAXException;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PreparedTemplate.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PreparedTemplate.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/PreparedTemplate.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -27,7 +27,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.xml.sax.SAXException;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ResourceElement.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ResourceElement.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/ResourceElement.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -27,7 +27,7 @@
import javax.faces.FacesException;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TemplateContext.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TemplateContext.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/compiler/TemplateContext.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,7 +28,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
/**
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/HtmlComponentTagBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/HtmlComponentTagBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/taglib/HtmlComponentTagBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -23,7 +23,7 @@
import javax.faces.component.UIComponent;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AJAXDataSerializer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,45 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+
+
+import org.ajax4jsf.javascript.ScriptUtils;
+
+/**
+ * @author shura
+ *
+ */
+public class AJAXDataSerializer {
+
+ public static final String SERVICE = AJAXDataSerializer.class.getName();
+
+ public String asString(Object data) {
+ StringBuffer result = new StringBuffer();
+ if(null != data){
+ result.append("<![CDATA[ ");
+ result.append(ScriptUtils.toScript(data));
+ result.append(" ]]>");
+ }
+ return result.toString();
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,189 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.AjaxChildrenEncoder;
+import org.ajax4jsf.component.AjaxOutput;
+import org.ajax4jsf.renderkit.AjaxRenderer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase implements AjaxRenderer {
+
+ public static final Log log = LogFactory.getLog(AjaxChildrenRenderer.class);
+
+ public static final String[] SPECIAL_COMPONENTS_TYPES = {
+ "org.ajax4jsf.Bundle"/*UILoadBundle.COMPONENT_TYPE*/, "org.apache.myfaces.AliasBean",
+ "org.apache.myfaces.AliasBeansScope" };
+ private static final String SPECIAL_TYPES_PARAMETER = "org.ajax4jsf.CONTROL_COMPONENTS";
+
+ /**
+ * Iterate over all childs of components. If component id contains in list ,
+ * or, if list is empty, compotents is submitted form - render it. TODO -
+ * Instead of calculate full path for every component, build current Path
+ * for componet and send as parameter.
+ *
+ * @param context -
+ * current context
+ * @param component -
+ * curent faces component.
+ * @param ids -
+ * list of Id to render.
+ * @throws IOException
+ * @deprecated Use {@link #encodeAjaxChildren(FacesContext,UIComponent,String,Set,Set)} instead
+ */
+ public void encodeAjaxChild(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
+ encodeAjaxChildren(context, component, path, ids, renderedAreas);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String, java.util.Set, java.util.Set)
+ */
+ public void encodeAjaxChildren(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_CHILD_AJAX_INFO,
+ path, component.getId()));
+ }
+ String currentPath = path;
+ if (component instanceof NamingContainer) {
+ currentPath += component.getId() + NamingContainer.SEPARATOR_CHAR;
+ }
+ for (Iterator it = component.getFacetsAndChildren(); it.hasNext();) {
+ UIComponent element = (UIComponent) it.next();
+ encodeAjaxComponent(context, element, currentPath, ids, renderedAreas);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxComponent(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String, java.util.Set, java.util.Set)
+ */
+ public void encodeAjaxComponent(FacesContext context, UIComponent component, String currentPath, Set ids, Set renderedAreas) throws IOException {
+ if (component.isRendered()) { // skip not-rendered components.
+ boolean found = false;
+ if (!ids.isEmpty()) {
+ // list for rendering may contains absolute id ( best ),
+ // component Id or client ID
+ String elementId = component.getId();
+ String absoluteId = currentPath + elementId;
+ // String clientId = element.getClientId(context);
+ if (ids.contains(absoluteId) || ids.contains(elementId)) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug(Messages.getMessage(
+ Messages.RENDER_AJAX_AREA_INFO,
+ absoluteId));
+ }
+ // renderChild(context, element);
+ found = true;
+ }
+ }
+ if (!found && component instanceof AjaxOutput) {
+ if (((AjaxOutput) component).isAjaxRendered()) {
+ // renderChild(context, element);
+ found = true;
+ }
+
+ }
+
+ if (!found) {
+ if (component instanceof AjaxChildrenEncoder) {
+ ((AjaxChildrenEncoder) component).encodeAjaxChild(
+ context, currentPath, ids, renderedAreas);
+ } else {
+ // Special case - for control components, not produced
+ // html code - such as message bundles loaders,
+ // MyFaces aliases etc. we call encodeBegin/end methods
+ // even if components not in rendered areas.
+ boolean special = isSpecialElement(context, component);
+ if (special) {
+ component.encodeBegin(context);
+ }
+ encodeAjaxChildren(context, component, currentPath, ids,
+ renderedAreas);
+ if (special) {
+ component.encodeEnd(context);
+ }
+
+ }
+ } else {
+ renderedAreas.add(component.getClientId(context));
+ renderChild(context, component);
+ }
+ }
+ }
+
+ private Set _specialComponentTypes = null;
+
+ /**
+ * Detect component as special control case - such as messages bundle
+ * loader, alias bean components etc. Type of component get by reflection
+ * from static field COMPONENT_TYPE
+ *
+ * @param context
+ * @param component
+ * @return true if encode methods must be called for this component even in
+ * not-rendered parts.
+ */
+ private boolean isSpecialElement(FacesContext context, UIComponent component) {
+ if (_specialComponentTypes == null) {
+ _specialComponentTypes = new HashSet(10);
+ for (int i = 0; i < SPECIAL_COMPONENTS_TYPES.length; i++) {
+ _specialComponentTypes.add(SPECIAL_COMPONENTS_TYPES[i]);
+ }
+ String special = context.getExternalContext().getInitParameter(
+ SPECIAL_TYPES_PARAMETER);
+ if (null != special) {
+ String[] split = special.split(",");
+ for (int i = 0; i < split.length; i++) {
+ _specialComponentTypes.add(split[i]);
+ }
+ }
+ }
+ boolean result;
+ try {
+ String componentType = (String) component.getClass().getField(
+ "COMPONENT_TYPE").get(null);
+ result = _specialComponentTypes.contains(componentType);
+ } catch (Exception e) {
+ // exception occurs if component not have accesible COMPONENT_TYPE
+ // constant
+ // we assume that component not in special types.
+ result = false;
+ }
+ return result;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxComponentRendererBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,93 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import org.ajax4jsf.javascript.AjaxScript;
+import org.ajax4jsf.renderkit.HeaderResourceProducer;
+import org.ajax4jsf.resource.InternetResource;
+
+
+/**
+ * Base class for all Ajax enabled components. Perform common task -
+ * output javasript for component.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:49 $
+ *
+ */
+public abstract class AjaxComponentRendererBase extends HeaderResourcesRendererBase implements HeaderResourceProducer {
+
+// private InternetResource ajaxScript = getResource("/com/exadel/vcp/framework/ajax/scripts/AJAX.js");
+ private static final String AJAX_SCRIPT = AjaxScript.class.getName();
+
+ private InternetResource[] scripts = null;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderScripts(javax.faces.context.FacesContext)
+ */
+// public LinkedHashSet getHeaderScripts(FacesContext context, UIComponent component) {
+// LinkedHashSet scripts = new LinkedHashSet() ; // Collections.singleton(ajaxScript.getUri(context, null));
+// scripts.add(ajaxScript.getUri(context, component));
+// String[] additionalScripts = getAdditionalScripts();
+// if (null != additionalScripts) {
+// for (int i = 0; i < additionalScripts.length; i++) {
+// String resource = additionalScripts[i];
+// scripts.add(getResource(resource).getUri(context, component));
+// }
+// }
+// return scripts;
+// }
+
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.HeaderResourcesRendererBase#getScripts()
+ */
+ protected InternetResource[] getScripts() {
+ // Lazy create
+ if (scripts == null) {
+ InternetResource[] additionalScripts = getAdditionalScripts();
+ // Custom scripts
+ if (null != additionalScripts) {
+ scripts = new InternetResource[additionalScripts.length+1];
+ System.arraycopy(additionalScripts,0,scripts,1,additionalScripts.length);
+ } else {
+ scripts = new InternetResource[1];
+ }
+ // Ajax script
+ scripts[0] = getResource(AJAX_SCRIPT);
+ }
+
+ return scripts;
+ }
+
+
+
+ /**
+ * Hoock method for append custom ajax scripts
+ * @return
+ */
+ protected InternetResource[] getAdditionalScripts() {
+ return null;
+ }
+
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxContainerRenderer.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxContainerRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxContainerRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,166 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.AjaxContainer;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.event.AjaxEvent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base renderer for all AJAX - subview components.
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/08 15:02:02 $
+ *
+ */
+public class AjaxContainerRenderer extends AjaxChildrenRenderer {
+
+ public static final String AJAX_PARAMETER_NAME = "AJAXREQUEST";
+
+ public static final String AJAX_JSF_SCRIPT = "AJAX.js";
+
+ public static final String SARISSA_SCRIPT = "sarissa.js";
+
+ public static final String JSDOM_SCRIPT = "JSDOM_sarissa.js";
+
+ public static final String AJAX_VIEW_STATE_TAG = "span";
+
+ public static final String AJAX_VIEW_STATE_ID = "ajax-update-ids";
+
+ public static final String AJAX_RESULT_GROUP_TAG = "meta";
+
+ public static final String AJAX_RESULT_GROUP_ATTR = "content";
+
+ public static final String AJAX_RESULT_STYLE = "display: none";
+
+ public static final String AJAX_UPDATE_HEADER = "Ajax-Update-Ids";
+
+ static final Log log = LogFactory
+ .getLog(AjaxContainerRenderer.class);
+
+ public static final String AJAX_FLAG_HEADER = "Ajax-Response";
+
+ public static final String AJAX_LOCATION_HEADER = "Location";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return AjaxContainer.class;
+ }
+
+ /**
+ *
+ *
+ * @see javax.faces.component.UIComponent#encodeChildren(javax.faces.context.FacesContext)
+ * Since main function of component - render subset of components, for
+ * update on page,don't delegate this for renderer.
+ *
+ */
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException {
+ // Normal request - render all ...
+ log.debug(Messages.getMessage(Messages.RENDER_CHILDREN_NON_AJAX_INFO));
+ renderChildren(context, component);
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeAjax(FacesContext context, UIComponent component)
+ throws IOException {
+ UIComponent root ;
+ // Iterate over all childrens, render it if nessesary...
+ log.debug(Messages.getMessage(Messages.RENDER_CHILDREN_AJAX_INFO));
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ Set ids = ajaxContext.getAjaxAreasToRender();
+ Set renderedAreas = ajaxContext.getAjaxRenderedAreas();
+ if (((AjaxContainer) component).isRenderRegionOnly()) {
+ root = component;
+ } else {
+ root = context.getViewRoot();
+ }
+ String path = AjaxRendererUtils.getAbsoluteId(root);
+ // if(! (component instanceof NamingContainer)){
+ path = path.substring(0, path
+ .lastIndexOf(NamingContainer.SEPARATOR_CHAR) + 1);
+ encodeAjaxComponent(context, root, path, ids, renderedAreas);
+ // Write information about encoded areas after submission.
+ AjaxRendererUtils.encodeAreas(context, component);
+ }
+
+
+
+ /*
+ * always return true, since component must maintain set of rendered
+ * components.
+ *
+ * @see javax.faces.component.UIComponent#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#doDecode(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ protected void doDecode(FacesContext context, UIComponent component) {
+ String clientId = component.getClientId(context);
+ Map paramMap = context.getExternalContext().getRequestParameterMap();
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.DECODE_AJAX_REQUEST_STATUS_INFO, clientId));
+ log.debug(Messages.getMessage(Messages.REQUEST_PARAMETERS_MAP,
+ paramMap.toString()));
+ }
+ Object ajaxParameter = paramMap.get(AJAX_PARAMETER_NAME);
+ AjaxContainer ajaxContainer = (AjaxContainer) component;
+ if (null != ajaxParameter && ajaxParameter.equals(clientId)) {
+ ajaxContainer.setSubmitted(true);
+ AjaxEvent event = new AjaxEvent(component);
+ component.queueEvent(event);
+ } else {
+ ajaxContainer.setSubmitted(false);
+ }
+
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxPhaseListener.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxPhaseListener.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxPhaseListener.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxPhaseListener.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,169 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.context.AjaxContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * Listener for act before Render phase to set RenderKit Id for current skin.
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:19 $
+ *
+ */
+public class AjaxPhaseListener implements PhaseListener {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4087936963051339868L;
+
+ public static final String VIEW_BEAN_PREFIX = "org.ajax4jsf.viewbean:";
+
+ public static final String VIEW_STATE_SAVED_PARAM = "org.ajax4jsf.VIEW_STATE_SAVED";
+
+ private static final Log log = LogFactory
+ .getLog(AjaxPhaseListener.class);
+
+ public static final String AJAX_BEAN_PREFIX = "org.ajax4jsf.ajaxviewbean:";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
+ */
+ public void afterPhase(PhaseEvent event) {
+ PhaseId phaseId = event.getPhaseId();
+ if(log.isDebugEnabled()){
+ log.debug("Process after phase "+phaseId.toString());
+ }
+ FacesContext context = event.getFacesContext();
+ Map requestMap = context.getExternalContext().getRequestMap();
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if (phaseId == PhaseId.RENDER_RESPONSE) {
+ if (ajaxContext.isAjaxRequest()) {
+ // JSF RI 1.1 hack - view state not saved in <f:view> tag.
+ if(null == requestMap.get(VIEW_STATE_SAVED_PARAM)){
+ try {
+ ajaxContext.saveViewState(context);
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
+ }
+// ajaxContext.processHeadResources(context);
+ } else if (phaseId == PhaseId.RESTORE_VIEW) {
+
+ UIViewRoot viewRoot = context.getViewRoot();
+ if(null != viewRoot){
+ boolean isAjax = ajaxContext.isAjaxRequest();
+ Map attributes = viewRoot.getAttributes();
+ for (Iterator it = attributes.keySet().iterator(); it.hasNext();) {
+ Object key = it.next();
+ if (key instanceof String) {
+ String stringKey = (String) key;
+ if(stringKey.startsWith(VIEW_BEAN_PREFIX)){
+ requestMap.put(stringKey.substring(VIEW_BEAN_PREFIX.length()), attributes.get(key));
+ } else if(isAjax && stringKey.startsWith(AJAX_BEAN_PREFIX)){
+ requestMap.put(stringKey.substring(AJAX_BEAN_PREFIX.length()), attributes.get(key));
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.event.PhaseListener#beforePhase(javax.faces.event.PhaseEvent)
+ */
+ public void beforePhase(PhaseEvent event) {
+ PhaseId phaseId = event.getPhaseId();
+ if(log.isDebugEnabled()){
+ log.debug("Process before phase "+phaseId.toString());
+ }
+ FacesContext context = event.getFacesContext();
+ if (phaseId == PhaseId.RENDER_RESPONSE) {
+ // Clear ViewId replacement, to avoid incorrect rendering of forms URI.
+ AjaxContext.getCurrentInstance(context).setViewIdHolder(null);
+
+ UIViewRoot root = context.getViewRoot();
+ log.debug(Messages.getMessage(
+ Messages.ENTER_BEFORE_RENDER_VIEW_PHASE, root.getViewId(),
+ root.getRenderKitId()));
+
+ // TODO - create special skin-config.xml configuration.
+ String renderKitId = null;
+ try {
+ renderKitId = SkinFactory.getInstance().getSkin(context)
+ .getRenderKitId(context);
+ } catch (Exception e) {
+ log.error("Exception on get current Skin ", e);
+ }
+ if (null != renderKitId) {
+ log.debug(Messages.getMessage(Messages.SET_RENDER_KIT_ID_INFO,
+ renderKitId));
+ root.setRenderKitId(renderKitId);
+ }
+ } else if (phaseId == PhaseId.RESTORE_VIEW) {
+
+ }
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.event.PhaseListener#getPhaseId()
+ */
+ public PhaseId getPhaseId() {
+ return PhaseId.ANY_PHASE;
+ }
+
+ protected boolean isValueReference(String value) {
+ if (value == null)
+ throw new NullPointerException("value");
+
+ int start = value.indexOf("#{");
+ if (start < 0)
+ return false;
+
+ int end = value.lastIndexOf('}');
+ return (end >= 0 && start < end);
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,934 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.component.ActionSource;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIParameter;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.AjaxComponent;
+import org.ajax4jsf.component.AjaxContainer;
+import org.ajax4jsf.component.AjaxLoadBundleComponent;
+import org.ajax4jsf.component.AjaxSupport;
+import org.ajax4jsf.component.AjaxViewRoot;
+import org.ajax4jsf.component.JavaScriptParameter;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.framework.util.ServicesUtils;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura
+ *
+ * Some utilites for render AJAX components.
+ */
+public class AjaxRendererUtils {
+
+ /**
+ * Name Javasript function for submit AJAX request
+ */
+ public static final String AJAX_FUNCTION_NAME = "A4J.AJAX.Submit";
+
+ /**
+ * Attribute for keep clientId of status component
+ */
+ public static final String STATUS_ATTR_NAME = "status";
+
+ /**
+ * Attribute for keep JavaScript funtion name for call after complete
+ * request.
+ */
+ public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
+
+ /**
+ * Attribute to keep
+ */
+ public static final String LIMITTOLIST_ATTR_NAME = "limitToList";
+
+ private static Log log = LogFactory.getLog(AjaxRendererUtils.class);
+
+ public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
+
+ private static final Class OBJECT_ARRAY_CLASS = (new Object[0]).getClass();
+
+ public static final String SEQUENCE_PARAM = "jsf_sequence";
+
+ private static final String VALUE_ATTR = "value";
+
+ public static final String AJAX_AREAS_RENDERED = "org.ajax4jsf.areas.rendered";
+
+ private static final String AJAX_SINGLE_ATTR = "ajaxSingle";
+
+ public static final String AJAX_QUEUE_ATTR = "eventsQueue";
+
+ public static final String AJAX_DELAY_ATTR = "requestDelay";
+
+ private static final Object AJAX_ABORT_ATTR = "ignoreDupResponses";
+
+ /**
+ * Static class - protect constructor TODO - make as subclass of chameleon
+ * RendererUtils.
+ *
+ */
+ private AjaxRendererUtils() {
+
+ }
+
+ /**
+ * Build JavaScript onclick event for given component
+ *
+ * @param uiComponent -
+ * component for build event
+ * @param facesContext
+ * @return <code>StringBuffer</code> with Javascript code
+ */
+ public static StringBuffer buildOnClick(UIComponent uiComponent,
+ FacesContext facesContext) {
+ return buildOnEvent(uiComponent, facesContext, HTML.onclick_ATTRIBUTE);
+ }
+
+ /**
+ * Build JavaScript event for component
+ *
+ * @param uiComponent -
+ * component for build event
+ * @param facesContext
+ * @param eventName -
+ * name of event
+ * @return <code>StringBuffer</code> with Javascript code TODO - for
+ * key-based events build list of supported keys
+ */
+ public static StringBuffer buildOnEvent(UIComponent uiComponent,
+ FacesContext facesContext, String eventName) {
+ StringBuffer onEvent = new StringBuffer();
+ if (null != eventName) {
+ String commandOnEvent = (String) uiComponent.getAttributes().get(
+ eventName);
+ if (commandOnEvent != null) {
+ onEvent.append(commandOnEvent);
+ onEvent.append(';');
+ }
+ }
+ JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext);
+ // Create formal parameter for non-input elements ???
+ // Link Control pseudo-object
+ // Options map. Possible options for function call :
+ // control - name of form control for submit.
+ // name - name for link control \
+ // value - value of control. - possible replace by parameters ?
+ // single true/false - submit all form or only one control.
+ // affected - array of element's ID for update on responce.
+ // oncomplete - function for call after complete request.
+ // status - id of request status component.
+ // parameters - map of parameters name/value for append on request.
+ // TODO
+ // sync true/false - run script in sync mode.
+ // ..........
+ ajaxFunction.addParameter(buildEventOptions(facesContext, uiComponent));
+
+ // appendAjaxSubmitParameters(facesContext, uiComponent, onEvent);
+ ajaxFunction.appendScript(onEvent);
+ if (uiComponent instanceof AjaxSupport) {
+ AjaxSupport support = (AjaxSupport) uiComponent;
+ if (support.isDisableDefault()) {
+ onEvent.append("; return false;");
+ }
+ }
+ log.debug(Messages.getMessage(Messages.BUILD_ONCLICK_INFO, uiComponent
+ .getId(), onEvent.toString()));
+ return onEvent;
+
+ }
+
+ /**
+ * @param facesContext
+ * @param uiComponent
+ * @return
+ */
+ public static Map buildEventOptions(FacesContext facesContext,
+ UIComponent uiComponent) {
+ String clientId = uiComponent.getClientId(facesContext);
+ Map componentAttributes = uiComponent.getAttributes();
+ Map options = new HashMap();
+ Map parameters = new HashMap();
+ // UIForm form = getNestingForm(uiComponent);
+ // "input" - if assigned to html input element.
+ boolean input = (uiComponent instanceof AjaxSupport && uiComponent
+ .getParent() instanceof EditableValueHolder)
+ || uiComponent instanceof EditableValueHolder;
+ // Action component - button etc.
+ boolean action = (uiComponent instanceof AjaxSupport && uiComponent
+ .getParent() instanceof ActionSource)
+ || uiComponent instanceof ActionSource;
+ // TODO - disable ( or not ? ) submission of action for disabled default
+ // ?
+ // if ( action && uiComponent instanceof AjaxSupport) {
+ // AjaxSupport support = (AjaxSupport) uiComponent;
+ // if (support.isDisableDefault()) {
+ // action = false;
+ // }
+ // }
+
+ boolean ajaxSingle = Boolean.TRUE.equals(componentAttributes
+ .get(AJAX_SINGLE_ATTR));
+ // For input components in single mode or without form submit input
+ // control )
+ if (ajaxSingle && input) { // || action
+ // TODO - inside form, put reference :
+ // document.forms['form'].controls['control']
+ options.put("control", JSReference.THIS);
+ }
+ // Control value for submit
+ String controlName;
+ Object controlValue;
+ // TODO - make compatible with JSF RI/MyFaces ? use submittedValue ( if
+ // any ) for UIInput, converted value for ValueHolder.
+ controlName = clientId;
+ controlValue = clientId;
+ parameters.put(controlName, controlValue);
+ // Move processing of a 'single' attribute to a server-side.
+// if (ajaxSingle) {
+// options.put("single", JSReference.TRUE);
+// }
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
+ // Setup action URL. For portlet environment, it will be different from
+ // page.
+ options.put("actionUrl", ajaxContext.getAjaxActionURL(facesContext));
+ // Add application-wide Ajax parameters
+ parameters.putAll(ajaxContext.getCommonAjaxParameters());
+ // add child parameters
+ for (Iterator it = uiComponent.getChildren().iterator(); it.hasNext();) {
+ UIComponent child = (UIComponent) it.next();
+ if (child instanceof UIParameter) {
+ String name = ((UIParameter) child).getName();
+ Object value = ((UIParameter) child).getValue();
+ if (null == name) {
+ throw new IllegalArgumentException(Messages.getMessage(
+ Messages.UNNAMED_PARAMETER_ERROR, uiComponent
+ .getClientId(facesContext)));
+ }
+ boolean escape = true;
+ if (child instanceof JavaScriptParameter) {
+ JavaScriptParameter actionParam = (JavaScriptParameter) child;
+ escape = !actionParam.isNoEscape();
+ }
+ if (escape) {
+ parameters.put(name, value);
+ } else {
+ parameters.put(name, new JSReference(value.toString()));
+ // if(it.hasNext()){onEvent.append(',');};
+ // renderAjaxLinkParameter( name,
+ // value, onClick, jsForm, nestingForm);
+ }
+ }
+ }
+ if (!parameters.isEmpty()) {
+ options.put("parameters", parameters);
+ }
+ // parameter to render only current list of areas.
+ if (isAjaxLimitToList(uiComponent)) {
+ Set ajaxAreas = getAjaxAreas(uiComponent);
+ Set areasIds = new HashSet();
+ if (null != ajaxAreas) {
+ for (Iterator iter = ajaxAreas.iterator(); iter.hasNext();) {
+ String id = (String) iter.next();
+ UIComponent comp = uiComponent.findComponent(id);
+ if (null != comp) {
+ areasIds.add(comp.getClientId(facesContext));
+ } else {
+ areasIds.add(id);
+ }
+ }
+ }
+ options.put("affected", areasIds);
+ }
+ String oncomplete = getAjaxOncomplete(uiComponent);
+ if (null != oncomplete) {
+ JSFunctionDefinition function = new JSFunctionDefinition();
+ function.addParameter("request");
+ function.addParameter("event");
+ function.addParameter("data");
+ function.addToBody(oncomplete);
+
+ options.put("oncomplete", function);
+ }
+ String status = getAjaxStatus(uiComponent);
+ if (null != status) {
+ options.put("status", status);
+ }
+ String queue = (String) componentAttributes.get(AJAX_QUEUE_ATTR);
+ Integer requestDelay = (Integer) componentAttributes
+ .get(AJAX_DELAY_ATTR);
+ if (null != requestDelay && requestDelay.intValue() > 0) {
+ options.put(AJAX_DELAY_ATTR, requestDelay);
+ if (null == queue) {
+ queue = clientId;
+ }
+ }
+ Boolean ignoreDupResponses = (Boolean) componentAttributes
+ .get(AJAX_ABORT_ATTR);
+ if (null != ignoreDupResponses && ignoreDupResponses.booleanValue()) {
+ options.put(AJAX_ABORT_ATTR, JSReference.TRUE);
+ if (null == queue) {
+ queue = clientId;
+ }
+ }
+ if (null != queue) {
+ options.put(AJAX_QUEUE_ATTR, queue);
+ }
+ // request timeout.
+ Integer timeout = (Integer) componentAttributes.get("timeout");
+ if (null != timeout && timeout.intValue() > 0) {
+ options.put("timeout", timeout);
+ }
+ // Encoding for requests
+ String encoding = (String) componentAttributes.get("encoding");
+ if (null != encoding) {
+ options.put("encoding", encoding);
+ }
+ return options;
+ }
+
+ /**
+ * Create call to Ajax Submit function with first two parameters
+ *
+ * @param uiComponent
+ * @param facesContext
+ * @param functionName
+ * TODO
+ * @return
+ */
+ public static JSFunction buildAjaxFunction(UIComponent uiComponent,
+ FacesContext facesContext) {
+ JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext,
+ AJAX_FUNCTION_NAME);
+ // client-side script must have reference to event-enabled object.
+ ajaxFunction.addParameter(new JSReference("event"));
+ return ajaxFunction;
+ }
+
+ /**
+ * Create call to Ajax Submit function with first two parameters
+ *
+ * @param uiComponent
+ * @param facesContext
+ * @param functionName
+ * TODO
+ * @return
+ */
+ public static JSFunction buildAjaxFunction(UIComponent uiComponent,
+ FacesContext facesContext, String functionName) {
+ JSFunction ajaxFunction = new JSFunction(functionName);
+ UIComponent nestingContainer = (UIComponent) findAjaxContainer(
+ facesContext, uiComponent);
+ ajaxFunction.addParameter(nestingContainer.getClientId(facesContext));
+ // build form name or ActionUrl for script
+ UIComponent nestingForm = getNestingForm(uiComponent);
+ if (null == nestingForm) {
+ ajaxFunction.addParameter(JSReference.NULL);
+ } else {
+ ajaxFunction.addParameter(nestingForm.getClientId(facesContext));
+ }
+ return ajaxFunction;
+ }
+
+ /**
+ * Append common parameters ( array of affected areas, status area id, on
+ * complete function ) to JavaScript event string.
+ *
+ * @param uiComponent
+ * @param onClick -
+ * buffer with JavaScript code eg... AJAX.Submit(form,this
+ */
+ // public static void appendAjaxSubmitParameters(FacesContext facesContext,
+ // UIComponent uiComponent, StringBuffer onClick)
+ // {
+ // Set ajaxAreas = getAjaxAreas(uiComponent);
+ // onClick.append(',');
+ // // parameter to render only current list of areas.
+ // if (isAjaxLimitToList(uiComponent) && ajaxAreas != null &&
+ // ajaxAreas.size() > 0)
+ // {
+ // onClick.append('[');
+ // Iterator areas = ajaxAreas.iterator();
+ // boolean first = true;
+ // while (areas.hasNext())
+ // {
+ // String element = (String) areas.next();
+ // UIComponent component = uiComponent.findComponent(element);
+ // if (null != component)
+ // {
+ // if (!first)
+ // {
+ // onClick.append(',');
+ // }
+ // else
+ // {
+ // first = false;
+ // }
+ // onClick.append('\'');
+ // onClick.append(component.getClientId(facesContext));
+ // onClick.append('\'');
+ // }
+ // }
+ // onClick.append("]");
+ // }
+ // else
+ // {
+ // onClick.append("null");
+ // }
+ // // insert id of request status element.
+ // onClick.append(',');
+ // String status = getAjaxStatus(uiComponent);
+ // if (null != status)
+ // {
+ // onClick.append('\'').append(status).append('\'');
+ // }
+ // else
+ // {
+ // onClick.append("null");
+ // }
+ // // insert function name for call after completed request
+ // onClick.append(',');
+ // String oncomplete = getAjaxOncomplete(uiComponent);
+ // if (null != oncomplete)
+ // {
+ // onClick.append(oncomplete);
+ // }
+ // else
+ // {
+ // onClick.append("null");
+ // }
+ //
+ // }
+ /**
+ * Get list of clientId's for given component
+ *
+ * @param uiComponent
+ * @return List of areas Id's , updated by this component.
+ */
+ public static Set getAjaxAreas(UIComponent uiComponent) {
+ Object areas;
+ if (uiComponent instanceof AjaxComponent) {
+ areas = ((AjaxComponent) uiComponent).getReRender();
+
+ } else {
+ areas = uiComponent.getAttributes().get(
+ AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE);
+ }
+ return asSet(areas);
+ }
+
+ /**
+ * Convert parameter ( Collection, List, array, String, comma-separated
+ * String ) to list of srings. TODO - when move to JDK 5, change to
+ * List<String>
+ *
+ * @param valueToSet -
+ * obect for convert to List.
+ * @return - list of strings.
+ */
+ public static Set asSet(Object valueToSet) {
+
+ if (null != valueToSet) {
+ // Simplest case - set.
+ if (valueToSet instanceof Set) {
+ return (Set) valueToSet;
+ }
+ // Other collections.
+ else if (valueToSet instanceof Collection) {
+ return new HashSet((Collection) valueToSet);
+ }
+ // Array
+ else if (OBJECT_ARRAY_CLASS.isAssignableFrom(valueToSet.getClass())) {
+ return new HashSet(Arrays.asList((Object[]) valueToSet));
+ }
+ // Tokenize string.
+ else if (valueToSet instanceof String) {
+ String areasString = (String) valueToSet;
+ if (areasString.indexOf(",") > 0) {
+ return new HashSet(Arrays.asList(areasString.trim().split(
+ "(\\s)*,(\\s)*")));
+ } else {
+ Set areasSet = new HashSet(5);
+ areasSet.add(areasString.trim());
+ return areasSet;
+ }
+
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get status area Id for given component.
+ *
+ * @param component
+ * @return clientId of status area, or <code>null</code>
+ */
+ public static String getAjaxStatus(UIComponent component) {
+ String statusId;
+ if (component instanceof AjaxComponent) {
+ statusId = ((AjaxComponent) component).getStatus();
+
+ } else {
+ statusId = (String) component.getAttributes().get(STATUS_ATTR_NAME);
+ }
+ if (null != statusId) {
+ UIComponent status = null;
+ UIComponent currentParent = component;
+ try {
+ // Check the naming container of the current
+ // component for component identified by
+ // 'forComponent'
+ while (currentParent != null) {
+ // If the current component is a NamingContainer,
+ // see if it contains what we're looking for.
+ status = currentParent.findComponent(statusId);
+ if (status != null)
+ break;
+ // if not, start checking further up in the view
+ currentParent = currentParent.getParent();
+ }
+ } catch (Exception e) {
+ // ignore - log the warning
+ }
+ if (null != status) {
+ statusId = status
+ .getClientId(FacesContext.getCurrentInstance());
+ } else {
+ log.warn(Messages.getMessage(
+ Messages.AJAX_STATUS_COMPONENT_NOT_FOWND_WARNING,
+ component.getId()));
+ }
+ }
+ return statusId;
+ }
+
+ /**
+ * Get function name for call on completed ajax request.
+ *
+ * @param component
+ * for wich calculate function name
+ * @return name of JavaScript function or <code>null</code>
+ */
+ public static String getAjaxOncomplete(UIComponent component) {
+ if (component instanceof AjaxComponent) {
+ return ((AjaxComponent) component).getOncomplete();
+
+ }
+ return (String) component.getAttributes().get(ONCOMPLETE_ATTR_NAME);
+ }
+
+ /**
+ * Calculate, must be component render only given areas, or all sended from
+ * server.
+ *
+ * @param component
+ * @return <code>true</code> if client must render ONLY given areas.
+ */
+ public static boolean isAjaxLimitToList(UIComponent component) {
+ boolean result = false;
+ if (component instanceof AjaxComponent) {
+ result = ((AjaxComponent) component).isLimitToList();
+
+ } else {
+ try {
+ result = ((Boolean) component.getAttributes().get(
+ LIMITTOLIST_ATTR_NAME)).booleanValue();
+ } catch (NullPointerException e) {
+ // NullPointer - ignore ...
+ } catch (ClassCastException e1) {
+ // not Boolean - false ...
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Replacement for buggy in MyFaces <code>RendererUtils</code>
+ *
+ * @param component
+ * @return
+ */
+ public static String getAbsoluteId(UIComponent component) {
+ if (component == null)
+ throw new NullPointerException(Messages
+ .getMessage(Messages.COMPONENT_NULL_ERROR_2));
+
+ StringBuffer idBuf = new StringBuffer();
+
+ idBuf.append(component.getId());
+
+ UIComponent parent = component;
+
+ while ((parent = parent.getParent()) != null) {
+ if (parent instanceof NamingContainer) {
+ idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
+ idBuf.insert(0, parent.getId());
+ }
+ }
+ idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
+ log.debug(Messages.getMessage(Messages.CALCULATE_COMPONENT_ID_INFO,
+ component.getId(), idBuf.toString()));
+ return idBuf.toString();
+ }
+
+ /**
+ * Find nested form for given component
+ *
+ * @param component
+ * @return nested <code>UIForm</code> component, or <code>null</code>
+ */
+ public static UIComponent getNestingForm(UIComponent component) {
+ UIComponent parent = component;
+ // Search enclosed UIForm or ADF UIXForm component
+ while (parent != null
+ && !(parent instanceof UIForm)
+ && !("org.apache.myfaces.trinidad.Form".equals(parent
+ .getFamily()))
+ && !("oracle.adf.Form".equals(parent.getFamily()))) {
+ parent = parent.getParent();
+ }
+
+ return parent;
+ }
+
+ protected static String getAjaxActionUrl(FacesContext facesContext) {
+ return AjaxContext.getCurrentInstance(facesContext).getAjaxActionURL(facesContext);
+ }
+
+ /**
+ * @param facesContext
+ * @param uiComponent
+ * @return
+ */
+ public static org.ajax4jsf.component.AjaxContainer findAjaxContainer(
+ FacesContext facesContext, UIComponent uiComponent) {
+ UIComponent parent = uiComponent.getParent();
+ while (parent != null
+ && !(parent instanceof org.ajax4jsf.component.AjaxContainer)) {
+ parent = parent.getParent();
+ }
+
+ org.ajax4jsf.component.AjaxContainer nestingContainer = null;
+ if (parent != null) {
+ // link is nested inside a form
+ nestingContainer = (org.ajax4jsf.component.AjaxContainer) parent;
+ } else if (facesContext.getViewRoot() instanceof AjaxViewRoot) {
+ nestingContainer = (AjaxContainer) facesContext.getViewRoot();
+ }
+ return nestingContainer;
+ }
+
+ /**
+ * For Myfaces, get current viev sequence.
+ *
+ * @param facescontext
+ * @return
+ */
+ private static Integer getViewSequence(FacesContext facescontext) {
+ Map map = facescontext.getExternalContext().getRequestMap();
+ Integer sequence = (Integer) map.get(SEQUENCE_PARAM);
+ if (sequence == null) {
+ sequence = new Integer(1);
+ map.put(SEQUENCE_PARAM, sequence);
+ }
+ return sequence;
+ }
+
+ /**
+ * Encode rendered areas as special HTML tag ( span in current release )
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public static void encodeAreas(FacesContext context,
+ UIComponent component) throws IOException {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ExternalContext externalContext = context.getExternalContext();
+ Map requestMap = externalContext.getRequestMap();
+ Set rendered = ajaxContext.getAjaxRenderedAreas();
+ StringBuffer senderString = new StringBuffer();
+ // write special area for list of rendered elements. Client-side
+ // Java
+ // Script
+ // read this structure for update areas of DOM tree.
+ ResponseWriter out = context.getResponseWriter();
+ // Create <span> element to keep list rendered aread ( in title
+ // attribute )
+ // More right will create special namespace for such
+ // information,
+ // but I want to keep simple html ( xhtml ) document - on case
+ // I have troubles with microsoft XMLHTTP validations.
+ out
+ .startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG,
+ component);
+ out.writeAttribute(HTML.NAME_ATTRIBUTE,
+ AjaxContainerRenderer.AJAX_UPDATE_HEADER, null);
+ for (Iterator it = rendered.iterator(); it.hasNext();) {
+ String id = (String) it.next();
+ // out.startElement(AJAX_RESULT_TAG, component);
+ // out.writeText(id,null);
+ // out.endElement(AJAX_RESULT_TAG);
+ senderString.append(id);
+ if (it.hasNext()) {
+ senderString.append(',');
+ }
+ }
+ out.writeAttribute(AjaxContainerRenderer.AJAX_RESULT_GROUP_ATTR,
+ senderString, null);
+ out.endElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG);
+ // For sequences and client-saved states.
+
+ out.startElement(AjaxContainerRenderer.AJAX_VIEW_STATE_TAG, component);
+ out.writeAttribute(HTML.id_ATTRIBUTE,
+ AjaxContainerRenderer.AJAX_VIEW_STATE_ID, null);
+ writeState(context);
+ out.endElement(AjaxContainerRenderer.AJAX_VIEW_STATE_TAG);
+ // Write rendered flag to html <meta>
+ out
+ .startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG,
+ component);
+ out.writeAttribute(HTML.id_ATTRIBUTE,
+ AjaxContainerRenderer.AJAX_FLAG_HEADER, null);
+ out.writeAttribute(HTML.NAME_ATTRIBUTE,
+ AjaxContainerRenderer.AJAX_FLAG_HEADER, null);
+ out.writeAttribute(AjaxContainerRenderer.AJAX_RESULT_GROUP_ATTR,
+ "true", null);
+ out.endElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG);
+ // set response header with list of rendered ID's
+ Object response = externalContext.getResponse();
+ // Use reflection for send responce headers - we can get
+ // different responces classes
+ // for different environment ( portal, cocoon etc )
+ if (response instanceof HttpServletResponse) {
+ HttpServletResponse httpResponse = (HttpServletResponse) response;
+ httpResponse.setHeader(AjaxContainerRenderer.AJAX_UPDATE_HEADER,
+ senderString.toString());
+ httpResponse.setHeader(AjaxContainerRenderer.AJAX_FLAG_HEADER,
+ "true");
+ } else {
+ try {
+ Method setHeadergMethod = response.getClass()
+ .getMethod("setHeader",
+ new Class[] { String.class, String.class });
+ setHeadergMethod.invoke(response, new Object[] {
+ AjaxContainerRenderer.AJAX_UPDATE_HEADER,
+ senderString.toString() });
+ setHeadergMethod.invoke(response, new Object[] {
+ AjaxContainerRenderer.AJAX_FLAG_HEADER, "true" });
+ } catch (Exception e) {
+ log
+ .error(Messages
+ .getMessage(Messages.DETECTING_ENCODING_DISABLED_ERROR));
+ log.error(Messages.getMessage(
+ Messages.OBTAIN_RESPONSE_SET_HEADER_ERROR, e));
+ }
+ }
+ Map responseDataMap = ajaxContext.getResponseDataMap();
+ // Get data serializer instance
+ AJAXDataSerializer serializer = (AJAXDataSerializer) ServicesUtils
+ .getServiceInstance(AJAXDataSerializer.SERVICE);
+ // Put data to JavaScript handlers, inside <span> elements.
+ for (Iterator dataIterator = responseDataMap.keySet().iterator(); dataIterator
+ .hasNext();) {
+ Object dataKey = dataIterator.next();
+ out.startElement(HTML.SPAN_ELEM, component);
+ out.writeAttribute(HTML.id_ATTRIBUTE, dataKey, null);
+ String dataString = serializer.asString(responseDataMap
+ .get(dataKey));
+ out.write(dataString);
+ out.endElement(HTML.SPAN_ELEM);
+ }
+ // For self-rendered case, we use own methods for replace stateKey by
+ // real value
+ // in XML filter.
+ // if(ajaxContext.isSelfRender()){
+ // saveViewState(context, out);
+ // }
+ requestMap.put(AJAX_AREAS_RENDERED, "true");
+ }
+
+ /**
+ * Write state saving markers to context, include MyFaces view sequence.
+ *
+ * @param context
+ * @throws IOException
+ */
+ public static void writeState(FacesContext context) throws IOException {
+ if (!context.getApplication().getStateManager().isSavingStateInClient(
+ context)) {
+ ResponseWriter writer = context.getResponseWriter();
+ // MyFaces-specific view sequence attribute
+ writer.startElement(HTML.INPUT_ELEM, null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE,
+ AjaxRendererUtils.SEQUENCE_PARAM, null);
+ writer.writeAttribute(HTML.value_ATTRIBUTE, AjaxRendererUtils
+ .getViewSequence(context), null);
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+ context.getApplication().getViewHandler().writeState(context);
+ }
+
+ /**
+ * Encode declaration for AJAX response. Render <html><body>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public static void encodeAjaxBegin(FacesContext context,
+ UIComponent component) throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+ out.startElement("html", component);
+ // TODO - html attributes. lang - from current locale ?
+ Locale locale = context.getViewRoot().getLocale();
+ out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
+ out.startElement("body", component);
+ }
+
+ /**
+ * End encoding of AJAX response. Render tag with included areas and close
+ * </body></html>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public static void encodeAjaxEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+
+ encodeAreas(context, component);
+ out.endElement("body");
+ out.endElement("html");
+ }
+
+ /**
+ * Find all instances of {@link UILoadBundle} in view tree and load bundles
+ * to request-scope map.
+ *
+ * @param context
+ * @throws IOException
+ */
+ public static void loadBundles(FacesContext context) {
+ // TODO - performanse improove - don't seek by all components tree.
+ loadBundles(context, context.getViewRoot());
+
+ }
+
+ /**
+ * Recursive helper for {@link #loadBundles(FacesContext)}
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ private static void loadBundles(FacesContext context, UIComponent component) {
+ // Iterate over cildrens
+ for (Iterator iter = component.getChildren().iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ loadCildBundles(context, child);
+ }
+ // Iterate over facets
+ for (Iterator iter = component.getFacets().values().iterator(); iter
+ .hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ loadCildBundles(context, child);
+ }
+ }
+
+ /**
+ * @param context
+ * @param child
+ */
+ private static void loadCildBundles(FacesContext context, UIComponent child) {
+ if (child instanceof AjaxLoadBundleComponent) {
+ try {
+ child.encodeBegin(context);
+ } catch (IOException e) {
+ // DO nothing - really, LoadBundle don't can throw exceptions.
+ }
+ } else {
+ loadBundles(context, child);
+ }
+ }
+
+ /**
+ * @param facesContext
+ * @return
+ */
+ public static boolean isAjaxRequest(FacesContext facesContext) {
+
+ return AjaxContext.getCurrentInstance(facesContext).isAjaxRequest(facesContext);
+ }
+
+ /**
+ * @param facesContext
+ * @param component
+ * @param id
+ */
+ public static void addRegionByName(FacesContext facesContext, UIComponent component, String id) {
+
+ AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(component, id);
+ }
+ /**
+ * @param facesContext
+ * @param component
+ * @param id
+ */
+ public static void addRegionsFromComponent(UIComponent component, FacesContext facesContext) {
+
+ AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(component);
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxViewRootRenderer.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxViewRootRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxViewRootRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxViewRootRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,108 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import org.ajax4jsf.component.AjaxViewRoot;
+import org.ajax4jsf.resource.InternetResource;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/08 15:02:03 $
+ *
+ */
+public class AjaxViewRootRenderer extends AjaxContainerRenderer {
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.AjaxComponentRendererBase#getScripts()
+ */
+ protected InternetResource[] getScripts() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#doDecode(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+// protected void doDecode(FacesContext context, UIComponent component) {
+// AjaxViewRoot root = (AjaxViewRoot) component;
+// if(root.isSubmitted()) {
+// // Find submitted ajax region.
+// String ajaxId = (String) context.getExternalContext().getRequestParameterMap().get(AJAX_PARAMETER_NAME);
+// String ajaxRegion = root.getAjaxRegionId(ajaxId);
+// if(null != ajaxRegion){
+// root.setSubmittedRegion(ajaxRegion);
+// }
+// }
+// }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.AjaxContainerRenderer#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ return AjaxViewRoot.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+// protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+// UIComponent submittedComponent = ((AjaxViewRoot) component).getSubmittedRegion(context);
+// if (null == submittedComponent) {
+// super.doEncodeEnd(writer,context,component);
+// } else {
+// submittedComponent.encodeEnd(context);
+// }
+// }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
+ * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+// protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+// // Reset instance of submitted region
+// AjaxViewRoot ajaxViewRoot = ((AjaxViewRoot) component);
+// ajaxViewRoot.resetSubmittedRegionInstance();
+// UIComponent submittedComponent = ajaxViewRoot.getSubmittedRegion(context);
+// if (null == submittedComponent) {
+// super.doEncodeBegin(writer, context, component);
+// } else {
+// submittedComponent.encodeBegin(context);
+// }
+// }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKit.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKit.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKit.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKit.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,40 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import javax.faces.render.RenderKit;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:55 $
+ *
+ */
+public interface ChameleonRenderKit {
+
+
+
+ /**
+ * @param renderKit
+ */
+ void setDefaultRenderKit(RenderKit renderKit);
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitFactory.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKitFactory.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitFactory.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitFactory.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,131 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.util.Iterator;
+
+import javax.faces.FactoryFinder;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.context.FacesContext;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:50 $
+ *
+ */
+public class ChameleonRenderKitFactory extends RenderKitFactory {
+ RenderKitFactory defaultFactory;
+
+ // private static final String AJAX_BASE_RENDER_KIT_PARAMETER =
+ // "AJAX_BASE_RENDERKIT_ID";
+ // private static final String AJAX_RENDER_KIT_PARAMETER =
+ // "AJAX_RENDER_KIT_ID";
+
+ private static final Log _log = LogFactory
+ .getLog(ChameleonRenderKitFactory.class);
+
+ /**
+ * @param defaultFactory
+ */
+ public ChameleonRenderKitFactory(RenderKitFactory defaultFactory) {
+ if (_log.isDebugEnabled()) {
+ _log.debug("ChameleonRenderKitFactory(RenderKitFactory) - Chameleon RenderKit factory instantiated"); //$NON-NLS-1$
+ }
+ this.defaultFactory = defaultFactory;
+ // Init resources builder before use.
+ InternetResourceBuilder.getInstance().init();
+ }
+
+ /**
+ * @param renderKitId
+ * @param renderKit
+ */
+ public void addRenderKit(String renderKitId, RenderKit renderKit) {
+ if (_log.isDebugEnabled()) {
+ _log.debug("addRenderKit(String, RenderKit) - Added RenderKit with id - renderKitId=" + renderKitId); //$NON-NLS-1$
+ }
+ if (renderKit instanceof ChameleonRenderKit) {
+ // ChameleonRenderKit chameleonRenderKit = (ChameleonRenderKit)
+ // renderKit;
+ // chameleonRenderKit.setConfiguration(ConfigurationFactory.getRendererConfigurationInstance(renderKitId))
+ // ;
+ }
+ defaultFactory.addRenderKit(renderKitId, renderKit);
+ }
+
+ /**
+ * @param context
+ * @param renderKitId
+ * @return
+ */
+ public RenderKit getRenderKit(FacesContext context, String renderKitId) {
+ RenderKit renderKit = defaultFactory.getRenderKit(context, renderKitId);
+ if (renderKit instanceof ChameleonRenderKit) {
+ if (_log.isDebugEnabled()) {
+ _log.debug(Messages
+ .getMessage(Messages.REQUEST_CHAMELEON_RENDER_KIT_INFO,
+ renderKitId));
+ }
+ String baseRenderKitId = null;
+ // TODO - get DefaultRenderKitId from ViewHandler ?
+ try {
+ // IN JSF-RI verifications, context may be null !
+ if (null != context) {
+ baseRenderKitId = context.getApplication()
+ .getDefaultRenderKitId();
+ } else {
+ ApplicationFactory appFactory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
+ baseRenderKitId = appFactory.getApplication()
+ .getDefaultRenderKitId();
+ }
+ } catch (Exception e) {
+ _log.warn(Messages
+ .getMessage(Messages.GET_DEFAULT_RENDER_KIT_ERROR), e);
+ }
+ if (baseRenderKitId == null) {
+ baseRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+ }
+ if (_log.isDebugEnabled()) {
+ _log.debug(Messages.getMessage(
+ Messages.DEFAULT_RENDER_KIT_INFO, baseRenderKitId));
+ }
+ ((ChameleonRenderKit) renderKit).setDefaultRenderKit(defaultFactory
+ .getRenderKit(context, baseRenderKitId));
+ }
+ return renderKit;
+ }
+
+ /**
+ * @return
+ */
+ public Iterator getRenderKitIds() {
+ return defaultFactory.getRenderKitIds();
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitImpl.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderKitImpl.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitImpl.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderKitImpl.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,163 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.FactoryFinder;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.Renderer;
+import javax.faces.render.ResponseStateManager;
+
+/**
+ * Wrapper for default applikation render kit. Only can append any
+ * custom renderers , all other methods delegate to default render kit.
+ *
+ * @see javax.faces.render.RenderKit
+ * @author shura
+ *
+ */
+public class ChameleonRenderKitImpl extends RenderKit implements ChameleonRenderKit {
+
+ private RenderKit defaultRenderKit = null;
+ public static final String RENDER_KIT_ID = "AJAX_HTML_BASIC";
+
+ private Map renderers;
+
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ public ChameleonRenderKitImpl()
+ {
+ renderers = new HashMap();
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ private String key(String componentFamily, String rendererType)
+ {
+ return componentFamily + "." + rendererType;
+ }
+ /**
+ * @param family
+ * @param rendererType
+ * @param renderer
+ */
+ public void addRenderer(String family, String rendererType,
+ Renderer renderer) {
+ if (renderer instanceof ChameleonRenderer) {
+ ChameleonRenderer chameleonRenderer = (ChameleonRenderer) renderer;
+// chameleonRenderer.setConfiguration(getConfiguration().getRendererConfiguration(family,rendererType));
+
+ }
+ renderers.put(key(family, rendererType), renderer);
+ }
+ /**
+ * @param writer
+ * @param contentTypeList
+ * @param characterEncoding
+ * @return
+ */
+ public ResponseWriter createResponseWriter(Writer writer,
+ String contentTypeList, String characterEncoding) {
+ return getDefaultRenderKit().createResponseWriter(writer, contentTypeList,
+ characterEncoding);
+ }
+ /**
+ * @param family
+ * @param rendererType
+ * @return
+ */
+ public Renderer getRenderer(String family, String rendererType) {
+ Renderer renderer = (Renderer) renderers.get(key(family, rendererType));
+ if (renderer != null) {
+ return renderer;
+ }
+ return getDefaultRenderKit().getRenderer(family, rendererType);
+ }
+ /**
+ * @return
+ */
+ public ResponseStateManager getResponseStateManager() {
+ return getDefaultRenderKit().getResponseStateManager();
+ }
+
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.RenderKit#createResponseStream(java.io.OutputStream)
+ */
+ public ResponseStream createResponseStream(OutputStream out)
+ {
+ return getDefaultRenderKit().createResponseStream(out);
+ }
+
+ /**
+ * TODO - create own implementation for @see javax.faces.component.UIViewRoot ,
+ * and get default renderKitId as value, setted at creation time.
+ * in this case, we can substitute concrete renderKit even if it pointed
+ * as value for <f:view> tag on 1.2 specification.
+ * @return Returns the defaultRenderer.
+ */
+ protected RenderKit getDefaultRenderKit() {
+ if (defaultRenderKit == null)
+ {
+ String defaultRenderkitId = null;
+ FacesContext context = null;
+ RenderKitFactory rdf = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ try {
+ context = FacesContext.getCurrentInstance();
+ // IN JSF-RI verifications, context may be null !
+ if(null != context) {
+ defaultRenderkitId = context.getApplication()
+ .getDefaultRenderKitId();
+ } else {
+ ApplicationFactory appFactory =(ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+ defaultRenderkitId = appFactory.getApplication().getDefaultRenderKitId();
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ if(defaultRenderkitId == null ){
+ defaultRenderkitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+ }
+ defaultRenderKit = rdf.getRenderKit(context, defaultRenderkitId);
+
+ }
+
+ return defaultRenderKit;
+ }
+
+ public void setDefaultRenderKit(RenderKit renderKit) {
+ // TODO Auto-generated method stub
+ this.defaultRenderKit = renderKit;
+
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderer.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ChameleonRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderer.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ChameleonRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,37 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import org.ajax4jsf.resource.ResourceProduser;
+
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:50 $
+ *
+ */
+public interface ChameleonRenderer extends ResourceProduser{
+
+
+
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentRendererBase.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentRendererBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentRendererBase.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,108 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.util.HashMap;
+import java.util.Stack;
+
+import javax.faces.component.UIComponent;
+
+
+
+/**
+ * Components Base Renderer for all chameleon Skin's and components.
+ * At most, make all common procedures and realise concrete work in "template" methods.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:52 $
+ *
+ */
+public abstract class ComponentRendererBase extends RendererBase{
+
+ /**
+ * logger for common cases.
+ */
+ protected static final String COMPONENT_RENDERER_BASE = ComponentRendererBase.class.getName();
+
+
+ public ComponentVariables getVariables(UIComponent component) {
+ HashMap components;
+ Stack stackComponentsVariables;
+ ComponentVariables variables;
+
+
+
+ components = (HashMap)component.getAttributes().get( COMPONENT_RENDERER_BASE );
+
+ if ( components == null ) {
+ components = new HashMap();
+ component.getAttributes().put( COMPONENT_RENDERER_BASE, components );
+ }
+
+ stackComponentsVariables = (Stack)components.get( this.getClass().getName() );
+
+ if ( stackComponentsVariables == null ) {
+ stackComponentsVariables = new Stack();
+ components.put( COMPONENT_RENDERER_BASE, stackComponentsVariables );
+ }
+
+ if ( stackComponentsVariables.empty() ) {
+ variables = new ComponentVariables();
+ stackComponentsVariables.push( variables );
+ } else {
+ variables = (ComponentVariables)stackComponentsVariables.peek();
+ }
+
+ return variables;
+ }
+
+ public void removeVariables(UIComponent component) {
+ HashMap components;
+ Stack stackComponentsVariables;
+ ComponentVariables variables;
+
+
+
+ components = (HashMap)component.getAttributes().get( COMPONENT_RENDERER_BASE );
+
+ if ( components != null ) {
+
+ stackComponentsVariables = (Stack)component.getAttributes().get( this.getClass().getName() );
+
+ if ( stackComponentsVariables != null ) {
+ if ( !stackComponentsVariables.empty() ) {
+ stackComponentsVariables.pop();
+ }
+
+ if ( stackComponentsVariables.empty() ) {
+ components.remove( this.getClass().getName() );
+ }
+ }
+
+ if ( components.isEmpty() ) {
+ component.getAttributes().remove( COMPONENT_RENDERER_BASE );
+ }
+
+
+ }
+
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentUtils.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentUtils.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentUtils.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentUtils.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,134 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.MethodNotFoundException;
+
+import org.ajax4jsf.Messages;
+import org.apache.commons.beanutils.MethodUtils;
+
+/**
+ * Utils for working with tempates
+ * @author ayukhovich(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:52 $
+ */
+public class ComponentUtils {
+ private final static String UTILS_PREFIX = "util.";
+ /**
+ *
+ * @param className
+ * @param functionName
+ * @param parameters
+ * @return
+ */
+ public static Object callFunction( FacesContext context, UIComponent component, RendererBase renderer, String functionName, Object[] parameters ) {
+
+ Object returnObject = null;
+
+ int sizeParameters = 0;
+ int sizeArrayParameters = 2;
+ if ( parameters != null ) {
+ sizeParameters = parameters.length;
+ sizeArrayParameters = 3;
+ }
+
+ Object[][] arrayParameters = new Object[sizeArrayParameters][];
+ arrayParameters[0] = new Object[sizeParameters+2];
+ arrayParameters[1] = new Object[sizeParameters+1];
+
+ if ( sizeParameters != 0 ) {
+ arrayParameters[2] = new Object[sizeParameters];
+ }
+
+ arrayParameters[0][0] = context;
+ arrayParameters[0][1] = component;
+ arrayParameters[1][0] = component;
+
+ if ( parameters != null ) {
+ for (int iParameter=0;iParameter<parameters.length;iParameter++) {
+ arrayParameters[0][iParameter+2] = parameters;
+ arrayParameters[1][iParameter+1] = parameters;
+ arrayParameters[2][iParameter] = parameters;
+ }
+ }
+
+ String methodName;
+ Object object;
+ if(functionName.startsWith(UTILS_PREFIX)){
+ methodName = functionName.substring(UTILS_PREFIX.length());
+ object = renderer.getUtils();
+ } else {
+ object = renderer;
+ methodName = functionName;
+ }
+
+
+ returnObject = invokeMethod(object, methodName, arrayParameters );
+
+ return returnObject;
+ }
+
+ /**
+ * Invoke a named method whose parameter type matches the object type.
+ * @param objects - invoke method on this object
+ * @param methodName - get method with this name
+ * @param arrayParameters - use these arguments - treat null as empty array
+ * @return
+ */
+ private static Object invokeMethod(Object object, String methodName, Object[][] arrayParameters) {
+
+ try {
+ for (int iParameter = 0; iParameter < arrayParameters.length; iParameter++) {
+ try {
+ return MethodUtils.invokeMethod(object, methodName, arrayParameters[iParameter]);
+ } catch (NoSuchMethodException e) {
+ continue;
+ }
+ }
+ } catch (InvocationTargetException e) {
+ throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_2b, methodName, e.getCause().getMessage()), e);
+ } catch (IllegalAccessException e) {
+ throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_4b, methodName, e.getMessage()), e);
+ }
+ throw new MethodNotFoundException(Messages.getMessage(Messages.METHOD_CALL_ERROR_6b, methodName, object));
+ }
+
+ /**
+ * Write html-attribute
+ * @param writer
+ * @param attribute
+ * @param value
+ * @throws IOException
+ */
+ public static void writeAttribute(ResponseWriter writer, String attribute, Object value ) throws IOException {
+ if ( (value != null) && (value.toString().length()!=0) ) {
+ writer.writeAttribute(attribute, value.toString(), attribute );
+ }
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentVariables.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentVariables.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentVariables.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentVariables.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,93 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+
+/**
+ * storing tempates variables
+ * @author ayukhovich(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/28 17:01:01 $
+ */
+public class ComponentVariables implements Serializable {
+
+ private transient HashMap variablesMap = new HashMap();
+
+ /**
+ * setting variable
+ * @param variableName
+ * @param variable
+ */
+ public void setVariable(final String variableName, final Object variable ) {
+ variablesMap.put(variableName, variable);
+ }
+
+ /**
+ *
+ * @param variableName
+ * @return
+ */
+ public Object getVariable(final String variableName ) {
+ return variablesMap.get(variableName);
+ }
+
+
+ /**
+ *
+ * @param variableName
+ * @param addValue
+ */
+ public void addValueToVariable(final String variableName, final Object addValue) {
+ Object variable = getVariable(variableName);
+ if ( variable == null )
+ return;
+
+ if (variable instanceof Integer) {
+ addToValue( variableName,(Integer) variable, addValue);
+ }
+ }
+
+ /**
+ *
+ * @param variableName
+ * @param variable
+ * @param addValue
+ */
+ protected void addToValue(final String variableName, Integer variable, final Object addValue ) {
+ Integer retultValue;
+ if ( addValue instanceof Integer ) {
+ Integer intAddValue =(Integer)addValue;
+ retultValue = new Integer(variable.intValue() + intAddValue.intValue());
+ } else {
+ retultValue = variable;
+ }
+
+ setVariable(variableName, retultValue);
+ }
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException{
+ variablesMap = new HashMap();
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentsVariableResolver.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/ComponentsVariableResolver.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentsVariableResolver.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/ComponentsVariableResolver.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,62 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * Resolve component variables
+ *
+ * @author ayukhovich(a)exadel.com (latest modification by $Author:
+ * alexeyyukhovich $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:53 $
+ */
+public class ComponentsVariableResolver {
+ private static String COMPONENTS_VARIABLE_RESOLVER = ComponentsVariableResolver.class
+ .getName();
+
+ private static String getAttributeName(RendererBase renderer) {
+ return COMPONENTS_VARIABLE_RESOLVER + ":" + (renderer != null ? renderer.getClass().getName() : null);
+ }
+
+ public static ComponentVariables getVariables(RendererBase renderer,
+ UIComponent component) {
+ ComponentVariables variables;
+
+ String attributeName = getAttributeName(renderer);
+
+ variables = (ComponentVariables) component.getAttributes().get(attributeName);
+
+ if (variables == null) {
+ variables = new ComponentVariables();
+
+ component.getAttributes().put(attributeName, variables);
+ }
+
+ return variables;
+ }
+
+ public static void removeVariables(RendererBase renderer,
+ UIComponent component) {
+ component.getAttributes().remove(getAttributeName(renderer));
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java (from rev 1559, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourcesRendererBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,137 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.io.IOException;
+import java.util.LinkedHashSet;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.HeaderResourceProducer;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.webapp.BaseFilter;
+
+/**
+ * Base renderer for components used JavaScripts and Styles in header. In real
+ * class override getScripts or/and getStyles methods
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:51 $
+ *
+ */
+public abstract class HeaderResourcesRendererBase extends RendererBase
+ implements HeaderResourceProducer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderScripts(javax.faces.context.FacesContext)
+ */
+ public LinkedHashSet getHeaderScripts(FacesContext context,
+ UIComponent component) {
+ return getUrisSet(context, getScripts(), component);
+ }
+
+ /**
+ * Hoock method to return array of scripts resources to store in head.
+ *
+ * @return
+ */
+ protected InternetResource[] getScripts() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderStyles(javax.faces.context.FacesContext)
+ */
+ public LinkedHashSet getHeaderStyles(FacesContext context,
+ UIComponent component) {
+ return getUrisSet(context, getStyles(), component);
+ }
+
+ /**
+ * Hoock method to return array of styles resources to store in head
+ *
+ * @return
+ */
+ protected InternetResource[] getStyles() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @param context
+ * @param resources
+ * @param component
+ * TODO
+ * @return
+ */
+ private LinkedHashSet getUrisSet(FacesContext context,
+ InternetResource[] resources, UIComponent component) {
+ if (null != resources) {
+ LinkedHashSet uris = new LinkedHashSet(); // Collections.singleton(ajaxScript.getUri(context,
+ // null));
+ for (int i = 0; i < resources.length; i++) {
+ InternetResource resource = resources[i];
+ uris.add(resource.getUri(context, component));
+ }
+ return uris;
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#preEncodeBegin(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ protected void preEncodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ if ((null == context.getExternalContext().getRequestMap().get(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE))
+ /*&& (!AjaxRendererUtils.isAjaxRequest(context))*/) {
+ // Filter not used - encode scripts and CSS before component.
+ encodeResourcesArray(context, component, getScripts());
+ encodeResourcesArray(context, component, getStyles());
+ }
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @param scripts
+ * @throws IOException
+ */
+ protected void encodeResourcesArray(FacesContext context, UIComponent component, InternetResource[] scripts) throws IOException {
+ if (scripts != null) {
+ for (int i = 0; i < scripts.length; i++) {
+ scripts[i].encode(context,component);
+ }
+ }
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/PrototypeBasedRendererBase.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/PrototypeBasedRendererBase.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/PrototypeBasedRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.util.LinkedHashSet;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.HeaderResourceProducer;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.PrototypeScript;
+
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class PrototypeBasedRendererBase extends RendererBase implements HeaderResourceProducer{
+
+ protected static final String[] EMPTY_ARRAY = {};
+ private InternetResource prototypeScript = getResource(PrototypeScript.class.getName());
+
+ public LinkedHashSet getHeaderScripts(FacesContext context, UIComponent component) {
+ LinkedHashSet scripts = new LinkedHashSet() ; // Collections.singleton(ajaxScript.getUri(context, null));
+ scripts.add(prototypeScript.getUri(context, null));
+ String[] additionalScripts = getAdditionalScripts();
+ for (int i = 0; i < additionalScripts.length; i++) {
+ String resource = additionalScripts[i];
+ scripts.add(getResource(resource).getUri(context, null));
+ }
+ return scripts;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderStyles(javax.faces.context.FacesContext)
+ */
+ public LinkedHashSet getHeaderStyles(FacesContext context, UIComponent component) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ protected String[] getAdditionalScripts() {
+ return EMPTY_ARRAY;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,289 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceNotFoundException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+
+/**
+ * Base Renderer for all chameleon Skin's and components.
+ * At most, make all common procedures and realise concrete work in "template" methods.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:51 $
+ *
+ */
+public abstract class RendererBase extends Renderer implements
+ ChameleonRenderer {
+
+ /**
+ * logger for common cases.
+ */
+ protected static final String JAVASCRIPT_NAMESPACE = "Exadel";
+ private static final Log log = LogFactory.getLog(RendererBase.class);
+ private static final RendererUtils utils = new RendererUtils();
+
+ private SkinFactory skinFactory = null;
+ private InternetResourceBuilder resourceBuilder = null;
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void decode(FacesContext context, UIComponent component) {
+ // Test for correct parameters.
+ if (context == null) throw new NullPointerException(Messages.getMessage(Messages.CONTEXT_NULL_ERROR, "decode"));
+ if (component == null) throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR, "decode"));
+ if (! getComponentClass().isInstance(component)) throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, "", getComponentClass().getName()));
+ if(log.isDebugEnabled()){
+ log.debug(Messages.getMessage(Messages.START_DECODING_COMPONENT_INFO, component.getClientId(context), component.getClass().getName()));
+ }
+ preDecode(context,component);
+ // TODO - create set od common decoders ( UIInput, ActionSource etc. ) for process decoding.
+ if (component.isRendered()) {
+ doDecode(context, component);
+ }
+ }
+
+ protected void preDecode(FacesContext context, UIComponent component) {
+ }
+
+ protected void preEncodeBegin(FacesContext context, UIComponent component) throws IOException {
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
+ // Test for correct parameters.
+ if (context == null) throw new NullPointerException(Messages.getMessage(Messages.CONTEXT_NULL_ERROR, "encodeBegin"));
+ if (component == null) throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR, "encodeBegin"));
+ if (! getComponentClass().isInstance(component)) throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, component.getClientId(context), getComponentClass().getName()));
+ if(log.isDebugEnabled()){
+ log.debug(Messages.getMessage(Messages.START_ENCODING_COMPONENT_INFO, component.getClientId(context), component.getClass().getName()));
+ }
+ preEncodeBegin(context,component);
+ if (component.isRendered()) {
+ ResponseWriter writer = context.getResponseWriter();
+ doEncodeBegin(writer, context, component);
+ }
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
+ // Test for correct parameters.
+ if (context == null) throw new NullPointerException(Messages.getMessage(Messages.CONTEXT_NULL_ERROR, "encodeBegin"));
+ if (component == null) throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR, "encodeBegin"));
+ if (! getComponentClass().isInstance(component)) throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, component.getClientId(context), getComponentClass().getName()));
+ if(log.isDebugEnabled()){
+ log.debug(Messages.getMessage(Messages.CHILDREN_ENCODING_COMPONENT_INFO, component.getClientId(context), component.getClass().getName()));
+ }
+ preEncodeBegin(context,component);
+ if (component.isRendered()) {
+ ResponseWriter writer = context.getResponseWriter();
+ doEncodeChildren(writer, context, component);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
+ // Test for correct parameters.
+ if (context == null) throw new NullPointerException(Messages.getMessage(Messages.CONTEXT_NULL_ERROR, "encodeEnd"));
+ if (component == null) throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR, "encodeEnd"));
+ if (! getComponentClass().isInstance(component)) throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, component.getClientId(context), getComponentClass().getName()));
+ if (component.isRendered()) {
+ ResponseWriter writer = context.getResponseWriter();
+ doEncodeEnd(writer, context, component);
+ }
+ if(log.isDebugEnabled()){
+ log.debug(Messages.getMessage(Messages.FINISH_ENCODING_COMPONENT_INFO, component.getClientId(context), component.getClass().getName()));
+ }
+ }
+
+ /**
+ * Base stub method for produce internet resource ( image, script ... )
+ * since resources must be implemented in "lightweight" pattern, it instances
+ * put in internal map to caching.
+ * @param resourceURI - relative ( to renderer class ) uri to resource in jar or
+ * key for generate ( in Java2D , for example ).
+ * @return - resource instance for this uri.
+ * @throws ResourceNotFoundException - if reqested resource not instantiated.
+ */
+ public InternetResource getResource(String resourceURI ) throws FacesException {
+ return getResourceBuilder().createResource(this,resourceURI);
+ }
+
+ private InternetResourceBuilder getResourceBuilder(){
+ if (resourceBuilder == null) {
+ resourceBuilder = InternetResourceBuilder.getInstance();
+
+ }
+
+ return resourceBuilder;
+ }
+ //==========================================================
+ // Protected common methods - for all Renderer's
+
+ /**
+ * Calculate current Skin for rendering.
+ * @param context - current {@link FacesContext }
+ * @return
+ */
+ protected Skin getSkin(FacesContext context) {
+ if (skinFactory == null) {
+ skinFactory = SkinFactory.getInstance();
+
+ }
+
+ return skinFactory.getSkin(context);
+ }
+
+
+ /**
+ * Due to big number of common utility methods, base renderer divide to 2 classes - renderer and utils.
+ * since use static methods of utility class breack object paradigm, we use getter for concrete util instance.
+ * Developer can override any utility metod in 2 stages :
+ * 1) Create subclass of {@link RendererUtils} and override utility method.
+ * 2) Override this method for return instance of such subclass.
+ *
+ * @return Returns the utils.
+ */
+ public RendererUtils getUtils() {
+ return utils;
+ }
+
+
+ /**
+ * Get base component slass , targetted for this renderer. Used for check arguments in decode/encode.
+ * @return
+ */
+ protected abstract Class getComponentClass();
+
+
+ /**
+ * Template method for custom decoding of concrete renderer.
+ * All parameters checking if performed in original {@see decode } method.
+ * @param context
+ * @param component
+ */
+ protected void doDecode(FacesContext context, UIComponent component) {
+
+ }
+
+ /**
+ * Template method for custom start encoding of concrete renderer.
+ * All parameters checking and writer is performed in original {@link encodeBegin } method.
+ * @param writer
+ * @param context
+ * @param component
+ */
+ protected void doEncodeBegin(ResponseWriter writer,FacesContext context, UIComponent component) throws IOException {
+
+ }
+ /**
+ * @param writer
+ * @param context
+ * @param component
+ */
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ // Hook method, must be overriden in renderers with special children processing
+ }
+
+ /**
+ * Template method for custom finish encoding of concrete renderer.
+ * All parameters checking and writer is performed in original {@link encodeEnd } method.
+ * @param writer
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+
+ }
+ /**
+ * Append new resource to renderer cache.
+ * @param key
+ * @param resource
+ */
+ protected void addResource(String key, InternetResource resource) {
+ getResourceBuilder().addResource(key,resource);
+ }
+
+ /**
+ * Render all children for given component.
+ * @param facesContext
+ * @param component
+ * @throws IOException
+ */
+ public void renderChildren(FacesContext facesContext,
+ UIComponent component) throws IOException {
+ if (component.getChildCount() > 0) {
+ for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
+ UIComponent child = (UIComponent) it.next();
+ renderChild(facesContext, child);
+ }
+ }
+ }
+
+
+ /**
+ * Render one component and it childrens
+ * @param facesContext
+ * @param child
+ * @throws IOException
+ */
+ public void renderChild(FacesContext facesContext, UIComponent child)
+ throws IOException {
+ if (!child.isRendered()) {
+ return;
+ }
+
+ child.encodeBegin(facesContext);
+ if (child.getRendersChildren()) {
+ child.encodeChildren(facesContext);
+ } else {
+ renderChildren(facesContext, child);
+ }
+ child.encodeEnd(facesContext);
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -0,0 +1,803 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit;
+
+import java.awt.Dimension;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
+import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.Java2Dresource;
+
+
+/**
+ * Util class for common render operations - render passthru html attributes,
+ * iterate over child components etc.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
+ *
+ */
+public class RendererUtils {
+
+ public static final String DUMMY_FORM_ID = ":_form";
+ /**
+ * Substitutions for components properies names and HTML attributes names.
+ */
+ private static Map substitutions = new HashMap();
+
+ static {
+ substitutions.put(HTML.class_ATTRIBUTE,"styleClass");
+ Arrays.sort(HTML.PASS_THRU);
+ Arrays.sort(HTML.PASS_THRU_BOOLEAN);
+ Arrays.sort(HTML.PASS_THRU_URI);
+ }
+ /**
+ * Common HTML elements and attributes names.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
+ *
+ */
+ public interface HTML {
+ // elements
+ public static final String BUTTON = "button";
+ // attributes
+ public static final String id_ATTRIBUTE = "id";
+ public static final String class_ATTRIBUTE = "class";
+// public static final String STYLE_ATTRIBUTE = "style";
+// public static final String dir_ATTRIBUTE = "dir";
+// public static final String lang_ATTRIBUTE = "lang";
+// public static final String title_ATTRIBUTE = "title";
+ public static final String accesskey_ATTRIBUTE = "accesskey";
+ public static final String alt_ATTRIBUTE = "alt";
+ public static final String cols_ATTRIBUTE = "cols";
+
+ public static final String height_ATTRIBUTE = "height";
+
+ public static final String lang_ATTRIBUTE = "lang";
+
+ public static final String longdesc_ATTRIBUTE = "longdesc";
+
+ public static final String maxlength_ATTRIBUTE = "maxlength";
+
+ public static final String onblur_ATTRIBUTE = "onblur";
+
+ public static final String onchange_ATTRIBUTE = "onchange";
+
+ public static final String onclick_ATTRIBUTE = "onclick";
+
+ public static final String ondblclick_ATTRIBUTE = "ondblclick";
+
+ public static final String onfocus_ATTRIBUTE = "onfocus";
+
+ public static final String onkeydown_ATTRIBUTE = "onkeydown";
+
+ public static final String onkeypress_ATTRIBUTE = "onkeypress";
+
+ public static final String onkeyup_ATTRIBUTE = "onkeyup";
+
+ public static final String onload_ATTRIBUTE = "onload";
+
+ public static final String onmousedown_ATTRIBUTE = "onmousedown";
+
+ public static final String onmousemove_ATTRIBUTE = "onmousemove";
+
+ public static final String onmouseout_ATTRIBUTE = "onmouseout";
+
+ public static final String onmouseover_ATTRIBUTE = "onmouseover";
+
+ public static final String onmouseup_ATTRIBUTE = "onmouseup";
+
+ public static final String onreset_ATTRIBUTE = "onreset";
+
+ public static final String onselect_ATTRIBUTE = "onselect";
+
+ // public static final String onsubmit_ATTRIBUTE = "onsubmit";
+ public static final String onunload_ATTRIBUTE = "onunload";
+
+ public static final String rows_ATTRIBUTE = "rows";
+
+ public static final String size_ATTRIBUTE = "size";
+
+ public static final String tabindex_ATTRIBUTE = "tabindex";
+
+ public static final String title_ATTRIBUTE = "title";
+
+ public static final String style_ATTRIBUTE = "style";
+
+ public static final String align_ATTRIBUTE = "align";
+
+ public static final String width_ATTRIBUTE = "width";
+
+ public static final String dir_ATTRIBUTE = "dir";
+
+ public static final String rules_ATTRIBUTE = "rules";
+
+ public static final String frame_ATTRIBUTE = "frame";
+
+ public static final String border_ATTRIBUTE = "border";
+
+ public static final String cellspacing_ATTRIBUTE = "cellspacing";
+
+ public static final String cellpadding_ATTRIBUTE = "cellpadding";
+
+ public static final String summary_ATTRIBUTE = "summary";
+
+ public static final String bgcolor_ATTRIBUTE = "bgcolor";
+
+ public static final String usemap_ATTRIBUTE = "usemap";
+
+ public static final String enctype_ATTRIBUTE = "enctype";
+
+ public static final String accept_charset_ATTRIBUTE = "accept-charset";
+
+ public static final String accept_ATTRIBUTE = "accept";
+
+ public static final String target_ATTRIBUTE = "target";
+
+ public static final String onsubmit_ATTRIBUTE = "onsubmit";
+
+ public static final String readonly_ATTRIBUTE = "readonly";
+
+ public static final String nowrap_ATTRIBUTE = "nowrap";
+
+ //public static final String onreset_ATTRIBUTE = "onreset";
+ // attributes sets.
+ public static final String[] PASS_THRU = {
+// DIR_ATTRIBUTE,
+// LANG_ATTRIBUTE,
+// STYLE_ATTRIBUTE,
+// TITLE_ATTRIBUTE
+ "accesskey",
+ "alt",
+ "cols",
+ "height",
+ "lang",
+ "longdesc",
+ "maxlength",
+ "onblur",
+ "onchange",
+ "onclick",
+ "ondblclick",
+ "onfocus",
+ "onkeydown",
+ "onkeypress",
+ "onkeyup",
+ "onload",
+ "onmousedown",
+ "onmousemove",
+ "onmouseout",
+ "onmouseover",
+ "onmouseup",
+ "onreset",
+ "onselect",
+ "onsubmit",
+ "onunload",
+ "rows",
+ "size",
+ "tabindex",
+ "title",
+ "width",
+ "dir",
+ "rules",
+ "frame",
+ "border",
+ "cellspacing",
+ "cellpadding",
+ "summary",
+ "bgcolor",
+ "usemap",
+ "enctype",
+ "accept-charset",
+ "accept",
+ "target",
+ "charset",
+ "coords",
+ "hreflang",
+ "rel",
+ "rev",
+ "shape",
+ "disabled",
+ "readonly",
+ "ismap"
+
+ };
+
+ /**
+ * HTML attributes allowed boolean-values only
+ */
+ public static final String[] PASS_THRU_BOOLEAN = {
+ "disabled",
+ "declare",
+ "readonly",
+ "compact",
+ "ismap",
+ "selected",
+ "checked",
+ "nowrap",
+ "noresize",
+ "nohref",
+ "noshade",
+ "multiple"
+ };
+
+
+ /**
+ * all HTML attributes with URI value.
+ */
+ public static final String[] PASS_THRU_URI = {
+ "usemap",
+ "background",
+ "codebase",
+ "cite",
+ "data",
+ "classid",
+ "href",
+ "longdesc",
+ "profile",
+ "src"
+ };
+
+ public static final String[] PASS_THRU_STYLES = {
+ "style",
+ "class",
+ };
+
+ public static final String SPAN_ELEM = "span";
+ public static final String DIV_ELEM = "div";
+ public static final String SCRIPT_ELEM = "script";
+ public static final String STYLE_CLASS_ATTR = "styleClass";
+ public static final String DISABLED_ATTR = "disabled";
+ public static final String TYPE_ATTR = "type";
+ public static final String CHARSET_ATTR = "charset";
+ public static final String COORDS_ATTR = "coords";
+ public static final String HREFLANG_ATTR = "hreflang";
+ public static final String REL_ATTR = "rel";
+ public static final String REV_ATTR = "rev";
+ public static final String SHAPE_ATTR = "shape";
+ public static final String title_ELEM = "title";
+ public static final String FORM_ELEMENT = "form";
+ public static final String NAME_ATTRIBUTE = "name";
+ public static final String METHOD_ATTRIBUTE = "method";
+ public static final String ACTION_ATTRIBUTE = "action";
+ public static final String INPUT_ELEM = "input";
+ public static final Object INPUT_TYPE_HIDDEN = "hidden";
+ public static final String value_ATTRIBUTE = "value";
+ public static final String td_ELEM = "td";
+ public static final String th_ELEM = "th";
+ public static final String valign_ATTRIBUTE = "valign";
+ public static final String a_ELEMENT = "a";
+ public static final String HTML_ELEMENT = "html";
+ public static final String BODY_ELEMENT = "body";
+ public static final String TR_ELEMENT = "tr";
+ public static final String CAPTION_ELEMENT = "caption";
+ public static final String THEAD_ELEMENT = "thead";
+ public static final String TFOOT_ELEMENT = "tfoot";
+ }
+
+ /**
+ * Encode id attribute with clientId component property
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeId(FacesContext context, UIComponent component) throws IOException {
+ encodeId(context,component,HTML.id_ATTRIBUTE);
+ }
+
+ /**
+ * Encode clientId to custom attribute ( for example, to control name )
+ * @param context
+ * @param component
+ * @param attribute
+ * @throws IOException
+ */
+ public void encodeId(FacesContext context,UIComponent component, String attribute) throws IOException {
+ String clientId = null;
+ try {
+ clientId = component.getClientId(context);
+ } catch(Exception e) {
+ //just ignore if clientId wasn't inited yet
+ }
+ if (null != clientId) {
+ context.getResponseWriter().writeAttribute(attribute,
+ clientId,
+ (String) getComponentAttributeName(attribute));
+ }
+ }
+ /**
+ * Encode id attribute with clientId component property.
+ * Encoded only if id not auto generated.
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeCustomId(FacesContext context, UIComponent component) throws IOException {
+ if(component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)){
+ context.getResponseWriter().writeAttribute(HTML.id_ATTRIBUTE,component.getClientId(context),HTML.id_ATTRIBUTE);
+ }
+ }
+
+ /**
+ * Encode common pass-thru html attributes.
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodePassThru(FacesContext context, UIComponent component) throws IOException {
+ encodeAttributesFromArray(context,component,HTML.PASS_THRU);
+ }
+
+ /**
+ * Encode pass-through attributes except specified ones
+ * @param context
+ * @param component
+ * @param exclusions
+ * @throws IOException
+ */
+ public void encodePassThruWithExclusions(FacesContext context, UIComponent component,String exclusions) throws IOException{
+ if (null != exclusions) {
+ String[] exclusionsArray = exclusions.split(",");
+ encodePassThruWithExclusionsArray(context,component,exclusionsArray);
+ }
+ }
+
+ public void encodePassThruWithExclusionsArray(FacesContext context, UIComponent component,String[] exclusions) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ Map attributes = component.getAttributes();
+ Arrays.sort(exclusions);
+ for (int i = 0; i < HTML.PASS_THRU.length; i++) {
+ String attribute = HTML.PASS_THRU[i];
+ if(Arrays.binarySearch(exclusions, attribute) < 0){
+ encodePassThruAttribute(context, attributes, writer, attribute);
+ }
+ }
+ }
+
+ /**
+ * Encode one pass-thru attribute, with plain/boolean/url value, got from properly component attribute.
+ * @param context
+ * @param component
+ * @param writer
+ * @param attribute
+ * @throws IOException
+ */
+ public void encodePassThruAttribute(FacesContext context, Map attributes, ResponseWriter writer, String attribute) throws IOException {
+ Object value = attributeValue(attribute,attributes.get(getComponentAttributeName(attribute)));
+ if (null != value && shouldRenderAttribute(value)) {
+ if(Arrays.binarySearch(HTML.PASS_THRU_URI, attribute)>=0){
+ String url = context.getApplication().getViewHandler().getResourceURL(context, value.toString());
+ url = context.getExternalContext().encodeResourceURL(url);
+ writer.writeURIAttribute(attribute,url,attribute);
+ } else {
+ writer.writeAttribute(attribute,value,attribute);
+ }
+ }
+ }
+
+
+ public void encodeAttributesFromArray(FacesContext context, UIComponent component,String[] attrs) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ Map attributes = component.getAttributes();
+ for (int i = 0; i < attrs.length; i++) {
+ String attribute = attrs[i];
+ encodePassThruAttribute(context, attributes, writer, attribute);
+ }
+ }
+
+
+ /**
+ * Encode attributes given by comma-separated string list.
+ * @param context current JSF context
+ * @param component for with render attributes values
+ * @param attrs comma separated list of attributes
+ * @throws IOException
+ */
+ public void encodeAttributes(FacesContext context, UIComponent component,String attrs) throws IOException {
+ if (null != attrs) {
+ String[] attrsArray = attrs.split(",");
+ encodeAttributesFromArray(context,component,attrsArray);
+ }
+ }
+ /**
+ * @param context
+ * @param component
+ * @param string
+ * @param string2
+ * @throws IOException
+ */
+ public void encodeAttribute(FacesContext context, UIComponent component, Object property, String attributeName) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ Object value = component.getAttributes().get(property);
+ if (shouldRenderAttribute(value)) {
+ writer.writeAttribute(attributeName,value,property.toString());
+ }
+
+ }
+
+ public void encodeAttribute(FacesContext context, UIComponent component,String attribute) throws IOException {
+ encodeAttribute(context,component,getComponentAttributeName(attribute),attribute);
+ }
+ /**
+ * Write html-attribute
+ * @param writer
+ * @param attribute
+ * @param value
+ * @throws IOException
+ */
+ public void writeAttribute(ResponseWriter writer, String attribute, Object value ) throws IOException {
+ if ( shouldRenderAttribute(value) ) {
+ writer.writeAttribute(attribute, value.toString(), attribute );
+ }
+ }
+
+ /**
+ * @return true if and only if the argument
+ * <code>attributeVal</code> is an instance of a wrapper for a
+ * primitive type and its value is equal to the default value for
+ * that type as given in the spec.
+ */
+
+ public boolean shouldRenderAttribute(Object attributeVal) {
+ if(null == attributeVal){
+ return false;
+ } else if (attributeVal instanceof Boolean &&
+ ((Boolean) attributeVal).booleanValue() ==
+ Boolean.FALSE.booleanValue()) {
+ return false;
+ } else if(attributeVal.toString().length() == 0){
+ return false;
+ } else return isValidProperty(attributeVal);
+ }
+
+
+ /**
+ * Test for valid value of property. by default, for non-setted properties with Java primitive types of
+ * JSF component return appropriate MIN_VALUE .
+ * @param property - value of property returned from {@link UIComponent#getAttributes()}
+ * @return true for setted property, false otherthise.
+ */
+ public boolean isValidProperty(Object property) {
+ if (null == property) {
+ return false;
+ } else if (property instanceof Integer
+ && ((Integer) property).intValue() == Integer.MIN_VALUE) {
+ return false;
+ } else if (property instanceof Double
+ && ((Double) property).doubleValue() == Double.MIN_VALUE) {
+ return false;
+ } else if (property instanceof Character
+ && ((Character) property).charValue() == Character.MIN_VALUE) {
+ return false;
+ } else if (property instanceof Float
+ && ((Float) property).floatValue() == Float.MIN_VALUE) {
+ return false;
+ } else if (property instanceof Short
+ && ((Short) property).shortValue() == Short.MIN_VALUE) {
+ return false;
+ } else if (property instanceof Byte
+ && ((Byte) property).byteValue() == Byte.MIN_VALUE) {
+ return false;
+ } else if (property instanceof Long
+ && ((Long) property).longValue() == Long.MIN_VALUE) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Convert HTML attribute name to component property name.
+ *
+ * @param key
+ * @return
+ */
+ protected Object getComponentAttributeName(Object key) {
+ Object converted = substitutions.get(key);
+ if (null==converted) {
+ return key;
+ } else {
+ return converted;
+ }
+ }
+
+ /**
+ * Convert attribute value to proper object. For known html boolean attributes return name
+ * for true value, otherthise - null. For non-boolean attributes return same value.
+ * @param name attribute name.
+ * @param value
+ * @return
+ */
+ protected Object attributeValue(String name, Object value){
+ if (null != value && Arrays.binarySearch(HTML.PASS_THRU_BOOLEAN,name)>=0) {
+ boolean checked = false;
+ if (value instanceof Boolean) {
+ checked = ((Boolean) value).booleanValue();
+ } else {
+ if( ! (value instanceof String) ){
+ value = value.toString();
+ }
+ checked = (new Boolean((String) value)).booleanValue();
+ }
+ return checked?name:null;
+ } else {
+ return value;
+ }
+ }
+
+
+ /**
+ * Get boolean value of logical attribute
+ * @param component
+ * @param name attribute name
+ * @return true if attribute is equals Boolean.TRUE or String "true" , false otherwise.
+ */
+ public boolean isBooleanAttribute(UIComponent component, String name){
+ Object attrValue = component.getAttributes().get(name);
+ boolean result = false;
+ if(null != attrValue){
+ if(attrValue instanceof String ){
+ result = "true".equalsIgnoreCase((String) attrValue);
+ } else {
+ result = Boolean.TRUE.equals(attrValue);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Return converted value for {@link javax.faces.component.ValueHolder} as String,
+ * perform nessesary convertions.
+ * @param context
+ * @param component
+ * @return
+ */
+ public String getValueAsString(FacesContext context, UIComponent component) {
+ // First - get submitted value for input components
+ if (component instanceof EditableValueHolder) {
+ EditableValueHolder input = (EditableValueHolder) component;
+ String submittedValue = (String) input.getSubmittedValue();
+ if(null != submittedValue) {
+ return submittedValue;
+ }
+ }
+ // If no submitted value presented - convert same for UIInput/UIOutput
+ if (component instanceof ValueHolder) {
+ return formatValue(context, component, ((ValueHolder) component).getValue() );
+ } else {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.CONVERTING_NON_VALUE_HOLDER_COMPONENT_ERROR, component.getId()));
+ }
+ }
+
+ /**
+ * Convert any object value to string. If component instance of {@link ValueHolder } got {@link Converter} for formatting.
+ * If not, attempt to use converter based on value type.
+ * @param context
+ * @param component
+ * @return
+ */
+ public String formatValue(FacesContext context, UIComponent component,Object value) {
+ if(value instanceof String) {
+ return (String) value;
+ }
+ Converter converter = null;
+ if (component instanceof ValueHolder) {
+ ValueHolder holder = (ValueHolder) component;
+ converter = holder.getConverter();
+ }
+ if(null == converter && null != value ) {
+ try {
+ converter = context.getApplication().createConverter(
+ value.getClass());
+ } catch (FacesException e) {
+ // TODO - log converter exception.
+ }
+ }
+ if(null == converter) {
+ if(null != value) {
+ return value.toString();
+ }
+ } else {
+ return converter.getAsString(context, component, value);
+ }
+ return "";
+ }
+
+ public void encodeDimensions(FacesContext context, UIComponent component, InternetResource resource) throws IOException {
+ if (resource instanceof Java2Dresource) {
+ Java2Dresource j2d = (Java2Dresource) resource;
+ Dimension dim = j2d.getDimensions(context, component);
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeAttribute("width", String.valueOf(dim.width), "width");
+ writer.writeAttribute("height", String.valueOf(dim.height), "height");
+ }
+ }
+ public String encodePx(String value){
+ return HtmlDimensions.formatPx(HtmlDimensions.decode(value));
+ }
+ /**
+ * formats given value to
+ * @param value
+ * @param pattern
+ * @return
+ */
+ public String encodePctOrPx(String value){
+ if(value.indexOf('%') > 0){
+ return value;
+ } else {
+ return encodePx(value);
+ }
+ }
+
+ /**
+ * Find nested form for given component
+ * @param component
+ * @return nested <code>UIForm</code> component, or <code>null</code>
+ */
+ public UIForm getNestingForm(FacesContext context,UIComponent component)
+ {
+ UIComponent parent = component.getParent();
+ while (parent != null && !(parent instanceof UIForm))
+ {
+ parent = parent.getParent();
+ }
+
+ UIForm nestingForm = null;
+ if (parent != null)
+ {
+ //link is nested inside a form
+ nestingForm = (UIForm) parent;
+ }
+ return nestingForm;
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @return
+ * @throws IOException
+ */
+ public void encodeBeginFormIfNessesary(FacesContext context, UIComponent component) throws IOException {
+ UIForm form = getNestingForm(context, component);
+ if(null == form) {
+ ResponseWriter writer = context.getResponseWriter();
+ String clientId = component.getClientId(context)+DUMMY_FORM_ID;
+ encodeBeginForm(context, component, writer, clientId);
+// writer.writeAttribute(HTML.style_ATTRIBUTE, "margin:0; padding:0;", null);
+ }
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @param writer
+ * @param clientId
+ * @throws IOException
+ */
+ public void encodeBeginForm(FacesContext context, UIComponent component, ResponseWriter writer, String clientId) throws IOException {
+ String actionURL = getActionUrl(context);
+ String encodeActionURL = context.getExternalContext().encodeActionURL(actionURL);
+
+ writer.startElement(HTML.FORM_ELEMENT, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, clientId, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId, null);
+ writer.writeAttribute(HTML.METHOD_ATTRIBUTE, "post", null);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "margin:0; padding:0;", null);
+ writer.writeURIAttribute(HTML.ACTION_ATTRIBUTE,
+ encodeActionURL,
+ "action");
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeEndFormIfNessesary(FacesContext context, UIComponent component) throws IOException {
+ UIForm form = getNestingForm(context, component);
+ if(null == form) {
+ ResponseWriter writer = context.getResponseWriter();
+ // TODO - hidden form parameters ?
+ encodeEndForm(context, writer);
+ }
+ }
+
+ /**
+ * @param context
+ * @param writer
+ * @throws IOException
+ */
+ public void encodeEndForm(FacesContext context, ResponseWriter writer) throws IOException {
+ AjaxRendererUtils.writeState(context);
+ writer.endElement(HTML.FORM_ELEMENT);
+ }
+
+ /**
+ * @param facesContext
+ * @return String A String representing the action URL
+ */
+ public String getActionUrl(FacesContext facesContext)
+ {
+ ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
+ String viewId = facesContext.getViewRoot().getViewId();
+ return viewHandler.getActionURL(facesContext, viewId);
+ }
+ /**
+ *
+ * @param context
+ * @param value
+ * @return URL of target resource (src, href, etc)
+ */
+ public String encodeResourceURL(TemplateContext context, Object value){
+ if(value == null){
+ return "";
+ }
+ FacesContext facesContext = context.getFacesContext();
+ value = facesContext.getApplication().getViewHandler().getResourceURL(facesContext, value.toString());
+ return facesContext.getExternalContext().encodeResourceURL((String)value);
+ }
+ /**
+ * Simplified version of {@link encodeId}
+ * @param context
+ * @param component
+ * @return client id of current component
+ */
+ public String clientId(FacesContext context, UIComponent component){
+ String clientId = "";
+ try {
+ clientId = component.getClientId(context);
+ } catch (Exception e) {
+ //just ignore
+ }
+ return clientId;
+ }
+
+ /**
+ * Wtrie JavaScript with start/end elements and type.
+ * @param context
+ * @param tab
+ * @param string
+ */
+
+ public void writeScript(FacesContext context, UIComponent component, Object script) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.SCRIPT_ELEM,component);
+ writer.writeAttribute(HTML.TYPE_ATTR,"text/javascript","type");
+ writer.writeText(script,null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ }
+
+}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -33,10 +33,10 @@
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
-import org.ajax4jsf.framework.renderer.RendererBase;
import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
+import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.skin.SkinFactory;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -40,7 +40,7 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.ajax.PushEventsCounter;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
import org.ajax4jsf.resource.InternetResourceService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -41,7 +41,7 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.application.AjaxViewHandler;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/framework/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -32,7 +32,7 @@
import javax.faces.event.PhaseId;
import javax.faces.event.ValueChangeEvent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.event.SwitchablePanelSwitchEvent;
/**
Modified: trunk/framework/impl/src/main/java/org/richfaces/component/util/FormUtil.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/component/util/FormUtil.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/richfaces/component/util/FormUtil.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -25,7 +25,7 @@
import javax.faces.component.UIForm;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.renderer.RendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.EnclosingFormRequiredException;
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -31,7 +31,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.renderer.AjaxChildrenRenderer;
+import org.ajax4jsf.renderkit.AjaxChildrenRenderer;
import org.ajax4jsf.resource.InternetResource;
/**
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -29,8 +29,8 @@
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
-import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
import org.ajax4jsf.framework.util.SelectUtils;
+import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -20,7 +20,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXResult;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.ajax4jsf.webapp.tidy.TidyParser;
import org.ajax4jsf.webapp.tidy.TidyXMLFilter;
import org.richfaces.json.JSContentHandler;
Modified: trunk/framework/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/faces-config.xml 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/impl/src/main/resources/META-INF/faces-config.xml 2007-07-10 01:10:15 UTC (rev 1560)
@@ -6,7 +6,7 @@
<faces-config>
<factory>
- <render-kit-factory>org.ajax4jsf.framework.renderer.ChameleonRenderKitFactory</render-kit-factory>
+ <render-kit-factory>org.ajax4jsf.renderkit.ChameleonRenderKitFactory</render-kit-factory>
<lifecycle-factory>org.ajax4jsf.application.DebugLifecycleFactory</lifecycle-factory>
</factory>
<application>
@@ -18,7 +18,7 @@
<state-manager>org.ajax4jsf.application.AjaxStateManager</state-manager>
</application>
<lifecycle>
- <phase-listener>org.ajax4jsf.framework.renderer.AjaxPhaseListener</phase-listener>
+ <phase-listener>org.ajax4jsf.renderkit.AjaxPhaseListener</phase-listener>
<phase-listener>org.ajax4jsf.event.InitPhaseListener</phase-listener>
</lifecycle>
<managed-bean>
@@ -55,7 +55,7 @@
</description>
<component-family>javax.faces.ViewRoot</component-family>
<renderer-type>javax.faces.ViewRoot</renderer-type>
- <renderer-class>org.ajax4jsf.framework.renderer.AjaxViewRootRenderer</renderer-class>
+ <renderer-class>org.ajax4jsf.renderkit.AjaxViewRootRenderer</renderer-class>
</renderer>
<!--
<renderer>
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/AbstractAjax4JsfTestCase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -46,11 +46,11 @@
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.context.AjaxContextImpl;
-import org.ajax4jsf.framework.renderer.AjaxViewRootRenderer;
-import org.ajax4jsf.framework.renderer.ChameleonRenderKitImpl;
import org.ajax4jsf.framework.skin.SkinBean;
import org.ajax4jsf.framework.skin.VersionBean;
import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.renderkit.AjaxViewRootRenderer;
+import org.ajax4jsf.renderkit.ChameleonRenderKitImpl;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.tests.org.apache.shale.test.config.ConfigParser;
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -26,6 +26,7 @@
import javax.faces.event.PhaseListener;
import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.renderkit.AjaxPhaseListener;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.ajax4jsf.webapp.BaseFilter;
import org.ajax4jsf.webapp.FilterServletResponseWrapper;
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/EventValueBinding.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -31,7 +31,7 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.component.AjaxComponent;
import org.ajax4jsf.component.AjaxSupport;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
/**
* Inner class for build event string for parent component.
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -36,7 +36,7 @@
import org.ajax4jsf.context.AjaxContextImpl;
import org.ajax4jsf.context.InvokerCallback;
import org.ajax4jsf.event.AjaxListener;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
/**
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxStatus.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxStatus.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxStatus.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -30,7 +30,7 @@
import javax.faces.el.ValueBinding;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -27,7 +27,7 @@
import javax.faces.el.ValueBinding;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -47,11 +47,11 @@
import javax.faces.model.ListDataModel;
import javax.faces.render.Renderer;
-import org.ajax4jsf.framework.renderer.AjaxChildrenRenderer;
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.SerializableDataModel;
+import org.ajax4jsf.renderkit.AjaxChildrenRenderer;
/**
* Base class for iterable components, like dataTable, Tomahawk dataList,
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UISelector.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UISelector.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UISelector.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -32,7 +32,7 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.AjaxDataEncoder;
-import org.ajax4jsf.framework.renderer.AjaxChildrenRenderer;
+import org.ajax4jsf.renderkit.AjaxChildrenRenderer;
import org.apache.commons.beanutils.PropertyUtils;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -32,8 +32,6 @@
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -30,7 +30,6 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.UIAjaxFunction;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,7 +28,6 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.UIResource;
-import org.ajax4jsf.framework.renderer.RendererBase;
import org.ajax4jsf.resource.InternetResource;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -37,10 +37,10 @@
import org.ajax4jsf.component.UIAjaxForm;
import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxIncludeRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,8 +28,8 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIInclude;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -31,8 +31,8 @@
import org.ajax4jsf.component.UIAjaxOutputPanel;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -32,8 +32,8 @@
import org.ajax4jsf.component.AjaxContainer;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.webapp.BaseFilter;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -29,11 +29,11 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIPoll;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
* @author shura
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -29,11 +29,11 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIPush;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
* @author shura
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxRegionRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -27,7 +27,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxStatusRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,9 +28,9 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIAjaxStatus;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -36,9 +36,9 @@
import javax.faces.event.ActionEvent;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/MediaOutputRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -34,8 +34,8 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.component.UIMediaOutput;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/RepeatRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,8 +28,8 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.UIRepeat;
-import org.ajax4jsf.framework.renderer.RendererBase;
import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.renderkit.RendererBase;
/**
* @author shura
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxReRendrRule.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -24,7 +24,7 @@
import java.util.Set;
import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import com.sun.facelets.FaceletContext;
import com.sun.facelets.tag.MetaRule;
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -30,7 +30,7 @@
import javax.faces.el.ValueBinding;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.AjaxPhaseListener;
+import org.ajax4jsf.renderkit.AjaxPhaseListener;
import com.sun.facelets.FaceletContext;
import com.sun.facelets.FaceletException;
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxSupportTag.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -26,9 +26,9 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.component.UIAjaxSupport;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.framework.taglib.UIComponentTagBase;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -29,7 +29,7 @@
import javax.servlet.jsp.tagext.TagSupport;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.renderer.AjaxPhaseListener;
+import org.ajax4jsf.renderkit.AjaxPhaseListener;
/**
* @author shura
Modified: trunk/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/log.jspx
===================================================================
--- trunk/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/log.jspx 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/log.jspx 2007-07-10 01:10:15 UTC (rev 1560)
@@ -7,7 +7,7 @@
xmlns:u=" http://jsf.exadel.com/vcp"
xmlns:x=" http://jsf.exadel.com/vcp"
class="org.ajax4jsf.renderkit.html.LogRenderer"
- baseclass="org.ajax4jsf.framework.renderer.AjaxComponentRendererBase"
+ baseclass="org.ajax4jsf.renderkit.AjaxComponentRendererBase"
component="org.ajax4jsf.component.UIAjaxLog"
xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0" >
<jsp:directive.page import="javax.faces.context.FacesContext,javax.faces.component.UIComponent"/>
Modified: trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java
===================================================================
--- trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/dataFilterSlider/src/main/java/org/richfaces/renderkit/DataFilterSliderRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -37,7 +37,7 @@
/**
* @author Wesley Hales
*/
-public class DataFilterSliderRendererBase extends org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase {
+public class DataFilterSliderRendererBase extends org.ajax4jsf.renderkit.HeaderResourcesRendererBase {
protected Class getComponentClass() {
return UIDataFltrSlider.class;
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractCellRenderer.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractCellRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractCellRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -26,7 +26,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
/**
* @author shura
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractDefinitionListRenderer.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractDefinitionListRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractDefinitionListRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,7 +28,7 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIDataAdaptor;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
* @author shura
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractGridRenderer.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractGridRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractGridRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,7 +28,7 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIDataAdaptor;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIDataGrid;
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractListRenderer.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractListRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractListRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -27,7 +27,7 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIDataAdaptor;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
/**
* @author shura
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -29,11 +29,11 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.component.UIDataAdaptor;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.Row;
/**
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -29,7 +29,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.FilterIterator;
import org.richfaces.component.Column;
Modified: trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java
===================================================================
--- trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/dataTable/src/main/java/org/richfaces/renderkit/html/ColgroupRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -29,7 +29,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.Column;
import org.richfaces.component.UIColumnGroup;
import org.richfaces.renderkit.AbstractRowsRenderer;
Modified: trunk/ui/dataTable/src/main/templates/org/richfaces/htmlSubTable.jspx
===================================================================
--- trunk/ui/dataTable/src/main/templates/org/richfaces/htmlSubTable.jspx 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/dataTable/src/main/templates/org/richfaces/htmlSubTable.jspx 2007-07-10 01:10:15 UTC (rev 1560)
@@ -6,7 +6,7 @@
xmlns:u=" http://ajax4jsf.org/cdk/u"
xmlns:x=" http://ajax4jsf.org/cdk/x"
class="org.richfaces.renderkit.html.SubTableRenderer"
- baseclass="org.ajax4jsf.framework.renderer.AjaxComponentRendererBase"
+ baseclass="org.ajax4jsf.renderkit.AjaxComponentRendererBase"
component="org.richfaces.component.UISubTable"
>
<f:clientid var="clientId"/>
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DnDValidator.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DnDValidator.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DnDValidator.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,7 +28,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
import org.richfaces.component.util.MessageUtil;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -29,8 +29,8 @@
import javax.faces.context.FacesContext;
import javax.faces.event.FacesEvent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.javascript.DnDScript;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,12 +28,12 @@
import javax.faces.context.FacesContext;
import javax.faces.event.FacesEvent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.javascript.DnDScript;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,9 +28,9 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.javascript.AjaxScript;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.UIDragSupport;
import org.richfaces.renderkit.CompositeRenderer;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,9 +28,9 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.javascript.AjaxScript;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.UIDropSupport;
import org.richfaces.renderkit.CompositeRenderer;
Modified: trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
--- trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -35,8 +35,8 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.richfaces.component.UIDropDownMenu;
import org.richfaces.component.UIMenuGroup;
import org.richfaces.component.UIMenuItem;
Modified: trunk/ui/gmap/src/main/templates/gmap.jspx
===================================================================
--- trunk/ui/gmap/src/main/templates/gmap.jspx 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/gmap/src/main/templates/gmap.jspx 2007-07-10 01:10:15 UTC (rev 1560)
@@ -6,7 +6,7 @@
xmlns:u=" http://ajax4jsf.org/cdk/u"
xmlns:x=" http://ajax4jsf.org/cdk/x"
class="org.richfaces.renderkit.html.GmapRenderer"
- baseclass="org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase"
+ baseclass="org.ajax4jsf.renderkit.HeaderResourcesRendererBase"
component="org.richfaces.component.UIGmap">
<f:clientid var="clientId"/>
Modified: trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
--- trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -25,10 +25,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.ComponentVariables;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.richfaces.component.MenuComponent;
import org.richfaces.component.UIMenuGroup;
import org.richfaces.component.UIMenuItem;
Modified: trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
===================================================================
--- trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -21,9 +21,9 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.ComponentVariables;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.richfaces.component.MenuComponent;
import org.richfaces.component.UIMenuItem;
import org.richfaces.component.util.ViewUtil;
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuSeparator.jspx
===================================================================
--- trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuSeparator.jspx 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuSeparator.jspx 2007-07-10 01:10:15 UTC (rev 1560)
@@ -5,7 +5,7 @@
xmlns:ui=" http://ajax4jsf.org/cdk/ui"
xmlns:u=" http://ajax4jsf.org/cdk/u"
xmlns:x=" http://ajax4jsf.org/cdk/x"
- baseclass="org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase"
+ baseclass="org.ajax4jsf.renderkit.HeaderResourcesRendererBase"
class="org.richfaces.renderkit.html.MenuSeparatorRenderer"
component="org.richfaces.component.UIMenuSeparator"
>
Modified: trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java
===================================================================
--- trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/modal-panel/src/main/java/org/richfaces/renderkit/ModalPanelRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -26,10 +26,10 @@
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;
-import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
-import org.ajax4jsf.framework.renderer.ComponentVariables;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.richfaces.component.UIModalPanel;
import org.richfaces.component.util.ViewUtil;
Modified: trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DRenderer.java
===================================================================
--- trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -28,7 +28,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.UIPaint2D;
Modified: trunk/ui/panel/src/main/templates/panel.jspx
===================================================================
--- trunk/ui/panel/src/main/templates/panel.jspx 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/panel/src/main/templates/panel.jspx 2007-07-10 01:10:15 UTC (rev 1560)
@@ -6,7 +6,7 @@
xmlns:x=" http://jsf.exadel.com/vcp"
xmlns:u="http://jsf.exadel.com/util"
xmlns:h="http://jsf.exadel.com/header"
- baseclass="org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase"
+ baseclass="org.ajax4jsf.renderkit.HeaderResourcesRendererBase"
class="org.richfaces.renderkit.html.PanelRenderer">
<f:clientid var="clientId"/>
Modified: trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java
===================================================================
--- trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/SeparatorRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -22,9 +22,9 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.framework.renderer.RendererBase;
import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.framework.util.style.CSSFormat;
+import org.ajax4jsf.renderkit.RendererBase;
import org.richfaces.component.UISeparator;
import org.richfaces.renderkit.html.images.BevelSeparatorImage;
import org.richfaces.renderkit.html.images.SimpleSeparatorImage;
Modified: trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java
===================================================================
--- trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -24,7 +24,7 @@
*/
package org.richfaces.renderkit.html;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.component.UISimpleTogglePanel;
import org.richfaces.event.SimpleToggleEvent;
@@ -38,7 +38,7 @@
//public class SimpleTogglePanelRenderer extends AjaxCommandLinkRenderer {
-public class SimpleTogglePanelRenderer extends org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase {
+public class SimpleTogglePanelRenderer extends org.ajax4jsf.renderkit.HeaderResourcesRendererBase {
//XXXX by nick - denis - seems there is a lot of code common to org.richfaces.renderkit.html.ToggleControlRenderer. Please commonize!
//private InternetResource[] _scripts = {new PrototypeScript(), getResource("scripts/simpleTogglePanel.js") };
Modified: trunk/ui/spacer/src/main/templates/spacer.jspx
===================================================================
--- trunk/ui/spacer/src/main/templates/spacer.jspx 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/spacer/src/main/templates/spacer.jspx 2007-07-10 01:10:15 UTC (rev 1560)
@@ -7,7 +7,7 @@
xmlns:x=" http://ajax4jsf.org/cdk/x"
xmlns:h="http://jsf.exadel.com/header"
class="org.richfaces.renderkit.html.SpacerRenderer"
- baseclass="org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase"
+ baseclass="org.ajax4jsf.renderkit.HeaderResourcesRendererBase"
component="org.richfaces.component.UISpacer"
>
<h:styles>css/spacer.xcss</h:styles>
Modified: trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
===================================================================
--- trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -26,7 +26,7 @@
import org.ajax4jsf.event.AjaxEvent;
import org.ajax4jsf.event.AjaxListener;
import org.ajax4jsf.event.AjaxSource;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
--- trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -22,15 +22,15 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.TemplateCSSResource;
import org.richfaces.component.AjaxSuggestionEvent;
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITab.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITab.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITab.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -24,7 +24,7 @@
import org.ajax4jsf.component.AjaxActionComponent;
import org.ajax4jsf.component.AjaxComponent;
import org.ajax4jsf.event.AjaxSource;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import javax.faces.FacesException;
import javax.faces.component.ActionSource;
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabHeaderRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -21,10 +21,10 @@
package org.richfaces.renderkit;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UISwitchablePanel;
import org.richfaces.component.UITab;
import org.richfaces.component.UITabPanel;
@@ -41,7 +41,7 @@
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 12.01.2007
*/
-public class TabHeaderRendererBase extends org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase {
+public class TabHeaderRendererBase extends org.ajax4jsf.renderkit.HeaderResourcesRendererBase {
private static final String LABEL_SUFFIX = "_lbl";
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabPanelRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -22,12 +22,12 @@
package org.richfaces.renderkit;
import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.framework.renderer.ComponentVariables;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UISwitchablePanel;
import org.richfaces.component.UITab;
import org.richfaces.component.UITabPanel;
@@ -48,7 +48,7 @@
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 12.01.2007
*/
-public class TabPanelRendererBase extends org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase {
+public class TabPanelRendererBase extends org.ajax4jsf.renderkit.HeaderResourcesRendererBase {
public final static String ACTIVE_CELL_CLASSES = "dr-tbpnl-tbcell-act rich-tabhdr-cell-active";
public final static String INACTIVE_CELL_CLASSES = "dr-tbpnl-tbcell-inact rich-tabhdr-cell-inactive";
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabRendererBase.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/TabRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -21,7 +21,7 @@
package org.richfaces.renderkit;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.richfaces.component.TabEncoder;
import org.richfaces.component.UISwitchablePanel;
import org.richfaces.component.UITab;
Modified: trunk/ui/togglePanel/src/main/java/org/richfaces/component/UIToggleControl.java
===================================================================
--- trunk/ui/togglePanel/src/main/java/org/richfaces/component/UIToggleControl.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/togglePanel/src/main/java/org/richfaces/component/UIToggleControl.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -34,8 +34,8 @@
import org.ajax4jsf.component.AjaxActionComponent;
import org.ajax4jsf.component.AjaxComponent;
import org.ajax4jsf.event.AjaxSource;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.RendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
/**
* @author igels
Modified: trunk/ui/togglePanel/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java
===================================================================
--- trunk/ui/togglePanel/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/togglePanel/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -32,9 +32,9 @@
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.UIToggleControl;
import org.richfaces.component.UITogglePanel;
import org.richfaces.event.SwitchablePanelSwitchEvent;
Modified: trunk/ui/togglePanel/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
===================================================================
--- trunk/ui/togglePanel/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/togglePanel/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -36,7 +36,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.richfaces.component.UITogglePanel;
import org.richfaces.event.SwitchablePanelSwitchEvent;
Modified: trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java
===================================================================
--- trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -30,7 +30,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.renderkit.RendererBase;
import org.richfaces.component.UIToolBarGroup;
import org.richfaces.renderkit.html.images.DotSeparatorImage;
Modified: trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java
===================================================================
--- trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -32,7 +32,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.richfaces.component.UIToolBar;
import org.richfaces.component.UIToolBarGroup;
import org.richfaces.renderkit.html.images.DotSeparatorImage;
Modified: trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -37,11 +37,11 @@
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.Range;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.apache.commons.collections.iterators.SingletonIterator;
import org.richfaces.component.events.TreeEvents;
import org.richfaces.component.state.TreeState;
Modified: trunk/ui/tree/src/main/java/org/richfaces/component/UITreeNode.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/component/UITreeNode.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/tree/src/main/java/org/richfaces/component/UITreeNode.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -13,7 +13,7 @@
import javax.faces.event.FacesEvent;
import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.component.events.TreeEvents;
import org.richfaces.event.DragEvent;
import org.richfaces.event.DragListener;
Modified: trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -12,11 +12,11 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.ComponentVariables;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
import org.richfaces.component.UITree;
Modified: trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
+++ trunk/ui/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-07-10 01:10:15 UTC (rev 1560)
@@ -35,14 +35,14 @@
import javax.faces.context.ResponseWriter;
import javax.faces.el.MethodBinding;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.ComponentVariables;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
-import org.ajax4jsf.framework.renderer.RendererUtils;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.UITree;
import org.richfaces.component.UITreeNode;
import org.richfaces.component.nsutils.NSUtils;
17 years, 6 months
JBoss Rich Faces SVN: r1559 - in trunk: framework/impl/src/main/java/org/ajax4jsf/context and 13 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-09 20:58:39 -0400 (Mon, 09 Jul 2007)
New Revision: 1559
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterServletResponseWrapper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/HtmlParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/Log4JConfigurator.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/NekkoFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserConfig.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletStreamWriter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/TidyFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/XMLResponseWriterState.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionState.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/FilterServletResponseWrapper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/Log4JConfigurator.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/PollEventsManager.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ServletStreamWriter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/TidyFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/XMLResponseWriterState.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionState.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/FastFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourcesRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
trunk/framework/impl/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/HtmlCorrectionFilterTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/AllTests.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContentTest.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoParserTest.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
Log:
packages and classes refactor in the "impl" project
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/FastFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/FastFilter.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/FastFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -22,6 +22,6 @@
package org.ajax4jsf;
public class FastFilter extends
- org.ajax4jsf.framework.ajax.xmlfilter.NekkoFilter {
+ org.ajax4jsf.webapp.NekkoFilter {
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -21,7 +21,7 @@
package org.ajax4jsf;
-import org.ajax4jsf.framework.ajax.xmlfilter.ConfigurableFilter;
+import org.ajax4jsf.webapp.ConfigurableFilter;
/**
* Proxy for resource/ajax xml parsing filter.
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -58,12 +58,12 @@
import org.ajax4jsf.component.AjaxViewRoot;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.context.ViewIdHolder;
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.renderkit.HeaderResourceProducer;
+import org.ajax4jsf.webapp.BaseFilter;
+import org.ajax4jsf.webapp.FilterServletResponseWrapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.richfaces.skin.Skin;
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,388 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.Date;
-import java.util.Enumeration;
-
-import javax.faces.application.ViewHandler;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.ajax.PushEventsCounter;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.resource.InternetResourceService;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base class for request processing filters, with convert Htmp content to XML
- * for ajax requests, and serve request to application off-page resources
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:21 $
- *
- */
-public abstract class BaseFilter implements Filter {
-
- public static final String AJAX_PUSH_KEY_HEADER = "Ajax-Push-Key";
-
- private static final Log log = LogFactory.getLog(BaseFilter.class);
-
- public static final boolean DEBUG = true;
-
- private FilterConfig filterConfig;
-
- private static final String FUNCTION_NAME_PARAMETER = "function";
-
- private String function = "alert('Data received');JSHttpRequest.dataReady";
-
- private String attributesNames;
-
- private boolean rewriteid = false;
-
- public static final String REWRITEID_PARAMETER = "rewriteid";
-
- public static final String STYLESHEET_PARAMETER = "xsl";
-
- public static final String ABSOLUTE_TAGS_PARAMETER = "absolute-attributes";
-
- // private WebXml webXml;
- // private String xsl;
- // private Templates xslTemplates;
- /**
- *
- */
- private static final long serialVersionUID = -2295534611886142935L;
-
- public static final String DATA_PARAMETER = "DATA";
-
- public static final String DEFAULT_SERVLET_PATH = "/resource";
-
- public static final String RENDERER_PREFIX = "/renderer";
-
- public static final String CACHEABLE_PREFIX = "/cache";
-
- // private static final Pattern rendererPattern =
- // Pattern.compile(RENDERER_PREFIX+"/([^/]+)/([^/]+)/([^/]+)/(.*)");
- // private static final Pattern builderPattern =
- // Pattern.compile(CACHEABLE_PREFIX+"/(.*)");
- public static final String FILTER_PERFORMED = "com.exade.vcp.Filter.done";
-
- public static final String RESPONSE_WRAPPER_ATTRIBUTE = "com.exade.vcp.Filter.ResponseWrapper";
-
- protected BaseXMLFilter xmlFilter = null;
-
- protected InternetResourceService resourceService = null;
-
- protected PollEventsManager eventsManager;
-
- /**
- * Initialize the filter.
- */
- public void init(FilterConfig config) throws ServletException {
- if (log.isDebugEnabled()) {
- log.debug("Init ajax4jsf filter with nane: "
- + config.getFilterName());
- Enumeration parameterNames = config.getInitParameterNames();
- StringBuffer parameters = new StringBuffer("Init parameters :\n");
- while (parameterNames.hasMoreElements()) {
- String name = (String) parameterNames.nextElement();
- parameters.append(name).append(" : '").append(
- config.getInitParameter(name)).append('\n');
- }
- log.debug(parameters);
- // log.debug("Stack Trace", new Exception());
- }
- // Save config
- filterConfig = config;
- setFunction((String) nz(filterConfig
- .getInitParameter(FUNCTION_NAME_PARAMETER), getFunction()));
- setAttributesNames(filterConfig
- .getInitParameter(ABSOLUTE_TAGS_PARAMETER));
- xmlFilter.init(config);
- if ("true".equalsIgnoreCase(filterConfig
- .getInitParameter(REWRITEID_PARAMETER))) {
- this.setRewriteid(true);
- }
-
- String prefix = filterConfig.getServletContext().getRealPath("/");
- String file = filterConfig.getInitParameter("log4j-init-file");
- // if the log4j-init-file is not set, then no point in trying
- if (file != null) {
- Log4JConfigurator log4jconfig = new Log4JConfigurator(prefix);
- log4jconfig.doConfigure(file);
- }
- resourceService = new InternetResourceService();
- // Caching initialization.
- resourceService.init(filterConfig);
- eventsManager = new PollEventsManager();
- eventsManager.init(filterConfig.getServletContext());
- }
-
- /**
- * @param httpServletRequest
- * @throws UnsupportedEncodingException
- */
- protected void setupRequestEncoding(HttpServletRequest httpServletRequest)
- throws UnsupportedEncodingException {
- String contentType = httpServletRequest.getHeader("Content-Type");
-
- String characterEncoding = lookupCharacterEncoding(contentType);
-
- if (characterEncoding == null) {
- HttpSession session = httpServletRequest.getSession(false);
-
- if (session != null) {
- characterEncoding = (String) session
- .getAttribute(ViewHandler.CHARACTER_ENCODING_KEY);
- }
-
- if (characterEncoding != null) {
- httpServletRequest.setCharacterEncoding(characterEncoding);
- }
- }
- }
-
- /**
- * Detect request encoding from Content-Type header
- *
- * @param contentType
- * @return - charset, if present.
- */
- private String lookupCharacterEncoding(String contentType) {
- String characterEncoding = null;
-
- if (contentType != null) {
- int charsetFind = contentType.indexOf("charset=");
- if (charsetFind != -1) {
- if (charsetFind == 0) {
- // charset at beginning of Content-Type, curious
- characterEncoding = contentType.substring(8);
- } else {
- char charBefore = contentType.charAt(charsetFind - 1);
- if (charBefore == ';' || Character.isWhitespace(charBefore)) {
- // Correct charset after mime type
- characterEncoding = contentType
- .substring(charsetFind + 8);
- }
- }
- if (log.isDebugEnabled())
- log.debug(Messages.getMessage(
- Messages.CONTENT_TYPE_ENCODING, characterEncoding));
- } else {
- if (log.isDebugEnabled())
- log.debug(Messages.getMessage(
- Messages.CONTENT_TYPE_NO_ENCODING, contentType));
- }
- }
- return characterEncoding;
- }
-
- /**
- * @param initParameter
- * @param function2
- * @return
- */
- private Object nz(Object param, Object def) {
- return param != null ? param : def;
- }
-
- /**
- * Execute the filter.
- */
- public void doFilter(ServletRequest request, ServletResponse response,
- FilterChain chain) throws IOException, ServletException {
- long startTimeMills = 0;
- // Detect case of request - normal, AJAX, AJAX - JavaScript
- // TODO - detect first processing in filter.
- HttpServletRequest httpServletRequest = (HttpServletRequest) request;
- HttpServletResponse httpServletResponse = (HttpServletResponse) response;
- if (log.isDebugEnabled()) {
- startTimeMills = System.currentTimeMillis();
- log.debug(Messages.getMessage(Messages.FILTER_START_INFO, new Date(
- startTimeMills), httpServletRequest.getRequestURI()));
- }
-
- if (request.getAttribute(FILTER_PERFORMED) != Boolean.TRUE) {
- // mark - and not processing same request twice.
- request.setAttribute(FILTER_PERFORMED, Boolean.TRUE);
- String ajaxPushHeader = httpServletRequest.getHeader(AJAX_PUSH_KEY_HEADER);
- // check for a push check request.
- if (httpServletRequest.getMethod().equals("HEAD")
- && null != ajaxPushHeader) {
- PushEventsCounter listener = eventsManager.getListener(ajaxPushHeader);
- if(listener.isPerformed()){
- listener.processed();
- httpServletResponse.setStatus(200);
- if (log.isDebugEnabled()) {
- log.debug("Occurs event for a id "+ajaxPushHeader);
- }
- } else {
- // Response code - 'No content'
- httpServletResponse.setStatus(204);
- if (log.isDebugEnabled()) {
- log.debug("No event for a id "+ajaxPushHeader);
- }
- }
- } else
- // check for resource request
- if (!getResourceService().serviceResource(httpServletRequest,
- httpServletResponse)) {
- // Not request to resource - perform filtering.
- // first stage - detect/set encoding of request. Same as in
- // Myfaces External Context.
- setupRequestEncoding(httpServletRequest);
- // check ajax request parameter
- // TODO - check for JSF page.
- if (true) {
- if (log.isDebugEnabled()) {
- log.debug(Messages
- .getMessage(Messages.FILTER_XML_OUTPUT));
- }
-
- // Execute the rest of the filter chain, including the
- // JSP
- xmlFilter.doXmlFilter(chain, httpServletRequest,
- httpServletResponse);
- } else {
- // normal request, execute chain ...
- if (log.isDebugEnabled()) {
- log.debug(Messages
- .getMessage(Messages.FILTER_NO_XML_CHAIN));
- }
- chain.doFilter(request, response);
-
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.FILTER_NO_XML_CHAIN_2));
- }
- chain.doFilter(request, response);
-
- }
- if (log.isDebugEnabled()) {
- startTimeMills = System.currentTimeMillis() - startTimeMills;
- log.debug(Messages.getMessage(Messages.FILTER_STOP_INFO, ""
- + startTimeMills, httpServletRequest.getRequestURI()));
- }
- }
-
- /**
- * @param request
- * @return
- */
- protected boolean isAjaxRequest(ServletRequest request) {
- try {
- return null != request
- .getParameter(AjaxContainerRenderer.AJAX_PARAMETER_NAME);
- } catch (Exception e) {
- // OCJ 10 - throw exception for static resources.
- return false;
- }
- }
-
- /**
- * Destroy the filter.
- */
- public void destroy() {
- }
-
- /**
- * @return Returns the servletContext.
- */
- ServletContext getServletContext() {
- return filterConfig.getServletContext();
- }
-
- /**
- * @return the resourceService
- * @throws ServletException
- */
- protected synchronized InternetResourceService getResourceService()
- throws ServletException {
- // if (resourceService == null) {
- // resourceService = new InternetResourceService();
- // // Caching initialization.
- // resourceService.init(filterConfig);
- //
- // }
- return resourceService;
- }
-
- /**
- * @param function
- * The function to set.
- */
- protected void setFunction(String function) {
- this.function = function;
- }
-
- /**
- * @return Returns the function.
- */
- protected String getFunction() {
- return function;
- }
-
- /**
- * @param rewriteid
- * The rewriteid to set.
- */
- protected void setRewriteid(boolean rewriteid) {
- this.rewriteid = rewriteid;
- }
-
- /**
- * @return Returns the rewriteid.
- */
- protected boolean isRewriteid() {
- return rewriteid;
- }
-
- /**
- * @param attributesNames
- * The attributesNames to set.
- */
- protected void setAttributesNames(String attributesNames) {
- this.attributesNames = attributesNames;
- }
-
- /**
- * @return Returns the attributesNames.
- */
- protected String getAttributesNames() {
- return attributesNames;
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,429 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.application.AjaxViewHandler;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class BaseXMLFilter {
- private static final Log log = LogFactory.getLog(BaseXMLFilter.class);
-
- public static final String RESPONSE_WRAPPER_ATTRIBUTE = "com.exade.vcp.Filter.ResponseWrapper";
-
- private String mimetype = "text/xml";
-
- private String publicid = "-//W3C//DTD XHTML 1.0 Transitional//EN";
-
- private String systemid = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
-
- private String namespace = "http://www.w3.org/1999/xhtml";
-
- private static final String MIME_TYPE_PARAMETER = "mime-type";
-
- private static final String PUBLICID_PARAMETER = "publicid";
-
- private static final String SYSTEMID_PARAMETER = "systemid";
-
- private static final String NAMESPACE_PARAMETER = "namespace";
-
- private boolean forcexml = false;
-
-
- private static final String FORCEXML_PARAMETER = "forceparser";
-
- private static final String INIT_PARAMETER_PREFIX = "org.ajax4jsf.xmlfilter.";
-
- public BaseFilter filter;
-
- public void setFilter(BaseFilter filter) {
- this.filter = filter;
- }
-
- public void init(FilterConfig config) throws ServletException {
- if (log.isDebugEnabled()) {
- log.debug("init XML filter service with class "
- + this.getClass().getName());
- }
- String forceXmlParameter = config
- .getInitParameter(FORCEXML_PARAMETER);
- setupForceXml(forceXmlParameter);
- forceXmlParameter = config.getServletContext().getInitParameter(INIT_PARAMETER_PREFIX+FORCEXML_PARAMETER);
- setMimetype((String) nz(config.getInitParameter(MIME_TYPE_PARAMETER),
- "text/xml"));
- setPublicid((String) nz(config.getInitParameter(PUBLICID_PARAMETER),
- getPublicid()));
- setSystemid((String) nz(config.getInitParameter(SYSTEMID_PARAMETER),
- getSystemid()));
- setNamespace((String) nz(config.getInitParameter(NAMESPACE_PARAMETER),
- getNamespace()));
- }
-
- /**
- * @param forceXmlParameter
- */
- private void setupForceXml(String forceXmlParameter) {
- if ("false".equalsIgnoreCase(forceXmlParameter)) {
- this.forcexml = false;
- }
- if ("true"
- .equalsIgnoreCase(forceXmlParameter)) {
- this.forcexml = true;
- }
- }
-
- /**
- * Perform filter chain with xml parsing and transformation. Subclasses
- * must implement concrete HTML to XML parsing, nesseasary
- * transformations and serialization.
- *
- * @param chain
- * @param httpServletRequest
- * @param httpServletResponse
- * @throws ServletException
- * @throws IOException
- */
- protected void doXmlFilter(FilterChain chain, HttpServletRequest request,
- final HttpServletResponse response) throws IOException,
- ServletException {
- if (log.isDebugEnabled()) {
- log.debug("XML filter service start processing request");
- }
- FilterServletResponseWrapper servletResponseWrapper = getWrapper(response);
- // HACK - to avoid MyFaces <f:view> incompabilites and bypass
- // intermediaty filters
- // in chain, self-rendered region write directly to wrapper stored in
- // request-scope attribute.
- request
- .setAttribute(RESPONSE_WRAPPER_ATTRIBUTE,
- servletResponseWrapper);
- chain.doFilter(request, servletResponseWrapper);
- String viewId = (String) request.getAttribute(AjaxViewHandler.VIEW_ID_KEY);
- HtmlParser parser = null;
- // setup response
- // Redirect in AJAX request - convert to special response recognized by
- // client.
- String redirectLocation = servletResponseWrapper.getRedirectLocation();
- String characterEncoding = servletResponseWrapper
- .getCharacterEncoding();
- Writer output;
- if (null != redirectLocation) {
- if (isAjaxRequest(request)) {
- // Special handling of redirect - client-side script must
- // Check for response and perform redirect by window.location
- if (log.isDebugEnabled()) {
- log.debug("Create AJAX redirect response to url: "
- + redirectLocation);
- }
- response.reset();
- // Keep cookies.
- for (Iterator iter = servletResponseWrapper.getCookies().iterator(); iter.hasNext();) {
- Cookie cookie = (Cookie) iter.next();
- response.addCookie(cookie);
- }
- // Copy response headers
- Map headers = servletResponseWrapper.getHeaders();
- for (Iterator iter = headers.entrySet().iterator(); iter
- .hasNext();) {
- Map.Entry header = (Map.Entry) iter.next();
- response.setHeader((String) header.getKey(),
- (String) header.getValue());
- }
- response.setHeader(AjaxContainerRenderer.AJAX_FLAG_HEADER,
- "redirect");
- // Not caching AJAX request
- response.setHeader("Cache-Control",
- "no-cache, must-revalidate, max_age=0, no-store");
- response.setHeader("Expires", "0");
- response.setHeader("Pragma", "no-cache");
- response.setContentType(getMimetype() + ";charset=UTF-8");
- response.setHeader(AjaxContainerRenderer.AJAX_LOCATION_HEADER,
- redirectLocation);
- output = createResponseWriter(response, "UTF-8");
- // For buggy XmlHttpRequest realisations repeat headers in
- // <meta>
- output.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
- + "<meta name=\""
- + AjaxContainerRenderer.AJAX_FLAG_HEADER
- + "\" content=\"redirect\" />" + "<meta name=\""
- + AjaxContainerRenderer.AJAX_LOCATION_HEADER
- + "\" content=\"" + redirectLocation + "\" />"
- + "</head></html>");
- output.flush();
- response.flushBuffer();
- } else {
- response.sendRedirect(redirectLocation);
- }
- return;
- } else if ("true".equals(servletResponseWrapper.getHeaders().get(
- AjaxContainerRenderer.AJAX_FLAG_HEADER))) {
- if (log.isDebugEnabled()) {
- log
- .debug("Process response to well-formed XML for AJAX XMLHttpRequest parser");
- }
- // Not caching AJAX request
- response.setHeader("Cache-Control",
- "no-cache, must-revalidate, max_age=0, no-store");
- response.setHeader("Expires", "0");
- response.setHeader("Pragma", "no-cache");
- // response.setCharacterEncoding(servletResponseWrapper
- // .getCharacterEncoding()); //
- // JSContentHandler.DEFAULT_ENCODING);
- // Set the content-type. For AJAX responses default encoding -
- // UTF8.
- // TODO - for null encoding, setup only Output encoding for
- // filter ?
- String outputEncoding = "UTF-8";
- String contentType = getMimetype() + ";charset=" + outputEncoding;
- response.setContentType(contentType);
- parser = getParser(getMimetype(), true, viewId);
- if (null == parser) {
- throw new ServletException(Messages.getMessage(
- Messages.PARSER_NOT_INSTANTIATED_ERROR, contentType));
- }
- output = createResponseWriter(response, outputEncoding);
- parser.setDoctype(getPublicid());
- parser.setInputEncoding(characterEncoding);
- parser.setOutputEncoding(outputEncoding);
- parser.setViewState((String) request
- .getAttribute(AjaxViewHandler.SERIALIZED_STATE_KEY));
- } else {
- // setup conversion reules for output contentType, send directly
- // if content not
- // supported by tidy.
- String contentType = servletResponseWrapper.getContentType();
- if (log.isDebugEnabled()) {
- log.debug("create HTML/XML parser for content type: "
- + contentType);
- }
- // if(contentType == null){
- // contentType = request.getContentType();
- // }
- if (contentType != null) {
- if (contentType.indexOf("charset") < 0
- && null != characterEncoding) {
- contentType += ";charset=" + characterEncoding;
- }
- parser = getParser(contentType, false, viewId);
- response.setContentType(contentType);
- }
- // null or unsupported content type
- if (null == parser) {
- if (log.isDebugEnabled()) {
- log
- .debug("Parser not have support for the such content type, send response as-is");
- }
- try {
- if (servletResponseWrapper.isUseWriter()) {
- output = createResponseWriter(response,
- characterEncoding);
- servletResponseWrapper.sendContent(output);
- } else if (servletResponseWrapper.isUseStream()) {
- ServletOutputStream out = response.getOutputStream();
- servletResponseWrapper.sendContent(out);
- }
- } finally {
- // reuseWrapper(servletResponseWrapper);
- }
- return;
- }
- output = createResponseWriter(response, characterEncoding);
-
- parser.setInputEncoding(characterEncoding);
- parser.setOutputEncoding(characterEncoding);
- }
-
- try {
- // Setup scripts and styles
- parser.setScripts((Set) request
- .getAttribute(AjaxContext.SCRIPTS_PARAMETER));
- parser.setStyles((Set) request
- .getAttribute(AjaxContext.STYLES_PARAMETER));
- // Process parsing.
- long startTimeMills = System.currentTimeMillis();
- servletResponseWrapper.parseContent(output, parser);
- if (log.isDebugEnabled()) {
- startTimeMills = System.currentTimeMillis() - startTimeMills;
- log.debug(Messages.getMessage(Messages.PARSING_TIME_INFO, ""
- + startTimeMills));
- }
- } catch (Exception e) {
- throw new ServletException(Messages
- .getMessage(Messages.JTIDY_PARSING_ERROR), e);
- } finally {
- reuseParser(parser);
- }
- }
-
- /**
- * @param response
- * @return
- * @throws ServletException
- */
- protected FilterServletResponseWrapper getWrapper(
- HttpServletResponse response) throws ServletException {
- return new FilterServletResponseWrapper(response);
- }
-
- /**
- * @param request
- * @return
- */
- protected boolean isAjaxRequest(ServletRequest request) {
- try {
- return null != request
- .getParameter(AjaxContainerRenderer.AJAX_PARAMETER_NAME);
- } catch (Exception e) {
- // OCJ 10 - throw exception for static resources.
- return false;
- }
- }
-
- /**
- * @param response
- * @param characterEncoding
- * @return
- * @throws IOException
- * @throws UnsupportedEncodingException
- */
- private Writer createResponseWriter(final HttpServletResponse response,
- String characterEncoding) throws IOException,
- UnsupportedEncodingException {
- Writer output;
- try {
- output = response.getWriter();
- } catch (IllegalStateException e) {
- if (null != characterEncoding) {
- output = new OutputStreamWriter(response.getOutputStream(),
- characterEncoding);
- } else {
- output = new OutputStreamWriter(response.getOutputStream());
- }
- }
- return output;
- }
-
- protected abstract void reuseParser(HtmlParser parser);
-
- protected abstract HtmlParser getParser(String mimetype, boolean isAjax, String viewId);
-
- /**
- * @param publicid
- * The publicid to set.
- */
- protected void setPublicid(String publicid) {
- this.publicid = publicid;
- }
-
- /**
- * @return Returns the publicid.
- */
- public String getPublicid() {
- return publicid;
- }
-
- /**
- * @param systemid
- * The systemid to set.
- */
- protected void setSystemid(String systemid) {
- this.systemid = systemid;
- }
-
- /**
- * @return Returns the systemid.
- */
- public String getSystemid() {
- return systemid;
- }
-
- /**
- * @param namespace
- * The namespace to set.
- */
- protected void setNamespace(String namespace) {
- this.namespace = namespace;
- }
-
- /**
- * @return Returns the namespace.
- */
- public String getNamespace() {
- return namespace;
- }
-
- /**
- * @param mimetype
- * The mimetype to set.
- */
- protected void setMimetype(String mimetype) {
- this.mimetype = mimetype;
- }
-
- /**
- * @return Returns the mimetype.
- */
- protected String getMimetype() {
- return mimetype;
- }
-
- /**
- * @return Returns the forcexml.
- */
- public boolean isForcexml() {
- return this.forcexml;
- }
-
- /**
- * @param forcexml
- * The forcexml to set.
- */
- protected void setForcexml(boolean forcexml) {
- this.forcexml = forcexml;
- }
-
- private Object nz(Object param, Object def) {
- return param != null ? param : def;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,277 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.io.FastBufferOutputStream;
-import org.ajax4jsf.io.FastBufferWriter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:20 $
- *
- */
-public class CacheContent implements Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 8120940486890871177L;
-
- private static final Log _log = LogFactory.getLog(CacheContent.class);
-
- // private transient ByteArrayOutputStream outputStream ;
- private transient FastBufferOutputStream outputStream;
-
- private transient FastBufferWriter stringOutputWriter;
-
- private transient PrintWriter servletWriter;
-
- private transient ServletOutputStream servletStream;
-
- // content to send.
- private byte[] content = null;
-
- private String writerContent = null;
-
- boolean filledOutputStream = false;
-
- boolean filledOutputWriter = false;
-
- private Map headers = new HashMap();
-
- private String contentType;
-
- /**
- * Send saved content to http responce
- *
- * @param response
- * @throws IOException
- */
- public void send(HttpServletResponse response) throws IOException {
- if (filledOutputStream) {
- OutputStream out = response.getOutputStream();
- if (content != null) {
- out.write(content);
- } else {
- this.outputStream.writeTo(out);
- }
- // out.flush();
- // out.close();
- } else if (filledOutputWriter) {
- Writer out = response.getWriter();
- if (null != writerContent) {
- out.write(writerContent);
- } else {
- stringOutputWriter.writeTo(out);
- }
- // out.flush();
- // out.close();
- }
- }
-
- /**
- * Send saved headers to http responce.
- *
- * @param response
- */
- public void sendHeaders(HttpServletResponse response) {
- for (Iterator iter = headers.entrySet().iterator(); iter.hasNext();) {
- Map.Entry element = (Map.Entry) iter.next();
- String header = (String) element.getKey();
- Object headerValue = element.getValue();
- try {
- if (headerValue instanceof Long) {
- Long time = (Long) headerValue;
- response.setDateHeader(header, time.longValue());
- } else if (headerValue instanceof Integer) {
- Integer value = (Integer) headerValue;
- response.setIntHeader(header, value.intValue());
- } else {
- response.setHeader(header, (String) headerValue);
- }
-
- } catch (Exception e) {
- _log.error("Error set response header "+header+"for value "+headerValue, e);
- }
- // set real content-length.
- // / if (null != content) {
- if (filledOutputStream) {
- // / response.setIntHeader("Content-Length", content.length);
- response.setIntHeader("Content-Length", outputStream
- .getLength());
- } // TODO - calculate content-lenght for writer ?
- if (null != contentType) {
- response.setContentType(this.contentType);
- }
- }
- }
-
- public void setDateHeader(String name, long value) {
- // Expires not stored in cache - must be re-calculated for every
- // response.
- if (!"Expires".equals(name)) {
- headers.put(name, new Long(value));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.resource.ResourceContext#setHeader(java.lang.String,
- * java.lang.String)
- */
- public void setHeader(String name, String value) {
- headers.put(name, value);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.resource.ResourceContext#setIntHeader(java.lang.String,
- * int)
- */
- public void setIntHeader(String name, int value) {
- headers.put(name, new Integer(value));
- }
-
- /**
- * Create UNIX command 'tee' like stream - send all data to servlet
- *
- * @param responseStream
- * @return
- */
- public OutputStream getOutputStream() {
- if (null == servletStream) {
- outputStream = new FastBufferOutputStream(1024);
- servletStream = new ServletOutputStream() {
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.OutputStream#close()
- */
- public void close() throws IOException {
- filledOutputStream = true;
- // / content = outputStream.toByteArray();
- content = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.OutputStream#flush()
- */
- public void flush() throws IOException {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- public void write(byte[] b, int off, int len)
- throws IOException {
- outputStream.write(b, off, len);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.OutputStream#write(byte[])
- */
- public void write(byte[] b) throws IOException {
- outputStream.write(b);
- }
-
- public void write(int b) throws IOException {
- outputStream.write(b);
- }
-
- };
- }
- return servletStream;
- }
-
- public PrintWriter getWriter() {
- if (null == servletWriter) {
- stringOutputWriter = new FastBufferWriter(1024);
- Writer out = new Writer() {
-
- public void write(char[] cbuf, int off, int len)
- throws IOException {
- stringOutputWriter.write(cbuf, off, len);
- }
-
- public void flush() throws IOException {
- }
-
- public void close() throws IOException {
- // / writerContent = stringOutputWriter.toString();
- filledOutputWriter = true;
- writerContent = null;
- }
-
- };
- servletWriter = new PrintWriter(out);
- }
- return servletWriter;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
-
- }
-
- /**
- * @return Returns the contentType.
- */
- public String getContentType() {
- return contentType;
- }
-
- private void writeObject(java.io.ObjectOutputStream s) throws IOException {
- if (filledOutputStream) {
- if (outputStream != null) {
- content = outputStream.toByteArray();
- }
- } else if (filledOutputWriter) {
- if (stringOutputWriter != null) {
- char[] cs = stringOutputWriter.toCharArray();
- writerContent = new String(cs);
- }
- }
- s.defaultWriteObject();
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,20 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-/**
- * @author asmirnov
- *
- */
-public class ConfigurableFilter extends BaseFilter {
-
- /**
- *
- */
- public ConfigurableFilter() {
- xmlFilter = new ConfigurableXMLFilter();
- xmlFilter.setFilter(this);
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,237 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.EmptyStackException;
-import java.util.Properties;
-import java.util.regex.PatternSyntaxException;
-
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.ajax.xmlfilter.nekko.NekkoParser;
-import org.ajax4jsf.framework.ajax.xmlfilter.tidy.TidyParser;
-import org.ajax4jsf.io.parser.FastHtmlParser;
-import org.apache.commons.collections.ArrayStack;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author asmirnov
- *
- */
-public class ConfigurableXMLFilter extends BaseXMLFilter {
-
- private static final Log log = LogFactory
- .getLog(ConfigurableXMLFilter.class);
-
- private static final String PARSERS_LIST_PARAMETER = "org.ajax4jsf.xmlparsers";
-
- private static final String VIEW_ID_PATTERN_PARAMETER = "org.ajax4jsf.xmlparser.";
-
- /**
- * map of the parsers names and viewId patterns for all parser type.
- */
- private ParserConfig parsers = new TidyParserConfig();
-
- // private ParserConfig passParserConfig = new PassParserConfig();
-
- public void init(FilterConfig config) throws ServletException {
- super.init(config);
- ServletContext servletContext = config.getServletContext();
- String parsersParameter = servletContext
- .getInitParameter(PARSERS_LIST_PARAMETER);
- if (null != parsersParameter) {
- configureParsers(servletContext, parsersParameter);
- }
- }
-
- /**
- * @param servletContext
- * @param parsersParameter
- * @throws ServletException
- */
- public void configureParsers(ServletContext servletContext,
- String parsersParameter) throws ServletException {
- String[] parsersNames = parsersParameter.split("\\s*,\\s*");
- for (int i = parsersNames.length - 1; i >= 0; i--) {
- String parserName = parsersNames[i];
- ParserConfig parserConfig;
- if ("TIDY".equals(parserName)) {
- parserConfig = new TidyParserConfig();
- } else if ("NEKO".equals(parserName)) {
- parserConfig = new NekoParserConfig();
- } else if ("PASS".equals(parserName)) {
- parserConfig = new PassParserConfig();
- } else {
- throw new ServletException(
- "Unknown XML parser type in config parameter "
- + parserName);
- }
- parserConfig.setNext(parsers);
- if (null != servletContext) {
- try {
- String parserViewPattern = servletContext
- .getInitParameter(VIEW_ID_PATTERN_PARAMETER
- + parserName);
- parserConfig.setPatterns(parserViewPattern);
-
- } catch (PatternSyntaxException e) {
- throw new ServletException("Invalid pattern for a parser "
- + parserName + " :" + e.getMessage());
- }
- }
- parsers = parserConfig;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter#getParser(java.lang.String,
- * boolean, java.lang.String)
- */
- protected HtmlParser getParser(String mimetype, boolean isAjax,
- String viewId) {
- HtmlParser parser = null;
- if (isAjax || isForcexml()) {
- parser = parsers.getParser(viewId, mimetype);
- } else if (mimetype.startsWith("text/html")
- || mimetype.startsWith("application/xhtml+xml")) {
- parser = new FastHtmlParser();
- }
- return parser;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter#reuseParser(org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser)
- */
- protected void reuseParser(HtmlParser parser) {
- parsers.reuseParser(parser);
-
- }
-
- private static final int STACK_SIZE = 100;
-
- private ArrayStack _xhtmlParsersPool = new ArrayStack(STACK_SIZE);
-
- private class NekoParserConfig extends ParserConfig {
-
- protected HtmlParser createParser(String mime) {
- 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());
- }
- // TODO - set header scripts/styles filter.
- return parser;
- }
-
- boolean storeParser(HtmlParser parser) {
- if (null != parser && parser instanceof NekkoParser) {
- synchronized (_xhtmlParsersPool) {
- if (_xhtmlParsersPool.size() < STACK_SIZE) {
- ((NekkoParser) parser).reset();
- _xhtmlParsersPool.push(parser);
- }
-
- }
- return true;
- }
- return false;
- }
- }
-
- private class TidyParserConfig extends ParserConfig {
-
- protected HtmlParser createParser(String mime) {
- // TODO Auto-generated method stub
- TidyParser tidyParser = new TidyParser(getTidyProperties());
- tidyParser.setMoveElements(isForcexml());
- tidyParser.setMime(mime);
- return tidyParser;
- }
-
- }
-
- private class PassParserConfig extends ParserConfig {
-
- protected HtmlParser createParser(String mime) {
- return new FastHtmlParser();
- }
-
- }
-
- private Properties _tidyProperties;
-
- private Properties getTidyProperties() {
- if (null == _tidyProperties) {
- _tidyProperties = new Properties();
- InputStream defaultprops = null;
- InputStream props = null;
- try {
- defaultprops = TidyParser.class
- .getResourceAsStream("tidy.properties");
- if (null != defaultprops) {
- _tidyProperties.load(defaultprops);
- if (log.isDebugEnabled()) {
- log.debug("default tidy parser properties loaded");
- }
- } else if (log.isDebugEnabled()) {
- log.debug("No default tidy parser properties found");
- }
-
- // Second part - user-defined properties.
- props = Thread.currentThread().getContextClassLoader()
- .getResourceAsStream("tidy.properties");
- if (null != props) {
- _tidyProperties.load(props);
- if (log.isDebugEnabled()) {
- log.debug("application-specific tidy parser properties loaded");
- }
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- log.warn(Messages
- .getMessage(Messages.READING_TIDY_PROPERTIES_ERROR), e);
- } finally {
- if (null != props) {
- try {
- props.close();
- } catch (IOException e) {
- // can be ignored
- }
- }
- if (null != defaultprops) {
- try {
- defaultprops.close();
- } catch (IOException e) {
- // can be ignored
- }
- }
- }
- }
- return _tidyProperties;
- }
-
- public ParserConfig getParsers() {
- return parsers;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/FilterServletResponseWrapper.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/FilterServletResponseWrapper.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/FilterServletResponseWrapper.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,653 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is XML RenderKit for JSF.
- *
- * The Initial Developer of the Original Code is
- * Orbeon, Inc (info(a)orbeon.com)
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- */
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.io.FastBufferInputStream;
-import org.ajax4jsf.io.FastBufferOutputStream;
-import org.ajax4jsf.io.FastBufferReader;
-import org.ajax4jsf.io.FastBufferWriter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.InputSource;
-
-/**
- * Base wrapper save JSF page response, for parse to XML with different parsers
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:17 $
- *
- */
-public class FilterServletResponseWrapper extends HttpServletResponseWrapper {
-
- private static final Log log = LogFactory.getLog(FilterServletResponseWrapper.class);
-
- public static final String DEFAULT_ENCODING = "UTF-8";
-
-
- protected FastBufferOutputStream byteStream = null;
- private ServletOutputStream servletOutputStream;
- private boolean useStream = false;
-
- private FastBufferWriter stringWriter;
- private PrintWriter printWriter;
- private boolean useWriter = false;
-
- private String contentType;
-
- private String charterEncoding = null;
-
- private HashMap headers = new HashMap();
-
- private int bufferSize = 2048;
-
- private int contentLength = Integer.MIN_VALUE;
-
- private String redirectLocation = null;
-
- private boolean useNullStream = false;
-
- private List cookies = new ArrayList();
-
- public FilterServletResponseWrapper(HttpServletResponse response) {
- super(response);
- }
-
- /**
- * Convert saved context to stream for parsing
- * @return stream from saved content
- */
- public InputStream getContentAsStream() {
- int length = 0;
- FastBufferInputStream result = null;
- String encoding = this.getCharacterEncoding() ;
-/// byte[] content;
- if (isUseStream()) {
- try {
- servletOutputStream.flush();
- } catch (IOException ex) {
- log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
- }
-/// content = byteStream.toByteArray();
- result = new FastBufferInputStream(byteStream);
- } else if (isUseWriter()) {
- printWriter.flush();
- printWriter.close();
- length = stringWriter.getLength();
-/// String stringContent = stringWriter.toString();
- try {
- FastBufferOutputStream stream = stringWriter.convertToOutputStream(encoding);
- result = new FastBufferInputStream(stream);
-/// content = stringContent.getBytes(encoding);
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- log.warn(Messages.getMessage(Messages.UNSUPPORTED_ENCODING_WARNING));
- FastBufferOutputStream stream = stringWriter.convertToOutputStream();
- result = new FastBufferInputStream(stream);
-/// content = stringContent.getBytes();
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.NO_WRITER_CALLED_INFO));
- }
- return null;
- }
-/// if (content.length > 0) {
- if (length > 0) {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.PARSE_XML_DOCUMENT_INFO));
-// try {
-// log.debug(new String(content, encoding));
-// } catch (UnsupportedEncodingException e) {
-// }
- }
- }
- return result;
-/// return new ByteArrayInputStream(content);
- }
-
- /**
- * Convert saved context to stream for parsing
- * @return stream from saved content
- */
- public Reader getContentAsReader() {
- FastBufferReader result = null;
- String encoding = this.getCharacterEncoding() ;
-/// String content;
- if (isUseWriter()) {
- printWriter.flush();
- printWriter.close();
- result = new FastBufferReader(stringWriter);
-/// content = stringWriter.toString();
- } else if (isUseStream()) {
- try {
- servletOutputStream.flush();
- } catch (IOException ex) {
- log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
- }
- try {
- FastBufferWriter writer = byteStream.convertToWriter(encoding);
- result = new FastBufferReader(writer);
-/// content = byteStream.toString(encoding);
- } catch (UnsupportedEncodingException e) {
- log.warn(Messages.getMessage(Messages.UNSUPPORTED_ENCODING_WARNING_2), e);
- FastBufferWriter writer = byteStream.convertToWriter();
- result = new FastBufferReader(writer);
-/// content = byteStream.toString();
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.NO_WRITER_CALLED_INFO));
- }
- return null;
- }
-// if (content.length() > 0) {
-// if (log.isDebugEnabled()) {
-// log.debug("XML document to parse in filter, return as Reader: ");
-// log.debug(content);
-// }
-// }
-/// return new StringReader(content);
- return result;
- }
-
- public PrintWriter getWriter() throws IOException {
- if (useStream) {
- throw new IllegalStateException(Messages.getMessage(Messages.NO_WRITER_POSSIBLE_ERROR));
- }
- if (printWriter == null) {
- printWriter = new PrintWriter(new ServletStringWriter());
- }
- if(log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.CREATE_WRITER_INFO));
- }
- useWriter = true;
- return printWriter;
- }
-
- public ServletOutputStream getOutputStream() throws IOException {
- if (useWriter) {
- if (isUseNullStream()) {
- return new NullServletOutputStream();
- }
- throw new IllegalStateException(Messages.getMessage(Messages.NO_STREAM_POSSIBLE_ERROR));
- }
- if (servletOutputStream == null) {
-// byteStream = new ByteArrayOutputStream();
- servletOutputStream = new ByteArrayServletOutputStream();
- }
- if(log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.CREATE_STREAM_INFO));
- }
- useStream = true;
- return servletOutputStream;
- }
-
-
- public class ByteArrayServletOutputStream extends ServletOutputStream {
-
- private boolean opened = true;
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#close()
- */
- public void close() throws IOException {
- flush();
- opened=false;
- }
-
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(byte[])
- */
- public void write(byte[] b) throws IOException {
- // TODO Auto-generated method stub
- if (opened) {
- byteStream.write(b);
- }
- }
-
-
- public ByteArrayServletOutputStream() {
- byteStream = new FastBufferOutputStream(bufferSize);
- }
-
- public void write(int b) throws IOException {
- if (opened) {
- byteStream.write(b);
- }
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- public void write(byte[] b, int off, int len) throws IOException {
- if (opened) {
- byteStream.write(b, off, len);
- }
- }
- }
-
- public static class NullServletOutputStream extends ServletOutputStream {
-
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- public void write(byte[] b, int off, int len) throws IOException {
- // this-is null stream, do nothing !
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(byte[])
- */
- public void write(byte[] b) throws IOException {
- // this-is null stream, do nothing !
- }
-
- public void write(int b) throws IOException {
- // this-is null stream, do nothing !
-
- }
-
- }
-
- public class ServletStringWriter extends Writer {
-
- private boolean opened = true;
-
- public ServletStringWriter() {
- super();
- stringWriter = new FastBufferWriter(bufferSize);
- }
-
- public void write(char[] cbuf, int off, int len) throws IOException {
- if (opened) {
- stringWriter.write(cbuf, off, len);
- }
- }
-
- /* (non-Javadoc)
- * @see java.io.Writer#write(char[])
- */
- public void write(char[] cbuf) throws IOException {
- // TODO Auto-generated method stub
- if (opened) {
- stringWriter.write(cbuf);
- }
- }
-
- /* (non-Javadoc)
- * @see java.io.Writer#write(int)
- */
- public void write(int c) throws IOException {
- // TODO Auto-generated method stub
- if (opened) {
- stringWriter.write(c);
- }
- }
-
- public void flush() throws IOException {
- stringWriter.flush();
- }
-
- public void close() throws IOException {
- stringWriter.close();
- opened = false;
- }
-
- }
-
-// public boolean isCommitted() {
-// // NOTE: What makes sense here?
-// return false;
-// }
-
- /**
- * Return a charset from a content-type.
- */
- public static String getContentTypeCharset(String contentType) {
- if (contentType == null)
- return null;
- int semicolumnIndex = contentType.indexOf(";");
- if (semicolumnIndex == -1)
- return null;
- int charsetIndex = contentType.indexOf("charset=", semicolumnIndex);
- if (charsetIndex == -1)
- return null;
- // FIXME: There may be other attributes after charset, right?
- String afterCharset = contentType.substring(charsetIndex + 8);
- afterCharset = afterCharset.replace('"', ' ');
- return afterCharset.trim();
- }
- /* (non-Javadoc)
- * @see javax.servlet.http.HttpServletResponse#addHeader(java.lang.String, java.lang.String)
- */
- public void addHeader(String name, String value) {
- if("Content-Type".equals(name)){
- setContentType(value);
- } else {
- this.headers.put(name,value);
- super.addHeader(name, value);
- }
- }
- /* (non-Javadoc)
- * @see javax.servlet.http.HttpServletResponse#setHeader(java.lang.String, java.lang.String)
- */
- public void setHeader(String name, String value) {
- // HACK - weblogic do not use setContentType, instead directly set header !
- if("Content-Type".equals(name)){
- setContentType(value);
- } else {
- this.headers.put(name,value);
- super.setHeader(name, value);
- }
- }
-
- public Map getHeaders(){
- return this.headers;
- }
- /* (non-Javadoc)
- * @see javax.servlet.ServletResponse#getCharacterEncoding()
- */
- public String getCharacterEncoding() {
-// return this.charterEncoding;
- if (null != this.charterEncoding) {
- return this.charterEncoding;
- } else {
- // For cases of implicit setting
- return super.getCharacterEncoding();
- }
- }
- /* (non-Javadoc)
- * @see javax.servlet.ServletResponse#setCharacterEncoding(java.lang.String)
- */
- public void setCharacterEncoding(String charset) {
- this.charterEncoding = charset;
- //super.setCharacterEncoding(charset);
- }
- public void setContentType(String type) {
- String contentTypeCharset = getContentTypeCharset(type);
- if (null != contentTypeCharset) {
- this.charterEncoding = contentTypeCharset;
- }
- this.contentType = type;
-// super.setContentType(type);
- }
- public void setLocale(Locale loc) {
- super.setLocale(loc);
- }
-
- public String getContentType() {
- return contentType;
- }
-
- /**
- * Send buffered content directly to output stream.
- * @param outputStream
- * @throws IOException
- */
- public void sendContent(ServletOutputStream outputStream) throws IOException {
- if(getContentLength() >0 ){
- super.setContentLength(getContentLength());
- }
- if (isUseWriter()) {
- printWriter.flush();
- printWriter.close();
- stringWriter.printTo(outputStream);
-/// outputStream.print(stringWriter.toString());
- } else if (isUseStream()) {
- try {
- servletOutputStream.flush();
- } catch (IOException ex) {
- log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
- }
- byteStream.writeTo(outputStream);
- }
- }
-
- /**
- * Send buffered content directly to output stream.
- * @param outputStream
- * @throws IOException
- */
- public void sendContent(Writer output) throws IOException {
- if(getContentLength() >0 ){
- super.setContentLength(getContentLength());
- }
- if (isUseWriter()) {
- printWriter.flush();
- printWriter.close();
- stringWriter.writeTo(output);
-/// outputStream.print(stringWriter.toString());
- } else if (isUseStream()) {
- try {
- servletOutputStream.flush();
- } catch (IOException ex) {
- log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
- }
- byteStream.writeTo(output,getCharacterEncoding());
- }
- }
- /**
- * @return Returns the useStream.
- */
- public boolean isUseStream() {
- return this.useStream;
- }
-
- /**
- * @return Returns the useWriter.
- */
- public boolean isUseWriter() {
- return this.useWriter;
- }
-
- /**
- * @return
- * @throws RuntimeException
- */
- public InputSource getContentAsInputSource() throws RuntimeException {
- // Create InputSource
- InputSource inputSource = null;
- String encoding = this.getCharacterEncoding() ;
- if(isUseWriter()) {
- inputSource = new InputSource(getContentAsReader());
- } else if(isUseStream()) {
- inputSource = new InputSource(getContentAsStream());
- if (encoding != null)
- inputSource.setEncoding(encoding);
- } else {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.NO_WRITER_CALLED_INFO));
- }
- return null;
- }
- return inputSource;
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.ServletResponseWrapper#flushBuffer()
- */
- public void flushBuffer() throws IOException {
- if(isUseStream()){
- servletOutputStream.flush();
- } else if(isUseWriter()){
- printWriter.flush();
- }
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.ServletResponseWrapper#getBufferSize()
- */
- public int getBufferSize() {
- // TODO Auto-generated method stub
- return bufferSize;
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.ServletResponseWrapper#resetBuffer()
- */
- public void resetBuffer() {
- this.printWriter = null;
- this.stringWriter = null;
- this.servletOutputStream = null;
- this.byteStream = null;
- this.useStream = false;
- this.useWriter = false;
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.ServletResponseWrapper#setBufferSize(int)
- */
- public void setBufferSize(int arg0) {
- // TODO Auto-generated method stub
- bufferSize = arg0;
- }
-
- /* (non-Javadoc)
- * @see javax.servlet.ServletResponseWrapper#reset()
- */
- public void reset() {
- // TODO Auto-generated method stub
- this.resetBuffer();
- this.headers = new HashMap();
- this.contentType=null;
- this.charterEncoding=null;
- super.reset();
- }
-
- /**
- * @return Returns the contentLength.
- */
- public int getContentLength() {
- return contentLength;
- }
-
- /**
- * @param contentLength The contentLength to set.
- */
- public void setContentLength(int contentLength) {
- this.contentLength = contentLength;
- }
-
- /**
- * Parse saved content to output stream ( and store as Dom Document tree )
- * @param out stream to send parsed content, if null - only build dom tree.
- * @return parsed document as dom tree.
- * @throws IOException
- */
- public void parseContent(Writer out,HtmlParser parser) throws IOException {
- parser.setInputEncoding(getCharacterEncoding());
- if (isUseWriter()) {
- parser.parseHtml(getContentAsReader(),out);
- } else if(isUseStream()){
- parser.parseHtml(getContentAsStream(),out);
- }
- }
-
- public void sendRedirect(String arg0) throws IOException {
- // TODO Auto-generated method stub
- this.redirectLocation = arg0;
- }
-
- public String getRedirectLocation() {
- return redirectLocation;
- }
-
- /**
- * @return the useNullStream
- */
- public boolean isUseNullStream() {
- return useNullStream;
- }
-
- /**
- * @param useNullStream the useNullStream to set
- */
- public void setUseNullStream(boolean useNullStream) {
- this.useNullStream = useNullStream;
- }
-
-
-
- public void addCookie(Cookie cookie) {
- cookies.add(cookie);
- super.addCookie(cookie);
- }
-
- public Collection getCookies() {
- return cookies;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,71 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.Set;
-
-public interface HtmlParser {
-
- public abstract void parseHtml(InputStream input, Writer output)
- throws IOException;
-
- public abstract void parseHtml(Reader input, Writer output)
- throws IOException;
- /**
- * @param encoding
- */
- public abstract void setInputEncoding(String encoding);
-
- /**
- * @param encoding
- */
- public abstract void setOutputEncoding(String encoding);
- /**
- * Setup, must tidy move style etc. elements to head or not.
- * @param move
- */
- public abstract void setMoveElements(boolean move);
-
- /**
- * @param scripts The scripts to set.
- */
- public abstract void setScripts(Set scripts);
-
- /**
- * @param styles The styles to set.
- */
- public abstract void setStyles(Set styles);
-
- public abstract void setDoctype(String doctype);
-
- /**
- * @param viewState The viewState to set.
- */
- public abstract void setViewState(String viewState);
-
- public abstract boolean setMime(String mimeType);
-
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/Log4JConfigurator.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/Log4JConfigurator.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/Log4JConfigurator.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,75 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.util.Properties;
-
-import org.ajax4jsf.Messages;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.xml.DOMConfigurator;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:18 $
- *
- */
-class Log4JConfigurator {
- private static final String CONTEXT_ROOT_VARIABLE = "context-root";
- private Properties props = new Properties();
- private String prefix;
-
- DOMConfigurator domConfig;
-
- void doConfigure(String file){
- domConfig.doConfigure(prefix + file, LogManager.getLoggerRepository());
- }
-
-
- /**
- * @param prefix
- */
- public Log4JConfigurator(String prefix) {
- this.prefix = prefix;
- props.setProperty(CONTEXT_ROOT_VARIABLE, prefix);
- domConfig = new DOMConfigurator() {
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.log4j.xml.DOMConfigurator#subst(java.lang.String)
- * append context-related properties for variable
- * substitution.
- */
- protected String subst(String value) {
- try {
- return OptionConverter.substVars(value, props);
- } catch (IllegalArgumentException e) {
- LogLog.warn(Messages.getMessage(Messages.VARIABLE_SUBSTITUTION_WARNING), e);
- return value;
- }
- };
-
- };
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoFilter.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import org.ajax4jsf.framework.ajax.xmlfilter.nekko.NekkoXMLFilter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * This class implements a simple Servlet filter that convert basic html
- * output of JSF to valid XML or JavaScript, for parsing different versions
- * of XmlHttpRequest's on client side.
- */
-public class NekkoFilter extends BaseFilter implements javax.servlet.Filter {
- static final Log log = LogFactory.getLog(NekkoFilter.class);
-
- /**
- *
- */
- public NekkoFilter() {
- super();
- // default - not force
-// setForcexml(false);
- xmlFilter = new NekkoXMLFilter();
- xmlFilter.setFilter(this);
- }
-
-}
-
-
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,67 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-abstract class ParserConfig {
-
- private static final Pattern[] ALL_VIEWS_PATTERN = { Pattern.compile(".*") };
-
- private static final Pattern SEPARATOR_PATTERN = Pattern.compile("\\s*,\\s*");
-
- private Pattern[] patterns = ALL_VIEWS_PATTERN;
-
- private ParserConfig next;
-
- protected abstract HtmlParser createParser(String mimetype);
-
- boolean storeParser(HtmlParser parser) {
- return false;
- }
-
- HtmlParser getParser(String viewId, String mimetype) {
- HtmlParser result = null;
- for (int i = 0; i < patterns.length && null == result; i++) {
- Matcher matcher = patterns[i].matcher(viewId);
- if (matcher.matches()) {
- result = createParser(mimetype);
- }
- }
- if (null == result && null != next) {
- result = next.getParser(viewId, mimetype);
- }
- return result;
- }
-
- public void reuseParser(HtmlParser parser) {
- if (!storeParser(parser) && null != next) {
- next.reuseParser(parser);
- }
- }
-
- public ParserConfig getNext() {
- return next;
- }
-
- public void setNext(ParserConfig next) {
- this.next = next;
- }
-
- public void setPatterns(String patternsString) {
- if (null != patternsString) {
- String[] split = SEPARATOR_PATTERN.split(patternsString);
- patterns = new Pattern[split.length];
- for (int i = 0; i < split.length; i++) {
- patterns[i]=Pattern.compile(split[i].trim());
- }
- }
- }
-
- public Pattern[] getPatterns() {
- return patterns;
- }
-
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/PollEventsManager.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/PollEventsManager.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/PollEventsManager.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,64 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.faces.FacesException;
-import javax.servlet.ServletContext;
-
-import org.ajax4jsf.ajax.PushEventsCounter;
-import org.ajax4jsf.cache.Cache;
-import org.ajax4jsf.cache.CacheConfigurationLoader;
-import org.ajax4jsf.cache.CacheException;
-import org.ajax4jsf.cache.CacheFactory;
-import org.ajax4jsf.cache.CacheLoader;
-import org.ajax4jsf.cache.CacheManager;
-import org.ajax4jsf.cache.ServletContextInitMap;
-
-/**
- * @author asmirnov
- *
- */
-public class PollEventsManager implements Serializable, CacheLoader, CacheConfigurationLoader {
-
- public static final String EVENTS_MANAGER_KEY=PollEventsManager.class.getName();
-
- private Cache cache;
-
- public void init(ServletContext servletContext) {
- try {
- CacheManager cacheManager = CacheManager.getInstance();
- Map env = new ServletContextInitMap(servletContext);
- CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
- this.cache = cacheFactory.createCache(env, this, this);
- servletContext.setAttribute(EVENTS_MANAGER_KEY, this);
- } catch (CacheException e) {
- throw new FacesException(e.getMessage(), e);
- }
-
- }
-
- public PushEventsCounter getListener(String key){
- if(null == cache){
- throw new FacesException("Poll events manager not initialized");
- }
- try {
- return (PushEventsCounter) cache.get(key, null);
- } catch (CacheException e) {
- throw new FacesException("error get push events listener for key "+key,e);
- }
- }
-
- public Object load(Object key, Object context) throws CacheException {
- // TODO Auto-generated method stub
- return new PushEventsCounter();
- }
-
- public Properties loadProperties(String name) {
- return new Properties();
- }
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ServletStreamWriter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ServletStreamWriter.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ServletStreamWriter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,111 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.servlet.ServletOutputStream;
-
-/**
- * HACK - for case if servlet response already use Writer, create wrapper to stream -
- * since most of serializers use outputStream. In future, must be replaced by Dual serialization
- * capabilites.
- * @author shura
- *
- */
-final class ServletStreamWriter extends ServletOutputStream {
-
- private PrintWriter _writer;
-
- private byte[] buff = new byte[1024];
-
- private int point = 0;
-
- private String _charset;
-
- /**
- * @param writer
- * @param charset
- */
- public ServletStreamWriter(PrintWriter writer, String charset) {
- super();
- // TODO Auto-generated constructor stub
- _writer = writer;
- _charset = charset;
- }
-
- public ServletStreamWriter(PrintWriter writer) {
- this._writer = writer;
- }
-
- public void write(int b) throws IOException {
- buff[point++]=(byte) b;
- if(point==buff.length){
- point = 0;
- String string = null==_charset?new String(buff):new String(buff,_charset);
- _writer.write(string);
- }
- }
-
- /**
- * @return Returns the charset.
- */
- public String getCharset() {
- return _charset;
- }
-
- /**
- * @param charset The charset to set.
- */
- public void setCharset(String charset) {
- _charset = charset;
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#close()
- */
- public void close() throws IOException {
- this.flush();
- super.close();
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#flush()
- */
- public void flush() throws IOException {
- if(point>0){
- String string = null==_charset?new String(buff,0,point):new String(buff,0,point,_charset);
- _writer.write(string);
- point = 0;
- }
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- public void write(byte[] b, int off, int len) throws IOException {
- this.flush();
- String string = null==_charset?new String(b,off,len):new String(b,off,len,_charset);
- _writer.write(string);
- }
-}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/TidyFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/TidyFilter.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/TidyFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,44 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import org.ajax4jsf.framework.ajax.xmlfilter.tidy.TidyXMLFilter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Convert Html Output to XML using Jtidy.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:20 $
- */
-public class TidyFilter extends BaseFilter {
- static final Log log = LogFactory.getLog(TidyFilter.class);
-
- public TidyFilter() {
- // For Tidy, publicId can be pre-defined omit | auto | strict | loose | ignore | [fpi]
- xmlFilter = new TidyXMLFilter();
- xmlFilter.setFilter(this);
- xmlFilter.setPublicid("omit");
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/XMLResponseWriterState.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/XMLResponseWriterState.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/XMLResponseWriterState.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,134 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.Messages;
-
-/**
- * @author shura Class to implement state pattern for
- * <code>ResponceWriter</code> Real states must extend this. By
- * default, block any events, ignore output.
- *
- */
-class XMLResponseWriterState {
- // private ResponseWriter writer;
- /**
- * @throws java.io.IOException
- */
- private static final String ILLEGAL_METOD_STATE = Messages.getMessage(Messages.ILLEGAL_METHOD_STATE);
-
- void endDocument() throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param name
- * @throws java.io.IOException
- */
- void endElement(String name) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @throws java.io.IOException
- */
- void startDocument() throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param name
- * @param component
- * @throws java.io.IOException
- */
- void startElement(String name, UIComponent component) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param name
- * @param value
- * @param property
- * @throws java.io.IOException
- */
- void writeAttribute(String name, Object value, String property)
- throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param comment
- * @throws java.io.IOException
- */
- void writeComment(Object comment) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param text
- * @param off
- * @param len
- * @throws java.io.IOException
- */
- void writeText(char[] text, int off, int len) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param text
- * @param property
- * @throws java.io.IOException
- */
- void writeText(Object text, String property) throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- * @param name
- * @param value
- * @param property
- * @throws java.io.IOException
- */
- void writeURIAttribute(String name, Object value, String property)
- throws IOException {
- throw new IOException(ILLEGAL_METOD_STATE);
- }
-
- /**
- *
- * Main hook for realise <code>Writer</code>. In document writed as
- * comment, outside of document do nothing ....
- *
- * @param cbuf
- * @param off
- * @param len
- * @throws IOException
- */
- void write(char[] cbuf, int off, int len) throws IOException {
- // DO NOTHING
-
- }
-}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourcesRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourcesRendererBase.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/HeaderResourcesRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -27,9 +27,9 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
import org.ajax4jsf.renderkit.HeaderResourceProducer;
import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.webapp.BaseFilter;
/**
* Base renderer for components used JavaScripts and Styles in header. In real
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -30,8 +30,8 @@
import java.util.Iterator;
import java.util.Set;
-import org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser;
import org.ajax4jsf.io.FastBufferReader;
+import org.ajax4jsf.webapp.HtmlParser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -26,8 +26,8 @@
import java.io.OutputStream;
import java.io.PrintWriter;
-import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.webapp.CacheContent;
/**
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -47,13 +47,13 @@
import org.ajax4jsf.cache.CacheLoader;
import org.ajax4jsf.cache.CacheManager;
import org.ajax4jsf.cache.ServletContextInitMap;
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
import org.ajax4jsf.framework.util.config.WebXml;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceContext;
import org.ajax4jsf.resource.ResourceNotFoundException;
+import org.ajax4jsf.webapp.BaseFilter;
+import org.ajax4jsf.webapp.CacheContent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,388 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.util.Enumeration;
+
+import javax.faces.application.ViewHandler;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.ajax.PushEventsCounter;
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.resource.InternetResourceService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base class for request processing filters, with convert Htmp content to XML
+ * for ajax requests, and serve request to application off-page resources
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:21 $
+ *
+ */
+public abstract class BaseFilter implements Filter {
+
+ public static final String AJAX_PUSH_KEY_HEADER = "Ajax-Push-Key";
+
+ private static final Log log = LogFactory.getLog(BaseFilter.class);
+
+ public static final boolean DEBUG = true;
+
+ private FilterConfig filterConfig;
+
+ private static final String FUNCTION_NAME_PARAMETER = "function";
+
+ private String function = "alert('Data received');JSHttpRequest.dataReady";
+
+ private String attributesNames;
+
+ private boolean rewriteid = false;
+
+ public static final String REWRITEID_PARAMETER = "rewriteid";
+
+ public static final String STYLESHEET_PARAMETER = "xsl";
+
+ public static final String ABSOLUTE_TAGS_PARAMETER = "absolute-attributes";
+
+ // private WebXml webXml;
+ // private String xsl;
+ // private Templates xslTemplates;
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2295534611886142935L;
+
+ public static final String DATA_PARAMETER = "DATA";
+
+ public static final String DEFAULT_SERVLET_PATH = "/resource";
+
+ public static final String RENDERER_PREFIX = "/renderer";
+
+ public static final String CACHEABLE_PREFIX = "/cache";
+
+ // private static final Pattern rendererPattern =
+ // Pattern.compile(RENDERER_PREFIX+"/([^/]+)/([^/]+)/([^/]+)/(.*)");
+ // private static final Pattern builderPattern =
+ // Pattern.compile(CACHEABLE_PREFIX+"/(.*)");
+ public static final String FILTER_PERFORMED = "com.exade.vcp.Filter.done";
+
+ public static final String RESPONSE_WRAPPER_ATTRIBUTE = "com.exade.vcp.Filter.ResponseWrapper";
+
+ protected BaseXMLFilter xmlFilter = null;
+
+ protected InternetResourceService resourceService = null;
+
+ protected PollEventsManager eventsManager;
+
+ /**
+ * Initialize the filter.
+ */
+ public void init(FilterConfig config) throws ServletException {
+ if (log.isDebugEnabled()) {
+ log.debug("Init ajax4jsf filter with nane: "
+ + config.getFilterName());
+ Enumeration parameterNames = config.getInitParameterNames();
+ StringBuffer parameters = new StringBuffer("Init parameters :\n");
+ while (parameterNames.hasMoreElements()) {
+ String name = (String) parameterNames.nextElement();
+ parameters.append(name).append(" : '").append(
+ config.getInitParameter(name)).append('\n');
+ }
+ log.debug(parameters);
+ // log.debug("Stack Trace", new Exception());
+ }
+ // Save config
+ filterConfig = config;
+ setFunction((String) nz(filterConfig
+ .getInitParameter(FUNCTION_NAME_PARAMETER), getFunction()));
+ setAttributesNames(filterConfig
+ .getInitParameter(ABSOLUTE_TAGS_PARAMETER));
+ xmlFilter.init(config);
+ if ("true".equalsIgnoreCase(filterConfig
+ .getInitParameter(REWRITEID_PARAMETER))) {
+ this.setRewriteid(true);
+ }
+
+ String prefix = filterConfig.getServletContext().getRealPath("/");
+ String file = filterConfig.getInitParameter("log4j-init-file");
+ // if the log4j-init-file is not set, then no point in trying
+ if (file != null) {
+ Log4JConfigurator log4jconfig = new Log4JConfigurator(prefix);
+ log4jconfig.doConfigure(file);
+ }
+ resourceService = new InternetResourceService();
+ // Caching initialization.
+ resourceService.init(filterConfig);
+ eventsManager = new PollEventsManager();
+ eventsManager.init(filterConfig.getServletContext());
+ }
+
+ /**
+ * @param httpServletRequest
+ * @throws UnsupportedEncodingException
+ */
+ protected void setupRequestEncoding(HttpServletRequest httpServletRequest)
+ throws UnsupportedEncodingException {
+ String contentType = httpServletRequest.getHeader("Content-Type");
+
+ String characterEncoding = lookupCharacterEncoding(contentType);
+
+ if (characterEncoding == null) {
+ HttpSession session = httpServletRequest.getSession(false);
+
+ if (session != null) {
+ characterEncoding = (String) session
+ .getAttribute(ViewHandler.CHARACTER_ENCODING_KEY);
+ }
+
+ if (characterEncoding != null) {
+ httpServletRequest.setCharacterEncoding(characterEncoding);
+ }
+ }
+ }
+
+ /**
+ * Detect request encoding from Content-Type header
+ *
+ * @param contentType
+ * @return - charset, if present.
+ */
+ private String lookupCharacterEncoding(String contentType) {
+ String characterEncoding = null;
+
+ if (contentType != null) {
+ int charsetFind = contentType.indexOf("charset=");
+ if (charsetFind != -1) {
+ if (charsetFind == 0) {
+ // charset at beginning of Content-Type, curious
+ characterEncoding = contentType.substring(8);
+ } else {
+ char charBefore = contentType.charAt(charsetFind - 1);
+ if (charBefore == ';' || Character.isWhitespace(charBefore)) {
+ // Correct charset after mime type
+ characterEncoding = contentType
+ .substring(charsetFind + 8);
+ }
+ }
+ if (log.isDebugEnabled())
+ log.debug(Messages.getMessage(
+ Messages.CONTENT_TYPE_ENCODING, characterEncoding));
+ } else {
+ if (log.isDebugEnabled())
+ log.debug(Messages.getMessage(
+ Messages.CONTENT_TYPE_NO_ENCODING, contentType));
+ }
+ }
+ return characterEncoding;
+ }
+
+ /**
+ * @param initParameter
+ * @param function2
+ * @return
+ */
+ private Object nz(Object param, Object def) {
+ return param != null ? param : def;
+ }
+
+ /**
+ * Execute the filter.
+ */
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain) throws IOException, ServletException {
+ long startTimeMills = 0;
+ // Detect case of request - normal, AJAX, AJAX - JavaScript
+ // TODO - detect first processing in filter.
+ HttpServletRequest httpServletRequest = (HttpServletRequest) request;
+ HttpServletResponse httpServletResponse = (HttpServletResponse) response;
+ if (log.isDebugEnabled()) {
+ startTimeMills = System.currentTimeMillis();
+ log.debug(Messages.getMessage(Messages.FILTER_START_INFO, new Date(
+ startTimeMills), httpServletRequest.getRequestURI()));
+ }
+
+ if (request.getAttribute(FILTER_PERFORMED) != Boolean.TRUE) {
+ // mark - and not processing same request twice.
+ request.setAttribute(FILTER_PERFORMED, Boolean.TRUE);
+ String ajaxPushHeader = httpServletRequest.getHeader(AJAX_PUSH_KEY_HEADER);
+ // check for a push check request.
+ if (httpServletRequest.getMethod().equals("HEAD")
+ && null != ajaxPushHeader) {
+ PushEventsCounter listener = eventsManager.getListener(ajaxPushHeader);
+ if(listener.isPerformed()){
+ listener.processed();
+ httpServletResponse.setStatus(200);
+ if (log.isDebugEnabled()) {
+ log.debug("Occurs event for a id "+ajaxPushHeader);
+ }
+ } else {
+ // Response code - 'No content'
+ httpServletResponse.setStatus(204);
+ if (log.isDebugEnabled()) {
+ log.debug("No event for a id "+ajaxPushHeader);
+ }
+ }
+ } else
+ // check for resource request
+ if (!getResourceService().serviceResource(httpServletRequest,
+ httpServletResponse)) {
+ // Not request to resource - perform filtering.
+ // first stage - detect/set encoding of request. Same as in
+ // Myfaces External Context.
+ setupRequestEncoding(httpServletRequest);
+ // check ajax request parameter
+ // TODO - check for JSF page.
+ if (true) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages
+ .getMessage(Messages.FILTER_XML_OUTPUT));
+ }
+
+ // Execute the rest of the filter chain, including the
+ // JSP
+ xmlFilter.doXmlFilter(chain, httpServletRequest,
+ httpServletResponse);
+ } else {
+ // normal request, execute chain ...
+ if (log.isDebugEnabled()) {
+ log.debug(Messages
+ .getMessage(Messages.FILTER_NO_XML_CHAIN));
+ }
+ chain.doFilter(request, response);
+
+ }
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.FILTER_NO_XML_CHAIN_2));
+ }
+ chain.doFilter(request, response);
+
+ }
+ if (log.isDebugEnabled()) {
+ startTimeMills = System.currentTimeMillis() - startTimeMills;
+ log.debug(Messages.getMessage(Messages.FILTER_STOP_INFO, ""
+ + startTimeMills, httpServletRequest.getRequestURI()));
+ }
+ }
+
+ /**
+ * @param request
+ * @return
+ */
+ protected boolean isAjaxRequest(ServletRequest request) {
+ try {
+ return null != request
+ .getParameter(AjaxContainerRenderer.AJAX_PARAMETER_NAME);
+ } catch (Exception e) {
+ // OCJ 10 - throw exception for static resources.
+ return false;
+ }
+ }
+
+ /**
+ * Destroy the filter.
+ */
+ public void destroy() {
+ }
+
+ /**
+ * @return Returns the servletContext.
+ */
+ ServletContext getServletContext() {
+ return filterConfig.getServletContext();
+ }
+
+ /**
+ * @return the resourceService
+ * @throws ServletException
+ */
+ protected synchronized InternetResourceService getResourceService()
+ throws ServletException {
+ // if (resourceService == null) {
+ // resourceService = new InternetResourceService();
+ // // Caching initialization.
+ // resourceService.init(filterConfig);
+ //
+ // }
+ return resourceService;
+ }
+
+ /**
+ * @param function
+ * The function to set.
+ */
+ protected void setFunction(String function) {
+ this.function = function;
+ }
+
+ /**
+ * @return Returns the function.
+ */
+ protected String getFunction() {
+ return function;
+ }
+
+ /**
+ * @param rewriteid
+ * The rewriteid to set.
+ */
+ protected void setRewriteid(boolean rewriteid) {
+ this.rewriteid = rewriteid;
+ }
+
+ /**
+ * @return Returns the rewriteid.
+ */
+ protected boolean isRewriteid() {
+ return rewriteid;
+ }
+
+ /**
+ * @param attributesNames
+ * The attributesNames to set.
+ */
+ protected void setAttributesNames(String attributesNames) {
+ this.attributesNames = attributesNames;
+ }
+
+ /**
+ * @return Returns the attributesNames.
+ */
+ protected String getAttributesNames() {
+ return attributesNames;
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java (from rev 1557, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/BaseXMLFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,429 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.application.AjaxViewHandler;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class BaseXMLFilter {
+ private static final Log log = LogFactory.getLog(BaseXMLFilter.class);
+
+ public static final String RESPONSE_WRAPPER_ATTRIBUTE = "com.exade.vcp.Filter.ResponseWrapper";
+
+ private String mimetype = "text/xml";
+
+ private String publicid = "-//W3C//DTD XHTML 1.0 Transitional//EN";
+
+ private String systemid = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
+
+ private String namespace = "http://www.w3.org/1999/xhtml";
+
+ private static final String MIME_TYPE_PARAMETER = "mime-type";
+
+ private static final String PUBLICID_PARAMETER = "publicid";
+
+ private static final String SYSTEMID_PARAMETER = "systemid";
+
+ private static final String NAMESPACE_PARAMETER = "namespace";
+
+ private boolean forcexml = false;
+
+
+ private static final String FORCEXML_PARAMETER = "forceparser";
+
+ private static final String INIT_PARAMETER_PREFIX = "org.ajax4jsf.xmlfilter.";
+
+ public BaseFilter filter;
+
+ public void setFilter(BaseFilter filter) {
+ this.filter = filter;
+ }
+
+ public void init(FilterConfig config) throws ServletException {
+ if (log.isDebugEnabled()) {
+ log.debug("init XML filter service with class "
+ + this.getClass().getName());
+ }
+ String forceXmlParameter = config
+ .getInitParameter(FORCEXML_PARAMETER);
+ setupForceXml(forceXmlParameter);
+ forceXmlParameter = config.getServletContext().getInitParameter(INIT_PARAMETER_PREFIX+FORCEXML_PARAMETER);
+ setMimetype((String) nz(config.getInitParameter(MIME_TYPE_PARAMETER),
+ "text/xml"));
+ setPublicid((String) nz(config.getInitParameter(PUBLICID_PARAMETER),
+ getPublicid()));
+ setSystemid((String) nz(config.getInitParameter(SYSTEMID_PARAMETER),
+ getSystemid()));
+ setNamespace((String) nz(config.getInitParameter(NAMESPACE_PARAMETER),
+ getNamespace()));
+ }
+
+ /**
+ * @param forceXmlParameter
+ */
+ private void setupForceXml(String forceXmlParameter) {
+ if ("false".equalsIgnoreCase(forceXmlParameter)) {
+ this.forcexml = false;
+ }
+ if ("true"
+ .equalsIgnoreCase(forceXmlParameter)) {
+ this.forcexml = true;
+ }
+ }
+
+ /**
+ * Perform filter chain with xml parsing and transformation. Subclasses
+ * must implement concrete HTML to XML parsing, nesseasary
+ * transformations and serialization.
+ *
+ * @param chain
+ * @param httpServletRequest
+ * @param httpServletResponse
+ * @throws ServletException
+ * @throws IOException
+ */
+ protected void doXmlFilter(FilterChain chain, HttpServletRequest request,
+ final HttpServletResponse response) throws IOException,
+ ServletException {
+ if (log.isDebugEnabled()) {
+ log.debug("XML filter service start processing request");
+ }
+ FilterServletResponseWrapper servletResponseWrapper = getWrapper(response);
+ // HACK - to avoid MyFaces <f:view> incompabilites and bypass
+ // intermediaty filters
+ // in chain, self-rendered region write directly to wrapper stored in
+ // request-scope attribute.
+ request
+ .setAttribute(RESPONSE_WRAPPER_ATTRIBUTE,
+ servletResponseWrapper);
+ chain.doFilter(request, servletResponseWrapper);
+ String viewId = (String) request.getAttribute(AjaxViewHandler.VIEW_ID_KEY);
+ HtmlParser parser = null;
+ // setup response
+ // Redirect in AJAX request - convert to special response recognized by
+ // client.
+ String redirectLocation = servletResponseWrapper.getRedirectLocation();
+ String characterEncoding = servletResponseWrapper
+ .getCharacterEncoding();
+ Writer output;
+ if (null != redirectLocation) {
+ if (isAjaxRequest(request)) {
+ // Special handling of redirect - client-side script must
+ // Check for response and perform redirect by window.location
+ if (log.isDebugEnabled()) {
+ log.debug("Create AJAX redirect response to url: "
+ + redirectLocation);
+ }
+ response.reset();
+ // Keep cookies.
+ for (Iterator iter = servletResponseWrapper.getCookies().iterator(); iter.hasNext();) {
+ Cookie cookie = (Cookie) iter.next();
+ response.addCookie(cookie);
+ }
+ // Copy response headers
+ Map headers = servletResponseWrapper.getHeaders();
+ for (Iterator iter = headers.entrySet().iterator(); iter
+ .hasNext();) {
+ Map.Entry header = (Map.Entry) iter.next();
+ response.setHeader((String) header.getKey(),
+ (String) header.getValue());
+ }
+ response.setHeader(AjaxContainerRenderer.AJAX_FLAG_HEADER,
+ "redirect");
+ // Not caching AJAX request
+ response.setHeader("Cache-Control",
+ "no-cache, must-revalidate, max_age=0, no-store");
+ response.setHeader("Expires", "0");
+ response.setHeader("Pragma", "no-cache");
+ response.setContentType(getMimetype() + ";charset=UTF-8");
+ response.setHeader(AjaxContainerRenderer.AJAX_LOCATION_HEADER,
+ redirectLocation);
+ output = createResponseWriter(response, "UTF-8");
+ // For buggy XmlHttpRequest realisations repeat headers in
+ // <meta>
+ output.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>"
+ + "<meta name=\""
+ + AjaxContainerRenderer.AJAX_FLAG_HEADER
+ + "\" content=\"redirect\" />" + "<meta name=\""
+ + AjaxContainerRenderer.AJAX_LOCATION_HEADER
+ + "\" content=\"" + redirectLocation + "\" />"
+ + "</head></html>");
+ output.flush();
+ response.flushBuffer();
+ } else {
+ response.sendRedirect(redirectLocation);
+ }
+ return;
+ } else if ("true".equals(servletResponseWrapper.getHeaders().get(
+ AjaxContainerRenderer.AJAX_FLAG_HEADER))) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Process response to well-formed XML for AJAX XMLHttpRequest parser");
+ }
+ // Not caching AJAX request
+ response.setHeader("Cache-Control",
+ "no-cache, must-revalidate, max_age=0, no-store");
+ response.setHeader("Expires", "0");
+ response.setHeader("Pragma", "no-cache");
+ // response.setCharacterEncoding(servletResponseWrapper
+ // .getCharacterEncoding()); //
+ // JSContentHandler.DEFAULT_ENCODING);
+ // Set the content-type. For AJAX responses default encoding -
+ // UTF8.
+ // TODO - for null encoding, setup only Output encoding for
+ // filter ?
+ String outputEncoding = "UTF-8";
+ String contentType = getMimetype() + ";charset=" + outputEncoding;
+ response.setContentType(contentType);
+ parser = getParser(getMimetype(), true, viewId);
+ if (null == parser) {
+ throw new ServletException(Messages.getMessage(
+ Messages.PARSER_NOT_INSTANTIATED_ERROR, contentType));
+ }
+ output = createResponseWriter(response, outputEncoding);
+ parser.setDoctype(getPublicid());
+ parser.setInputEncoding(characterEncoding);
+ parser.setOutputEncoding(outputEncoding);
+ parser.setViewState((String) request
+ .getAttribute(AjaxViewHandler.SERIALIZED_STATE_KEY));
+ } else {
+ // setup conversion reules for output contentType, send directly
+ // if content not
+ // supported by tidy.
+ String contentType = servletResponseWrapper.getContentType();
+ if (log.isDebugEnabled()) {
+ log.debug("create HTML/XML parser for content type: "
+ + contentType);
+ }
+ // if(contentType == null){
+ // contentType = request.getContentType();
+ // }
+ if (contentType != null) {
+ if (contentType.indexOf("charset") < 0
+ && null != characterEncoding) {
+ contentType += ";charset=" + characterEncoding;
+ }
+ parser = getParser(contentType, false, viewId);
+ response.setContentType(contentType);
+ }
+ // null or unsupported content type
+ if (null == parser) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Parser not have support for the such content type, send response as-is");
+ }
+ try {
+ if (servletResponseWrapper.isUseWriter()) {
+ output = createResponseWriter(response,
+ characterEncoding);
+ servletResponseWrapper.sendContent(output);
+ } else if (servletResponseWrapper.isUseStream()) {
+ ServletOutputStream out = response.getOutputStream();
+ servletResponseWrapper.sendContent(out);
+ }
+ } finally {
+ // reuseWrapper(servletResponseWrapper);
+ }
+ return;
+ }
+ output = createResponseWriter(response, characterEncoding);
+
+ parser.setInputEncoding(characterEncoding);
+ parser.setOutputEncoding(characterEncoding);
+ }
+
+ try {
+ // Setup scripts and styles
+ parser.setScripts((Set) request
+ .getAttribute(AjaxContext.SCRIPTS_PARAMETER));
+ parser.setStyles((Set) request
+ .getAttribute(AjaxContext.STYLES_PARAMETER));
+ // Process parsing.
+ long startTimeMills = System.currentTimeMillis();
+ servletResponseWrapper.parseContent(output, parser);
+ if (log.isDebugEnabled()) {
+ startTimeMills = System.currentTimeMillis() - startTimeMills;
+ log.debug(Messages.getMessage(Messages.PARSING_TIME_INFO, ""
+ + startTimeMills));
+ }
+ } catch (Exception e) {
+ throw new ServletException(Messages
+ .getMessage(Messages.JTIDY_PARSING_ERROR), e);
+ } finally {
+ reuseParser(parser);
+ }
+ }
+
+ /**
+ * @param response
+ * @return
+ * @throws ServletException
+ */
+ protected FilterServletResponseWrapper getWrapper(
+ HttpServletResponse response) throws ServletException {
+ return new FilterServletResponseWrapper(response);
+ }
+
+ /**
+ * @param request
+ * @return
+ */
+ protected boolean isAjaxRequest(ServletRequest request) {
+ try {
+ return null != request
+ .getParameter(AjaxContainerRenderer.AJAX_PARAMETER_NAME);
+ } catch (Exception e) {
+ // OCJ 10 - throw exception for static resources.
+ return false;
+ }
+ }
+
+ /**
+ * @param response
+ * @param characterEncoding
+ * @return
+ * @throws IOException
+ * @throws UnsupportedEncodingException
+ */
+ private Writer createResponseWriter(final HttpServletResponse response,
+ String characterEncoding) throws IOException,
+ UnsupportedEncodingException {
+ Writer output;
+ try {
+ output = response.getWriter();
+ } catch (IllegalStateException e) {
+ if (null != characterEncoding) {
+ output = new OutputStreamWriter(response.getOutputStream(),
+ characterEncoding);
+ } else {
+ output = new OutputStreamWriter(response.getOutputStream());
+ }
+ }
+ return output;
+ }
+
+ protected abstract void reuseParser(HtmlParser parser);
+
+ protected abstract HtmlParser getParser(String mimetype, boolean isAjax, String viewId);
+
+ /**
+ * @param publicid
+ * The publicid to set.
+ */
+ protected void setPublicid(String publicid) {
+ this.publicid = publicid;
+ }
+
+ /**
+ * @return Returns the publicid.
+ */
+ public String getPublicid() {
+ return publicid;
+ }
+
+ /**
+ * @param systemid
+ * The systemid to set.
+ */
+ protected void setSystemid(String systemid) {
+ this.systemid = systemid;
+ }
+
+ /**
+ * @return Returns the systemid.
+ */
+ public String getSystemid() {
+ return systemid;
+ }
+
+ /**
+ * @param namespace
+ * The namespace to set.
+ */
+ protected void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ /**
+ * @return Returns the namespace.
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+ /**
+ * @param mimetype
+ * The mimetype to set.
+ */
+ protected void setMimetype(String mimetype) {
+ this.mimetype = mimetype;
+ }
+
+ /**
+ * @return Returns the mimetype.
+ */
+ protected String getMimetype() {
+ return mimetype;
+ }
+
+ /**
+ * @return Returns the forcexml.
+ */
+ public boolean isForcexml() {
+ return this.forcexml;
+ }
+
+ /**
+ * @param forcexml
+ * The forcexml to set.
+ */
+ protected void setForcexml(boolean forcexml) {
+ this.forcexml = forcexml;
+ }
+
+ private Object nz(Object param, Object def) {
+ return param != null ? param : def;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java (from rev 1557, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,277 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.io.FastBufferOutputStream;
+import org.ajax4jsf.io.FastBufferWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:20 $
+ *
+ */
+public class CacheContent implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8120940486890871177L;
+
+ private static final Log _log = LogFactory.getLog(CacheContent.class);
+
+ // private transient ByteArrayOutputStream outputStream ;
+ private transient FastBufferOutputStream outputStream;
+
+ private transient FastBufferWriter stringOutputWriter;
+
+ private transient PrintWriter servletWriter;
+
+ private transient ServletOutputStream servletStream;
+
+ // content to send.
+ private byte[] content = null;
+
+ private String writerContent = null;
+
+ boolean filledOutputStream = false;
+
+ boolean filledOutputWriter = false;
+
+ private Map headers = new HashMap();
+
+ private String contentType;
+
+ /**
+ * Send saved content to http responce
+ *
+ * @param response
+ * @throws IOException
+ */
+ public void send(HttpServletResponse response) throws IOException {
+ if (filledOutputStream) {
+ OutputStream out = response.getOutputStream();
+ if (content != null) {
+ out.write(content);
+ } else {
+ this.outputStream.writeTo(out);
+ }
+ // out.flush();
+ // out.close();
+ } else if (filledOutputWriter) {
+ Writer out = response.getWriter();
+ if (null != writerContent) {
+ out.write(writerContent);
+ } else {
+ stringOutputWriter.writeTo(out);
+ }
+ // out.flush();
+ // out.close();
+ }
+ }
+
+ /**
+ * Send saved headers to http responce.
+ *
+ * @param response
+ */
+ public void sendHeaders(HttpServletResponse response) {
+ for (Iterator iter = headers.entrySet().iterator(); iter.hasNext();) {
+ Map.Entry element = (Map.Entry) iter.next();
+ String header = (String) element.getKey();
+ Object headerValue = element.getValue();
+ try {
+ if (headerValue instanceof Long) {
+ Long time = (Long) headerValue;
+ response.setDateHeader(header, time.longValue());
+ } else if (headerValue instanceof Integer) {
+ Integer value = (Integer) headerValue;
+ response.setIntHeader(header, value.intValue());
+ } else {
+ response.setHeader(header, (String) headerValue);
+ }
+
+ } catch (Exception e) {
+ _log.error("Error set response header "+header+"for value "+headerValue, e);
+ }
+ // set real content-length.
+ // / if (null != content) {
+ if (filledOutputStream) {
+ // / response.setIntHeader("Content-Length", content.length);
+ response.setIntHeader("Content-Length", outputStream
+ .getLength());
+ } // TODO - calculate content-lenght for writer ?
+ if (null != contentType) {
+ response.setContentType(this.contentType);
+ }
+ }
+ }
+
+ public void setDateHeader(String name, long value) {
+ // Expires not stored in cache - must be re-calculated for every
+ // response.
+ if (!"Expires".equals(name)) {
+ headers.put(name, new Long(value));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.resource.ResourceContext#setHeader(java.lang.String,
+ * java.lang.String)
+ */
+ public void setHeader(String name, String value) {
+ headers.put(name, value);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.resource.ResourceContext#setIntHeader(java.lang.String,
+ * int)
+ */
+ public void setIntHeader(String name, int value) {
+ headers.put(name, new Integer(value));
+ }
+
+ /**
+ * Create UNIX command 'tee' like stream - send all data to servlet
+ *
+ * @param responseStream
+ * @return
+ */
+ public OutputStream getOutputStream() {
+ if (null == servletStream) {
+ outputStream = new FastBufferOutputStream(1024);
+ servletStream = new ServletOutputStream() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.OutputStream#close()
+ */
+ public void close() throws IOException {
+ filledOutputStream = true;
+ // / content = outputStream.toByteArray();
+ content = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.OutputStream#flush()
+ */
+ public void flush() throws IOException {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public void write(byte[] b, int off, int len)
+ throws IOException {
+ outputStream.write(b, off, len);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.OutputStream#write(byte[])
+ */
+ public void write(byte[] b) throws IOException {
+ outputStream.write(b);
+ }
+
+ public void write(int b) throws IOException {
+ outputStream.write(b);
+ }
+
+ };
+ }
+ return servletStream;
+ }
+
+ public PrintWriter getWriter() {
+ if (null == servletWriter) {
+ stringOutputWriter = new FastBufferWriter(1024);
+ Writer out = new Writer() {
+
+ public void write(char[] cbuf, int off, int len)
+ throws IOException {
+ stringOutputWriter.write(cbuf, off, len);
+ }
+
+ public void flush() throws IOException {
+ }
+
+ public void close() throws IOException {
+ // / writerContent = stringOutputWriter.toString();
+ filledOutputWriter = true;
+ writerContent = null;
+ }
+
+ };
+ servletWriter = new PrintWriter(out);
+ }
+ return servletWriter;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+
+ }
+
+ /**
+ * @return Returns the contentType.
+ */
+ public String getContentType() {
+ return contentType;
+ }
+
+ private void writeObject(java.io.ObjectOutputStream s) throws IOException {
+ if (filledOutputStream) {
+ if (outputStream != null) {
+ content = outputStream.toByteArray();
+ }
+ } else if (filledOutputWriter) {
+ if (stringOutputWriter != null) {
+ char[] cs = stringOutputWriter.toCharArray();
+ writerContent = new String(cs);
+ }
+ }
+ s.defaultWriteObject();
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableFilter.java (from rev 1557, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,20 @@
+/**
+ *
+ */
+package org.ajax4jsf.webapp;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ConfigurableFilter extends BaseFilter {
+
+ /**
+ *
+ */
+ public ConfigurableFilter() {
+ xmlFilter = new ConfigurableXMLFilter();
+ xmlFilter.setFilter(this);
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java (from rev 1557, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,237 @@
+/**
+ *
+ */
+package org.ajax4jsf.webapp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.EmptyStackException;
+import java.util.Properties;
+import java.util.regex.PatternSyntaxException;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.io.parser.FastHtmlParser;
+import org.ajax4jsf.webapp.nekko.NekkoParser;
+import org.ajax4jsf.webapp.tidy.TidyParser;
+import org.apache.commons.collections.ArrayStack;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ConfigurableXMLFilter extends BaseXMLFilter {
+
+ private static final Log log = LogFactory
+ .getLog(ConfigurableXMLFilter.class);
+
+ private static final String PARSERS_LIST_PARAMETER = "org.ajax4jsf.xmlparsers";
+
+ private static final String VIEW_ID_PATTERN_PARAMETER = "org.ajax4jsf.xmlparser.";
+
+ /**
+ * map of the parsers names and viewId patterns for all parser type.
+ */
+ private ParserConfig parsers = new TidyParserConfig();
+
+ // private ParserConfig passParserConfig = new PassParserConfig();
+
+ public void init(FilterConfig config) throws ServletException {
+ super.init(config);
+ ServletContext servletContext = config.getServletContext();
+ String parsersParameter = servletContext
+ .getInitParameter(PARSERS_LIST_PARAMETER);
+ if (null != parsersParameter) {
+ configureParsers(servletContext, parsersParameter);
+ }
+ }
+
+ /**
+ * @param servletContext
+ * @param parsersParameter
+ * @throws ServletException
+ */
+ public void configureParsers(ServletContext servletContext,
+ String parsersParameter) throws ServletException {
+ String[] parsersNames = parsersParameter.split("\\s*,\\s*");
+ for (int i = parsersNames.length - 1; i >= 0; i--) {
+ String parserName = parsersNames[i];
+ ParserConfig parserConfig;
+ if ("TIDY".equals(parserName)) {
+ parserConfig = new TidyParserConfig();
+ } else if ("NEKO".equals(parserName)) {
+ parserConfig = new NekoParserConfig();
+ } else if ("PASS".equals(parserName)) {
+ parserConfig = new PassParserConfig();
+ } else {
+ throw new ServletException(
+ "Unknown XML parser type in config parameter "
+ + parserName);
+ }
+ parserConfig.setNext(parsers);
+ if (null != servletContext) {
+ try {
+ String parserViewPattern = servletContext
+ .getInitParameter(VIEW_ID_PATTERN_PARAMETER
+ + parserName);
+ parserConfig.setPatterns(parserViewPattern);
+
+ } catch (PatternSyntaxException e) {
+ throw new ServletException("Invalid pattern for a parser "
+ + parserName + " :" + e.getMessage());
+ }
+ }
+ parsers = parserConfig;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.BaseXMLFilter#getParser(java.lang.String,
+ * boolean, java.lang.String)
+ */
+ protected HtmlParser getParser(String mimetype, boolean isAjax,
+ String viewId) {
+ HtmlParser parser = null;
+ if (isAjax || isForcexml()) {
+ parser = parsers.getParser(viewId, mimetype);
+ } else if (mimetype.startsWith("text/html")
+ || mimetype.startsWith("application/xhtml+xml")) {
+ parser = new FastHtmlParser();
+ }
+ return parser;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.BaseXMLFilter#reuseParser(org.ajax4jsf.webapp.HtmlParser)
+ */
+ protected void reuseParser(HtmlParser parser) {
+ parsers.reuseParser(parser);
+
+ }
+
+ private static final int STACK_SIZE = 100;
+
+ private ArrayStack _xhtmlParsersPool = new ArrayStack(STACK_SIZE);
+
+ private class NekoParserConfig extends ParserConfig {
+
+ protected HtmlParser createParser(String mime) {
+ 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());
+ }
+ // TODO - set header scripts/styles filter.
+ return parser;
+ }
+
+ boolean storeParser(HtmlParser parser) {
+ if (null != parser && parser instanceof NekkoParser) {
+ synchronized (_xhtmlParsersPool) {
+ if (_xhtmlParsersPool.size() < STACK_SIZE) {
+ ((NekkoParser) parser).reset();
+ _xhtmlParsersPool.push(parser);
+ }
+
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+
+ private class TidyParserConfig extends ParserConfig {
+
+ protected HtmlParser createParser(String mime) {
+ // TODO Auto-generated method stub
+ TidyParser tidyParser = new TidyParser(getTidyProperties());
+ tidyParser.setMoveElements(isForcexml());
+ tidyParser.setMime(mime);
+ return tidyParser;
+ }
+
+ }
+
+ private class PassParserConfig extends ParserConfig {
+
+ protected HtmlParser createParser(String mime) {
+ return new FastHtmlParser();
+ }
+
+ }
+
+ private Properties _tidyProperties;
+
+ private Properties getTidyProperties() {
+ if (null == _tidyProperties) {
+ _tidyProperties = new Properties();
+ InputStream defaultprops = null;
+ InputStream props = null;
+ try {
+ defaultprops = TidyParser.class
+ .getResourceAsStream("tidy.properties");
+ if (null != defaultprops) {
+ _tidyProperties.load(defaultprops);
+ if (log.isDebugEnabled()) {
+ log.debug("default tidy parser properties loaded");
+ }
+ } else if (log.isDebugEnabled()) {
+ log.debug("No default tidy parser properties found");
+ }
+
+ // Second part - user-defined properties.
+ props = Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream("tidy.properties");
+ if (null != props) {
+ _tidyProperties.load(props);
+ if (log.isDebugEnabled()) {
+ log.debug("application-specific tidy parser properties loaded");
+ }
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ log.warn(Messages
+ .getMessage(Messages.READING_TIDY_PROPERTIES_ERROR), e);
+ } finally {
+ if (null != props) {
+ try {
+ props.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+ }
+ if (null != defaultprops) {
+ try {
+ defaultprops.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+ }
+ }
+ }
+ return _tidyProperties;
+ }
+
+ public ParserConfig getParsers() {
+ return parsers;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterServletResponseWrapper.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/FilterServletResponseWrapper.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterServletResponseWrapper.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/FilterServletResponseWrapper.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,653 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is XML RenderKit for JSF.
+ *
+ * The Initial Developer of the Original Code is
+ * Orbeon, Inc (info(a)orbeon.com)
+ * Portions created by the Initial Developer are Copyright (C) 2002
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+package org.ajax4jsf.webapp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.io.FastBufferInputStream;
+import org.ajax4jsf.io.FastBufferOutputStream;
+import org.ajax4jsf.io.FastBufferReader;
+import org.ajax4jsf.io.FastBufferWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Base wrapper save JSF page response, for parse to XML with different parsers
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:17 $
+ *
+ */
+public class FilterServletResponseWrapper extends HttpServletResponseWrapper {
+
+ private static final Log log = LogFactory.getLog(FilterServletResponseWrapper.class);
+
+ public static final String DEFAULT_ENCODING = "UTF-8";
+
+
+ protected FastBufferOutputStream byteStream = null;
+ private ServletOutputStream servletOutputStream;
+ private boolean useStream = false;
+
+ private FastBufferWriter stringWriter;
+ private PrintWriter printWriter;
+ private boolean useWriter = false;
+
+ private String contentType;
+
+ private String charterEncoding = null;
+
+ private HashMap headers = new HashMap();
+
+ private int bufferSize = 2048;
+
+ private int contentLength = Integer.MIN_VALUE;
+
+ private String redirectLocation = null;
+
+ private boolean useNullStream = false;
+
+ private List cookies = new ArrayList();
+
+ public FilterServletResponseWrapper(HttpServletResponse response) {
+ super(response);
+ }
+
+ /**
+ * Convert saved context to stream for parsing
+ * @return stream from saved content
+ */
+ public InputStream getContentAsStream() {
+ int length = 0;
+ FastBufferInputStream result = null;
+ String encoding = this.getCharacterEncoding() ;
+/// byte[] content;
+ if (isUseStream()) {
+ try {
+ servletOutputStream.flush();
+ } catch (IOException ex) {
+ log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
+ }
+/// content = byteStream.toByteArray();
+ result = new FastBufferInputStream(byteStream);
+ } else if (isUseWriter()) {
+ printWriter.flush();
+ printWriter.close();
+ length = stringWriter.getLength();
+/// String stringContent = stringWriter.toString();
+ try {
+ FastBufferOutputStream stream = stringWriter.convertToOutputStream(encoding);
+ result = new FastBufferInputStream(stream);
+/// content = stringContent.getBytes(encoding);
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ log.warn(Messages.getMessage(Messages.UNSUPPORTED_ENCODING_WARNING));
+ FastBufferOutputStream stream = stringWriter.convertToOutputStream();
+ result = new FastBufferInputStream(stream);
+/// content = stringContent.getBytes();
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.NO_WRITER_CALLED_INFO));
+ }
+ return null;
+ }
+/// if (content.length > 0) {
+ if (length > 0) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.PARSE_XML_DOCUMENT_INFO));
+// try {
+// log.debug(new String(content, encoding));
+// } catch (UnsupportedEncodingException e) {
+// }
+ }
+ }
+ return result;
+/// return new ByteArrayInputStream(content);
+ }
+
+ /**
+ * Convert saved context to stream for parsing
+ * @return stream from saved content
+ */
+ public Reader getContentAsReader() {
+ FastBufferReader result = null;
+ String encoding = this.getCharacterEncoding() ;
+/// String content;
+ if (isUseWriter()) {
+ printWriter.flush();
+ printWriter.close();
+ result = new FastBufferReader(stringWriter);
+/// content = stringWriter.toString();
+ } else if (isUseStream()) {
+ try {
+ servletOutputStream.flush();
+ } catch (IOException ex) {
+ log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
+ }
+ try {
+ FastBufferWriter writer = byteStream.convertToWriter(encoding);
+ result = new FastBufferReader(writer);
+/// content = byteStream.toString(encoding);
+ } catch (UnsupportedEncodingException e) {
+ log.warn(Messages.getMessage(Messages.UNSUPPORTED_ENCODING_WARNING_2), e);
+ FastBufferWriter writer = byteStream.convertToWriter();
+ result = new FastBufferReader(writer);
+/// content = byteStream.toString();
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.NO_WRITER_CALLED_INFO));
+ }
+ return null;
+ }
+// if (content.length() > 0) {
+// if (log.isDebugEnabled()) {
+// log.debug("XML document to parse in filter, return as Reader: ");
+// log.debug(content);
+// }
+// }
+/// return new StringReader(content);
+ return result;
+ }
+
+ public PrintWriter getWriter() throws IOException {
+ if (useStream) {
+ throw new IllegalStateException(Messages.getMessage(Messages.NO_WRITER_POSSIBLE_ERROR));
+ }
+ if (printWriter == null) {
+ printWriter = new PrintWriter(new ServletStringWriter());
+ }
+ if(log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.CREATE_WRITER_INFO));
+ }
+ useWriter = true;
+ return printWriter;
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException {
+ if (useWriter) {
+ if (isUseNullStream()) {
+ return new NullServletOutputStream();
+ }
+ throw new IllegalStateException(Messages.getMessage(Messages.NO_STREAM_POSSIBLE_ERROR));
+ }
+ if (servletOutputStream == null) {
+// byteStream = new ByteArrayOutputStream();
+ servletOutputStream = new ByteArrayServletOutputStream();
+ }
+ if(log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.CREATE_STREAM_INFO));
+ }
+ useStream = true;
+ return servletOutputStream;
+ }
+
+
+ public class ByteArrayServletOutputStream extends ServletOutputStream {
+
+ private boolean opened = true;
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#close()
+ */
+ public void close() throws IOException {
+ flush();
+ opened=false;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[])
+ */
+ public void write(byte[] b) throws IOException {
+ // TODO Auto-generated method stub
+ if (opened) {
+ byteStream.write(b);
+ }
+ }
+
+
+ public ByteArrayServletOutputStream() {
+ byteStream = new FastBufferOutputStream(bufferSize);
+ }
+
+ public void write(int b) throws IOException {
+ if (opened) {
+ byteStream.write(b);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public void write(byte[] b, int off, int len) throws IOException {
+ if (opened) {
+ byteStream.write(b, off, len);
+ }
+ }
+ }
+
+ public static class NullServletOutputStream extends ServletOutputStream {
+
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public void write(byte[] b, int off, int len) throws IOException {
+ // this-is null stream, do nothing !
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[])
+ */
+ public void write(byte[] b) throws IOException {
+ // this-is null stream, do nothing !
+ }
+
+ public void write(int b) throws IOException {
+ // this-is null stream, do nothing !
+
+ }
+
+ }
+
+ public class ServletStringWriter extends Writer {
+
+ private boolean opened = true;
+
+ public ServletStringWriter() {
+ super();
+ stringWriter = new FastBufferWriter(bufferSize);
+ }
+
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ if (opened) {
+ stringWriter.write(cbuf, off, len);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.Writer#write(char[])
+ */
+ public void write(char[] cbuf) throws IOException {
+ // TODO Auto-generated method stub
+ if (opened) {
+ stringWriter.write(cbuf);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.Writer#write(int)
+ */
+ public void write(int c) throws IOException {
+ // TODO Auto-generated method stub
+ if (opened) {
+ stringWriter.write(c);
+ }
+ }
+
+ public void flush() throws IOException {
+ stringWriter.flush();
+ }
+
+ public void close() throws IOException {
+ stringWriter.close();
+ opened = false;
+ }
+
+ }
+
+// public boolean isCommitted() {
+// // NOTE: What makes sense here?
+// return false;
+// }
+
+ /**
+ * Return a charset from a content-type.
+ */
+ public static String getContentTypeCharset(String contentType) {
+ if (contentType == null)
+ return null;
+ int semicolumnIndex = contentType.indexOf(";");
+ if (semicolumnIndex == -1)
+ return null;
+ int charsetIndex = contentType.indexOf("charset=", semicolumnIndex);
+ if (charsetIndex == -1)
+ return null;
+ // FIXME: There may be other attributes after charset, right?
+ String afterCharset = contentType.substring(charsetIndex + 8);
+ afterCharset = afterCharset.replace('"', ' ');
+ return afterCharset.trim();
+ }
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpServletResponse#addHeader(java.lang.String, java.lang.String)
+ */
+ public void addHeader(String name, String value) {
+ if("Content-Type".equals(name)){
+ setContentType(value);
+ } else {
+ this.headers.put(name,value);
+ super.addHeader(name, value);
+ }
+ }
+ /* (non-Javadoc)
+ * @see javax.servlet.http.HttpServletResponse#setHeader(java.lang.String, java.lang.String)
+ */
+ public void setHeader(String name, String value) {
+ // HACK - weblogic do not use setContentType, instead directly set header !
+ if("Content-Type".equals(name)){
+ setContentType(value);
+ } else {
+ this.headers.put(name,value);
+ super.setHeader(name, value);
+ }
+ }
+
+ public Map getHeaders(){
+ return this.headers;
+ }
+ /* (non-Javadoc)
+ * @see javax.servlet.ServletResponse#getCharacterEncoding()
+ */
+ public String getCharacterEncoding() {
+// return this.charterEncoding;
+ if (null != this.charterEncoding) {
+ return this.charterEncoding;
+ } else {
+ // For cases of implicit setting
+ return super.getCharacterEncoding();
+ }
+ }
+ /* (non-Javadoc)
+ * @see javax.servlet.ServletResponse#setCharacterEncoding(java.lang.String)
+ */
+ public void setCharacterEncoding(String charset) {
+ this.charterEncoding = charset;
+ //super.setCharacterEncoding(charset);
+ }
+ public void setContentType(String type) {
+ String contentTypeCharset = getContentTypeCharset(type);
+ if (null != contentTypeCharset) {
+ this.charterEncoding = contentTypeCharset;
+ }
+ this.contentType = type;
+// super.setContentType(type);
+ }
+ public void setLocale(Locale loc) {
+ super.setLocale(loc);
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ /**
+ * Send buffered content directly to output stream.
+ * @param outputStream
+ * @throws IOException
+ */
+ public void sendContent(ServletOutputStream outputStream) throws IOException {
+ if(getContentLength() >0 ){
+ super.setContentLength(getContentLength());
+ }
+ if (isUseWriter()) {
+ printWriter.flush();
+ printWriter.close();
+ stringWriter.printTo(outputStream);
+/// outputStream.print(stringWriter.toString());
+ } else if (isUseStream()) {
+ try {
+ servletOutputStream.flush();
+ } catch (IOException ex) {
+ log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
+ }
+ byteStream.writeTo(outputStream);
+ }
+ }
+
+ /**
+ * Send buffered content directly to output stream.
+ * @param outputStream
+ * @throws IOException
+ */
+ public void sendContent(Writer output) throws IOException {
+ if(getContentLength() >0 ){
+ super.setContentLength(getContentLength());
+ }
+ if (isUseWriter()) {
+ printWriter.flush();
+ printWriter.close();
+ stringWriter.writeTo(output);
+/// outputStream.print(stringWriter.toString());
+ } else if (isUseStream()) {
+ try {
+ servletOutputStream.flush();
+ } catch (IOException ex) {
+ log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
+ }
+ byteStream.writeTo(output,getCharacterEncoding());
+ }
+ }
+ /**
+ * @return Returns the useStream.
+ */
+ public boolean isUseStream() {
+ return this.useStream;
+ }
+
+ /**
+ * @return Returns the useWriter.
+ */
+ public boolean isUseWriter() {
+ return this.useWriter;
+ }
+
+ /**
+ * @return
+ * @throws RuntimeException
+ */
+ public InputSource getContentAsInputSource() throws RuntimeException {
+ // Create InputSource
+ InputSource inputSource = null;
+ String encoding = this.getCharacterEncoding() ;
+ if(isUseWriter()) {
+ inputSource = new InputSource(getContentAsReader());
+ } else if(isUseStream()) {
+ inputSource = new InputSource(getContentAsStream());
+ if (encoding != null)
+ inputSource.setEncoding(encoding);
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.NO_WRITER_CALLED_INFO));
+ }
+ return null;
+ }
+ return inputSource;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.ServletResponseWrapper#flushBuffer()
+ */
+ public void flushBuffer() throws IOException {
+ if(isUseStream()){
+ servletOutputStream.flush();
+ } else if(isUseWriter()){
+ printWriter.flush();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.ServletResponseWrapper#getBufferSize()
+ */
+ public int getBufferSize() {
+ // TODO Auto-generated method stub
+ return bufferSize;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.ServletResponseWrapper#resetBuffer()
+ */
+ public void resetBuffer() {
+ this.printWriter = null;
+ this.stringWriter = null;
+ this.servletOutputStream = null;
+ this.byteStream = null;
+ this.useStream = false;
+ this.useWriter = false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.ServletResponseWrapper#setBufferSize(int)
+ */
+ public void setBufferSize(int arg0) {
+ // TODO Auto-generated method stub
+ bufferSize = arg0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.ServletResponseWrapper#reset()
+ */
+ public void reset() {
+ // TODO Auto-generated method stub
+ this.resetBuffer();
+ this.headers = new HashMap();
+ this.contentType=null;
+ this.charterEncoding=null;
+ super.reset();
+ }
+
+ /**
+ * @return Returns the contentLength.
+ */
+ public int getContentLength() {
+ return contentLength;
+ }
+
+ /**
+ * @param contentLength The contentLength to set.
+ */
+ public void setContentLength(int contentLength) {
+ this.contentLength = contentLength;
+ }
+
+ /**
+ * Parse saved content to output stream ( and store as Dom Document tree )
+ * @param out stream to send parsed content, if null - only build dom tree.
+ * @return parsed document as dom tree.
+ * @throws IOException
+ */
+ public void parseContent(Writer out,HtmlParser parser) throws IOException {
+ parser.setInputEncoding(getCharacterEncoding());
+ if (isUseWriter()) {
+ parser.parseHtml(getContentAsReader(),out);
+ } else if(isUseStream()){
+ parser.parseHtml(getContentAsStream(),out);
+ }
+ }
+
+ public void sendRedirect(String arg0) throws IOException {
+ // TODO Auto-generated method stub
+ this.redirectLocation = arg0;
+ }
+
+ public String getRedirectLocation() {
+ return redirectLocation;
+ }
+
+ /**
+ * @return the useNullStream
+ */
+ public boolean isUseNullStream() {
+ return useNullStream;
+ }
+
+ /**
+ * @param useNullStream the useNullStream to set
+ */
+ public void setUseNullStream(boolean useNullStream) {
+ this.useNullStream = useNullStream;
+ }
+
+
+
+ public void addCookie(Cookie cookie) {
+ cookies.add(cookie);
+ super.addCookie(cookie);
+ }
+
+ public Collection getCookies() {
+ return cookies;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/HtmlParser.java (from rev 1557, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/HtmlParser.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/HtmlParser.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,71 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.Set;
+
+public interface HtmlParser {
+
+ public abstract void parseHtml(InputStream input, Writer output)
+ throws IOException;
+
+ public abstract void parseHtml(Reader input, Writer output)
+ throws IOException;
+ /**
+ * @param encoding
+ */
+ public abstract void setInputEncoding(String encoding);
+
+ /**
+ * @param encoding
+ */
+ public abstract void setOutputEncoding(String encoding);
+ /**
+ * Setup, must tidy move style etc. elements to head or not.
+ * @param move
+ */
+ public abstract void setMoveElements(boolean move);
+
+ /**
+ * @param scripts The scripts to set.
+ */
+ public abstract void setScripts(Set scripts);
+
+ /**
+ * @param styles The styles to set.
+ */
+ public abstract void setStyles(Set styles);
+
+ public abstract void setDoctype(String doctype);
+
+ /**
+ * @param viewState The viewState to set.
+ */
+ public abstract void setViewState(String viewState);
+
+ public abstract boolean setMime(String mimeType);
+
+}
\ No newline at end of file
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/Log4JConfigurator.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/Log4JConfigurator.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/Log4JConfigurator.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/Log4JConfigurator.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,75 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import java.util.Properties;
+
+import org.ajax4jsf.Messages;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.helpers.LogLog;
+import org.apache.log4j.helpers.OptionConverter;
+import org.apache.log4j.xml.DOMConfigurator;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:18 $
+ *
+ */
+class Log4JConfigurator {
+ private static final String CONTEXT_ROOT_VARIABLE = "context-root";
+ private Properties props = new Properties();
+ private String prefix;
+
+ DOMConfigurator domConfig;
+
+ void doConfigure(String file){
+ domConfig.doConfigure(prefix + file, LogManager.getLoggerRepository());
+ }
+
+
+ /**
+ * @param prefix
+ */
+ public Log4JConfigurator(String prefix) {
+ this.prefix = prefix;
+ props.setProperty(CONTEXT_ROOT_VARIABLE, prefix);
+ domConfig = new DOMConfigurator() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.log4j.xml.DOMConfigurator#subst(java.lang.String)
+ * append context-related properties for variable
+ * substitution.
+ */
+ protected String subst(String value) {
+ try {
+ return OptionConverter.substVars(value, props);
+ } catch (IllegalArgumentException e) {
+ LogLog.warn(Messages.getMessage(Messages.VARIABLE_SUBSTITUTION_WARNING), e);
+ return value;
+ }
+ };
+
+ };
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/NekkoFilter.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoFilter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/NekkoFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/NekkoFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import org.ajax4jsf.webapp.nekko.NekkoXMLFilter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * This class implements a simple Servlet filter that convert basic html
+ * output of JSF to valid XML or JavaScript, for parsing different versions
+ * of XmlHttpRequest's on client side.
+ */
+public class NekkoFilter extends BaseFilter implements javax.servlet.Filter {
+ static final Log log = LogFactory.getLog(NekkoFilter.class);
+
+ /**
+ *
+ */
+ public NekkoFilter() {
+ super();
+ // default - not force
+// setForcexml(false);
+ xmlFilter = new NekkoXMLFilter();
+ xmlFilter.setFilter(this);
+ }
+
+}
+
+
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserConfig.java (from rev 1557, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserConfig.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ParserConfig.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package org.ajax4jsf.webapp;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+abstract class ParserConfig {
+
+ private static final Pattern[] ALL_VIEWS_PATTERN = { Pattern.compile(".*") };
+
+ private static final Pattern SEPARATOR_PATTERN = Pattern.compile("\\s*,\\s*");
+
+ private Pattern[] patterns = ALL_VIEWS_PATTERN;
+
+ private ParserConfig next;
+
+ protected abstract HtmlParser createParser(String mimetype);
+
+ boolean storeParser(HtmlParser parser) {
+ return false;
+ }
+
+ HtmlParser getParser(String viewId, String mimetype) {
+ HtmlParser result = null;
+ for (int i = 0; i < patterns.length && null == result; i++) {
+ Matcher matcher = patterns[i].matcher(viewId);
+ if (matcher.matches()) {
+ result = createParser(mimetype);
+ }
+ }
+ if (null == result && null != next) {
+ result = next.getParser(viewId, mimetype);
+ }
+ return result;
+ }
+
+ public void reuseParser(HtmlParser parser) {
+ if (!storeParser(parser) && null != next) {
+ next.reuseParser(parser);
+ }
+ }
+
+ public ParserConfig getNext() {
+ return next;
+ }
+
+ public void setNext(ParserConfig next) {
+ this.next = next;
+ }
+
+ public void setPatterns(String patternsString) {
+ if (null != patternsString) {
+ String[] split = SEPARATOR_PATTERN.split(patternsString);
+ patterns = new Pattern[split.length];
+ for (int i = 0; i < split.length; i++) {
+ patterns[i]=Pattern.compile(split[i].trim());
+ }
+ }
+ }
+
+ public Pattern[] getPatterns() {
+ return patterns;
+ }
+
+}
\ No newline at end of file
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/PollEventsManager.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.ajax4jsf.webapp;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.faces.FacesException;
+import javax.servlet.ServletContext;
+
+import org.ajax4jsf.ajax.PushEventsCounter;
+import org.ajax4jsf.cache.Cache;
+import org.ajax4jsf.cache.CacheConfigurationLoader;
+import org.ajax4jsf.cache.CacheException;
+import org.ajax4jsf.cache.CacheFactory;
+import org.ajax4jsf.cache.CacheLoader;
+import org.ajax4jsf.cache.CacheManager;
+import org.ajax4jsf.cache.ServletContextInitMap;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class PollEventsManager implements Serializable, CacheLoader, CacheConfigurationLoader {
+
+ public static final String EVENTS_MANAGER_KEY=PollEventsManager.class.getName();
+
+ private Cache cache;
+
+ public void init(ServletContext servletContext) {
+ try {
+ CacheManager cacheManager = CacheManager.getInstance();
+ Map env = new ServletContextInitMap(servletContext);
+ CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
+ this.cache = cacheFactory.createCache(env, this, this);
+ servletContext.setAttribute(EVENTS_MANAGER_KEY, this);
+ } catch (CacheException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+
+ }
+
+ public PushEventsCounter getListener(String key){
+ if(null == cache){
+ throw new FacesException("Poll events manager not initialized");
+ }
+ try {
+ return (PushEventsCounter) cache.get(key, null);
+ } catch (CacheException e) {
+ throw new FacesException("error get push events listener for key "+key,e);
+ }
+ }
+
+ public Object load(Object key, Object context) throws CacheException {
+ // TODO Auto-generated method stub
+ return new PushEventsCounter();
+ }
+
+ public Properties loadProperties(String name) {
+ return new Properties();
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletStreamWriter.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ServletStreamWriter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletStreamWriter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/ServletStreamWriter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,111 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletOutputStream;
+
+/**
+ * HACK - for case if servlet response already use Writer, create wrapper to stream -
+ * since most of serializers use outputStream. In future, must be replaced by Dual serialization
+ * capabilites.
+ * @author shura
+ *
+ */
+final class ServletStreamWriter extends ServletOutputStream {
+
+ private PrintWriter _writer;
+
+ private byte[] buff = new byte[1024];
+
+ private int point = 0;
+
+ private String _charset;
+
+ /**
+ * @param writer
+ * @param charset
+ */
+ public ServletStreamWriter(PrintWriter writer, String charset) {
+ super();
+ // TODO Auto-generated constructor stub
+ _writer = writer;
+ _charset = charset;
+ }
+
+ public ServletStreamWriter(PrintWriter writer) {
+ this._writer = writer;
+ }
+
+ public void write(int b) throws IOException {
+ buff[point++]=(byte) b;
+ if(point==buff.length){
+ point = 0;
+ String string = null==_charset?new String(buff):new String(buff,_charset);
+ _writer.write(string);
+ }
+ }
+
+ /**
+ * @return Returns the charset.
+ */
+ public String getCharset() {
+ return _charset;
+ }
+
+ /**
+ * @param charset The charset to set.
+ */
+ public void setCharset(String charset) {
+ _charset = charset;
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#close()
+ */
+ public void close() throws IOException {
+ this.flush();
+ super.close();
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#flush()
+ */
+ public void flush() throws IOException {
+ if(point>0){
+ String string = null==_charset?new String(buff,0,point):new String(buff,0,point,_charset);
+ _writer.write(string);
+ point = 0;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public void write(byte[] b, int off, int len) throws IOException {
+ this.flush();
+ String string = null==_charset?new String(b,off,len):new String(b,off,len,_charset);
+ _writer.write(string);
+ }
+}
\ No newline at end of file
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/TidyFilter.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/TidyFilter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/TidyFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/TidyFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,44 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import org.ajax4jsf.webapp.tidy.TidyXMLFilter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * Convert Html Output to XML using Jtidy.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:20 $
+ */
+public class TidyFilter extends BaseFilter {
+ static final Log log = LogFactory.getLog(TidyFilter.class);
+
+ public TidyFilter() {
+ // For Tidy, publicId can be pre-defined omit | auto | strict | loose | ignore | [fpi]
+ xmlFilter = new TidyXMLFilter();
+ xmlFilter.setFilter(this);
+ xmlFilter.setPublicid("omit");
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/XMLResponseWriterState.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/XMLResponseWriterState.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/XMLResponseWriterState.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/XMLResponseWriterState.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,134 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * @author shura Class to implement state pattern for
+ * <code>ResponceWriter</code> Real states must extend this. By
+ * default, block any events, ignore output.
+ *
+ */
+class XMLResponseWriterState {
+ // private ResponseWriter writer;
+ /**
+ * @throws java.io.IOException
+ */
+ private static final String ILLEGAL_METOD_STATE = Messages.getMessage(Messages.ILLEGAL_METHOD_STATE);
+
+ void endDocument() throws IOException {
+ throw new IOException(ILLEGAL_METOD_STATE);
+ }
+
+ /**
+ * @param name
+ * @throws java.io.IOException
+ */
+ void endElement(String name) throws IOException {
+ throw new IOException(ILLEGAL_METOD_STATE);
+ }
+
+ /**
+ * @throws java.io.IOException
+ */
+ void startDocument() throws IOException {
+ throw new IOException(ILLEGAL_METOD_STATE);
+ }
+
+ /**
+ * @param name
+ * @param component
+ * @throws java.io.IOException
+ */
+ void startElement(String name, UIComponent component) throws IOException {
+ throw new IOException(ILLEGAL_METOD_STATE);
+ }
+
+ /**
+ * @param name
+ * @param value
+ * @param property
+ * @throws java.io.IOException
+ */
+ void writeAttribute(String name, Object value, String property)
+ throws IOException {
+ throw new IOException(ILLEGAL_METOD_STATE);
+ }
+
+ /**
+ * @param comment
+ * @throws java.io.IOException
+ */
+ void writeComment(Object comment) throws IOException {
+ throw new IOException(ILLEGAL_METOD_STATE);
+ }
+
+ /**
+ * @param text
+ * @param off
+ * @param len
+ * @throws java.io.IOException
+ */
+ void writeText(char[] text, int off, int len) throws IOException {
+ throw new IOException(ILLEGAL_METOD_STATE);
+ }
+
+ /**
+ * @param text
+ * @param property
+ * @throws java.io.IOException
+ */
+ void writeText(Object text, String property) throws IOException {
+ throw new IOException(ILLEGAL_METOD_STATE);
+ }
+
+ /**
+ * @param name
+ * @param value
+ * @param property
+ * @throws java.io.IOException
+ */
+ void writeURIAttribute(String name, Object value, String property)
+ throws IOException {
+ throw new IOException(ILLEGAL_METOD_STATE);
+ }
+
+ /**
+ *
+ * Main hook for realise <code>Writer</code>. In document writed as
+ * comment, outside of document do nothing ....
+ *
+ * @param cbuf
+ * @param off
+ * @param len
+ * @throws IOException
+ */
+ void write(char[] cbuf, int off, int len) throws IOException {
+ // DO NOTHING
+
+ }
+}
\ No newline at end of file
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko)
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/HtmlCorrectionFilter.java 2007-07-09 15:13:40 UTC (rev 1551)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,166 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter.nekko;
-
-import org.apache.xerces.util.XMLAttributesImpl;
-import org.apache.xerces.xni.Augmentations;
-import org.apache.xerces.xni.QName;
-import org.apache.xerces.xni.XMLAttributes;
-import org.apache.xerces.xni.XNIException;
-import org.apache.xerces.xni.parser.XMLComponentManager;
-import org.apache.xerces.xni.parser.XMLConfigurationException;
-import org.cyberneko.html.HTMLAugmentations;
-import org.cyberneko.html.filters.DefaultFilter;
-
-/**
- * Fix common DHTML incompabilites for html - insert ommited tbody tag in tables.
- * @author shura
- *
- */
-public class HtmlCorrectionFilter extends DefaultFilter{
-
- private HtmlCorrectionState _state;
-
-
- /**
- *
- */
- public HtmlCorrectionFilter() {
- super();
- _state = new BaseHtmlCorrectionState(null);
- }
-
- public void reset(XMLComponentManager componentManager)
- throws XMLConfigurationException {
- super.reset(componentManager);
- _state = new BaseHtmlCorrectionState(null);
- }
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#endElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.Augmentations)
- */
- public void endElement(QName element, Augmentations augs) throws XNIException {
- _state.endElement(element,augs);
- super.endElement(element, augs);
- }
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#startElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
- */
- public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
- _state.startElement(element,attributes,augs);
- super.startElement(element, attributes, augs);
- }
-
- void insertStartElement(String name, QName base) {
- QName element = createQName(name, base);
- XMLAttributes attrs = new XMLAttributesImpl();
- Augmentations augs = new HTMLAugmentations();
- super.startElement(element,attrs,augs);
- }
-
- /**
- * @param name
- * @param base
- * @return
- */
- private QName createQName(String name, QName base) {
- String prefix = base.prefix;
- String rawname = null != prefix && (!"".equals(prefix))? prefix+':'+name:name;
- QName element = new QName(prefix,name,rawname,base.uri);
- return element;
- }
-
-
- void insertEndElement(String name, QName base) {
- QName element = createQName(name, base);
- Augmentations augs = new HTMLAugmentations();
- super.endElement(element,augs);
- }
-
- private class BaseHtmlCorrectionState implements HtmlCorrectionState {
- private int depth = 0;
- private HtmlCorrectionState previsiosState;
- /**
- * @param previsiosState
- */
- public BaseHtmlCorrectionState(HtmlCorrectionState previsiosState) {
- super();
- // TODO Auto-generated constructor stub
- this.previsiosState = previsiosState;
- }
- public void endElement(QName element, Augmentations augs) throws XNIException {
- depth--;
- if(depth<0 && previsiosState != null){
- _state = previsiosState;
- }
- }
-
- public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
- if(element.rawname.equalsIgnoreCase("table")){
- _state = new TableHtmlCorrectionState(this);
- } else {
- depth++;
- }
- }
-
-
- }
- private class TableHtmlCorrectionState implements HtmlCorrectionState {
- private int depth = 0;
- private boolean inTbody = false;
- private HtmlCorrectionState previsiosState;
- /**
- * @param previsiosState
- */
- public TableHtmlCorrectionState(HtmlCorrectionState previsiosState) {
- super();
- // TODO Auto-generated constructor stub
- this.previsiosState = previsiosState;
- }
-
- public void endElement(QName element, Augmentations augs) throws XNIException {
- if (inTbody) {
- insertEndElement("tbody", element);
- }
- _state = previsiosState;
- }
-
- public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
- if(element.rawname.equalsIgnoreCase("tr")){
- if(!inTbody){
- inTbody = true;
- insertStartElement("tbody", element);
- }
- } else {
- if (inTbody) {
- insertEndElement("tbody", element);
- inTbody = false;
- }
- }
- _state = new BaseHtmlCorrectionState(this);
- }
-
-
- }
-
-}
\ No newline at end of file
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionFilter.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/HtmlCorrectionFilter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,166 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax.xmlfilter.nekko;
+
+import org.apache.xerces.util.XMLAttributesImpl;
+import org.apache.xerces.xni.Augmentations;
+import org.apache.xerces.xni.QName;
+import org.apache.xerces.xni.XMLAttributes;
+import org.apache.xerces.xni.XNIException;
+import org.apache.xerces.xni.parser.XMLComponentManager;
+import org.apache.xerces.xni.parser.XMLConfigurationException;
+import org.cyberneko.html.HTMLAugmentations;
+import org.cyberneko.html.filters.DefaultFilter;
+
+/**
+ * Fix common DHTML incompabilites for html - insert ommited tbody tag in tables.
+ * @author shura
+ *
+ */
+public class HtmlCorrectionFilter extends DefaultFilter{
+
+ private HtmlCorrectionState _state;
+
+
+ /**
+ *
+ */
+ public HtmlCorrectionFilter() {
+ super();
+ _state = new BaseHtmlCorrectionState(null);
+ }
+
+ public void reset(XMLComponentManager componentManager)
+ throws XMLConfigurationException {
+ super.reset(componentManager);
+ _state = new BaseHtmlCorrectionState(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#endElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.Augmentations)
+ */
+ public void endElement(QName element, Augmentations augs) throws XNIException {
+ _state.endElement(element,augs);
+ super.endElement(element, augs);
+ }
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#startElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
+ */
+ public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
+ _state.startElement(element,attributes,augs);
+ super.startElement(element, attributes, augs);
+ }
+
+ void insertStartElement(String name, QName base) {
+ QName element = createQName(name, base);
+ XMLAttributes attrs = new XMLAttributesImpl();
+ Augmentations augs = new HTMLAugmentations();
+ super.startElement(element,attrs,augs);
+ }
+
+ /**
+ * @param name
+ * @param base
+ * @return
+ */
+ private QName createQName(String name, QName base) {
+ String prefix = base.prefix;
+ String rawname = null != prefix && (!"".equals(prefix))? prefix+':'+name:name;
+ QName element = new QName(prefix,name,rawname,base.uri);
+ return element;
+ }
+
+
+ void insertEndElement(String name, QName base) {
+ QName element = createQName(name, base);
+ Augmentations augs = new HTMLAugmentations();
+ super.endElement(element,augs);
+ }
+
+ private class BaseHtmlCorrectionState implements HtmlCorrectionState {
+ private int depth = 0;
+ private HtmlCorrectionState previsiosState;
+ /**
+ * @param previsiosState
+ */
+ public BaseHtmlCorrectionState(HtmlCorrectionState previsiosState) {
+ super();
+ // TODO Auto-generated constructor stub
+ this.previsiosState = previsiosState;
+ }
+ public void endElement(QName element, Augmentations augs) throws XNIException {
+ depth--;
+ if(depth<0 && previsiosState != null){
+ _state = previsiosState;
+ }
+ }
+
+ public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
+ if(element.rawname.equalsIgnoreCase("table")){
+ _state = new TableHtmlCorrectionState(this);
+ } else {
+ depth++;
+ }
+ }
+
+
+ }
+ private class TableHtmlCorrectionState implements HtmlCorrectionState {
+ private int depth = 0;
+ private boolean inTbody = false;
+ private HtmlCorrectionState previsiosState;
+ /**
+ * @param previsiosState
+ */
+ public TableHtmlCorrectionState(HtmlCorrectionState previsiosState) {
+ super();
+ // TODO Auto-generated constructor stub
+ this.previsiosState = previsiosState;
+ }
+
+ public void endElement(QName element, Augmentations augs) throws XNIException {
+ if (inTbody) {
+ insertEndElement("tbody", element);
+ }
+ _state = previsiosState;
+ }
+
+ public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
+ if(element.rawname.equalsIgnoreCase("tr")){
+ if(!inTbody){
+ inTbody = true;
+ insertStartElement("tbody", element);
+ }
+ } else {
+ if (inTbody) {
+ insertEndElement("tbody", element);
+ inTbody = false;
+ }
+ }
+ _state = new BaseHtmlCorrectionState(this);
+ }
+
+
+ }
+
+}
\ No newline at end of file
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionState.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/HtmlCorrectionState.java 2007-07-09 15:13:40 UTC (rev 1551)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionState.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter.nekko;
-
-import org.apache.xerces.xni.Augmentations;
-import org.apache.xerces.xni.QName;
-import org.apache.xerces.xni.XMLAttributes;
-import org.apache.xerces.xni.XNIException;
-
-public interface HtmlCorrectionState {
-
- public void endElement(QName element, Augmentations augs) throws XNIException;
- public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException;
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionState.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/HtmlCorrectionState.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionState.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/HtmlCorrectionState.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,33 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax.xmlfilter.nekko;
+
+import org.apache.xerces.xni.Augmentations;
+import org.apache.xerces.xni.QName;
+import org.apache.xerces.xni.XMLAttributes;
+import org.apache.xerces.xni.XNIException;
+
+public interface HtmlCorrectionState {
+
+ public void endElement(QName element, Augmentations augs) throws XNIException;
+ public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException;
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java 2007-07-09 15:13:40 UTC (rev 1551)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,644 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter.nekko;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.servlet.ServletException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.ajax4jsf.framework.ajax.AjaxViewHandler;
-import org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser;
-import org.ajax4jsf.xml.serializer.Method;
-import org.ajax4jsf.xml.serializer.OutputPropertiesFactory;
-import org.ajax4jsf.xml.serializer.Serializer;
-import org.ajax4jsf.xml.serializer.SerializerFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.html.dom.HTMLDocumentImpl;
-import org.apache.xerces.parsers.AbstractSAXParser;
-import org.apache.xerces.util.XMLAttributesImpl;
-import org.apache.xerces.xni.Augmentations;
-import org.apache.xerces.xni.QName;
-import org.apache.xerces.xni.XMLAttributes;
-import org.apache.xerces.xni.XMLString;
-import org.apache.xerces.xni.XNIException;
-import org.apache.xerces.xni.parser.XMLComponentManager;
-import org.apache.xerces.xni.parser.XMLConfigurationException;
-import org.apache.xerces.xni.parser.XMLDocumentFilter;
-import org.cyberneko.html.HTMLAugmentations;
-import org.cyberneko.html.HTMLConfiguration;
-import org.cyberneko.html.filters.DefaultFilter;
-import org.cyberneko.html.filters.ElementRemover;
-import org.cyberneko.html.filters.Purifier;
-import org.cyberneko.html.filters.Writer;
-import org.cyberneko.html.parsers.DOMFragmentParser;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * @author shura
- *
- */
-public class NekkoParser implements HtmlParser {
-
- private static final Log _log = LogFactory.getLog(NekkoParser.class);
-
- private HtmlSAXParser _parser;
-
-// private HtmlWriter _writer= new HtmlWriter();
-
- private ElementRemover remover = new ElementRemover();
-
- private XMLDocumentFilter[] _filters = { new ViewStateFilter()/*,remover */, new HtmlCorrectionFilter(), new Purifier() /*, _writer*/ };
-
- private DOMFragmentParser viewStateParser ;//= new DOMFragmentParser();
-
- private Document viewStateDocument ;//= new HTMLDocumentImpl();
-
- private DocumentFragment fragment = null;
-
- private Set _scripts;
-
- private Set _styles;
-
- private String _viewState;
-
- private String _encoding;
-
- private Serializer _serializer;
-
- private String _publicId = "-//W3C//DTD XHTML 1.0 Transitional//EN";
- private String _systemid = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
- private String _namespace = "http://www.w3.org/1999/xhtml";
-
- private String _outputEncoding;
- /**
- *
- */
- public NekkoParser() {
- _parser=new HtmlSAXParser(getHtmlConfig());
- Properties properties = OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML);
-// properties.put("encoding",_encoding);
- _serializer = SerializerFactory.getSerializer(properties);
-// serializer.setOutputStream(output);
-// _parser.setContentHandler(serializer.asContentHandler());
- viewStateParser = new DOMFragmentParser();
- // Set parser features
- try {
- viewStateParser.setProperty(
- "http://cyberneko.org/html/properties/names/elems",
- "lower");
- viewStateParser.setProperty(
- "http://cyberneko.org/html/properties/names/attrs",
- "lower");
- } catch (SAXException e) {
- _log.error("Exception in DOM parser configuration", e);
- }
- try {
- // Create Document Builder Factory
- DocumentBuilderFactory docFactory = DocumentBuilderFactory
- .newInstance();
- // Create Document Builder
- DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
- viewStateDocument = docBuilder.newDocument();
- } catch (ParserConfigurationException e) {
- viewStateDocument = new HTMLDocumentImpl();
- _log.error("Error on create DOM Document by JAXP, use Xerxes implementation. Check JAXP configuration ",e);
- }
-// viewStateDocument = new HTMLDocumentImpl();
- remover.removeElement("style");
- }
-
- /**
- * Reset parser state
- */
- public void reset(){
- _scripts=null;
- _styles=null;
- _viewState=null;
- _parser.reset();
- _serializer.reset();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#parseHtml(java.io.InputStream, java.io.OutputStream)
- */
- public void parseHtml(InputStream input, java.io.Writer output)
- throws IOException {
- InputSource src = new InputSource(input);
- parseSAXSource(src,output);
- }
-
- private void parseSAXSource(InputSource src, java.io.Writer output) throws IOException {
-// PrintWriter printWriter = null;
- fragment = null;
- if(null != _viewState){
- fragment = viewStateDocument.createDocumentFragment();
- try {
- viewStateParser.parse(new InputSource(new StringReader(
- _viewState)), fragment);
- } catch (Exception e) {
- fragment = null;
- }
- // TODO - parse view state to DOM Fragment.
- }
- try {
- _parser.setProperty("http://cyberneko.org/html/properties/default-encoding",
- _encoding);
- Properties properties = _serializer.getOutputFormat();
- properties.put("encoding",_outputEncoding);
- _serializer.setOutputFormat(properties);
- _serializer.setWriter(output);
-// _serializer.setOutputStream(new OutputStream(){
-//
-// public void write(int b) throws IOException {
-// // TODO Auto-generated method stub
-//
-// }});
- _parser.setContentHandler(_serializer.asContentHandler());
-// printWriter = new PrintWriter(output);
-// _writer.setWriter(printWriter);
-// _writer.setEncoding(_encoding);
- _parser.parse(src);
- } catch (SAXException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
-// _writer.setWriter(null);
-// if(null != printWriter){
-// printWriter.flush();
-// printWriter.close();
-// }
-
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#parseHtml(java.io.Reader, java.io.OutputStream)
- */
- public void parseHtml(Reader input, java.io.Writer output) throws IOException {
- InputSource src = new InputSource(input);
- parseSAXSource(src,output);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setEncoding(java.lang.String)
- */
- public void setInputEncoding(String encoding) {
- _encoding = encoding;
- }
-
- public void setOutputEncoding(String encoding) {
- _outputEncoding = encoding;
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setMoveElements(boolean)
- */
- public void setMoveElements(boolean move) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setScripts(java.util.Set)
- */
- public void setScripts(Set scripts) {
- _scripts = scripts;
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setStyles(java.util.Set)
- */
- public void setStyles(Set styles) {
- _styles = styles;
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setDoctype(java.lang.String)
- */
- public void setDoctype(String doctype) {
- this._publicId = doctype;
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setViewState(java.lang.String)
- */
- public void setViewState(String viewState) {
- _viewState = viewState;
-
- }
-
- private static class HtmlSAXParser extends AbstractSAXParser {
- /** Default constructor.
- * @throws ServletException */
- public HtmlSAXParser(HTMLConfiguration config) {
- super(config);
-
- }
- }
-
- private class ViewStateFilter extends DefaultFilter{
- private boolean haveHtml = false;
- private boolean haveHead = false;
- private boolean headParsed = false;
- private int stateMarkerLevel = -1;
-
-
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#reset(org.apache.xerces.xni.parser.XMLComponentManager)
- */
- public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
- haveHead = false;
- haveHtml = false;
- headParsed = false;
- stateMarkerLevel = -1;
- super.reset(componentManager);
- }
-
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#startElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
- */
- public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
- if(stateMarkerLevel >=0){
- stateMarkerLevel++;
- if(null != fragment){
- return;
- }
- }
- if (!headParsed) {
- if("html".equalsIgnoreCase(element.rawname)){
- haveHtml = true;
- } else if("head".equalsIgnoreCase(element.rawname)){
- haveHead = true;
- super.startElement(element, attributes, augs);
- insertResources();
- return;
- } else {
- if(!haveHtml){
- insertStartElement("html");
- }
- insertStartElement("head");
- insertResources();
- insertEndElement("head");
- }
-
- }
- if(isStateMarker(element, attributes)){
- stateMarkerLevel = 0;
- return;
- };
- super.startElement(element, attributes, augs);
- }
-
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#characters(org.apache.xerces.xni.XMLString, org.apache.xerces.xni.Augmentations)
- */
- public void characters(XMLString text, Augmentations augs) throws XNIException {
- if(stateMarkerLevel >=0){
- if(null != fragment){
- return;
- }
- }
- super.characters(text, augs);
- }
-
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#endElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.Augmentations)
- */
- public void endElement(QName element, Augmentations augs) throws XNIException {
- if(stateMarkerLevel >=0){
- stateMarkerLevel--;
- if(null != fragment || stateMarkerLevel == -1){
- return;
- }
- }
- super.endElement(element, augs);
- }
-
-
- private void insertResources() {
- headParsed = true;
- if(null != _styles){
- for (Iterator iter = _styles.iterator(); iter.hasNext();) {
- String style = (String) iter.next();
- QName element = new QName(null,"link","link",null);
- XMLAttributes attrs = new XMLAttributesImpl();
- attrs.addAttribute(new QName(null,"href","href",null), "CDATA", style);
- attrs.addAttribute(new QName(null,"type","type",null), "CDATA", "text/css");
- attrs.addAttribute(new QName(null,"rel","rel",null), "CDATA", "stylesheet");
- Augmentations augs = new HTMLAugmentations();
- super.emptyElement(element,attrs,augs);
- }
- }
- if(null != _scripts){
- for (Iterator iter = _scripts.iterator(); iter.hasNext();) {
- String script = (String) iter.next();
- QName element = new QName(null,"script","script",null);
- XMLAttributes attrs = new XMLAttributesImpl();
- attrs.addAttribute(new QName(null,"src","src",null), "CDATA", script);
- attrs.addAttribute(new QName(null,"type","type",null), "CDATA", "text/javascript");
- Augmentations augs = new HTMLAugmentations();
- super.startElement(element,attrs,augs);
- super.endElement(element, augs);
- }
- }
-
- }
-
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#emptyElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
- */
- public void emptyElement(QName name, XMLAttributes attributes, Augmentations augmentation) throws XNIException {
- if(stateMarkerLevel >=0){
- if(null != fragment){
- return;
- }
- }
- if (!headParsed) {
- if("head".equalsIgnoreCase(name.rawname)){
- haveHead = true;
- super.startElement(name, attributes, augmentation);
- insertResources();
- insertEndElement(name.rawname);
- return;
- }
- }
- if(isStateMarker(name, attributes)){
- return;
- };
- super.emptyElement(name, attributes, augmentation);
- }
-
-
- /**
- * @param name
- * @param attributes
- */
- private boolean isStateMarker(QName name, XMLAttributes attributes) {
- if(name.rawname.equalsIgnoreCase("span") && AjaxViewHandler.STATE_MARKER_KEY.equals(attributes.getValue("id"))){
- // STATE marker element - out real content.
- if(null != fragment){
- try {
- _serializer.asDOMSerializer().serialize(fragment);
- } catch (IOException e) {
- // Break output.
- }
- }
- return true;
- }
- return false;
- }
-
- void insertStartElement(String name) {
- QName element = new QName(null,name,name,null);
- XMLAttributes attrs = new XMLAttributesImpl();
- Augmentations augs = new HTMLAugmentations();
- super.startElement(element,attrs,augs);
- }
-
-
- void insertEndElement(String name) {
- QName element = new QName(null,name,name,null);
-// XMLAttributes attrs = new XMLAttributesImpl();
- Augmentations augs = new HTMLAugmentations();
- super.endElement(element,augs);
- }
-
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#endDocument(org.apache.xerces.xni.Augmentations)
- */
- public void endDocument(Augmentations augs) throws XNIException {
- if (!haveHtml) {
- insertEndElement("html");
- }
- super.endDocument(augs);
- }
-
-
-
- }
-
- private static class HtmlWriter extends Writer {
-
- /**
- *
- */
- public HtmlWriter() {
- super();
- fEncoding = "UTF-8";
- }
-
- public void setEncoding(String encoding){
- this.fEncoding = encoding;
- }
-
- public void setWriter( PrintWriter writer){
- this.fPrinter = writer;
- }
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.Writer#emptyElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
- */
- public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
- // TODO Auto-generated method stub
- super.emptyElement(element, attributes, augs);
- printEndElement(element);
- }
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#endCDATA(org.apache.xerces.xni.Augmentations)
- */
- public void endCDATA(Augmentations augs) throws XNIException {
- // TODO Auto-generated method stub
- super.endCDATA(augs);
- }
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#startCDATA(org.apache.xerces.xni.Augmentations)
- */
- public void startCDATA(Augmentations augs) throws XNIException {
- // TODO Auto-generated method stub
- super.startCDATA(augs);
- }
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#textDecl(java.lang.String, java.lang.String, org.apache.xerces.xni.Augmentations)
- */
- public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {
- // TODO Auto-generated method stub
- super.textDecl(version, encoding, augs);
- }
-
- /* (non-Javadoc)
- * @see org.cyberneko.html.filters.DefaultFilter#xmlDecl(java.lang.String, java.lang.String, java.lang.String, org.apache.xerces.xni.Augmentations)
- */
- public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException {
- // TODO Auto-generated method stub
- super.xmlDecl(version, encoding, standalone, augs);
- }
-
-
- }
- /**
- * Factory method for create and configure HTML parser configuration.
- * Create configuration for use in parsing, set nessesary features and properties
- * @return
- * @throws ServletException
- */
- protected HTMLConfiguration getHtmlConfig() {
- HTMLConfiguration _config = new HTMLConfiguration();
- try {
- if (this.getPublicid() != null || this.getSystemid() != null) {
- _config.setFeature(
- "http://cyberneko.org/html/features/insert-doctype",
- true);
- _config.setFeature(
- "http://cyberneko.org/html/features/override-doctype",
- true);
- }
- if (this.getPublicid() != null) {
- _config.setProperty(
- "http://cyberneko.org/html/properties/doctype/pubid",
- getPublicid());
-
- }
- if (this.getSystemid() != null) {
- _config.setProperty(
- "http://cyberneko.org/html/properties/doctype/sysid",
- getSystemid());
-
- }
- if (this.getNamespace() != null) {
- _config.setFeature(
- "http://xml.org/sax/features/namespaces",
- true);
- _config.setFeature(
- "http://cyberneko.org/html/features/override-namespaces",
- true);
- _config.setFeature(
- "http://cyberneko.org/html/features/insert-namespaces",
- true);
- _config.setProperty(
- "http://cyberneko.org/html/properties/namespaces-uri",
- getNamespace());
-
- }
- // config
- // .setFeature(
- // "http://cyberneko.org/html/features/balance-tags/ignore-outside-content",
- // true);
- _config
- .setFeature(
- "http://cyberneko.org/html/features/scanner/cdata-sections",
- true);
- _config
- .setFeature(
- "http://cyberneko.org/html/features/scanner/script/strip-comment-delims",
- true);
- _config
- .setFeature(
- "http://cyberneko.org/html/features/scanner/style/strip-comment-delims",
- true);
- _config.setFeature(
- "http://cyberneko.org/html/features/insert-doctype",
- true);
- _config.setFeature(
- "http://cyberneko.org/html/features/insert-namespaces",
- true);
- //
- // Set properties http://cyberneko.org/html/features/insert-namespaces
- // _config
- // .setProperty(
- // "http://cyberneko.org/html/properties/default-encoding",
- // encoding);
- _config.setProperty(
- "http://cyberneko.org/html/properties/names/elems",
- "lower");
- _config.setProperty(
- "http://cyberneko.org/html/properties/names/attrs",
- "lower");
- _config.setProperty("http://cyberneko.org/html/properties/filters", _filters);
- } catch (XMLConfigurationException e) {
-// throw new ServletException("error set Neko feature ", e);
- }
- return _config;
- }
-
- private String getNamespace() {
- // TODO Auto-generated method stub
- return this._namespace;
- }
-
- private String getSystemid() {
- // TODO Auto-generated method stub
- return this._systemid;
- }
-
- private String getPublicid() {
- // TODO Auto-generated method stub
- return this._publicId;
- }
-
- /**
- * @param namespace The namespace to set.
- */
- public void setNamespace(String namespace) {
- _namespace = namespace;
- }
-
- /**
- * @param publicId The publicId to set.
- */
- public void setPublicId(String publicId) {
- _publicId = publicId;
- }
-
- /**
- * @param systemid The systemid to set.
- */
- public void setSystemid(String systemid) {
- _systemid = systemid;
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoParser.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,649 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp.nekko;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.servlet.ServletException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.ajax4jsf.application.AjaxViewHandler;
+import org.ajax4jsf.webapp.HtmlParser;
+import org.ajax4jsf.xml.serializer.Method;
+import org.ajax4jsf.xml.serializer.OutputPropertiesFactory;
+import org.ajax4jsf.xml.serializer.Serializer;
+import org.ajax4jsf.xml.serializer.SerializerFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.html.dom.HTMLDocumentImpl;
+import org.apache.xerces.parsers.AbstractSAXParser;
+import org.apache.xerces.util.XMLAttributesImpl;
+import org.apache.xerces.xni.Augmentations;
+import org.apache.xerces.xni.QName;
+import org.apache.xerces.xni.XMLAttributes;
+import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.XNIException;
+import org.apache.xerces.xni.parser.XMLComponentManager;
+import org.apache.xerces.xni.parser.XMLConfigurationException;
+import org.apache.xerces.xni.parser.XMLDocumentFilter;
+import org.cyberneko.html.HTMLAugmentations;
+import org.cyberneko.html.HTMLConfiguration;
+import org.cyberneko.html.filters.DefaultFilter;
+import org.cyberneko.html.filters.ElementRemover;
+import org.cyberneko.html.filters.Purifier;
+import org.cyberneko.html.filters.Writer;
+import org.cyberneko.html.parsers.DOMFragmentParser;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @author shura
+ *
+ */
+public class NekkoParser implements HtmlParser {
+
+ private static final Log _log = LogFactory.getLog(NekkoParser.class);
+
+ private HtmlSAXParser _parser;
+
+// private HtmlWriter _writer= new HtmlWriter();
+
+ private ElementRemover remover = new ElementRemover();
+
+ private XMLDocumentFilter[] _filters = { new ViewStateFilter()/*,remover */, new HtmlCorrectionFilter(), new Purifier() /*, _writer*/ };
+
+ private DOMFragmentParser viewStateParser ;//= new DOMFragmentParser();
+
+ private Document viewStateDocument ;//= new HTMLDocumentImpl();
+
+ private DocumentFragment fragment = null;
+
+ private Set _scripts;
+
+ private Set _styles;
+
+ private String _viewState;
+
+ private String _encoding;
+
+ private Serializer _serializer;
+
+ private String _publicId = "-//W3C//DTD XHTML 1.0 Transitional//EN";
+ private String _systemid = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";
+ private String _namespace = "http://www.w3.org/1999/xhtml";
+
+ private String _outputEncoding;
+ /**
+ *
+ */
+ public NekkoParser() {
+ _parser=new HtmlSAXParser(getHtmlConfig());
+// Properties properties = OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML);
+ Properties properties = OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
+// properties.put("encoding",_encoding);
+ _serializer = SerializerFactory.getSerializer(properties);
+// serializer.setOutputStream(output);
+// _parser.setContentHandler(serializer.asContentHandler());
+ viewStateParser = new DOMFragmentParser();
+ // Set parser features
+ try {
+ viewStateParser.setProperty(
+ "http://cyberneko.org/html/properties/names/elems",
+ "lower");
+ viewStateParser.setProperty(
+ "http://cyberneko.org/html/properties/names/attrs",
+ "lower");
+ } catch (SAXException e) {
+ _log.error("Exception in DOM parser configuration", e);
+ }
+ try {
+ // Create Document Builder Factory
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory
+ .newInstance();
+ // Create Document Builder
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ viewStateDocument = docBuilder.newDocument();
+ } catch (ParserConfigurationException e) {
+ viewStateDocument = new HTMLDocumentImpl();
+ _log.error("Error on create DOM Document by JAXP, use Xerxes implementation. Check JAXP configuration ",e);
+ }
+// viewStateDocument = new HTMLDocumentImpl();
+ remover.removeElement("style");
+ }
+
+ /**
+ * Reset parser state
+ */
+ public void reset(){
+ _scripts=null;
+ _styles=null;
+ _viewState=null;
+ _parser.reset();
+ _serializer.reset();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.webapp.HtmlParser#parseHtml(java.io.InputStream, java.io.OutputStream)
+ */
+ public void parseHtml(InputStream input, java.io.Writer output)
+ throws IOException {
+ InputSource src = new InputSource(input);
+ parseSAXSource(src,output);
+ }
+
+ private void parseSAXSource(InputSource src, java.io.Writer output) throws IOException {
+// PrintWriter printWriter = null;
+ fragment = null;
+ if(null != _viewState){
+ fragment = viewStateDocument.createDocumentFragment();
+ try {
+ viewStateParser.parse(new InputSource(new StringReader(
+ _viewState)), fragment);
+ } catch (Exception e) {
+ fragment = null;
+ }
+ // TODO - parse view state to DOM Fragment.
+ }
+ try {
+ _parser.setProperty("http://cyberneko.org/html/properties/default-encoding",
+ _encoding);
+ Properties properties = _serializer.getOutputFormat();
+ properties.put("encoding",_outputEncoding);
+ _serializer.setOutputFormat(properties);
+ _serializer.setWriter(output);
+// _serializer.setOutputStream(new OutputStream(){
+//
+// public void write(int b) throws IOException {
+// // TODO Auto-generated method stub
+//
+// }});
+ _parser.setContentHandler(_serializer.asContentHandler());
+// printWriter = new PrintWriter(output);
+// _writer.setWriter(printWriter);
+// _writer.setEncoding(_encoding);
+ _parser.parse(src);
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+// _writer.setWriter(null);
+// if(null != printWriter){
+// printWriter.flush();
+// printWriter.close();
+// }
+
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.webapp.HtmlParser#parseHtml(java.io.Reader, java.io.OutputStream)
+ */
+ public void parseHtml(Reader input, java.io.Writer output) throws IOException {
+ InputSource src = new InputSource(input);
+ parseSAXSource(src,output);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.webapp.HtmlParser#setEncoding(java.lang.String)
+ */
+ public void setInputEncoding(String encoding) {
+ _encoding = encoding;
+ }
+
+ public void setOutputEncoding(String encoding) {
+ _outputEncoding = encoding;
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.webapp.HtmlParser#setMoveElements(boolean)
+ */
+ public void setMoveElements(boolean move) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.webapp.HtmlParser#setScripts(java.util.Set)
+ */
+ public void setScripts(Set scripts) {
+ _scripts = scripts;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.webapp.HtmlParser#setStyles(java.util.Set)
+ */
+ public void setStyles(Set styles) {
+ _styles = styles;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.webapp.HtmlParser#setDoctype(java.lang.String)
+ */
+ public void setDoctype(String doctype) {
+ this._publicId = doctype;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.webapp.HtmlParser#setViewState(java.lang.String)
+ */
+ public void setViewState(String viewState) {
+ _viewState = viewState;
+
+ }
+
+ private static class HtmlSAXParser extends AbstractSAXParser {
+ /** Default constructor.
+ * @throws ServletException */
+ public HtmlSAXParser(HTMLConfiguration config) {
+ super(config);
+
+ }
+ }
+
+ private class ViewStateFilter extends DefaultFilter{
+ private boolean haveHtml = false;
+ private boolean haveHead = false;
+ private boolean headParsed = false;
+ private int stateMarkerLevel = -1;
+
+
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#reset(org.apache.xerces.xni.parser.XMLComponentManager)
+ */
+ public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
+ haveHead = false;
+ haveHtml = false;
+ headParsed = false;
+ stateMarkerLevel = -1;
+ super.reset(componentManager);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#startElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
+ */
+ public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
+ if(stateMarkerLevel >=0){
+ stateMarkerLevel++;
+ if(null != fragment){
+ return;
+ }
+ }
+ if (!headParsed) {
+ if("html".equalsIgnoreCase(element.rawname)){
+ haveHtml = true;
+ } else if("head".equalsIgnoreCase(element.rawname)){
+ haveHead = true;
+ super.startElement(element, attributes, augs);
+ insertResources();
+ return;
+ } else {
+ if(!haveHtml){
+ insertStartElement("html");
+ }
+ insertStartElement("head");
+ insertResources();
+ insertEndElement("head");
+ }
+
+ }
+ if(isStateMarker(element, attributes)){
+ stateMarkerLevel = 0;
+ return;
+ };
+ super.startElement(element, attributes, augs);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#characters(org.apache.xerces.xni.XMLString, org.apache.xerces.xni.Augmentations)
+ */
+ public void characters(XMLString text, Augmentations augs) throws XNIException {
+ if(stateMarkerLevel >=0){
+ if(null != fragment){
+ return;
+ }
+ }
+ super.characters(text, augs);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#endElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.Augmentations)
+ */
+ public void endElement(QName element, Augmentations augs) throws XNIException {
+ if(stateMarkerLevel >=0){
+ stateMarkerLevel--;
+ if(null != fragment || stateMarkerLevel == -1){
+ return;
+ }
+ }
+ super.endElement(element, augs);
+ }
+
+
+ private void insertResources() {
+ headParsed = true;
+ if(null != _styles){
+ for (Iterator iter = _styles.iterator(); iter.hasNext();) {
+ String style = (String) iter.next();
+ QName element = new QName(null,"link","link",null);
+ XMLAttributes attrs = new XMLAttributesImpl();
+ attrs.addAttribute(new QName(null,"href","href",null), "CDATA", style);
+ attrs.addAttribute(new QName(null,"type","type",null), "CDATA", "text/css");
+ attrs.addAttribute(new QName(null,"rel","rel",null), "CDATA", "stylesheet");
+ Augmentations augs = new HTMLAugmentations();
+ super.emptyElement(element,attrs,augs);
+ }
+ }
+ if(null != _scripts){
+ for (Iterator iter = _scripts.iterator(); iter.hasNext();) {
+ String script = (String) iter.next();
+ QName element = new QName(null,"script","script",null);
+ XMLAttributes attrs = new XMLAttributesImpl();
+ attrs.addAttribute(new QName(null,"src","src",null), "CDATA", script);
+ attrs.addAttribute(new QName(null,"type","type",null), "CDATA", "text/javascript");
+ Augmentations augs = new HTMLAugmentations();
+ super.startElement(element,attrs,augs);
+ super.endElement(element, augs);
+ }
+ }
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#emptyElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
+ */
+ public void emptyElement(QName name, XMLAttributes attributes, Augmentations augmentation) throws XNIException {
+ if(stateMarkerLevel >=0){
+ if(null != fragment){
+ return;
+ }
+ }
+ if (!headParsed) {
+ if("head".equalsIgnoreCase(name.rawname)){
+ haveHead = true;
+ super.startElement(name, attributes, augmentation);
+ insertResources();
+ insertEndElement(name.rawname);
+ return;
+ }
+ }
+ if(isStateMarker(name, attributes)){
+ return;
+ };
+ super.emptyElement(name, attributes, augmentation);
+ }
+
+
+ /**
+ * @param name
+ * @param attributes
+ */
+ private boolean isStateMarker(QName name, XMLAttributes attributes) {
+ if(name.rawname.equalsIgnoreCase("span") && AjaxViewHandler.STATE_MARKER_KEY.equals(attributes.getValue("id"))){
+ // STATE marker element - out real content.
+ if(null != fragment){
+ try {
+ _serializer.asDOMSerializer().serialize(fragment);
+ } catch (IOException e) {
+ // Break output.
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ void insertStartElement(String name) {
+ QName element = new QName(null,name,name,null);
+ XMLAttributes attrs = new XMLAttributesImpl();
+ Augmentations augs = new HTMLAugmentations();
+ super.startElement(element,attrs,augs);
+ }
+
+
+ void insertEndElement(String name) {
+ QName element = new QName(null,name,name,null);
+// XMLAttributes attrs = new XMLAttributesImpl();
+ Augmentations augs = new HTMLAugmentations();
+ super.endElement(element,augs);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#endDocument(org.apache.xerces.xni.Augmentations)
+ */
+ public void endDocument(Augmentations augs) throws XNIException {
+ if (!haveHtml) {
+ insertEndElement("html");
+ }
+ super.endDocument(augs);
+ }
+
+
+
+ }
+
+ private static class HtmlWriter extends Writer {
+
+ /**
+ *
+ */
+ public HtmlWriter() {
+ super();
+ fEncoding = "UTF-8";
+ }
+
+ public void setEncoding(String encoding){
+ this.fEncoding = encoding;
+ }
+
+ public void setWriter( PrintWriter writer){
+ this.fPrinter = writer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.Writer#emptyElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)
+ */
+ public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
+ // TODO Auto-generated method stub
+ super.emptyElement(element, attributes, augs);
+ printEndElement(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#endCDATA(org.apache.xerces.xni.Augmentations)
+ */
+ public void endCDATA(Augmentations augs) throws XNIException {
+ // TODO Auto-generated method stub
+ super.endCDATA(augs);
+ }
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#startCDATA(org.apache.xerces.xni.Augmentations)
+ */
+ public void startCDATA(Augmentations augs) throws XNIException {
+ // TODO Auto-generated method stub
+ super.startCDATA(augs);
+ }
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#textDecl(java.lang.String, java.lang.String, org.apache.xerces.xni.Augmentations)
+ */
+ public void textDecl(String version, String encoding, Augmentations augs) throws XNIException {
+ // TODO Auto-generated method stub
+ super.textDecl(version, encoding, augs);
+ }
+
+ /* (non-Javadoc)
+ * @see org.cyberneko.html.filters.DefaultFilter#xmlDecl(java.lang.String, java.lang.String, java.lang.String, org.apache.xerces.xni.Augmentations)
+ */
+ public void xmlDecl(String version, String encoding, String standalone, Augmentations augs) throws XNIException {
+ // TODO Auto-generated method stub
+ super.xmlDecl(version, encoding, standalone, augs);
+ }
+
+
+ }
+ /**
+ * Factory method for create and configure HTML parser configuration.
+ * Create configuration for use in parsing, set nessesary features and properties
+ * @return
+ * @throws ServletException
+ */
+ protected HTMLConfiguration getHtmlConfig() {
+ HTMLConfiguration _config = new HTMLConfiguration();
+ try {
+ if (this.getPublicid() != null || this.getSystemid() != null) {
+ _config.setFeature(
+ "http://cyberneko.org/html/features/insert-doctype",
+ true);
+ _config.setFeature(
+ "http://cyberneko.org/html/features/override-doctype",
+ true);
+ }
+ if (this.getPublicid() != null) {
+ _config.setProperty(
+ "http://cyberneko.org/html/properties/doctype/pubid",
+ getPublicid());
+
+ }
+ if (this.getSystemid() != null) {
+ _config.setProperty(
+ "http://cyberneko.org/html/properties/doctype/sysid",
+ getSystemid());
+
+ }
+ if (this.getNamespace() != null) {
+ _config.setFeature(
+ "http://xml.org/sax/features/namespaces",
+ true);
+ _config.setFeature(
+ "http://cyberneko.org/html/features/override-namespaces",
+ true);
+ _config.setFeature(
+ "http://cyberneko.org/html/features/insert-namespaces",
+ true);
+ _config.setProperty(
+ "http://cyberneko.org/html/properties/namespaces-uri",
+ getNamespace());
+
+ }
+ // config
+ // .setFeature(
+ // "http://cyberneko.org/html/features/balance-tags/ignore-outside-content",
+ // true);
+ _config
+ .setFeature(
+ "http://cyberneko.org/html/features/scanner/cdata-sections",
+ true);
+ _config
+ .setFeature(
+ "http://cyberneko.org/html/features/scanner/script/strip-comment-delims",
+ true);
+ _config
+ .setFeature(
+ "http://cyberneko.org/html/features/scanner/style/strip-comment-delims",
+ true);
+ _config.setFeature(
+ "http://cyberneko.org/html/features/insert-doctype",
+ true);
+ _config.setFeature(
+ "http://cyberneko.org/html/features/insert-namespaces",
+ true);
+ //
+ // Set properties http://cyberneko.org/html/features/insert-namespaces
+ // _config
+ // .setProperty(
+ // "http://cyberneko.org/html/properties/default-encoding",
+ // encoding);
+ _config.setProperty(
+ "http://cyberneko.org/html/properties/names/elems",
+ "lower");
+ _config.setProperty(
+ "http://cyberneko.org/html/properties/names/attrs",
+ "lower");
+ _config.setProperty("http://cyberneko.org/html/properties/filters", _filters);
+ } catch (XMLConfigurationException e) {
+// throw new ServletException("error set Neko feature ", e);
+ }
+ return _config;
+ }
+
+ private String getNamespace() {
+ // TODO Auto-generated method stub
+ return this._namespace;
+ }
+
+ private String getSystemid() {
+ // TODO Auto-generated method stub
+ return this._systemid;
+ }
+
+ private String getPublicid() {
+ // TODO Auto-generated method stub
+ return this._publicId;
+ }
+
+ /**
+ * @param namespace The namespace to set.
+ */
+ public void setNamespace(String namespace) {
+ _namespace = namespace;
+ }
+
+ /**
+ * @param publicId The publicId to set.
+ */
+ public void setPublicId(String publicId) {
+ _publicId = publicId;
+ }
+
+ /**
+ * @param systemid The systemid to set.
+ */
+ public void setSystemid(String systemid) {
+ _systemid = systemid;
+ }
+
+ public boolean setMime(String mimeType) {
+ return false;
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoXMLFilter.java 2007-07-09 15:13:40 UTC (rev 1551)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,108 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter.nekko;
-
-import java.util.EmptyStackException;
-
-import javax.servlet.ServletException;
-
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser;
-import org.ajax4jsf.io.parser.FastHtmlParser;
-import org.apache.commons.collections.ArrayStack;
-
-public class NekkoXMLFilter extends BaseXMLFilter {
- private static final int STACK_SIZE = 100;
- private static ArrayStack _xhtmlParsersPool = new ArrayStack(STACK_SIZE);
-
- public NekkoXMLFilter() {}
-
- protected HtmlParser getParser(String mimetype, boolean isAjax) {
- HtmlParser parser = null;
- if( isAjax ){
- parser = getXmlParser();
- } else if (mimetype.startsWith("text/html") || mimetype.startsWith("application/xhtml+xml")) {
- parser = new FastHtmlParser();
- } else {
- return null;
- }
-// parser.setEncoding(characterEncoding);
- return parser;
- }
-
- /**
- * Peturn parser to pool
- * @param parser
- */
- protected void reuseParser(HtmlParser parser) {
- if (null != parser) {
- if (parser instanceof NekkoParser ) {
- synchronized (_xhtmlParsersPool) {
- if (_xhtmlParsersPool.size() < STACK_SIZE) {
- ((NekkoParser) parser).reset();
- _xhtmlParsersPool.push(parser);
- }
-
- }
- }
- }
- }
-
- /**
- * Factory method for create parsing object - contain chain of parsing,
- * transformation and serialization of response output
- * @param string Encodings for parser
- * @return
- * @throws ServletException
- */
- protected HtmlParser getXmlParser() {
- // TODO make pool of parsers-transformers.
- 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());
- }
- // TODO - set header scripts/styles filter.
- return parser;
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter#getWrapper(javax.servlet.http.HttpServletResponse)
- */
-// protected FilterServletResponseWrapper getWrapper(HttpServletResponse response) throws ServletException {
-// // TODO Auto-generated method stub
-// NekkoHtmlServletResponseWrapper wrapper = new NekkoHtmlServletResponseWrapper(response);
-// // TODO - create pool of parsers.
-// wrapper.setParser(getParser());
-// return wrapper;
-// }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoXMLFilter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/nekko/NekkoXMLFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,108 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp.nekko;
+
+import java.util.EmptyStackException;
+
+import javax.servlet.ServletException;
+
+import org.ajax4jsf.io.parser.FastHtmlParser;
+import org.ajax4jsf.webapp.BaseXMLFilter;
+import org.ajax4jsf.webapp.HtmlParser;
+import org.apache.commons.collections.ArrayStack;
+
+public class NekkoXMLFilter extends BaseXMLFilter {
+ private static final int STACK_SIZE = 100;
+ private static ArrayStack _xhtmlParsersPool = new ArrayStack(STACK_SIZE);
+
+ public NekkoXMLFilter() {}
+
+ protected HtmlParser getParser(String mimetype, boolean isAjax, String viewId) {
+ HtmlParser parser = null;
+ if( isAjax ){
+ parser = getXmlParser();
+ } else if (mimetype.startsWith("text/html") || mimetype.startsWith("application/xhtml+xml")) {
+ parser = new FastHtmlParser();
+ } else {
+ return null;
+ }
+// parser.setEncoding(characterEncoding);
+ return parser;
+ }
+
+ /**
+ * Peturn parser to pool
+ * @param parser
+ */
+ protected void reuseParser(HtmlParser parser) {
+ if (null != parser) {
+ if (parser instanceof NekkoParser ) {
+ synchronized (_xhtmlParsersPool) {
+ if (_xhtmlParsersPool.size() < STACK_SIZE) {
+ ((NekkoParser) parser).reset();
+ _xhtmlParsersPool.push(parser);
+ }
+
+ }
+ }
+ }
+ }
+
+ /**
+ * Factory method for create parsing object - contain chain of parsing,
+ * transformation and serialization of response output
+ * @param string Encodings for parser
+ * @return
+ * @throws ServletException
+ */
+ protected HtmlParser getXmlParser() {
+ // TODO make pool of parsers-transformers.
+ 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());
+ }
+ // TODO - set header scripts/styles filter.
+ return parser;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.webapp.BaseFilter#getWrapper(javax.servlet.http.HttpServletResponse)
+ */
+// protected FilterServletResponseWrapper getWrapper(HttpServletResponse response) throws ServletException {
+// // TODO Auto-generated method stub
+// NekkoHtmlServletResponseWrapper wrapper = new NekkoHtmlServletResponseWrapper(response);
+// // TODO - create pool of parsers.
+// wrapper.setParser(getParser());
+// return wrapper;
+// }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy)
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyParser.java 2007-07-09 15:13:40 UTC (rev 1551)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,399 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter.tidy;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.ajax.AjaxViewHandler;
-import org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser;
-import org.ajax4jsf.org.w3c.tidy.Lexer;
-import org.ajax4jsf.org.w3c.tidy.Node;
-import org.ajax4jsf.org.w3c.tidy.Tidy;
-import org.ajax4jsf.org.w3c.tidy.TidyMessage;
-import org.ajax4jsf.org.w3c.tidy.TidyMessageListener;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.impl.NoOpLog;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:17 $
- *
- */
-public class TidyParser implements TidyMessageListener, HtmlParser {
-
- private static final Log log = LogFactory.getLog(TidyParser.class);
-
- private Tidy tidy;
-
- private Set _scripts;
-
- private Set _styles;
-
- private String _viewState;
-
- private String _encoding;
-
- private String _outputEncoding;
-
- private static final String[] _htmlTypes = { "text/html" };
-
- private static final String[] _xmlTypes = { "text/xml" };// "text/xml"};
-
- private static final String[] _xhtmlTypes = { "application/xhtml+xml" };
-
- private static final String TIDY_MARK = "[TIDY_MESSAGE]";
-
- /**
- *
- */
- public TidyParser(Properties props) {
- tidy = new Tidy();
- tidy.setConfigurationFromProps(props);
- // tidy.setConfigurationFromProps(getProperties("tidy.properties"));
- PrintWriter errout = new PrintWriter(new ErrorWriter());
- tidy.setErrout(errout);
- tidy.setForceOutput(true);
- tidy.setHideEndTags(false);
- tidy.setMessageListener(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#parseHtml(java.lang.Object,
- * java.io.OutputStream)
- */
- public Document parseHtmlByTidy(Object input, Writer output)
- throws IOException {
- Document document = tidy.parseDOM(input, null);
- if (null != document) {
- Element documentElement = document.getDocumentElement();
- if (null != documentElement) {
- // Replace state elements with real stored.
-
- NodeList inputs = documentElement.getElementsByTagName("span");
- for (int i = 0; i < inputs.getLength(); i++) {
- Element node = (Element) inputs.item(i);
- if (AjaxViewHandler.STATE_MARKER_KEY.equals(node
- .getAttribute("id"))
- && AjaxViewHandler.STATE_MARKER_KEY.equals(node
- .getAttribute("name"))) {
- // State marker - replace with real.
- org.w3c.dom.Node parentNode = node.getParentNode();
- if (null != _viewState) {
- parentNode.replaceChild(document
- .createCDATASection(_viewState), node);
- } else {
- // Remove marker element, but keep it content.
- if (node.hasChildNodes()) {
- org.w3c.dom.Node nextSibling = node
- .getNextSibling();
- NodeList childNodes = node.getChildNodes();
- // Copy all nodes by temporary array ( since
- // moving nodes in iteration
- // modify NodeList with side effects.
- org.w3c.dom.Node[] childArray = new org.w3c.dom.Node[childNodes
- .getLength()];
- for (int j = 0; j < childArray.length; j++) {
- childArray[j] = childNodes.item(j);
- }
- for (int j = 0; j < childArray.length; j++) {
- parentNode.insertBefore(childArray[j],
- nextSibling);
- }
- }
- parentNode.removeChild(node);
- }
- }
- }
-
- // Inserts scripts and styles to head.
- if (null != _scripts || null != _styles || null != _viewState) {
- // find head
- org.w3c.dom.Node head = documentElement
- .getElementsByTagName("head").item(0);
- // Insert empty if not found
- if (null == head) {
- head = document.createElement("head");
- documentElement.insertBefore(head, documentElement
- .getFirstChild());
- }
- NodeList headChildren = head.getChildNodes();
- org.w3c.dom.Node child = null;
- for (int i = 0; i < headChildren.getLength(); i++) {
- child = headChildren.item(i);
- if (child instanceof Element) {
- String nodeName = ((Element) child).getNodeName();
- if (!("title".equalsIgnoreCase(nodeName) || "base"
- .equalsIgnoreCase(nodeName))) {
- break;
- }
- }
- child = null;
- }
- if (null != _styles) {
- for (Iterator iter = _styles.iterator(); iter.hasNext();) {
- String url = (String) iter.next();
- Element style = document.createElement("link");
- style.setAttribute("type", "text/css");
- style.setAttribute("rel", "stylesheet");
- style.setAttribute("href", url);
- head.insertBefore(style, child);
- }
- }
- // Scripts
- if (null != _scripts) {
- for (Iterator iter = _scripts.iterator(); iter
- .hasNext();) {
- String url = (String) iter.next();
- Element script = document.createElement("script");
-
- script.setAttribute("type", "text/javascript");
- // script.setAttribute("defer", "defer");
- script.setAttribute("src", url);
- // script.appendChild(document.createTextNode(""));
- head.insertBefore(script, child);
- }
- }
- }
- }
- if (null != output) {
- tidy.pprint(document, output);
- }
- }
- return document;
- }
-
- public void parseHtml(InputStream input, Writer output) throws IOException {
- this.parseHtmlByTidy(input, output);
-
- }
-
- public void parseHtml(Reader input, Writer output) throws IOException {
- this.parseHtmlByTidy(input, output);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.w3c.tidy.TidyMessageListener#messageReceived(org.w3c.tidy.TidyMessage)
- */
- public void messageReceived(TidyMessage message) {
- // TODO record messages for output.
- // TODO change signature for receive current node and append message in
- // tree.
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.MESSAGE_PARSING_INFO,
- message.getMessage()));
- }
- // TODO - configurable output for reeors in page.
- if (false) {
- Lexer lexer = message.getLexer();
- Node element = message.getElement();
- if (null == element) {
- element = lexer.getLastNode();
- } else if ("style".equalsIgnoreCase(element.getElement())
- || "script".equalsIgnoreCase(element.getElement())) {
- element = lexer.getLastNode();
- }
- // Insert comment about error.
- if (null != element) {
- String messageText = message.getMessage();
- byte[] msg = (TIDY_MARK + messageText + TIDY_MARK).getBytes();
- Node comment = lexer.newNode(Node.COMMENT_TAG, msg, 0,
- msg.length);
- // TODO - detect style or script elements - not allow comment in
- // it.
- element.insertNodeAtEnd(comment);
- }
- }
- }
-
- /**
- * 'null' writer for discard errors - since processed in message listener
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:17 $
- *
- */
- private static class ErrorWriter extends Writer {
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Writer#write(char[], int, int)
- */
- public void write(char[] cbuf, int off, int len) throws IOException {
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Writer#flush()
- */
- public void flush() throws IOException {
- // do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Writer#close()
- */
- public void close() throws IOException {
- // do nothing
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setEncoding(java.lang.String)
- */
- public void setInputEncoding(String encoding) {
- if (null != encoding) {
- this._encoding = encoding;
- if (null != encoding) {
- this.tidy.setInputEncoding(encoding);
- }
- // this.tidy.setOutputEncoding(encoding);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setEncoding(java.lang.String)
- */
- public void setOutputEncoding(String encoding) {
- if (null != encoding) {
- this._outputEncoding = encoding;
- // this.tidy.setInputEncoding(encoding);
- if (null != encoding) {
- this.tidy.setOutputEncoding(encoding);
- }
- }
- }
-
- /**
- * Setup properly tidy output for given mime type. return {@link false } if
- * this type not supported by tidy.
- *
- * @param mimeType
- * @return
- */
- public boolean setMime(String mimeType) {
- if (null != mimeType) {
- for (int i = 0; i < _htmlTypes.length; i++) {
- String mime = _htmlTypes[i];
- if (mimeType.startsWith(mime)) {
- // setup html output
- tidy.setXHTML(false);
- tidy.setXmlOut(false);
- // TODO - auto doctype ?
- return true;
- }
- }
- for (int i = 0; i < _xhtmlTypes.length; i++) {
- String mime = _xhtmlTypes[i];
- if (mimeType.startsWith(mime)) {
- // setup xhtml output
- tidy.setXHTML(true);
- tidy.setXmlOut(false);
- return true;
- }
- }
- for (int i = 0; i < _xmlTypes.length; i++) {
- String mime = _xmlTypes[i];
- if (mimeType.startsWith(mime)) {
- // setup html output
- tidy.setXHTML(true);
- tidy.setXmlOut(true);
- tidy.setXmlPi(true);
- tidy.setEscapeCdata(false);
- tidy.setNumEntities(true);
- return true;
- }
- }
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setMoveElements(boolean)
- */
- public void setMoveElements(boolean move) {
- tidy.setMoveElements(move);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setScripts(java.util.Set)
- */
- public void setScripts(Set scripts) {
- this._scripts = scripts;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setStyles(java.util.Set)
- */
- public void setStyles(Set styles) {
- this._styles = styles;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setDoctype(java.lang.String)
- */
- public void setDoctype(String doctype) {
- tidy.setDocType(doctype);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setViewState(java.lang.String)
- */
- public void setViewState(String viewState) {
- _viewState = viewState;
- }
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyParser.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyParser.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,406 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp.tidy;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.application.AjaxViewHandler;
+import org.ajax4jsf.org.w3c.tidy.Lexer;
+import org.ajax4jsf.org.w3c.tidy.Node;
+import org.ajax4jsf.org.w3c.tidy.Tidy;
+import org.ajax4jsf.org.w3c.tidy.TidyMessage;
+import org.ajax4jsf.org.w3c.tidy.TidyMessageListener;
+import org.ajax4jsf.webapp.HtmlParser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:17 $
+ *
+ */
+public class TidyParser implements TidyMessageListener, HtmlParser {
+
+ private static final Log log = LogFactory.getLog(TidyParser.class);
+
+ private Tidy tidy;
+
+ private Set _scripts;
+
+ private Set _styles;
+
+ private String _viewState;
+
+ private String _encoding;
+
+ private String _outputEncoding;
+
+ private static final String[] _htmlTypes = { "text/html" };
+
+ private static final String[] _xmlTypes = { "text/xml" };// "text/xml"};
+
+ private static final String[] _xhtmlTypes = { "application/xhtml+xml" };
+
+ private static final String TIDY_MARK = "[TIDY_MESSAGE]";
+
+ /**
+ *
+ */
+ public TidyParser(Properties props) {
+ tidy = new Tidy();
+ tidy.setConfigurationFromProps(props);
+ // tidy.setConfigurationFromProps(getProperties("tidy.properties"));
+ PrintWriter errout = new PrintWriter(new ErrorWriter());
+ tidy.setErrout(errout);
+ tidy.setForceOutput(true);
+ tidy.setHideEndTags(false);
+ tidy.setMessageListener(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.HtmlParser#parseHtml(java.lang.Object,
+ * java.io.OutputStream)
+ */
+ public Document parseHtmlByTidy(Object input, Writer output)
+ throws IOException {
+ Document document = tidy.parseDOM(input, null);
+ if (null != document) {
+ Element documentElement = document.getDocumentElement();
+ if (null != documentElement) {
+ // Replace state elements with real stored.
+
+ NodeList inputs = documentElement.getElementsByTagName("span");
+ for (int i = 0; i < inputs.getLength(); i++) {
+ Element node = (Element) inputs.item(i);
+ if (AjaxViewHandler.STATE_MARKER_KEY.equals(node
+ .getAttribute("id"))
+ && AjaxViewHandler.STATE_MARKER_KEY.equals(node
+ .getAttribute("name"))) {
+ // State marker - replace with real.
+ org.w3c.dom.Node parentNode = node.getParentNode();
+ if (null != _viewState) {
+ parentNode.replaceChild(document
+ .createCDATASection(_viewState), node);
+ } else {
+ // Remove marker element, but keep it content.
+ if (node.hasChildNodes()) {
+ org.w3c.dom.Node nextSibling = node
+ .getNextSibling();
+ NodeList childNodes = node.getChildNodes();
+ // Copy all nodes by temporary array ( since
+ // moving nodes in iteration
+ // modify NodeList with side effects.
+ org.w3c.dom.Node[] childArray = new org.w3c.dom.Node[childNodes
+ .getLength()];
+ for (int j = 0; j < childArray.length; j++) {
+ childArray[j] = childNodes.item(j);
+ }
+ for (int j = 0; j < childArray.length; j++) {
+ parentNode.insertBefore(childArray[j],
+ nextSibling);
+ }
+ }
+ parentNode.removeChild(node);
+ }
+ }
+ }
+
+ // Inserts scripts and styles to head.
+ if (null != _scripts || null != _styles || null != _viewState) {
+ // find head
+ org.w3c.dom.Node head = documentElement
+ .getElementsByTagName("head").item(0);
+ // Insert empty if not found
+ if (null == head) {
+ head = document.createElement("head");
+ documentElement.insertBefore(head, documentElement
+ .getFirstChild());
+ }
+ NodeList headChildren = head.getChildNodes();
+ org.w3c.dom.Node child = null;
+ for (int i = 0; i < headChildren.getLength(); i++) {
+ child = headChildren.item(i);
+ if (child instanceof Element) {
+ String nodeName = ((Element) child).getNodeName();
+ if (!("title".equalsIgnoreCase(nodeName) || "base"
+ .equalsIgnoreCase(nodeName))) {
+ break;
+ }
+ }
+ child = null;
+ }
+ if (null != _styles) {
+ for (Iterator iter = _styles.iterator(); iter.hasNext();) {
+ String url = (String) iter.next();
+ Element style = document.createElement("link");
+ style.setAttribute("type", "text/css");
+ style.setAttribute("rel", "stylesheet");
+ style.setAttribute("href", url);
+ head.insertBefore(style, child);
+ }
+ }
+ // Scripts
+ if (null != _scripts) {
+ for (Iterator iter = _scripts.iterator(); iter
+ .hasNext();) {
+ String url = (String) iter.next();
+ Element script = document.createElement("script");
+
+ script.setAttribute("type", "text/javascript");
+ // script.setAttribute("defer", "defer");
+ script.setAttribute("src", url);
+ // script.appendChild(document.createTextNode(""));
+ head.insertBefore(script, child);
+ }
+ }
+ }
+ }
+ if (null != output) {
+ tidy.pprint(document, output);
+ }
+ }
+ return document;
+ }
+
+ public void parseHtml(InputStream input, Writer output) throws IOException {
+ this.parseHtmlByTidy(input, output);
+
+ }
+
+ public void parseHtml(Reader input, Writer output) throws IOException {
+ this.parseHtmlByTidy(input, output);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.w3c.tidy.TidyMessageListener#messageReceived(org.w3c.tidy.TidyMessage)
+ */
+ public void messageReceived(TidyMessage message) {
+ // TODO record messages for output.
+ // TODO change signature for receive current node and append message in
+ // tree.
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.MESSAGE_PARSING_INFO,
+ message.getMessage()));
+ }
+ // TODO - configurable output for reeors in page.
+ if (false) {
+ Lexer lexer = message.getLexer();
+ Node element = message.getElement();
+ if (null == element) {
+ element = lexer.getLastNode();
+ } else if ("style".equalsIgnoreCase(element.getElement())
+ || "script".equalsIgnoreCase(element.getElement())) {
+ element = lexer.getLastNode();
+ }
+ // Insert comment about error.
+ if (null != element) {
+ String messageText = message.getMessage();
+ byte[] msg = (TIDY_MARK + messageText + TIDY_MARK).getBytes();
+ Node comment = lexer.newNode(Node.COMMENT_TAG, msg, 0,
+ msg.length);
+ // TODO - detect style or script elements - not allow comment in
+ // it.
+ element.insertNodeAtEnd(comment);
+ }
+ }
+ }
+
+ /**
+ * 'null' writer for discard errors - since processed in message listener
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:59:17 $
+ *
+ */
+ private static class ErrorWriter extends Writer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.Writer#write(char[], int, int)
+ */
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ // do nothing
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.Writer#flush()
+ */
+ public void flush() throws IOException {
+ // do nothing
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.io.Writer#close()
+ */
+ public void close() throws IOException {
+ // do nothing
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.HtmlParser#setEncoding(java.lang.String)
+ */
+ public void setInputEncoding(String encoding) {
+ if (null != encoding) {
+ this._encoding = encoding;
+ if (null != encoding) {
+ this.tidy.setInputEncoding(encoding);
+ }
+ // this.tidy.setOutputEncoding(encoding);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.HtmlParser#setEncoding(java.lang.String)
+ */
+ public void setOutputEncoding(String encoding) {
+ if (null != encoding) {
+ this._outputEncoding = encoding;
+ // this.tidy.setInputEncoding(encoding);
+ if (null != encoding) {
+ this.tidy.setOutputEncoding(encoding);
+ }
+ }
+ }
+
+ /**
+ * Setup properly tidy output for given mime type. return {@link false } if
+ * this type not supported by tidy.
+ *
+ * @param mimeType
+ * @return
+ */
+ public boolean setMime(String mimeType) {
+ if (null != mimeType) {
+ for (int i = 0; i < _htmlTypes.length; i++) {
+ String mime = _htmlTypes[i];
+ if (mimeType.startsWith(mime)) {
+ // setup html output
+ tidy.setXHTML(false);
+ tidy.setXmlOut(false);
+ if (log.isDebugEnabled()) {
+ log.debug("Print output as ordinary HTML");
+ }
+ return true;
+ }
+ }
+ for (int i = 0; i < _xhtmlTypes.length; i++) {
+ String mime = _xhtmlTypes[i];
+ if (mimeType.startsWith(mime)) {
+ // setup xhtml output
+ tidy.setXHTML(true);
+ tidy.setXmlOut(false);
+ if (log.isDebugEnabled()) {
+ log.debug("Print output as XHTML");
+ }
+ return true;
+ }
+ }
+ for (int i = 0; i < _xmlTypes.length; i++) {
+ String mime = _xmlTypes[i];
+ if (mimeType.startsWith(mime)) {
+ // setup html output
+ tidy.setXHTML(true);
+ tidy.setXmlOut(true);
+ tidy.setXmlPi(true);
+ tidy.setEscapeCdata(false);
+ tidy.setNumEntities(true);
+ if (log.isDebugEnabled()) {
+ log.debug("Print output as XML");
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.HtmlParser#setMoveElements(boolean)
+ */
+ public void setMoveElements(boolean move) {
+ tidy.setMoveElements(move);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.HtmlParser#setScripts(java.util.Set)
+ */
+ public void setScripts(Set scripts) {
+ this._scripts = scripts;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.HtmlParser#setStyles(java.util.Set)
+ */
+ public void setStyles(Set styles) {
+ this._styles = styles;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.HtmlParser#setDoctype(java.lang.String)
+ */
+ public void setDoctype(String doctype) {
+ tidy.setDocType("omit");//doctype);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.webapp.HtmlParser#setViewState(java.lang.String)
+ */
+ public void setViewState(String viewState) {
+ _viewState = viewState;
+ }
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyXMLFilter.java 2007-07-09 15:13:40 UTC (rev 1551)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -1,123 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax.xmlfilter.tidy;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser;
-import org.ajax4jsf.io.parser.FastHtmlParser;
-import org.apache.commons.collections.ArrayStack;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class TidyXMLFilter extends BaseXMLFilter {
- static final Log log = LogFactory.getLog(TidyXMLFilter.class);
- private Properties _tidyProperties;
- private static final int STACK_SIZE = 100;
-
- /**
- * Stack for handle parsers pool - to avoid instantiane on each request.
- */
- private ArrayStack _parsersPool = new ArrayStack(STACK_SIZE);
-
- public TidyXMLFilter() {}
-
- /**
- * Peturn parser to pool
- * @param parser
- */
- protected void reuseParser(HtmlParser parser) {
-// synchronized (_parsersPool) {
-// if (_parsersPool.size()<STACK_SIZE) {
-// if (log.isDebugEnabled()) {
-// log.debug("Push JTidy parser to pool");
-// }
-// _parsersPool.push(parser);
-// }
-// }
- }
-
- /**
- * Factory method for create parsing object - contain chain of parsing,
- * transformation and serialization of response output
- * @param string Encodings for parser
- * @return
- */
- protected HtmlParser getParser(String mime, boolean isAjax) {
- // For non-ajax, parse only html types !
- if (isAjax || mime.startsWith("text/html") || mime.startsWith("application/xhtml+xml")) {
- if(isAjax || isForcexml()){
- TidyParser parser ;
- parser = new TidyParser(getTidyProperties());
- // If tidy not handle all requests, disable reorganising of html
- parser.setMoveElements(isForcexml());
- // Setup configuration.
- if (parser.setMime(mime)) {
- // parser.setEncoding(encoding);
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.CREATE_JTIDY_INFO));
- }
- return parser;
- }
- } else {
- return new FastHtmlParser();
- }
- }
- return null;
- }
-
- private Properties getTidyProperties() {
- if (null == _tidyProperties) {
- _tidyProperties = new Properties();
- InputStream props = null;
- try {
- props = TidyXMLFilter.class.getResourceAsStream("tidy.properties");
- if (null != props) {
- _tidyProperties.load(props);
- }
- // Second part - user-defined properties.
- props = Thread.currentThread().getContextClassLoader().getResourceAsStream("tidy.properties");
- if (null != props) {
- _tidyProperties.load(props);
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- log.warn(Messages.getMessage(Messages.READING_TIDY_PROPERTIES_ERROR), e);
- } finally {
- if(null != props){
- try {
- props.close();
- } catch (IOException e) {
- // can be ignored
- }
- }
- }
- }
- return _tidyProperties;
-
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java (from rev 1558, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyXMLFilter.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/webapp/tidy/TidyXMLFilter.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -0,0 +1,123 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.webapp.tidy;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.io.parser.FastHtmlParser;
+import org.ajax4jsf.webapp.BaseXMLFilter;
+import org.ajax4jsf.webapp.HtmlParser;
+import org.apache.commons.collections.ArrayStack;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class TidyXMLFilter extends BaseXMLFilter {
+ static final Log log = LogFactory.getLog(TidyXMLFilter.class);
+ private Properties _tidyProperties;
+ private static final int STACK_SIZE = 100;
+
+ /**
+ * Stack for handle parsers pool - to avoid instantiane on each request.
+ */
+ private ArrayStack _parsersPool = new ArrayStack(STACK_SIZE);
+
+ public TidyXMLFilter() {}
+
+ /**
+ * Peturn parser to pool
+ * @param parser
+ */
+ protected void reuseParser(HtmlParser parser) {
+// synchronized (_parsersPool) {
+// if (_parsersPool.size()<STACK_SIZE) {
+// if (log.isDebugEnabled()) {
+// log.debug("Push JTidy parser to pool");
+// }
+// _parsersPool.push(parser);
+// }
+// }
+ }
+
+ /**
+ * Factory method for create parsing object - contain chain of parsing,
+ * transformation and serialization of response output
+ * @param string Encodings for parser
+ * @return
+ */
+ protected HtmlParser getParser(String mime, boolean isAjax, String viewId) {
+ // For non-ajax, parse only html types !
+ if (isAjax || mime.startsWith("text/html") || mime.startsWith("application/xhtml+xml")) {
+ if(isAjax || isForcexml()){
+ TidyParser parser ;
+ parser = new TidyParser(getTidyProperties());
+ // If tidy not handle all requests, disable reorganising of html
+ parser.setMoveElements(isForcexml());
+ // Setup configuration.
+ if (parser.setMime(mime)) {
+ // parser.setEncoding(encoding);
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.CREATE_JTIDY_INFO));
+ }
+ return parser;
+ }
+ } else {
+ return new FastHtmlParser();
+ }
+ }
+ return null;
+ }
+
+ private Properties getTidyProperties() {
+ if (null == _tidyProperties) {
+ _tidyProperties = new Properties();
+ InputStream props = null;
+ try {
+ props = TidyXMLFilter.class.getResourceAsStream("tidy.properties");
+ if (null != props) {
+ _tidyProperties.load(props);
+ }
+ // Second part - user-defined properties.
+ props = Thread.currentThread().getContextClassLoader().getResourceAsStream("tidy.properties");
+ if (null != props) {
+ _tidyProperties.load(props);
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ log.warn(Messages.getMessage(Messages.READING_TIDY_PROPERTIES_ERROR), e);
+ } finally {
+ if(null != props){
+ try {
+ props.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+ }
+ }
+ }
+ return _tidyProperties;
+
+ }
+
+}
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -20,9 +20,9 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXResult;
-import org.ajax4jsf.framework.ajax.xmlfilter.tidy.TidyParser;
-import org.ajax4jsf.framework.ajax.xmlfilter.tidy.TidyXMLFilter;
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
+import org.ajax4jsf.webapp.tidy.TidyParser;
+import org.ajax4jsf.webapp.tidy.TidyXMLFilter;
import org.richfaces.json.JSContentHandler;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
Modified: trunk/framework/impl/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/HtmlCorrectionFilterTestCase.java
===================================================================
--- trunk/framework/impl/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/HtmlCorrectionFilterTestCase.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/impl/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/HtmlCorrectionFilterTestCase.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -7,6 +7,7 @@
import java.util.Iterator;
import java.util.List;
+import org.ajax4jsf.webapp.nekko.HtmlCorrectionFilter;
import org.apache.xerces.util.XMLAttributesImpl;
import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni.NamespaceContext;
@@ -102,7 +103,7 @@
}
}
/**
- * Test method for {@link org.ajax4jsf.framework.ajax.xmlfilter.nekko.HtmlCorrectionFilter#endElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.Augmentations)}.
+ * Test method for {@link org.ajax4jsf.webapp.nekko.HtmlCorrectionFilter#endElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.Augmentations)}.
*/
public void testEndElementQNameAugmentations() {
startElement("html");//0
@@ -289,7 +290,7 @@
assertSequence(expect);
}
/**
- * Test method for {@link org.ajax4jsf.framework.ajax.xmlfilter.nekko.HtmlCorrectionFilter#startElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)}.
+ * Test method for {@link org.ajax4jsf.webapp.nekko.HtmlCorrectionFilter#startElement(org.apache.xerces.xni.QName, org.apache.xerces.xni.XMLAttributes, org.apache.xerces.xni.Augmentations)}.
*/
// public void testResVoid() {
// fail("Not yet implemented");
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/AllTests.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/AllTests.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/AllTests.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -28,7 +28,7 @@
public static Test suite() {
TestSuite suite = new TestSuite(
- "Test for org.ajax4jsf.framework.ajax.xmlfilter");
+ "Test for org.ajax4jsf.webapp");
//$JUnit-BEGIN$
suite.addTestSuite(CacheContentTest.class);
suite.addTestSuite(NekkoParserTest.class);
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContentTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContentTest.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContentTest.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -30,6 +30,7 @@
import java.io.PrintWriter;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.webapp.CacheContent;
import org.apache.shale.test.mock.MockPrintWriter;
import org.apache.shale.test.mock.MockServletOutputStream;
@@ -64,7 +65,7 @@
/**
- * Test method for {@link org.ajax4jsf.framework.ajax.xmlfilter.CacheContent#getOutputStream(java.io.OutputStream)}.
+ * Test method for {@link org.ajax4jsf.webapp.CacheContent#getOutputStream(java.io.OutputStream)}.
* @throws IOException
*/
public void testGetOutputStream() throws IOException {
@@ -93,7 +94,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.framework.ajax.xmlfilter.CacheContent#getWriter(java.io.Writer)}.
+ * Test method for {@link org.ajax4jsf.webapp.CacheContent#getWriter(java.io.Writer)}.
* @throws IOException
*/
public void testGetWriter() throws IOException {
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoParserTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoParserTest.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/NekkoParserTest.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -28,7 +28,7 @@
import junit.framework.TestCase;
-import org.ajax4jsf.framework.ajax.xmlfilter.nekko.NekkoParser;
+import org.ajax4jsf.webapp.nekko.NekkoParser;
public class NekkoParserTest extends TestCase {
@@ -47,7 +47,7 @@
}
/*
- * Test method for 'org.ajax4jsf.framework.ajax.xmlfilter.NekkoParser.parseHtml(Reader, Writer)'
+ * Test method for 'org.ajax4jsf.webapp.NekkoParser.parseHtml(Reader, Writer)'
*/
public void testParseHtmlReaderWriter() {
String html = "<html><body><table><tr><td>xxx</td></tr></table></body></html>";
Modified: trunk/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/framework/renderer/BeforeRendererListenerTestCase.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -26,9 +26,9 @@
import javax.faces.event.PhaseListener;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.webapp.BaseFilter;
+import org.ajax4jsf.webapp.FilterServletResponseWrapper;
/**
* @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIPush.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -29,7 +29,7 @@
import javax.servlet.http.HttpSession;
import org.ajax4jsf.ajax.PushEventsCounter;
-import org.ajax4jsf.framework.ajax.xmlfilter.PollEventsManager;
+import org.ajax4jsf.webapp.PollEventsManager;
/**
* Component for periodically call AJAX events on server ( poll actions )
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java 2007-07-10 00:39:15 UTC (rev 1558)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPageRenderer.java 2007-07-10 00:58:39 UTC (rev 1559)
@@ -32,9 +32,9 @@
import org.ajax4jsf.component.AjaxContainer;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.webapp.BaseFilter;
/**
* @author shura
17 years, 6 months
JBoss Rich Faces SVN: r1558 - in trunk: framework/impl/src/main/java/org/ajax4jsf/application and 16 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-09 20:39:15 -0400 (Mon, 09 Jul 2007)
New Revision: 1558
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/package.html
trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/AjaxScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/ImageCacheScript.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/ResourceBundleMap.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/ResourceBundleMap.java
trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/package.html
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxComponentRendererBase.java
trunk/framework/impl/src/main/resources/META-INF/resources-config.xml
trunk/framework/test/src/test/java/DnDScriptTest.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UILoadBundle.java
trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java
trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx
trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx
trunk/ui/tabPanel/src/main/templates/tabPanel.jspx
trunk/ui/togglePanel/src/main/templates/toggleControl.jspx
Log:
packages and classes refactor in the "impl" project
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/ResourceBundleMap.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/ResourceBundleMap.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/ResourceBundleMap.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -1,147 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-import org.ajax4jsf.Messages;
-
-/**
- * Very limited Map decorator to ResourceBundle.
- * @author shura
- *
- */
-public class ResourceBundleMap implements Map {
-
- private ResourceBundle _bundle;
-
- /**
- * @param bundle
- */
- public ResourceBundleMap(ResourceBundle bundle) {
- super();
- _bundle = bundle;
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#size()
- */
- public int size() {
- return 0;
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#isEmpty()
- */
- public boolean isEmpty() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#containsKey(java.lang.Object)
- */
- public boolean containsKey(Object key) {
-
- try {
- _bundle.getObject(key.toString());
- return true;
- } catch (MissingResourceException e) {
- return false;
- }
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#containsValue(java.lang.Object)
- */
- public boolean containsValue(Object value) {
- // TODO Auto-generated method stub
- return false;
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#get(java.lang.Object)
- */
- public Object get(Object key) {
- try {
- return _bundle.getObject(key.toString());
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#put(java.lang.Object, java.lang.Object)
- */
- public Object put(Object arg0, Object arg1) {
- throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_PUT_VALUE));
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#remove(java.lang.Object)
- */
- public Object remove(Object key) {
- throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_REMOVE_VALUE));
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#putAll(java.util.Map)
- */
- public void putAll(Map arg0) {
- throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_PUT_VALUE));
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#clear()
- */
- public void clear() {
- throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_REMOVE_VALUE));
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#keySet()
- */
- public Set keySet() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#values()
- */
- public Collection values() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see java.util.Map#entrySet()
- */
- public Set entrySet() {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/application/package.html (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/package.html)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/package.html (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/application/package.html 2007-07-10 00:39:15 UTC (rev 1558)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Cp1251"/>
+<title>Package description for AJAX components</title>
+</head>
+<body>
+</body>
+</html>
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -1,46 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd;
-
-import org.ajax4jsf.resource.ClientScript;
-
-/**
- * @author shura
- *
- */
-public class DnDScript extends ClientScript {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ClientScript#getJavaScript()
- */
- public String getJavaScript() {
- return "/org/ajax4jsf/framework/ajax/scripts/dnd.js";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ClientScript#isUsePrototype()
- */
- protected boolean isUsePrototype() {
- return true;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -1,58 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.ajax4jsf.resource.ClientScript;
-
-/**
- * Resource for AJAX client-side script. Render one time per page.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:33 $
- *
- */
-public class AjaxScript extends ClientScript {
-
- private static final Log _log = LogFactory.getLog(AjaxScript.class);
-
- /**
- * Set JavaScript renderer and modification time to application-startup time.
- */
- public AjaxScript() {
- super();
- if (_log.isDebugEnabled()) {
- _log.debug("AjaxScript() - Created instance of AjaxScript resource"); //$NON-NLS-1$
- }
- }
-
-
- /**
- * @return Returns the javaScript.
- */
- public String getJavaScript() {
- return "scripts/AJAX.js";
- }
-
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -1,55 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import org.ajax4jsf.resource.ClientScript;
-
-/**
- * Resource for Drag ' Drop client javascript
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:33 $
- *
- */
-public class ImageCacheScript extends ClientScript {
-
-
-
- /**
- *
- */
- public ImageCacheScript() {
- super();
- usePrototype=true;
-// setRenderer(new ScriptRenderer());
-// setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.ajax.ClientScript#getJavaScript()
- */
- public String getJavaScript() {
- // TODO Auto-generated method stub
- return "scripts/imagecache.js";
- }
-
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/package.html
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/package.html 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/package.html 2007-07-10 00:39:15 UTC (rev 1558)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=Cp1251"/>
-<title>Package description for AJAX components</title>
-</head>
-<body>
-</body>
-</html>
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxComponentRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxComponentRendererBase.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxComponentRendererBase.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -21,7 +21,7 @@
package org.ajax4jsf.framework.renderer;
-import org.ajax4jsf.framework.ajax.AjaxScript;
+import org.ajax4jsf.javascript.AjaxScript;
import org.ajax4jsf.renderkit.HeaderResourceProducer;
import org.ajax4jsf.resource.InternetResource;
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/AjaxScript.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/AjaxScript.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/AjaxScript.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.javascript;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.ajax4jsf.resource.ClientScript;
+
+/**
+ * Resource for AJAX client-side script. Render one time per page.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:33 $
+ *
+ */
+public class AjaxScript extends ClientScript {
+
+ private static final Log _log = LogFactory.getLog(AjaxScript.class);
+
+ /**
+ * Set JavaScript renderer and modification time to application-startup time.
+ */
+ public AjaxScript() {
+ super();
+ if (_log.isDebugEnabled()) {
+ _log.debug("AjaxScript() - Created instance of AjaxScript resource"); //$NON-NLS-1$
+ }
+ }
+
+
+ /**
+ * @return Returns the javaScript.
+ */
+ public String getJavaScript() {
+ return "scripts/AJAX.js";
+ }
+
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/DnDScript.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.javascript;
+
+import org.ajax4jsf.resource.ClientScript;
+
+/**
+ * @author shura
+ *
+ */
+public class DnDScript extends ClientScript {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ClientScript#getJavaScript()
+ */
+ public String getJavaScript() {
+ return "/org/ajax4jsf/framework/ajax/scripts/dnd.js";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ClientScript#isUsePrototype()
+ */
+ protected boolean isUsePrototype() {
+ return true;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/ImageCacheScript.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/ImageCacheScript.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/ImageCacheScript.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.javascript;
+
+import org.ajax4jsf.resource.ClientScript;
+
+/**
+ * Resource for Drag ' Drop client javascript
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:33 $
+ *
+ */
+public class ImageCacheScript extends ClientScript {
+
+
+
+ /**
+ *
+ */
+ public ImageCacheScript() {
+ super();
+ usePrototype=true;
+// setRenderer(new ScriptRenderer());
+// setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.ajax.ClientScript#getJavaScript()
+ */
+ public String getJavaScript() {
+ // TODO Auto-generated method stub
+ return "scripts/imagecache.js";
+ }
+
+
+}
Modified: trunk/framework/impl/src/main/resources/META-INF/resources-config.xml
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/resources-config.xml 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/framework/impl/src/main/resources/META-INF/resources-config.xml 2007-07-10 00:39:15 UTC (rev 1558)
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<resource-config>
- <resource class="org.ajax4jsf.framework.ajax.AjaxScript">
- <name>org.ajax4jsf.framework.ajax.AjaxScript</name>
+ <resource class="org.ajax4jsf.javascript.AjaxScript">
+ <name>org.ajax4jsf.javascript.AjaxScript</name>
</resource>
- <resource class="org.ajax4jsf.framework.ajax.AjaxScript">
+ <resource class="org.ajax4jsf.javascript.AjaxScript">
<name>ajax.js</name>
</resource>
<resource class="org.ajax4jsf.resource.PrototypeScript">
<name>prototype.js</name>
</resource>
- <resource class="org.ajax4jsf.dnd.DnDScript">
+ <resource class="org.ajax4jsf.javascript.DnDScript">
<name>dnd.js</name>
</resource>
<resource >
Modified: trunk/framework/test/src/test/java/DnDScriptTest.java
===================================================================
--- trunk/framework/test/src/test/java/DnDScriptTest.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/framework/test/src/test/java/DnDScriptTest.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -21,7 +21,7 @@
import java.io.IOException;
-import org.ajax4jsf.dnd.DnDScript;
+import org.ajax4jsf.javascript.DnDScript;
import org.ajax4jsf.resource.FacesResourceContext;
import org.ajax4jsf.resource.ResourceContext;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
Copied: trunk/ui/core/src/main/java/org/ajax4jsf/component/ResourceBundleMap.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/ajax/ResourceBundleMap.java)
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/ResourceBundleMap.java (rev 0)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/ResourceBundleMap.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -0,0 +1,147 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.component;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import org.ajax4jsf.Messages;
+
+/**
+ * Very limited Map decorator to ResourceBundle.
+ * @author shura
+ *
+ */
+public class ResourceBundleMap implements Map {
+
+ private ResourceBundle _bundle;
+
+ /**
+ * @param bundle
+ */
+ public ResourceBundleMap(ResourceBundle bundle) {
+ super();
+ _bundle = bundle;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#size()
+ */
+ public int size() {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#isEmpty()
+ */
+ public boolean isEmpty() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#containsKey(java.lang.Object)
+ */
+ public boolean containsKey(Object key) {
+
+ try {
+ _bundle.getObject(key.toString());
+ return true;
+ } catch (MissingResourceException e) {
+ return false;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#containsValue(java.lang.Object)
+ */
+ public boolean containsValue(Object value) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#get(java.lang.Object)
+ */
+ public Object get(Object key) {
+ try {
+ return _bundle.getObject(key.toString());
+ } catch (MissingResourceException e) {
+ return key;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#put(java.lang.Object, java.lang.Object)
+ */
+ public Object put(Object arg0, Object arg1) {
+ throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_PUT_VALUE));
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#remove(java.lang.Object)
+ */
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_REMOVE_VALUE));
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#putAll(java.util.Map)
+ */
+ public void putAll(Map arg0) {
+ throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_PUT_VALUE));
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#clear()
+ */
+ public void clear() {
+ throw new UnsupportedOperationException(Messages.getMessage(Messages.BUNDLE_MAP_NO_REMOVE_VALUE));
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#keySet()
+ */
+ public Set keySet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#values()
+ */
+ public Collection values() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Map#entrySet()
+ */
+ public Set entrySet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UILoadBundle.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UILoadBundle.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UILoadBundle.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -31,7 +31,6 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.ajax.ResourceBundleMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
===================================================================
--- trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2007-07-10 00:39:15 UTC (rev 1558)
@@ -13,7 +13,7 @@
<h:scripts>
new org.ajax4jsf.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
</h:scripts>
<f:clientid var="clientId"/>
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -29,8 +29,8 @@
import javax.faces.context.FacesContext;
import javax.faces.event.FacesEvent;
-import org.ajax4jsf.dnd.DnDScript;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.javascript.DnDScript;
import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -28,8 +28,8 @@
import javax.faces.context.FacesContext;
import javax.faces.event.FacesEvent;
-import org.ajax4jsf.dnd.DnDScript;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.javascript.DnDScript;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DragSupportRenderer.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -28,8 +28,8 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.ajax.AjaxScript;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.javascript.AjaxScript;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.UIDragSupport;
Modified: trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java
===================================================================
--- trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/html/DropSupportRenderer.java 2007-07-10 00:39:15 UTC (rev 1558)
@@ -28,8 +28,8 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.framework.ajax.AjaxScript;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.javascript.AjaxScript;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.UIDropSupport;
Modified: trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx
===================================================================
--- trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/drag-drop/src/main/templates/org/richfaces/htmlDragIndicator.jspx 2007-07-10 00:39:15 UTC (rev 1558)
@@ -13,8 +13,8 @@
<h:scripts>
new org.ajax4jsf.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript(),
- new org.ajax4jsf.dnd.DnDScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
+ new org.ajax4jsf.javascript.DnDScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
/org/richfaces/renderkit/html/scripts/json/json-dom.js,
/org/richfaces/renderkit/html/scripts/dnd/dnd-common.js,
Modified: trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
===================================================================
--- trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-07-10 00:39:15 UTC (rev 1558)
@@ -13,7 +13,7 @@
<h:scripts>
new org.ajax4jsf.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
scripts/menu.js
</h:scripts>
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
===================================================================
--- trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-07-10 00:39:15 UTC (rev 1558)
@@ -14,7 +14,7 @@
<h:scripts>
new org.ajax4jsf.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript()
+ new org.ajax4jsf.javascript.AjaxScript()
</h:scripts>
<f:clientid var="clientId"/>
Modified: trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx
===================================================================
--- trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/menu-components/src/main/templates/org/richfaces/htmlMenuItem.jspx 2007-07-10 00:39:15 UTC (rev 1558)
@@ -13,7 +13,7 @@
<h:scripts>
new org.ajax4jsf.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
/org/richfaces/renderkit/html/scripts/utils.js,
/org/ajax4jsf/renderkit/html/scripts/form.js,
/org/richfaces/renderkit/html/scripts/form.js
Modified: trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx
===================================================================
--- trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/simpleTogglePanel/src/main/templates/simpleTogglePanel.jspx 2007-07-10 00:39:15 UTC (rev 1558)
@@ -13,8 +13,8 @@
<h:styles>css/simpleTogglePanel.xcss</h:styles>
<h:scripts>
new org.ajax4jsf.resource.PrototypeScript(),
-new org.ajax4jsf.framework.ajax.AjaxScript(),
-new org.ajax4jsf.framework.ajax.ImageCacheScript(),
+new org.ajax4jsf.javascript.AjaxScript(),
+new org.ajax4jsf.javascript.ImageCacheScript(),
/org/ajax4jsf/renderkit/html/scripts/form.js,
/org/richfaces/renderkit/html/scripts/browser_info.js,
scripts/simpleTogglePanel.js
Modified: trunk/ui/tabPanel/src/main/templates/tabPanel.jspx
===================================================================
--- trunk/ui/tabPanel/src/main/templates/tabPanel.jspx 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/tabPanel/src/main/templates/tabPanel.jspx 2007-07-10 00:39:15 UTC (rev 1558)
@@ -13,8 +13,8 @@
<h:styles>css/tabPanel.xcss</h:styles>
<h:scripts>
new org.ajax4jsf.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript(),
- new org.ajax4jsf.framework.ajax.ImageCacheScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
+ new org.ajax4jsf.javascript.ImageCacheScript(),
/org/richfaces/renderkit/html/scripts/browser_info.js,
/org/ajax4jsf/renderkit/html/scripts/form.js,
scripts/tabPanel.js
Modified: trunk/ui/togglePanel/src/main/templates/toggleControl.jspx
===================================================================
--- trunk/ui/togglePanel/src/main/templates/toggleControl.jspx 2007-07-10 00:31:28 UTC (rev 1557)
+++ trunk/ui/togglePanel/src/main/templates/toggleControl.jspx 2007-07-10 00:39:15 UTC (rev 1558)
@@ -12,7 +12,7 @@
<h:styles>css/toggleControl.xcss</h:styles>
<h:scripts>
new org.ajax4jsf.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
scripts/togglePanel.js
</h:scripts> <f:clientid var="clientId"/>
<a id="#{clientId}" href="#"
17 years, 6 months
JBoss Rich Faces SVN: r1557 - in trunk/framework/impl/src/main/java/org/ajax4jsf: application and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-09 20:31:28 -0400 (Mon, 09 Jul 2007)
New Revision: 1557
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java
trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyParser.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyXMLFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
Log:
packages and classes refactor in the "impl" project
Merge configurable XML filter from ajax4jsf 1.1.2
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/Filter.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -21,7 +21,7 @@
package org.ajax4jsf;
-import org.ajax4jsf.framework.ajax.xmlfilter.TidyFilter;
+import org.ajax4jsf.framework.ajax.xmlfilter.ConfigurableFilter;
/**
* Proxy for resource/ajax xml parsing filter.
@@ -29,6 +29,6 @@
* @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:29 $
*
*/
-public class Filter extends TidyFilter {
+public class Filter extends ConfigurableFilter {
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -60,6 +60,8 @@
private static final String REDIRECTED = "org.ajax4jsf.view.REDIRECTED";
+ public static final String VIEW_ID_KEY = "org.ajax4jsf.VIEW_ID";
+
/**
* @param parent
*/
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -385,6 +385,9 @@
}
// Mark as processed.
requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
+ // Save viewId for a parser selection
+ requestMap.put(
+ AjaxViewHandler.VIEW_ID_KEY,root.getViewId());
}
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -67,9 +67,12 @@
private static final String NAMESPACE_PARAMETER = "namespace";
private boolean forcexml = false;
+
private static final String FORCEXML_PARAMETER = "forceparser";
+ private static final String INIT_PARAMETER_PREFIX = "org.ajax4jsf.xmlfilter.";
+
public BaseFilter filter;
public void setFilter(BaseFilter filter) {
@@ -81,14 +84,10 @@
log.debug("init XML filter service with class "
+ this.getClass().getName());
}
- if ("false".equalsIgnoreCase(config
- .getInitParameter(FORCEXML_PARAMETER))) {
- this.forcexml = false;
- }
- if ("true"
- .equalsIgnoreCase(config.getInitParameter(FORCEXML_PARAMETER))) {
- this.forcexml = true;
- }
+ String forceXmlParameter = config
+ .getInitParameter(FORCEXML_PARAMETER);
+ setupForceXml(forceXmlParameter);
+ forceXmlParameter = config.getServletContext().getInitParameter(INIT_PARAMETER_PREFIX+FORCEXML_PARAMETER);
setMimetype((String) nz(config.getInitParameter(MIME_TYPE_PARAMETER),
"text/xml"));
setPublicid((String) nz(config.getInitParameter(PUBLICID_PARAMETER),
@@ -100,6 +99,19 @@
}
/**
+ * @param forceXmlParameter
+ */
+ private void setupForceXml(String forceXmlParameter) {
+ if ("false".equalsIgnoreCase(forceXmlParameter)) {
+ this.forcexml = false;
+ }
+ if ("true"
+ .equalsIgnoreCase(forceXmlParameter)) {
+ this.forcexml = true;
+ }
+ }
+
+ /**
* Perform filter chain with xml parsing and transformation. Subclasses
* must implement concrete HTML to XML parsing, nesseasary
* transformations and serialization.
@@ -125,6 +137,7 @@
.setAttribute(RESPONSE_WRAPPER_ATTRIBUTE,
servletResponseWrapper);
chain.doFilter(request, servletResponseWrapper);
+ String viewId = (String) request.getAttribute(AjaxViewHandler.VIEW_ID_KEY);
HtmlParser parser = null;
// setup response
// Redirect in AJAX request - convert to special response recognized by
@@ -203,7 +216,7 @@
String outputEncoding = "UTF-8";
String contentType = getMimetype() + ";charset=" + outputEncoding;
response.setContentType(contentType);
- parser = getParser(getMimetype(), true);
+ parser = getParser(getMimetype(), true, viewId);
if (null == parser) {
throw new ServletException(Messages.getMessage(
Messages.PARSER_NOT_INSTANTIATED_ERROR, contentType));
@@ -231,7 +244,7 @@
&& null != characterEncoding) {
contentType += ";charset=" + characterEncoding;
}
- parser = getParser(contentType, false);
+ parser = getParser(contentType, false, viewId);
response.setContentType(contentType);
}
// null or unsupported content type
@@ -332,7 +345,7 @@
protected abstract void reuseParser(HtmlParser parser);
- protected abstract HtmlParser getParser(String mimetype, boolean isAjax);
+ protected abstract HtmlParser getParser(String mimetype, boolean isAjax, String viewId);
/**
* @param publicid
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -149,7 +149,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String,
+ * @see org.ajax4jsf.framework.resource.ResourceContext#setHeader(java.lang.String,
* java.lang.String)
*/
public void setHeader(String name, String value) {
@@ -159,7 +159,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String,
+ * @see org.ajax4jsf.framework.resource.ResourceContext#setIntHeader(java.lang.String,
* int)
*/
public void setIntHeader(String name, int value) {
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableFilter.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -0,0 +1,20 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax.xmlfilter;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ConfigurableFilter extends BaseFilter {
+
+ /**
+ *
+ */
+ public ConfigurableFilter() {
+ xmlFilter = new ConfigurableXMLFilter();
+ xmlFilter.setFilter(this);
+ }
+
+}
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ConfigurableXMLFilter.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -0,0 +1,237 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax.xmlfilter;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.EmptyStackException;
+import java.util.Properties;
+import java.util.regex.PatternSyntaxException;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.framework.ajax.xmlfilter.nekko.NekkoParser;
+import org.ajax4jsf.framework.ajax.xmlfilter.tidy.TidyParser;
+import org.ajax4jsf.io.parser.FastHtmlParser;
+import org.apache.commons.collections.ArrayStack;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ConfigurableXMLFilter extends BaseXMLFilter {
+
+ private static final Log log = LogFactory
+ .getLog(ConfigurableXMLFilter.class);
+
+ private static final String PARSERS_LIST_PARAMETER = "org.ajax4jsf.xmlparsers";
+
+ private static final String VIEW_ID_PATTERN_PARAMETER = "org.ajax4jsf.xmlparser.";
+
+ /**
+ * map of the parsers names and viewId patterns for all parser type.
+ */
+ private ParserConfig parsers = new TidyParserConfig();
+
+ // private ParserConfig passParserConfig = new PassParserConfig();
+
+ public void init(FilterConfig config) throws ServletException {
+ super.init(config);
+ ServletContext servletContext = config.getServletContext();
+ String parsersParameter = servletContext
+ .getInitParameter(PARSERS_LIST_PARAMETER);
+ if (null != parsersParameter) {
+ configureParsers(servletContext, parsersParameter);
+ }
+ }
+
+ /**
+ * @param servletContext
+ * @param parsersParameter
+ * @throws ServletException
+ */
+ public void configureParsers(ServletContext servletContext,
+ String parsersParameter) throws ServletException {
+ String[] parsersNames = parsersParameter.split("\\s*,\\s*");
+ for (int i = parsersNames.length - 1; i >= 0; i--) {
+ String parserName = parsersNames[i];
+ ParserConfig parserConfig;
+ if ("TIDY".equals(parserName)) {
+ parserConfig = new TidyParserConfig();
+ } else if ("NEKO".equals(parserName)) {
+ parserConfig = new NekoParserConfig();
+ } else if ("PASS".equals(parserName)) {
+ parserConfig = new PassParserConfig();
+ } else {
+ throw new ServletException(
+ "Unknown XML parser type in config parameter "
+ + parserName);
+ }
+ parserConfig.setNext(parsers);
+ if (null != servletContext) {
+ try {
+ String parserViewPattern = servletContext
+ .getInitParameter(VIEW_ID_PATTERN_PARAMETER
+ + parserName);
+ parserConfig.setPatterns(parserViewPattern);
+
+ } catch (PatternSyntaxException e) {
+ throw new ServletException("Invalid pattern for a parser "
+ + parserName + " :" + e.getMessage());
+ }
+ }
+ parsers = parserConfig;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter#getParser(java.lang.String,
+ * boolean, java.lang.String)
+ */
+ protected HtmlParser getParser(String mimetype, boolean isAjax,
+ String viewId) {
+ HtmlParser parser = null;
+ if (isAjax || isForcexml()) {
+ parser = parsers.getParser(viewId, mimetype);
+ } else if (mimetype.startsWith("text/html")
+ || mimetype.startsWith("application/xhtml+xml")) {
+ parser = new FastHtmlParser();
+ }
+ return parser;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter#reuseParser(org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser)
+ */
+ protected void reuseParser(HtmlParser parser) {
+ parsers.reuseParser(parser);
+
+ }
+
+ private static final int STACK_SIZE = 100;
+
+ private ArrayStack _xhtmlParsersPool = new ArrayStack(STACK_SIZE);
+
+ private class NekoParserConfig extends ParserConfig {
+
+ protected HtmlParser createParser(String mime) {
+ 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());
+ }
+ // TODO - set header scripts/styles filter.
+ return parser;
+ }
+
+ boolean storeParser(HtmlParser parser) {
+ if (null != parser && parser instanceof NekkoParser) {
+ synchronized (_xhtmlParsersPool) {
+ if (_xhtmlParsersPool.size() < STACK_SIZE) {
+ ((NekkoParser) parser).reset();
+ _xhtmlParsersPool.push(parser);
+ }
+
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+
+ private class TidyParserConfig extends ParserConfig {
+
+ protected HtmlParser createParser(String mime) {
+ // TODO Auto-generated method stub
+ TidyParser tidyParser = new TidyParser(getTidyProperties());
+ tidyParser.setMoveElements(isForcexml());
+ tidyParser.setMime(mime);
+ return tidyParser;
+ }
+
+ }
+
+ private class PassParserConfig extends ParserConfig {
+
+ protected HtmlParser createParser(String mime) {
+ return new FastHtmlParser();
+ }
+
+ }
+
+ private Properties _tidyProperties;
+
+ private Properties getTidyProperties() {
+ if (null == _tidyProperties) {
+ _tidyProperties = new Properties();
+ InputStream defaultprops = null;
+ InputStream props = null;
+ try {
+ defaultprops = TidyParser.class
+ .getResourceAsStream("tidy.properties");
+ if (null != defaultprops) {
+ _tidyProperties.load(defaultprops);
+ if (log.isDebugEnabled()) {
+ log.debug("default tidy parser properties loaded");
+ }
+ } else if (log.isDebugEnabled()) {
+ log.debug("No default tidy parser properties found");
+ }
+
+ // Second part - user-defined properties.
+ props = Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream("tidy.properties");
+ if (null != props) {
+ _tidyProperties.load(props);
+ if (log.isDebugEnabled()) {
+ log.debug("application-specific tidy parser properties loaded");
+ }
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ log.warn(Messages
+ .getMessage(Messages.READING_TIDY_PROPERTIES_ERROR), e);
+ } finally {
+ if (null != props) {
+ try {
+ props.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+ }
+ if (null != defaultprops) {
+ try {
+ defaultprops.close();
+ } catch (IOException e) {
+ // can be ignored
+ }
+ }
+ }
+ }
+ return _tidyProperties;
+ }
+
+ public ParserConfig getParsers() {
+ return parsers;
+ }
+
+}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/HtmlParser.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -66,4 +66,6 @@
*/
public abstract void setViewState(String viewState);
+ public abstract boolean setMime(String mimeType);
+
}
\ No newline at end of file
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/ParserConfig.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax.xmlfilter;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+abstract class ParserConfig {
+
+ private static final Pattern[] ALL_VIEWS_PATTERN = { Pattern.compile(".*") };
+
+ private static final Pattern SEPARATOR_PATTERN = Pattern.compile("\\s*,\\s*");
+
+ private Pattern[] patterns = ALL_VIEWS_PATTERN;
+
+ private ParserConfig next;
+
+ protected abstract HtmlParser createParser(String mimetype);
+
+ boolean storeParser(HtmlParser parser) {
+ return false;
+ }
+
+ HtmlParser getParser(String viewId, String mimetype) {
+ HtmlParser result = null;
+ for (int i = 0; i < patterns.length && null == result; i++) {
+ Matcher matcher = patterns[i].matcher(viewId);
+ if (matcher.matches()) {
+ result = createParser(mimetype);
+ }
+ }
+ if (null == result && null != next) {
+ result = next.getParser(viewId, mimetype);
+ }
+ return result;
+ }
+
+ public void reuseParser(HtmlParser parser) {
+ if (!storeParser(parser) && null != next) {
+ next.reuseParser(parser);
+ }
+ }
+
+ public ParserConfig getNext() {
+ return next;
+ }
+
+ public void setNext(ParserConfig next) {
+ this.next = next;
+ }
+
+ public void setPatterns(String patternsString) {
+ if (null != patternsString) {
+ String[] split = SEPARATOR_PATTERN.split(patternsString);
+ patterns = new Pattern[split.length];
+ for (int i = 0; i < split.length; i++) {
+ patterns[i]=Pattern.compile(split[i].trim());
+ }
+ }
+ }
+
+ public Pattern[] getPatterns() {
+ return patterns;
+ }
+
+}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -108,7 +108,8 @@
*/
public NekkoParser() {
_parser=new HtmlSAXParser(getHtmlConfig());
- Properties properties = OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML);
+// Properties properties = OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML);
+ Properties properties = OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
// properties.put("encoding",_encoding);
_serializer = SerializerFactory.getSerializer(properties);
// serializer.setOutputStream(output);
@@ -641,4 +642,8 @@
_systemid = systemid;
}
+ public boolean setMime(String mimeType) {
+ return false;
+ }
+
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoXMLFilter.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoXMLFilter.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -36,7 +36,7 @@
public NekkoXMLFilter() {}
- protected HtmlParser getParser(String mimetype, boolean isAjax) {
+ protected HtmlParser getParser(String mimetype, boolean isAjax, String viewId) {
HtmlParser parser = null;
if( isAjax ){
parser = getXmlParser();
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyParser.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyParser.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -40,7 +40,6 @@
import org.ajax4jsf.org.w3c.tidy.TidyMessageListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.impl.NoOpLog;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -323,7 +322,9 @@
// setup html output
tidy.setXHTML(false);
tidy.setXmlOut(false);
- // TODO - auto doctype ?
+ if (log.isDebugEnabled()) {
+ log.debug("Print output as ordinary HTML");
+ }
return true;
}
}
@@ -333,6 +334,9 @@
// setup xhtml output
tidy.setXHTML(true);
tidy.setXmlOut(false);
+ if (log.isDebugEnabled()) {
+ log.debug("Print output as XHTML");
+ }
return true;
}
}
@@ -345,6 +349,9 @@
tidy.setXmlPi(true);
tidy.setEscapeCdata(false);
tidy.setNumEntities(true);
+ if (log.isDebugEnabled()) {
+ log.debug("Print output as XML");
+ }
return true;
}
}
@@ -385,7 +392,7 @@
* @see org.ajax4jsf.framework.ajax.xmlfilter.HtmlParser#setDoctype(java.lang.String)
*/
public void setDoctype(String doctype) {
- tidy.setDocType(doctype);
+ tidy.setDocType("omit");//doctype);
}
/*
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyXMLFilter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyXMLFilter.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/tidy/TidyXMLFilter.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -66,7 +66,7 @@
* @param string Encodings for parser
* @return
*/
- protected HtmlParser getParser(String mime, boolean isAjax) {
+ protected HtmlParser getParser(String mime, boolean isAjax, String viewId) {
// For non-ajax, parse only html types !
if (isAjax || mime.startsWith("text/html") || mime.startsWith("application/xhtml+xml")) {
if(isAjax || isForcexml()){
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2007-07-10 00:17:10 UTC (rev 1556)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2007-07-10 00:31:28 UTC (rev 1557)
@@ -56,6 +56,8 @@
private String viewState;
+ private String mimeType;
+
public void parse(Reader in, Writer out) throws IOException {
boolean haveHtml = false;
boolean haveHead = false;
@@ -163,7 +165,7 @@
private void writeToHead(Writer out, boolean haveHtml, boolean haveHead)
throws IOException {
if (!haveHead && !haveHtml) {
- out.write("<html>");
+ out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
}
if (!haveHead) {
out.write("<head>");
@@ -252,4 +254,9 @@
this.viewState = viewState;
}
+
+ public boolean setMime(String mimeType) {
+ this.mimeType=mimeType;
+ return true;
+ }
}
17 years, 6 months
JBoss Rich Faces SVN: r1556 - in trunk: framework/impl/src/main/java/org/ajax4jsf and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-07-09 20:17:10 -0400 (Mon, 09 Jul 2007)
New Revision: 1556
Added:
trunk/framework/api/src/main/java/org/ajax4jsf/component/JavaScriptParameter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/event/
trunk/framework/impl/src/main/java/org/ajax4jsf/event/AjaxListenerHelper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/event/AjaxValidationActionEvent.java
trunk/framework/impl/src/main/java/org/ajax4jsf/event/InitPhaseListener.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxListenerHelper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxValidationActionEvent.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/InitPhaseListener.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/JavaScriptParameter.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
trunk/framework/impl/src/main/resources/META-INF/faces-config.xml
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIActionParameter.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
Log:
packages and classes refactor in the "impl" project
Copied: trunk/framework/api/src/main/java/org/ajax4jsf/component/JavaScriptParameter.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/JavaScriptParameter.java)
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/component/JavaScriptParameter.java (rev 0)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/component/JavaScriptParameter.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -0,0 +1,37 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.component;
+
+/**
+ * Interface for extend {@link javax.faces.component.UIParameter} component by
+ * handling isertion parameters into JavaScript code as references, not string literals.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:40 $
+ *
+ */
+public interface JavaScriptParameter {
+
+ public void setNoEscape(boolean noEscape);
+
+ public boolean isNoEscape();
+
+}
\ No newline at end of file
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/event/AjaxListenerHelper.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxListenerHelper.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/event/AjaxListenerHelper.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/event/AjaxListenerHelper.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -0,0 +1,120 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.event;
+
+import java.io.Serializable;
+
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.event.AjaxListener;
+
+/**
+ * Helper class to keep reference to listener binded as EL-expression.
+ * @author shura
+ *
+ */
+public class AjaxListenerHelper implements AjaxListener,StateHolder {
+
+
+ private ValueBinding _binding;
+
+
+ private boolean _transient = false;
+
+
+ /**
+ *
+ */
+ public AjaxListenerHelper() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param binding
+ */
+ public AjaxListenerHelper(ValueBinding binding) {
+ super();
+ if (null == binding) {
+ throw new IllegalArgumentException("Binding expression for AjaxListener helper must be not null");
+ }
+ _binding = binding;
+ }
+
+ private AjaxListener getHandler(FacesContext context) {
+ return (AjaxListener) _binding.getValue(context);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public void restoreState(FacesContext context, Object state) {
+ State helperState = (State) state;
+ _binding = (ValueBinding) UIComponentBase.restoreAttachedState(context,helperState.binding);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ State helperState = new State();
+ helperState.binding = UIComponentBase.saveAttachedState(context,_binding);
+ return helperState;
+ }
+
+ /**
+ * @return Returns the transient.
+ */
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ /**
+ * @param transient1 The transient to set.
+ */
+ public void setTransient(boolean transient1) {
+ _transient = transient1;
+ }
+
+ /**
+ * @author shura
+ *
+ */
+ private static class State implements Serializable {
+
+
+ private Object binding;
+
+
+ }
+
+ public void processAjax(AjaxEvent event) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ AjaxListener handler = getHandler(context);
+ handler.processAjax(event);
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/event/AjaxValidationActionEvent.java (from rev 1551, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxValidationActionEvent.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/event/AjaxValidationActionEvent.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/event/AjaxValidationActionEvent.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -0,0 +1,59 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.PhaseId;
+
+/**
+ * Action event - always assigned to {@link javax.faces.event.PhaseId#PROCESS_VALIDATIONS} phase
+ * for bypass change phase in components , setPhaseId method do nothing.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:37 $
+ *
+ */
+public class AjaxValidationActionEvent extends ActionEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 941784856915815112L;
+
+ /**
+ * @param component
+ */
+ public AjaxValidationActionEvent(UIComponent component) {
+ super(component);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#getPhaseId()
+ */
+ public PhaseId getPhaseId() {
+ // TODO Auto-generated method stub
+ return PhaseId.PROCESS_VALIDATIONS;
+ }
+
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/event/InitPhaseListener.java (from rev 1555, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/InitPhaseListener.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/event/InitPhaseListener.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/event/InitPhaseListener.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -0,0 +1,108 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.event;
+
+import java.util.Iterator;
+
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+
+import org.ajax4jsf.application.AjaxStateManager;
+import org.ajax4jsf.application.AjaxViewHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * One time called listener, for initialize framework at first request.
+ * @author shura
+ *
+ */
+public class InitPhaseListener implements PhaseListener {
+
+ private boolean removed= false;
+ private boolean initialized = false;
+
+ private static final Log log = LogFactory.getLog(InitPhaseListener.class);
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
+ */
+ public synchronized void afterPhase(PhaseEvent event) {
+ if (!removed) {
+ if(log.isDebugEnabled()){
+ log.debug("Remove init phase listener from factories");
+ }
+ LifecycleFactory factory = (LifecycleFactory)
+ FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ for(Iterator iter = factory.getLifecycleIds(); iter.hasNext(); ) {
+ Lifecycle lifecycle = factory.getLifecycle((String) iter.next());
+ lifecycle.removePhaseListener(this);
+ }
+ removed = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#beforePhase(javax.faces.event.PhaseEvent)
+ */
+ public synchronized void beforePhase(PhaseEvent event) {
+ if(!initialized){
+ if(log.isDebugEnabled()){
+ log.debug("Perform additional framework initialization on first request");
+ }
+ FacesContext facesContext = event.getFacesContext();
+ Application application = facesContext.getApplication();
+ StateManager stateManager = application.getStateManager();
+ if(! (stateManager instanceof AjaxStateManager)){
+ if(log.isDebugEnabled()){
+ log.debug("Set AjaxStateManager on top of chain");
+ }
+ application.setStateManager(new AjaxStateManager(stateManager));
+ }
+ ViewHandler viewHandler = application.getViewHandler();
+ if (!(viewHandler instanceof AjaxViewHandler)) {
+ if(log.isDebugEnabled()){
+ log.debug("Set AjaxViewHandler on top of chain");
+ }
+ application.setViewHandler(new AjaxViewHandler(viewHandler));
+ }
+ initialized = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#getPhaseId()
+ */
+ public PhaseId getPhaseId() {
+ // TODO Auto-generated method stub
+ return PhaseId.ANY_PHASE;
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxListenerHelper.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxListenerHelper.java 2007-07-10 00:08:19 UTC (rev 1555)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxListenerHelper.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -1,120 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.io.Serializable;
-
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.event.AjaxEvent;
-import org.ajax4jsf.event.AjaxListener;
-
-/**
- * Helper class to keep reference to listener binded as EL-expression.
- * @author shura
- *
- */
-public class AjaxListenerHelper implements AjaxListener,StateHolder {
-
-
- private ValueBinding _binding;
-
-
- private boolean _transient = false;
-
-
- /**
- *
- */
- public AjaxListenerHelper() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param binding
- */
- public AjaxListenerHelper(ValueBinding binding) {
- super();
- if (null == binding) {
- throw new IllegalArgumentException("Binding expression for AjaxListener helper must be not null");
- }
- _binding = binding;
- }
-
- private AjaxListener getHandler(FacesContext context) {
- return (AjaxListener) _binding.getValue(context);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
- State helperState = (State) state;
- _binding = (ValueBinding) UIComponentBase.restoreAttachedState(context,helperState.binding);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- State helperState = new State();
- helperState.binding = UIComponentBase.saveAttachedState(context,_binding);
- return helperState;
- }
-
- /**
- * @return Returns the transient.
- */
- public boolean isTransient() {
- return _transient;
- }
-
- /**
- * @param transient1 The transient to set.
- */
- public void setTransient(boolean transient1) {
- _transient = transient1;
- }
-
- /**
- * @author shura
- *
- */
- private static class State implements Serializable {
-
-
- private Object binding;
-
-
- }
-
- public void processAjax(AjaxEvent event) {
- FacesContext context = FacesContext.getCurrentInstance();
- AjaxListener handler = getHandler(context);
- handler.processAjax(event);
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxValidationActionEvent.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxValidationActionEvent.java 2007-07-10 00:08:19 UTC (rev 1555)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxValidationActionEvent.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -1,59 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.PhaseId;
-
-/**
- * Action event - always assigned to {@link javax.faces.event.PhaseId#PROCESS_VALIDATIONS} phase
- * for bypass change phase in components , setPhaseId method do nothing.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:37 $
- *
- */
-public class AjaxValidationActionEvent extends ActionEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = 941784856915815112L;
-
- /**
- * @param component
- */
- public AjaxValidationActionEvent(UIComponent component) {
- super(component);
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#getPhaseId()
- */
- public PhaseId getPhaseId() {
- // TODO Auto-generated method stub
- return PhaseId.PROCESS_VALIDATIONS;
- }
-
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/InitPhaseListener.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/InitPhaseListener.java 2007-07-10 00:08:19 UTC (rev 1555)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/InitPhaseListener.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -1,108 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.util.Iterator;
-
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.StateManager;
-import javax.faces.application.ViewHandler;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.event.PhaseListener;
-import javax.faces.lifecycle.Lifecycle;
-import javax.faces.lifecycle.LifecycleFactory;
-
-import org.ajax4jsf.application.AjaxStateManager;
-import org.ajax4jsf.application.AjaxViewHandler;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * One time called listener, for initialize framework at first request.
- * @author shura
- *
- */
-public class InitPhaseListener implements PhaseListener {
-
- private boolean removed= false;
- private boolean initialized = false;
-
- private static final Log log = LogFactory.getLog(InitPhaseListener.class);
-
- /* (non-Javadoc)
- * @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
- */
- public synchronized void afterPhase(PhaseEvent event) {
- if (!removed) {
- if(log.isDebugEnabled()){
- log.debug("Remove init phase listener from factories");
- }
- LifecycleFactory factory = (LifecycleFactory)
- FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
- for(Iterator iter = factory.getLifecycleIds(); iter.hasNext(); ) {
- Lifecycle lifecycle = factory.getLifecycle((String) iter.next());
- lifecycle.removePhaseListener(this);
- }
- removed = true;
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.PhaseListener#beforePhase(javax.faces.event.PhaseEvent)
- */
- public synchronized void beforePhase(PhaseEvent event) {
- if(!initialized){
- if(log.isDebugEnabled()){
- log.debug("Perform additional framework initialization on first request");
- }
- FacesContext facesContext = event.getFacesContext();
- Application application = facesContext.getApplication();
- StateManager stateManager = application.getStateManager();
- if(! (stateManager instanceof AjaxStateManager)){
- if(log.isDebugEnabled()){
- log.debug("Set AjaxStateManager on top of chain");
- }
- application.setStateManager(new AjaxStateManager(stateManager));
- }
- ViewHandler viewHandler = application.getViewHandler();
- if (!(viewHandler instanceof AjaxViewHandler)) {
- if(log.isDebugEnabled()){
- log.debug("Set AjaxViewHandler on top of chain");
- }
- application.setViewHandler(new AjaxViewHandler(viewHandler));
- }
- initialized = true;
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.PhaseListener#getPhaseId()
- */
- public PhaseId getPhaseId() {
- // TODO Auto-generated method stub
- return PhaseId.ANY_PHASE;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/JavaScriptParameter.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/JavaScriptParameter.java 2007-07-10 00:08:19 UTC (rev 1555)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/JavaScriptParameter.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -1,37 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-/**
- * Interface for extend {@link javax.faces.component.UIParameter} component by
- * handling isertion parameters into JavaScript code as references, not string literals.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:40 $
- *
- */
-public interface JavaScriptParameter {
-
- public void setNoEscape(boolean noEscape);
-
- public boolean isNoEscape();
-
-}
\ No newline at end of file
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-07-10 00:08:19 UTC (rev 1555)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -49,8 +49,8 @@
import org.ajax4jsf.component.AjaxLoadBundleComponent;
import org.ajax4jsf.component.AjaxSupport;
import org.ajax4jsf.component.AjaxViewRoot;
+import org.ajax4jsf.component.JavaScriptParameter;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.framework.ajax.JavaScriptParameter;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.framework.util.ServicesUtils;
import org.ajax4jsf.javascript.JSFunction;
Modified: trunk/framework/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/faces-config.xml 2007-07-10 00:08:19 UTC (rev 1555)
+++ trunk/framework/impl/src/main/resources/META-INF/faces-config.xml 2007-07-10 00:17:10 UTC (rev 1556)
@@ -19,7 +19,7 @@
</application>
<lifecycle>
<phase-listener>org.ajax4jsf.framework.renderer.AjaxPhaseListener</phase-listener>
- <phase-listener>org.ajax4jsf.framework.ajax.InitPhaseListener</phase-listener>
+ <phase-listener>org.ajax4jsf.event.InitPhaseListener</phase-listener>
</lifecycle>
<managed-bean>
<managed-bean-name>a4j</managed-bean-name>
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIActionParameter.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIActionParameter.java 2007-07-10 00:08:19 UTC (rev 1555)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIActionParameter.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -32,7 +32,6 @@
import javax.faces.event.ActionListener;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.ajax.JavaScriptParameter;
/**
* @author shura (latest modification by $Author: alexsmirnov $)
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java 2007-07-10 00:08:19 UTC (rev 1555)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -30,8 +30,8 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.event.AjaxListener;
+import org.ajax4jsf.event.AjaxListenerHelper;
import org.ajax4jsf.event.AjaxSource;
-import org.ajax4jsf.framework.ajax.AjaxListenerHelper;
import com.sun.facelets.FaceletContext;
import com.sun.facelets.FaceletException;
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java 2007-07-10 00:08:19 UTC (rev 1555)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java 2007-07-10 00:17:10 UTC (rev 1556)
@@ -32,8 +32,8 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.event.AjaxListener;
+import org.ajax4jsf.event.AjaxListenerHelper;
import org.ajax4jsf.event.AjaxSource;
-import org.ajax4jsf.framework.ajax.AjaxListenerHelper;
/**
17 years, 6 months