JBoss Ajax4JSF SVN: r160 - in trunk/docs: userguide/en and 1 other directory.
by ajax4jsf-svn-commits@lists.jboss.org
Author: smukhina
Date: 2007-05-03 07:09:36 -0400 (Thu, 03 May 2007)
New Revision: 160
Modified:
trunk/docs/resources/support.properties
trunk/docs/resources/support.xml
trunk/docs/userguide/en/master.xml
Log:
Modified: trunk/docs/resources/support.properties
===================================================================
--- trunk/docs/resources/support.properties 2007-05-03 08:35:14 UTC (rev 159)
+++ trunk/docs/resources/support.properties 2007-05-03 11:09:36 UTC (rev 160)
@@ -1,2 +1,2 @@
#Wed Apr 11 15:30:36 EEST 2007
-ajax4jsf.location=E\:\\projects\\eclipse-worspaces\\workspace\\ajax4jsf
+ajax4jsf.location=E\:\\projects\\eclipse-worspaces\\workspace\\ajax4jsf\\trunk
Modified: trunk/docs/resources/support.xml
===================================================================
--- trunk/docs/resources/support.xml 2007-05-03 08:35:14 UTC (rev 159)
+++ trunk/docs/resources/support.xml 2007-05-03 11:09:36 UTC (rev 160)
@@ -2,7 +2,7 @@
<dirname property="support.startdir" file="${ant.file.DocSupport}"/>
- <property name="support.basedir" value="${support.startdir}/../../../../resources"/>
+ <property name="support.basedir" value="${support.startdir}/../../../../jbosstools/trunk/documentation/resources"/>
<property file="${support.startdir}/support.properties" />
Modified: trunk/docs/userguide/en/master.xml
===================================================================
--- trunk/docs/userguide/en/master.xml 2007-05-03 08:35:14 UTC (rev 159)
+++ trunk/docs/userguide/en/master.xml 2007-05-03 11:09:36 UTC (rev 160)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3CR3//EN"
-"../../../../../resources/support/docbook-dtd/docbookx.dtd"
+"../../../../jbosstools/trunk/documentation/resources/support/docbook-dtd/docbookx.dtd"
[ <!ENTITY introduction SYSTEM "modules/a4jUGintro.xml">
<!ENTITY technicalRequirements SYSTEM "modules/a4jUGtechreqs.xml">
<!ENTITY getttingStarted SYSTEM "modules/a4jUGstart.xml">
19 years
JBoss Ajax4JSF SVN: r159 - in trunk/docs/userguide/en: modules and 1 other directory.
by ajax4jsf-svn-commits@lists.jboss.org
Author: vkukharchuk
Date: 2007-05-03 04:35:14 -0400 (Thu, 03 May 2007)
New Revision: 159
Modified:
trunk/docs/userguide/en/included/commandButton.xml
trunk/docs/userguide/en/included/commandlink.xml
trunk/docs/userguide/en/included/form.xml
trunk/docs/userguide/en/included/jsFunction.xml
trunk/docs/userguide/en/modules/a4jUGfaq.xml
trunk/docs/userguide/en/modules/a4jUGstart.xml
trunk/docs/userguide/en/modules/a4jUGusingAJAX.xml
Log:
Modified: trunk/docs/userguide/en/included/commandButton.xml
===================================================================
--- trunk/docs/userguide/en/included/commandButton.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ trunk/docs/userguide/en/included/commandButton.xml 2007-05-03 08:35:14 UTC (rev 159)
@@ -34,14 +34,14 @@
<section>
<title>Creating on a page</title>
<para><emphasis role="bold"><property><a4j:commandButton></property></emphasis> is used in the same way as <emphasis role="bold"><property><h:commandButton></property></emphasis>, but with definition of the area that is updated after the response comes back from the server.</para>
- <programlisting role="XML"><![CDATA[<a4j:commandButton reRender="someData" action="#bean.action1" value="Link"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<a4j:commandButton reRender="someData" action="#{bean.action1}" value="Link"/>]]></programlisting>
<para>This definition of the component provides a link, a click on the link causes an AJAX form submit on the server, "action1" method performance, and rendering of the component with "someData" id after the response comes back from the server.</para>
</section>
<section>
<title>Dynamical creation of a component from Java code</title>
<programlisting role="JAVA"><![CDATA[import org.ajax4jsf.ajax.html.HtmlAjaxCommandButton;
...
-HtmlAjaxCommandButton myButton = new org.ajax4jsf.ajax.html.HtmlAjaxCommandButton();
+HtmlAjaxCommandButton myButton = new HtmlAjaxCommandButton();
...
]]></programlisting>
</section>
Modified: trunk/docs/userguide/en/included/commandlink.xml
===================================================================
--- trunk/docs/userguide/en/included/commandlink.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ trunk/docs/userguide/en/included/commandlink.xml 2007-05-03 08:35:14 UTC (rev 159)
@@ -34,7 +34,7 @@
<section>
<title>Creating on a page</title>
<para><emphasis role="bold"><property><a4j:commandLink></property></emphasis> is used in the same way as <emphasis role="bold"><property><h:commandLink></property></emphasis>, but with definition of the area that is updated after the response comes back from the server.</para>
- <programlisting role="XML"><![CDATA[<a4j:commandLink reRender="someData" action="#bean.action1" value="Link"/>]]></programlisting>
+ <programlisting role="XML"><![CDATA[<a4j:commandLink reRender="someData" action="#{bean.action1}" value="Link"/>]]></programlisting>
<para>This definition of the component provides a link, a click on the link causes an AJAX form
submit on the server, "action1" method performance, and rendering of the component
with "someData" id after the response comes back from the server.</para>
@@ -43,7 +43,7 @@
<title>Dynamical creation of a component from Java code</title>
<programlisting role="JAVA"><![CDATA[import org.ajax4jsf.ajax.html.HtmlAjaxCommandLink;
...
-HtmlAjaxCommandLink myLink = new org.ajax4jsf.ajax.html.HtmlAjaxCommandLink();
+HtmlAjaxCommandLink myLink = new HtmlAjaxCommandLink();
...
]]></programlisting>
</section>
Modified: trunk/docs/userguide/en/included/form.xml
===================================================================
--- trunk/docs/userguide/en/included/form.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ trunk/docs/userguide/en/included/form.xml 2007-05-03 08:35:14 UTC (rev 159)
@@ -43,7 +43,7 @@
<title>Dynamical creation of a component from Java code</title>
<programlisting role="JAVA"><![CDATA[import org.ajax4jsf.ajax.html.AjaxForm;
...
-AjaxForm myForm = new org.ajax4jsf.ajax.html.AjaxForm();
+AjaxForm myForm = new AjaxForm();
...
]]></programlisting>
</section>
Modified: trunk/docs/userguide/en/included/jsFunction.xml
===================================================================
--- trunk/docs/userguide/en/included/jsFunction.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ trunk/docs/userguide/en/included/jsFunction.xml 2007-05-03 08:35:14 UTC (rev 159)
@@ -54,7 +54,7 @@
<title>Dynamical creation of a component from Java code</title>
<programlisting role="JAVA"><![CDATA[import org.ajax4jsf.ajax.html.HtmlAjaxFunction;
...
-AjaxFunction myFunction = new org.ajax4jsf.ajax.html.HtmlAjaxFunction();
+AjaxFunction myFunction = new HtmlAjaxFunction();
...
]]></programlisting>
</section>
Modified: trunk/docs/userguide/en/modules/a4jUGfaq.xml
===================================================================
--- trunk/docs/userguide/en/modules/a4jUGfaq.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ trunk/docs/userguide/en/modules/a4jUGfaq.xml 2007-05-03 08:35:14 UTC (rev 159)
@@ -263,7 +263,7 @@
<a4j:outputPanel id="panel">
<h:panelGroup rendered="#{bean.rendered}">
<!--Some nested content to be hidden/shown depending on bean.rendered -->
-</h:panelGroup>
+ </h:panelGroup>
</a4j:outputPanel>
...
<a4j:commandButton action=".." value=".." reRender="panel"/>
Modified: trunk/docs/userguide/en/modules/a4jUGstart.xml
===================================================================
--- trunk/docs/userguide/en/modules/a4jUGstart.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ trunk/docs/userguide/en/modules/a4jUGstart.xml 2007-05-03 08:35:14 UTC (rev 159)
@@ -103,7 +103,7 @@
<?dbhtml filename="JSPPage.html"?>
<title>JSP Page</title>
<para>Here is the necessary page (echo.jsp):</para>
- <programlisting role="JSP"> <![CDATA[<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
+ <programlisting role="JSP"> <![CDATA[
<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
@@ -148,16 +148,17 @@
<title>Data Bean</title>
<para>In order to build this application, you should create a managed bean:</para>
<programlisting role="JAVA">package demo;
+
public class Bean {
-private String text;
-public Bean() {
-}
- public String getText() {
-return text;
-}
-public void setText(String text) {
-this.text = text;
-}
+ private String text;
+ public Bean() {
+ }
+ public String getText() {
+ return text;
+ }
+ public void setText(String text) {
+ this.text = text;
+ }
}</programlisting>
</section>
<section id="faces-config.xml">
Modified: trunk/docs/userguide/en/modules/a4jUGusingAJAX.xml
===================================================================
--- trunk/docs/userguide/en/modules/a4jUGusingAJAX.xml 2007-05-02 17:40:09 UTC (rev 158)
+++ trunk/docs/userguide/en/modules/a4jUGusingAJAX.xml 2007-05-03 08:35:14 UTC (rev 159)
@@ -168,8 +168,8 @@
<itemizedlist>
<listitem>
<emphasis role="italic">
- <property>"reRender attribute"</property>
- </emphasis> as it was mentioned before specifies components to be reRendered
+ <property>"reRender"</property>
+ </emphasis>attribute as it was mentioned before 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>
@@ -276,7 +276,7 @@
<para>To execute your own code on the client in case of an error during AJAX request, it's necessary to redefine the standard "A4J.AJAX.onError " method:</para>
<programlisting role="JAVA"><![CDATA[A4J.AJAX.onError = function(req,status,message) {
// Custom Developer Code
- };]]></programlisting>
+};]]></programlisting>
<para>The function defined this way accepts as parameters:</para>
<itemizedlist>
<listitem>req - a params string of a request that calls an error</listitem>
19 years
JBoss Ajax4JSF SVN: r158 - trunk/framework/src/main/java/org/ajax4jsf/cache.
by ajax4jsf-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-05-02 13:40:09 -0400 (Wed, 02 May 2007)
New Revision: 158
Modified:
trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java
Log:
AJSF-39: LRUMapCacheFactory is selected by default
Modified: trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java 2007-05-02 17:38:50 UTC (rev 157)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java 2007-05-02 17:40:09 UTC (rev 158)
@@ -1,12 +1,16 @@
package org.ajax4jsf.cache;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import org.ajax4jsf.framework.resource.InternetResourceService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -17,7 +21,7 @@
private static final Log log = LogFactory.getLog(CacheManager.class);
private static final String FACTORY_PROPERTY_NAME = "org.ajax4jsf.cache.CacheFactory";
- private static final String DEFAULT_FACTORY_NAME = "org.ajax4jsf.cache.OSCacheCacheFactory";
+ private static final String DEFAULT_FACTORY_NAME = "org.ajax4jsf.cache.LRUMapCacheFactory";
public static final String CACHE_MANAGER_FACTORY_CLASS = "org.ajax4jsf.cache.CACHE_MANAGER_FACTORY_CLASS";
protected static CacheManager instance = new CacheManager();
19 years
JBoss Ajax4JSF SVN: r157 - in trunk/framework/src: main/java/org/ajax4jsf/framework/resource and 1 other directories.
by ajax4jsf-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-05-02 13:38:50 -0400 (Wed, 02 May 2007)
New Revision: 157
Added:
trunk/framework/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java
trunk/framework/src/main/java/org/ajax4jsf/cache/ServletContextInitMap.java
Modified:
trunk/framework/src/main/java/org/ajax4jsf/cache/CacheFactory.java
trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java
trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java
trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java
trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCache.java
trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java
trunk/framework/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java
trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java
Log:
AJSF-39: configuration added, console logging removed
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/CacheConfigurationLoader.java 2007-05-02 17:38:50 UTC (rev 157)
@@ -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.cache;
+
+import java.util.Properties;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 02.05.2007
+ *
+ */
+public interface CacheConfigurationLoader {
+ public Properties loadProperties(String name);
+}
Modified: trunk/framework/src/main/java/org/ajax4jsf/cache/CacheFactory.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/CacheFactory.java 2007-05-02 17:14:44 UTC (rev 156)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/CacheFactory.java 2007-05-02 17:38:50 UTC (rev 157)
@@ -14,8 +14,9 @@
* @param env implementation specific environment parameters passed to the
* CacheFactory.
* @param cacheLoader implementation of the {@link CacheLoader} to use
+ * @param cacheConfigurationloader TODO
* @return an implementation specific Cache object.
* @throws CacheException if any error occurs.
*/
- public Cache createCache(Map env, CacheLoader cacheLoader) throws CacheException;
+ public Cache createCache(Map env, CacheLoader cacheLoader, CacheConfigurationLoader cacheConfigurationloader) throws CacheException;
}
Modified: trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java 2007-05-02 17:14:44 UTC (rev 156)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java 2007-05-02 17:38:50 UTC (rev 157)
@@ -6,13 +6,19 @@
import java.util.Map;
import java.util.Properties;
+import org.ajax4jsf.framework.resource.InternetResourceService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* CacheManager is used in J2SE environments for looking up named caches.
*/
public class CacheManager {
+ private static final Log log = LogFactory.getLog(CacheManager.class);
private static final String FACTORY_PROPERTY_NAME = "org.ajax4jsf.cache.CacheFactory";
private static final String DEFAULT_FACTORY_NAME = "org.ajax4jsf.cache.OSCacheCacheFactory";
+ public static final String CACHE_MANAGER_FACTORY_CLASS = "org.ajax4jsf.cache.CACHE_MANAGER_FACTORY_CLASS";
protected static CacheManager instance = new CacheManager();
@@ -35,9 +41,10 @@
caches.put(cacheName, cache);
}
- public CacheFactory getCacheFactory() throws CacheException {
- String factoryName = findFactory(FACTORY_PROPERTY_NAME);
-
+ public CacheFactory getCacheFactory(Map env) throws CacheException {
+ String factoryName = findFactory(FACTORY_PROPERTY_NAME, env);
+ log.info("Selected [" + factoryName + "] cache factory");
+
try {
ClassLoader cl = findClassLoader();
Class spiClass = Class.forName(factoryName, true, cl);
@@ -63,8 +70,11 @@
return s == null || "".equals(s);
}
- String findFactory(String factoryId) {
+ String findFactory(String factoryId, Map env) {
+ String envFactoryClass = (String) env.get(CACHE_MANAGER_FACTORY_CLASS);
+ if (!isEmptyString(envFactoryClass)) return envFactoryClass;
+
// Use the system property first
try {
String factoryClass = System.getProperty(factoryId);
Modified: trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java 2007-05-02 17:14:44 UTC (rev 156)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java 2007-05-02 17:38:50 UTC (rev 157)
@@ -1,6 +1,24 @@
/**
- *
+ * 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.cache;
import java.util.HashMap;
Modified: trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java 2007-05-02 17:14:44 UTC (rev 156)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java 2007-05-02 17:38:50 UTC (rev 157)
@@ -1,11 +1,32 @@
/**
- *
+ * 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.cache;
import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* @author Nick - mailto:nbelaevski@exadel.com
* created 01.05.2007
@@ -13,9 +34,24 @@
*/
public class LRUMapCacheFactory implements CacheFactory {
- public Cache createCache(Map env, CacheLoader cacheLoader)
+ private static final Log log = LogFactory.getLog(LRUMapCacheFactory.class);
+
+ public final static String CACHE_SIZE_PARAMETER = "org.ajax4jsf.cache.LRU_MAP_CACHE_SIZE";
+
+ public Cache createCache(Map env, CacheLoader cacheLoader, CacheConfigurationLoader cacheConfigurationloader)
throws CacheException {
- return new LRUMapCache(cacheLoader);
+
+ log.info("Creating LRUMap cache instance using parameters: " + env);
+
+ String size = (String) env.get(CACHE_SIZE_PARAMETER);
+ if (size == null || size.length() == 0) {
+ log.info("Creating LRUMap cache instance of default capacity");
+ return new LRUMapCache(cacheLoader);
+ } else {
+ int parsedSize = Integer.parseInt(size);
+ log.info("Creating LRUMap cache instance of " + parsedSize + " items capacity");
+ return new LRUMapCache(cacheLoader, parsedSize);
+ }
}
}
Modified: trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCache.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCache.java 2007-05-02 17:14:44 UTC (rev 156)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCache.java 2007-05-02 17:38:50 UTC (rev 157)
@@ -1,6 +1,24 @@
/**
- *
+ * 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.cache;
import java.util.Collection;
Modified: trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java 2007-05-02 17:14:44 UTC (rev 156)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java 2007-05-02 17:38:50 UTC (rev 157)
@@ -1,10 +1,31 @@
/**
- *
+ * 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.cache;
import java.util.Map;
+import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import com.opensymphony.oscache.general.GeneralCacheAdministrator;
@@ -15,12 +36,20 @@
*/
public class OSCacheCacheFactory implements CacheFactory {
- /* (non-Javadoc)
+ private static final Log log = LogFactory.getLog(OSCacheCacheFactory.class);
+
+ /* (non-Javadoc)
* @see org.ajax4jsf.framework.resource.cache.CacheFactory#createCache(java.util.Map, org.ajax4jsf.framework.resource.cache.CacheLoader)
*/
- public Cache createCache(Map env, CacheLoader cacheLoader)
+ public Cache createCache(Map env, CacheLoader cacheLoader, CacheConfigurationLoader cacheConfigurationloader)
throws CacheException {
- GeneralCacheAdministrator cacheAdministrator = new GeneralCacheAdministrator();
+ // Load our implementation properties
+ Properties cacheProperties = cacheConfigurationloader.loadProperties("oscache.properties");
+ cacheProperties.putAll(cacheConfigurationloader.loadProperties("/oscache.properties"));
+ cacheProperties.putAll(env);
+
+ log.info("Creating OSCache cache instance using parameters: " + cacheProperties);
+ GeneralCacheAdministrator cacheAdministrator = new GeneralCacheAdministrator(cacheProperties);
return new OSCacheCache(cacheAdministrator.getCache(), cacheLoader);
}
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/ServletContextInitMap.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/ServletContextInitMap.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/ServletContextInitMap.java 2007-05-02 17:38:50 UTC (rev 157)
@@ -0,0 +1,119 @@
+/**
+ * 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.cache;
+
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.ServletContext;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 02.05.2007
+ *
+ */
+public class ServletContextInitMap extends AbstractMap {
+ private ServletContext servletContext;
+
+ public ServletContextInitMap(ServletContext servletContext) {
+ super();
+ this.servletContext = servletContext;
+ }
+
+ public Set entrySet() {
+ return new AbstractSet() {
+
+ public Iterator iterator() {
+ return new Iterator() {
+ private Enumeration initNames = servletContext.getInitParameterNames();
+
+ public boolean hasNext() {
+ return initNames.hasMoreElements();
+ }
+
+ public Object next() {
+ String key = (String) initNames.nextElement();
+ String value = servletContext.getInitParameter(key);
+
+ return new ServletContextInitMapEntry(key, value);
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ };
+ }
+
+ public int size() {
+ int result = 0;
+ Enumeration initNames = servletContext.getInitParameterNames();
+ while (initNames.hasMoreElements()) {
+ result++;
+ }
+
+ return result;
+ }
+
+ public boolean isEmpty() {
+ return !servletContext.getInitParameterNames().hasMoreElements();
+ }
+ };
+ }
+
+}
+
+class ServletContextInitMapEntry implements Map.Entry {
+
+ private Object key;
+ private Object value;
+
+ public ServletContextInitMapEntry(Object key, Object value) {
+ super();
+ this.key = key;
+ this.value = value;
+ }
+
+ public ServletContextInitMapEntry(Object key) {
+ super();
+ this.key = key;
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public Object setValue(Object value) {
+ Object oldValue = this.value;
+ this.value = value;
+ return oldValue;
+ }
+
+}
\ No newline at end of file
Modified: trunk/framework/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java 2007-05-02 17:14:44 UTC (rev 156)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java 2007-05-02 17:38:50 UTC (rev 157)
@@ -23,9 +23,7 @@
import java.io.IOException;
import java.io.InputStream;
-import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -42,9 +40,12 @@
import javax.servlet.http.HttpServletResponse;
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;
import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
import org.ajax4jsf.framework.util.config.WebXml;
@@ -53,7 +54,7 @@
import org.apache.commons.logging.LogFactory;
-public class InternetResourceService implements CacheLoader {
+public class InternetResourceService implements CacheLoader, CacheConfigurationLoader {
private static final Log log = LogFactory
.getLog(InternetResourceService.class);
@@ -96,17 +97,15 @@
// this.cacheEnabled = false;
//this.cacheAdmin = null;
} else {
- // Load our implementation properties
- Properties cacheProperties = getProperties("oscache.properties");
- cacheProperties.putAll(getProperties("/oscache.properties"));
//this.cacheAdmin = ServletCacheAdministrator.getInstance(
// servletContext, cacheProperties);
- Map env = new HashMap();
try {
- this.cache = CacheManager.getInstance().getCacheFactory().createCache(env, this);
+ CacheManager cacheManager = CacheManager.getInstance();
+ Map env = new ServletContextInitMap(servletContext);
+ CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
+ this.cache = cacheFactory.createCache(env, this, this);
} catch (CacheException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new FacesException(e.getMessage(), e);
}
}
// Create Resource-specific Faces Lifecycle instance.
@@ -230,8 +229,12 @@
}
}*/
} catch (CacheException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.error(
+ Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
+ e);
+ throw new ServletException(Messages.getMessage(
+ Messages.SEND_RESOURCE_ERROR_2, e.getMessage()),
+ e);
}
} else {
sendResource(resource, request, response, resourceDataForKey);
@@ -361,12 +364,8 @@
resourceContext.setResourceData(cacheKey.getResourceData());
try {
getLifecycle().send(resourceContext, cacheKey.getResource());
- } catch (FacesException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new CacheException(e.getMessage(), e);
}
resourceContext.release();
@@ -375,9 +374,8 @@
return resourceContext.getContent();
}
- public Map loadAll(Collection keys, Object context) throws CacheException {
- // TODO Auto-generated method stub
- return null;
+ public Properties loadProperties(String name) {
+ return getProperties(name);
}
}
Modified: trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java
===================================================================
--- trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java 2007-05-02 17:14:44 UTC (rev 156)
+++ trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java 2007-05-02 17:38:50 UTC (rev 157)
@@ -27,7 +27,7 @@
};
private static final int COUNT = 2000;
- private static final int PASS_COUNT = 200;
+ private static final int PASS_COUNT = 2;
public void testCache() throws Exception {
@@ -39,7 +39,7 @@
try {
for (int i = 0; i < COUNT; i++) {
- threads[i] = new TestThread(cache, new Integer(new Random().nextInt(10)));
+ threads[i] = new LRUMapCacheTestThread(cache, new Integer(new Random().nextInt(10)));
threads[i].start();
}
} catch (Exception e) {
@@ -55,11 +55,11 @@
}
}
-class TestThread extends Thread {
+class LRUMapCacheTestThread extends Thread {
private Cache cache;
private Integer idx;
- public TestThread(Cache cache, Integer idx) {
+ public LRUMapCacheTestThread(Cache cache, Integer idx) {
super();
this.cache = cache;
this.idx = idx;
19 years
JBoss Ajax4JSF SVN: r156 - trunk/cdk/generator.
by ajax4jsf-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-02 13:14:44 -0400 (Wed, 02 May 2007)
New Revision: 156
Modified:
trunk/cdk/generator/pom.xml
Log:
Modified: trunk/cdk/generator/pom.xml
===================================================================
--- trunk/cdk/generator/pom.xml 2007-05-02 17:11:26 UTC (rev 155)
+++ trunk/cdk/generator/pom.xml 2007-05-02 17:14:44 UTC (rev 156)
@@ -54,10 +54,10 @@
<version>1.2_03</version>
</dependency>
<dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.1</version>
- </dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ </dependency>
<dependency>
<groupId>qdox</groupId>
<artifactId>qdox</artifactId>
19 years
JBoss Ajax4JSF SVN: r155 - trunk/cdk/generator/src/main/resources/META-INF/templates.
by ajax4jsf-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-02 13:11:26 -0400 (Wed, 02 May 2007)
New Revision: 155
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates/converter.vm
trunk/cdk/generator/src/main/resources/META-INF/templates/validator.vm
Log:
Bug AJSF-12, validators&converters stateHolder support
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates/converter.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/converter.vm 2007-05-02 17:05:09 UTC (rev 154)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/converter.vm 2007-05-02 17:11:26 UTC (rev 155)
@@ -1,204 +1,221 @@
-package $package;
-
-#foreach($import in $imports)
-import $import ;
-#end
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import java.io.IOException;
-import javax.faces.FacesException;
-import javax.faces.component.StateHolder;
-
-/**
- * Converter-Id ${converter.id}
- * ${converter.xmlEncodedDescription}
- */
-public class $converter.simpleClassName extends $converter.superclass implements StateHolder
-{
-
- public static final String CONVERTER_ID = "${converter.id}";
-
- /**
- * Default no-args contstructor
- */
- public $converter.simpleClassName ()
- {
- }
-
-// Conveter properties fields
-#set( $fiedCounter = 0 )
-#foreach( $prop in $converter.properties )
- #if( !$prop.exist )
- /**
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- #if($prop.simpleType)
- private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
- /**
- * Flag indicated that $prop.name is set.
- */
- private boolean _${prop.name}Set = false;
- #set( $fiedCounter = $fiedCounter+2)
- #else
- private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
- #set( $fiedCounter = $fiedCounter+1)
- #end
- #end
-#end
-
-// Getters and setters
-#foreach( $prop in $converter.properties )
- #if( !$prop.exist )
- /**
- * ${prop.xmlEncodedDescription}
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
-#if($prop.simpleType)
- this._${prop.name}Set = true;
-#end
- }
-
- /**
- * ${prop.xmlEncodedDescription}
- * Getter for $prop.name
- * @return $prop.name value from local variable or value binding
- */
- public $prop.simpleClassName ${prop.getterName}()
- {
- ValueBinding vb = getValueBinding("${prop.name}");
-#if($prop.simpleType)
- if(this._${prop.name}Set)
- {
- return this._${prop.name};
- }
- if (vb != null)
- {
- ${prop.boxingClass} value = (${prop.boxingClass}) vb.getValue(getFacesContext());
- if (null == value)
- {
- return this._${prop.name};
- }
- //return (value.${prop.classname}Value());
- } else
- {
- return (this._${prop.name});
- }
- }
- #else
- if (null != this._${prop.name})
- {
- return this._${prop.name};
- }
- #if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
- else if (null != vb)
- {
- return (${prop.simpleClassName})vb.getValue(getFacesContext());
- }
- #end
- else
- {
- return ${prop.defaultvalue};
- }
- #end
- }
- #if($prop.raw)
- /**
- * ${prop.xmlEncodedDescription}
- * Raw Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}Raw( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
- }
- /*
- * ${prop.xmlEncodedDescription}
- * Raw ( bypadd bindings ) Getter for $prop.name
- * @return $prop.name value from local variable
- */
- public $prop.simpleClassName ${prop.getterName}Raw()
- {
- return this._${prop.name};
- }
- #end
- #end
-#end
-
-// Save state
-// ----------------------------------------------------- StateHolder Methods
-
-
- public Object saveState(FacesContext context) {
- Object values[] = new Object[${fiedCounter}];
- //values[0] = super.saveState(context);
-#set($currentField = 0)
-#foreach( $prop in $converter.properties )
- #if( !$prop.exist )
- #if($prop.simpleType)
- values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
- #set( $currentField = $currentField+1)
- values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
- #set( $currentField = $currentField+1)
- #else
- #if(!${prop.attachedstate} )
- values[${currentField}] = _$prop.name;
- #else
- values[${currentField}] = saveAttachedState(context, _$prop.name );
- #end
- #set( $currentField = $currentField+1)
- #end
- #end
-#end
- return values;
- }
-
-
- public void restoreState(FacesContext context, Object state) {
- Object values[] = (Object[]) state;
- //super.restoreState(context, values[0]);
-#set($currentField = 0)
-#foreach( $prop in $converter.properties )
- #if( !$prop.exist )
- #if($prop.simpleType)
- _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
- #set( $currentField = $currentField+1)
- _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
- #set( $currentField = $currentField+1)
- #else
- #if( !${prop.attachedstate} )
- _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
- #else
- _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
- #end
- #end
- #set( $currentField = $currentField+1)
- #end
-#end
-
-
- }
-// Utilites
-
- public boolean isTransient() {
- return false;
- }
-
- public void setTransient(boolean newTransientValue){
- }
-
-
- private FacesContext getFacesContext() {
- return FacesContext.getCurrentInstance();
- }
-
- private ValueBinding getValueBinding(String name) {
- return getFacesContext().getApplication().createValueBinding(name);
- }
-
-}
+package $package;
+
+#foreach($import in $imports)
+import $import ;
+#end
+
+ import javax.faces.context.FacesContext;
+ import javax.faces.el.ValueBinding;
+import javax.faces.component.StateHolder;
+
+ /**
+ * Converter-Id ${converter.id}
+ * ${converter.xmlEncodedDescription}
+ */
+
+public class $converter.simpleClassName extends $converter.superclass #if(${converter.stateHolderRequired} && !${converter.superclassImplementsStateHolder})implements StateHolder#end
+ {
+
+ public static final String CONVERTER_ID = "${converter.id}";
+
+
+
+ // Conveter properties fields
+
+#set( $fieldCounter = 0 )
+ #foreach( $prop in $converter.properties )
+
+#if( !$prop.exist )
+ /**
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+
+#if($prop.simpleType)
+ private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
+ /**
+ * Flag indicated that $prop.name is set.
+ */
+ private boolean _${prop.name}Set = false;
+#set( $fieldCounter = $fieldCounter+2)
+#else
+ private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
+#set( $fieldCounter = $fieldCounter+1)
+ #end
+#end
+#end
+
+ // Getters and setters
+ #foreach( $prop in $converter.properties )
+
+#if( !$prop.exist )
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Setter for $prop.name
+ */
+ public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
+ {
+ this._${prop.name} = __$prop.name;
+
+#if($prop.simpleType)
+ this._${prop.name}Set = true;
+
+#end
+ }
+
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Getter for $prop.name
+ * @return $prop.name value from local variable or value binding
+ */
+ public $prop.simpleClassName ${prop.getterName}()
+ {
+ ValueBinding vb = getValueBinding("${prop.name}");
+
+#if($prop.simpleType)
+ if(this._${prop.name}Set)
+ {
+ return this._${prop.name};
+
+ return (this._${prop.name});
+ }
+ }
+
+#else
+ if (null != this._${prop.name})
+ {
+ return this._${prop.name};
+ }
+
+#if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
+ else if (null != vb)
+ {
+ return (${prop.simpleClassName})vb.getValue(getFacesContext());
+ }
+
+#end
+ else
+ {
+ return ${prop.defaultvalue};
+ }
+
+#end
+ }
+ #if($prop.raw)
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Raw Setter for $prop.name
+ * @param $prop.name - new value
+ */
+
+ {
+ return this._${prop.name};
+ }
+ #end
+#end
+#end
+
+#if($converter.stateHolderRequired)
+
+ // Save state
+ // ----------------------------------------------------- StateHolder Methods
+
+ private boolean _transient;
+
+#if(${converter.superclassImplementsStateHolder})
+#set($currentField=1)
+#set($fieldCounter = $fieldCounter+1)
+#else
+#set($currentField=0)
+#end
+ public Object saveState(FacesContext context) {
+
+#if(${converter.superSaveStateMethodExists})
+ Object values[] = new Object[${fieldCounter}];
+ values[0] = super.saveState(context);
+#else
+ Object values[] = new Object[${fieldCounter}];
+#end
+#foreach( $prop in $converter.properties )
+#if( !$prop.exist )
+#if($prop.simpleType)
+ values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
+#set( $currentField = $currentField+1)
+ values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
+#set( $currentField = $currentField+1)
+#else
+#if(!${prop.attachedstate} )
+ values[${currentField}] = _$prop.name;
+#else
+ values[${currentField}] = saveAttachedState(context, _$prop.name );
+ #end
+
+#set( $currentField = $currentField+1)
+#end
+#end
+#end
+ return values;
+ }
+
+
+#if(${converter.superclassImplementsStateHolder})
+#set($currentField=1)
+#else
+#set($currentField=0)
+#end
+ public void restoreState(FacesContext context, Object state) {
+#if(${converter.superRestoreStateMethodExists})
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+#else
+ Object values[] = (Object[]) state;
+#end
+#foreach( $prop in $converter.properties )
+#if( !$prop.exist )
+#if($prop.simpleType)
+ _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
+#set( $currentField = $currentField+1)
+ _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
+#set( $currentField = $currentField+1)
+#else
+#if( !${prop.attachedstate} )
+ _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
+#else
+ _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
+ #end
+#set( $currentField = $currentField+1)
+#end
+
+#end
+#end
+ }
+
+#if(!$converter.superIsTransientMethodExists)
+ public boolean isTransient()
+ {
+ return _transient;
+ }
+#end
+
+#if(!$converter.superSetTransientMethodExists)
+ public void setTransient(boolean newTransientValue)
+ {
+ this._transient = newTransientValue;
+ }
+#end
+
+#end
+
+ // Utilites
+
+ private FacesContext getFacesContext()
+ {
+ return FacesContext.getCurrentInstance();
+ }
+
+ private ValueBinding getValueBinding(String name)
+ {
+ return getFacesContext().getApplication().createValueBinding(name);
+ }
+
+ }
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates/validator.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/validator.vm 2007-05-02 17:05:09 UTC (rev 154)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/validator.vm 2007-05-02 17:11:26 UTC (rev 155)
@@ -1,434 +1,232 @@
-package $package;
-package $package;
-
-#foreach($import in $imports)
-import $import ;
-#end
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.component.StateHolder;
-
-/**
- * Validator-Id ${validator.id}
- * ${validator.xmlEncodedDescription}
- */
-public class $validator.simpleClassName extends $validator.superclass #if(${validator.stateHolderRequired} && !${validator.superclassImplementsStateHolder})implements StateHolder#end
-{
-
- public static final String VALIDATOR_ID = "${validator.id}";
-
- /**
- * Default no-args contstructor
- */
- public $validator.simpleClassName ()
- {
- }
-
-// Validator properties fields
-#set( $fieldCounter = 0 )
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
- /**
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
-#if($prop.simpleType)
- private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
- /**
- * Flag indicated that $prop.name is set.
- */
- private boolean _${prop.name}Set = false;
-#set( $fieldCounter = $fieldCounter+2)
-#else
- private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
-#set( $fieldCounter = $fieldCounter+1)
-#end
-#end
-#end
-
-// Getters and setters
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
- /**
- * ${prop.xmlEncodedDescription}
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
-#if($prop.simpleType)
- this._${prop.name}Set = true;
-#end
- }
-
- /**
- * ${prop.xmlEncodedDescription}
- * Getter for $prop.name
- * @return $prop.name value from local variable or value binding
- */
- public $prop.simpleClassName ${prop.getterName}()
- {
- ValueBinding vb = getValueBinding(_${prop.name});
-#if($prop.simpleType)
- if(this._${prop.name}Set)
- {
- return this._${prop.name};
- }
- if (vb != null)
- {
- ${prop.boxingClass} value = (${prop.boxingClass}) vb.getValue(getFacesContext());
- if (null == value)
- {
- return this._${prop.name};
- }
- //return (value.${prop.classname}Value());
- } else
- {
- return (this._${prop.name});
- }
- }
-#else
- if (null != this._${prop.name})
- {
- return this._${prop.name};
- }
-#if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
- else if (null != vb)
- {
- return (${prop.simpleClassName})vb.getValue(getFacesContext());
- }
-#end
- else
- {
- return ${prop.defaultvalue};
- }
- }
-#end
-#if($prop.raw)
- /**
- * ${prop.xmlEncodedDescription}
- * Raw Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}Raw( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
- }
- /*
- * ${prop.xmlEncodedDescription}
- * Raw ( bypadd bindings ) Getter for $prop.name
- * @return $prop.name value from local variable
- */
- public $prop.simpleClassName ${prop.getterName}Raw()
- {
- return this._${prop.name};
- }
-#end
-#end
-#end
-
-
-#if($validator.stateHolderRequired)
-
- // Save state
- // ----------------------------------------------------- StateHolder Methods
-
- private boolean _transient;
-#if(${validator.superclassImplementsStateHolder})
-#set($currentField=1)
-#set( $fieldCounter = $fieldCounter+1)
-#else
-#set($currentField=0)
-#end
- public Object saveState(FacesContext context) {
-#if(${validator.superSaveStateMethodExists})
- Object values[] = new Object[${fieldCounter}];
- values[0] = super.saveState(context);
-#else
- Object values[] = new Object[${fieldCounter}];
-#end
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
-#if($prop.simpleType)
- values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
-#set( $currentField = $currentField+1)
- values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
-#set( $currentField = $currentField+1)
-#else
-#if(!${prop.attachedstate} )
- values[${currentField}] = _$prop.name;
-#else
- values[${currentField}] = saveAttachedState(context, _$prop.name );
-#end
-#set( $currentField = $currentField+1)
-#end
-#end
-#end
- return values;
- }
-
-#if(${validator.superclassImplementsStateHolder})
-#set($currentField=1)
-#else
-#set($currentField=0)
-#end
- public void restoreState(FacesContext context, Object state) {
-#if(${validator.superRestoreStateMethodExists})
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
-#else
- Object values[] = (Object[]) state;
-#end
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
-#if($prop.simpleType)
- _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
-#set( $currentField = $currentField+1)
- _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
-#set( $currentField = $currentField+1)
-#else
-#if( !${prop.attachedstate} )
- _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
-#else
- _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
-#end
-#set( $currentField = $currentField+1)
-#end
-
-#end
-#end
- }
-
-#if(!$validator.superIsTransientMethodExists)
- public boolean isTransient()
- {
- return _transient;
- }
-#end
-
-#if(!$validator.superSetTransientMethodExists)
- public void setTransient(boolean newTransientValue)
- {
- this._transient = newTransientValue;
- }
-#end
-
-#end
-
-
-// Utilites
-
- private FacesContext getFacesContext()
- {
- return FacesContext.getCurrentInstance();
- }
-
- private ValueBinding getValueBinding(String name)
- {
- return getFacesContext().getApplication().createValueBinding(name);
- }
-
-}
-
-#foreach($import in $imports)
-import $import ;
-#end
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import java.io.IOException;
-import javax.faces.FacesException;
-import javax.faces.component.StateHolder;
-
-/**
- * Validator-Id ${validator.id}
- * ${validator.xmlEncodedDescription}
- */
-public class $validator.simpleClassName extends $validator.superclass implements StateHolder {
-
- public static final String VALIDATOR_ID = "${validator.id}";
-
- /**
- * Default no-args contstructor
- */
- public $validator.simpleClassName () {
- }
-
-// Validator properties fields
-#set( $fiedCounter = 0 )
-#foreach( $prop in $validator.properties )
- #if( !$prop.exist )
- /**
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- #if($prop.simpleType)
- private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
- /**
- * Flag indicated that $prop.name is set.
- */
- private boolean _${prop.name}Set = false;
- #set( $fiedCounter = $fiedCounter+2)
- #else
- private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
- #set( $fiedCounter = $fiedCounter+1)
- #end
- #end
-#end
-
-// Getters and setters
-#foreach( $prop in $validator.properties )
- #if( !$prop.exist )
- /**
- * ${prop.xmlEncodedDescription}
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
- #if($prop.simpleType)
- this._${prop.name}Set = true;
- #end
- }
-
- /**
- * ${prop.xmlEncodedDescription}
- * Getter for $prop.name
- * @return $prop.name value from local variable or value binding
- */
- public $prop.simpleClassName ${prop.getterName}()
- {
- ValueBinding vb = getValueBinding("${prop.name}");
- #if($prop.simpleType)
- if(this._${prop.name}Set)
- {
- return this._${prop.name};
- }
- if (vb != null)
- {
- ${prop.boxingClass} value = (${prop.boxingClass}) vb.getValue(getFacesContext());
- if (null == value)
- {
- return this._${prop.name};
- }
- //return (value.${prop.classname}Value());
- } else
- {
- return (this._${prop.name});
- }
- }
- #else
- if (null != this._${prop.name})
- {
- return this._${prop.name};
- }
- #if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
- else if (null != vb)
- {
- return (${prop.simpleClassName})vb.getValue(getFacesContext());
- }
- #end
- else
- {
- return ${prop.defaultvalue};
- }
- #end
- }
- #if($prop.raw)
-
- /**
- * ${prop.xmlEncodedDescription}
- * Raw Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}Raw( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
- }
- /*
- * ${prop.xmlEncodedDescription}
- * Raw ( bypadd bindings ) Getter for $prop.name
- * @return $prop.name value from local variable
- */
- public $prop.simpleClassName ${prop.getterName}Raw()
- {
- return this._${prop.name};
- }
- #end
- #end
-#end
-
-// Save state
-// ----------------------------------------------------- StateHolder Methods
-
-
- public Object saveState(FacesContext context) {
- Object values[] = new Object[${fiedCounter}];
-// values[0] = super.saveState(context);
-#set($currentField = 0)
-#foreach( $prop in $validator.properties )
- #if( !$prop.exist )
- #if($prop.simpleType)
- values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
- #set( $currentField = $currentField+1)
- values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
- #set( $currentField = $currentField+1)
- #else
- #if(!${prop.attachedstate} )
- values[${currentField}] = _$prop.name;
- #else
- values[${currentField}] = saveAttachedState(context, _$prop.name );
- #end
- #set( $currentField = $currentField+1)
- #end
- #end
-#end
- return values;
- }
-
-
- public void restoreState(FacesContext context, Object state) {
- Object values[] = (Object[]) state;
-// super.restoreState(context, values[0]);
-#set($currentField = 0)
-#foreach( $prop in $validator.properties )
- #if( !$prop.exist )
- #if($prop.simpleType)
- _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
- #set( $currentField = $currentField+1)
- _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
- #set( $currentField = $currentField+1)
- #else
- #if( !${prop.attachedstate} )
- _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
- #else
- _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
- #end
- #end
- #set( $currentField = $currentField+1)
- #end
-#end
-
- }
-
- public boolean isTransient() {
- return false;
- }
-
- public void setTransient(boolean newTransientValue){
- }
-
- // Utilites
-
- private FacesContext getFacesContext() {
- return FacesContext.getCurrentInstance();
- }
-
- private ValueBinding getValueBinding(String name) {
- return getFacesContext().getApplication().createValueBinding(name);
- }
-
-}
+package $package;
+
+#foreach($import in $imports)
+import $import ;
+#end
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.component.StateHolder;
+
+/**
+ * Validator-Id ${validator.id}
+ * ${validator.xmlEncodedDescription}
+ */
+public class $validator.simpleClassName extends $validator.superclass #if(${validator.stateHolderRequired} && !${validator.superclassImplementsStateHolder})implements StateHolder#end
+{
+
+ public static final String VALIDATOR_ID = "${validator.id}";
+
+ /**
+ * Default no-args contstructor
+ */
+ public $validator.simpleClassName ()
+ {
+ }
+
+// Validator properties fields
+#set( $fieldCounter = 0 )
+#foreach( $prop in $validator.properties )
+#if( !$prop.exist )
+ /**
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+#if($prop.simpleType)
+ private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
+ /**
+ * Flag indicated that $prop.name is set.
+ */
+ private boolean _${prop.name}Set = false;
+#set( $fieldCounter = $fieldCounter+2)
+#else
+ private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
+#set( $fieldCounter = $fieldCounter+1)
+#end
+#end
+#end
+
+// Getters and setters
+#foreach( $prop in $validator.properties )
+#if( !$prop.exist )
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Setter for $prop.name
+ * @param $prop.name - new value
+ */
+ public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
+ {
+ this._${prop.name} = __$prop.name;
+#if($prop.simpleType)
+ this._${prop.name}Set = true;
+#end
+ }
+
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Getter for $prop.name
+ * @return $prop.name value from local variable or value binding
+ */
+ public $prop.simpleClassName ${prop.getterName}()
+ {
+ ValueBinding vb = getValueBinding(_${prop.name});
+#if($prop.simpleType)
+ if(this._${prop.name}Set)
+ {
+ return this._${prop.name};
+ }
+ if (vb != null)
+ {
+ ${prop.boxingClass} value = (${prop.boxingClass}) vb.getValue(getFacesContext());
+ if (null == value)
+ {
+ return this._${prop.name};
+ }
+ //return (value.${prop.classname}Value());
+ } else
+ {
+ return (this._${prop.name});
+ }
+ }
+#else
+ if (null != this._${prop.name})
+ {
+ return this._${prop.name};
+ }
+#if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
+ else if (null != vb)
+ {
+ return (${prop.simpleClassName})vb.getValue(getFacesContext());
+ }
+#end
+ else
+ {
+ return ${prop.defaultvalue};
+ }
+ }
+#end
+#if($prop.raw)
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Raw Setter for $prop.name
+ * @param $prop.name - new value
+ */
+ public void ${prop.setterName}Raw( $prop.simpleClassName __$prop.name )
+ {
+ this._${prop.name} = __$prop.name;
+ }
+ /*
+ * ${prop.xmlEncodedDescription}
+ * Raw ( bypadd bindings ) Getter for $prop.name
+ * @return $prop.name value from local variable
+ */
+ public $prop.simpleClassName ${prop.getterName}Raw()
+ {
+ return this._${prop.name};
+ }
+#end
+#end
+#end
+
+
+#if($validator.stateHolderRequired)
+
+ // Save state
+ // ----------------------------------------------------- StateHolder Methods
+
+ private boolean _transient;
+#if(${validator.superclassImplementsStateHolder})
+#set($currentField=1)
+#set( $fieldCounter = $fieldCounter+1)
+#else
+#set($currentField=0)
+#end
+ public Object saveState(FacesContext context) {
+#if(${validator.superSaveStateMethodExists})
+ Object values[] = new Object[${fieldCounter}];
+ values[0] = super.saveState(context);
+#else
+ Object values[] = new Object[${fieldCounter}];
+#end
+#foreach( $prop in $validator.properties )
+#if( !$prop.exist )
+#if($prop.simpleType)
+ values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
+#set( $currentField = $currentField+1)
+ values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
+#set( $currentField = $currentField+1)
+#else
+#if(!${prop.attachedstate} )
+ values[${currentField}] = _$prop.name;
+#else
+ values[${currentField}] = saveAttachedState(context, _$prop.name );
+#end
+#set( $currentField = $currentField+1)
+#end
+#end
+#end
+ return values;
+ }
+
+#if(${validator.superclassImplementsStateHolder})
+#set($currentField=1)
+#else
+#set($currentField=0)
+#end
+ public void restoreState(FacesContext context, Object state) {
+#if(${validator.superRestoreStateMethodExists})
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+#else
+ Object values[] = (Object[]) state;
+#end
+#foreach( $prop in $validator.properties )
+#if( !$prop.exist )
+#if($prop.simpleType)
+ _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
+#set( $currentField = $currentField+1)
+ _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
+#set( $currentField = $currentField+1)
+#else
+#if( !${prop.attachedstate} )
+ _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
+#else
+ _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
+#end
+#set( $currentField = $currentField+1)
+#end
+
+#end
+#end
+ }
+
+#if(!$validator.superIsTransientMethodExists)
+ public boolean isTransient()
+ {
+ return _transient;
+ }
+#end
+
+#if(!$validator.superSetTransientMethodExists)
+ public void setTransient(boolean newTransientValue)
+ {
+ this._transient = newTransientValue;
+ }
+#end
+
+#end
+
+
+// Utilites
+
+ private FacesContext getFacesContext()
+ {
+ return FacesContext.getCurrentInstance();
+ }
+
+ private ValueBinding getValueBinding(String name)
+ {
+ return getFacesContext().getApplication().createValueBinding(name);
+ }
+
+}
\ No newline at end of file
19 years
JBoss Ajax4JSF SVN: r154 - trunk/cdk/generator/src/main/resources/META-INF/templates12.
by ajax4jsf-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-02 13:05:09 -0400 (Wed, 02 May 2007)
New Revision: 154
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm
Log:
javadoc instead of comments
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm 2007-05-02 17:04:21 UTC (rev 153)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm 2007-05-02 17:05:09 UTC (rev 154)
@@ -1,149 +1,149 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-package ${tag.packageName};
-
-#foreach($import in $imports)
-import $import ;
-#end
-import javax.faces.component.UIComponent;
-import ${component.classname};
-
-public class $tag.simpleClassName extends $tag.superclass {
-
-// Fields
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- /*
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- private String _$prop.name = null;
-
- #end
-#end
-// Setters
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- /*
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- /*
- * $prop.description
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( String __${prop.name} ){
- this._${prop.name} = __${prop.name};
- }
-
- #end
- #if( $prop.alias)
- /*
- * ${prop.xmlEncodedDescription}
- * Setter for alias of $prop.name as $prop.alias
- * @param $prop.name - new value
- */
- public void set${prop.upperFirstChar($prop.alias)}( String __${prop.alias} ){
- this.${prop.setterName}(__${prop.alias});
- }
- #end
-#end
-// Release
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#release()
- */
- public void release()
- {
- // TODO Auto-generated method stub
- super.release();
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- this._${prop.name} = null;
- #end
-#end
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
- */
- protected void setProperties(UIComponent component)
- {
- // TODO Auto-generated method stub
- super.setProperties(component);
-
-#foreach( $prop in $component.properties )
- #if( !$prop.existintag )
- #if(!$prop.el)
- if(isValueReference(this._${prop.name})){
- throw new IllegalArgumentException("Component ${component.name} with Id " + component.getClientId(getFacesContext() +" not allowed EL expression for property ${prop.name}")
- }
- #end
- #if($prop.name == "action")
- setActionProperty(component, this._${prop.name});
- #elseif($prop.name == "actionListener")
- setActionListenerProperty(component, this._${prop.name});
- #elseif($prop.name == "converter")
- setConverterProperty(component, this._${prop.name});
- #elseif($prop.name == "validator")
- setValidatorProperty(component, this._${prop.name});
- #elseif($prop.name == "valueChangeListener")
- setValueChangedListenerProperty(component, this._${prop.name});
- #elseif($prop.name == "value")
- setValueProperty(component, this._${prop.name});
- #elseif($prop.elOnly || $prop.isInstanceof("javax.faces.el.ValueBinding") )
- setValueBinding(component, "${prop.name}",this._${prop.name});
- #elseif(${prop.simpleType})
- // Simple type - ${prop.simpleClassName}
- set${prop.boxingClass}Property(component, "${prop.name}",this._${prop.name});
- #elseif($prop.classname == "java.lang.Boolean" || $prop.classname == "java.lang.Integer" || $prop.classname == "java.lang.Long")
- set${prop.simpleClassName}Property(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.classname == "java.lang.String")
- setStringProperty(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.classname == "java.lang.Object")
- // TODO - handle object
- setStringProperty(component, "${prop.name}",this._${prop.name});
- #elseif( $prop.isInstanceof("javax.faces.el.MethodBinding") )
- if(null != this._${prop.name}){
- if (isValueReference(this._${prop.name}))
- {
- MethodBinding mb = getFacesContext().getApplication().createMethodBinding(this._${prop.name},
- new Class[]{${prop.methodargs}});
- ((${component.simpleClassName})component).${prop.setterName}(mb);
- }
- else
- {
- getFacesContext().getExternalContext().log("Component " + component.getClientId(getFacesContext()) + " has invalid ${prop.name} value: " + this._${prop.name});
- }
- }
- #else
- // TODO - setup properties for other cases.
- // name ${prop.name} with type $prop.classname
- #end
- #end
-#end
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getComponentType()
- */
- public String getComponentType() {
- // TODO Auto-generated method stub
- return "${component.name}";
- }
-
- /* (non-Javadoc)
- * @see javax.faces.webapp.UIComponentTag#getRendererType()
- */
- public String getRendererType() {
- #if($renderer)
- return "${renderer.name}";
- #else
- return null;
- #end
- }
-
-}
+/**
+ * GENERATED FILE - DO NOT EDIT
+ *
+ */
+package ${tag.packageName};
+
+#foreach($import in $imports)
+import $import ;
+#end
+import javax.faces.component.UIComponent;
+import ${component.classname};
+
+public class $tag.simpleClassName extends $tag.superclass {
+
+// Fields
+#foreach( $prop in $component.properties )
+ #if( !$prop.existintag )
+ /*
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+ private String _$prop.name = null;
+
+ #end
+#end
+// Setters
+#foreach( $prop in $component.properties )
+ #if( !$prop.existintag )
+ /*
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+ /**
+ * $prop.description
+ * Setter for $prop.name
+ * @param $prop.name - new value
+ */
+ public void ${prop.setterName}( String __${prop.name} ){
+ this._${prop.name} = __${prop.name};
+ }
+
+ #end
+ #if( $prop.alias)
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Setter for alias of $prop.name as $prop.alias
+ * @param $prop.name - new value
+ */
+ public void set${prop.upperFirstChar($prop.alias)}( String __${prop.alias} ){
+ this.${prop.setterName}(__${prop.alias});
+ }
+ #end
+#end
+// Release
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#release()
+ */
+ public void release()
+ {
+ // TODO Auto-generated method stub
+ super.release();
+#foreach( $prop in $component.properties )
+ #if( !$prop.existintag )
+ this._${prop.name} = null;
+ #end
+#end
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component)
+ {
+ // TODO Auto-generated method stub
+ super.setProperties(component);
+
+#foreach( $prop in $component.properties )
+ #if( !$prop.existintag )
+ #if(!$prop.el)
+ if(isValueReference(this._${prop.name})){
+ throw new IllegalArgumentException("Component ${component.name} with Id " + component.getClientId(getFacesContext() +" not allowed EL expression for property ${prop.name}")
+ }
+ #end
+ #if($prop.name == "action")
+ setActionProperty(component, this._${prop.name});
+ #elseif($prop.name == "actionListener")
+ setActionListenerProperty(component, this._${prop.name});
+ #elseif($prop.name == "converter")
+ setConverterProperty(component, this._${prop.name});
+ #elseif($prop.name == "validator")
+ setValidatorProperty(component, this._${prop.name});
+ #elseif($prop.name == "valueChangeListener")
+ setValueChangedListenerProperty(component, this._${prop.name});
+ #elseif($prop.name == "value")
+ setValueProperty(component, this._${prop.name});
+ #elseif($prop.elOnly || $prop.isInstanceof("javax.faces.el.ValueBinding") )
+ setValueBinding(component, "${prop.name}",this._${prop.name});
+ #elseif(${prop.simpleType})
+ // Simple type - ${prop.simpleClassName}
+ set${prop.boxingClass}Property(component, "${prop.name}",this._${prop.name});
+ #elseif($prop.classname == "java.lang.Boolean" || $prop.classname == "java.lang.Integer" || $prop.classname == "java.lang.Long")
+ set${prop.simpleClassName}Property(component, "${prop.name}",this._${prop.name});
+ #elseif( $prop.classname == "java.lang.String")
+ setStringProperty(component, "${prop.name}",this._${prop.name});
+ #elseif( $prop.classname == "java.lang.Object")
+ // TODO - handle object
+ setStringProperty(component, "${prop.name}",this._${prop.name});
+ #elseif( $prop.isInstanceof("javax.faces.el.MethodBinding") )
+ if(null != this._${prop.name}){
+ if (isValueReference(this._${prop.name}))
+ {
+ MethodBinding mb = getFacesContext().getApplication().createMethodBinding(this._${prop.name},
+ new Class[]{${prop.methodargs}});
+ ((${component.simpleClassName})component).${prop.setterName}(mb);
+ }
+ else
+ {
+ getFacesContext().getExternalContext().log("Component " + component.getClientId(getFacesContext()) + " has invalid ${prop.name} value: " + this._${prop.name});
+ }
+ }
+ #else
+ // TODO - setup properties for other cases.
+ // name ${prop.name} with type $prop.classname
+ #end
+ #end
+#end
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType() {
+ // TODO Auto-generated method stub
+ return "${component.name}";
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType() {
+ #if($renderer)
+ return "${renderer.name}";
+ #else
+ return null;
+ #end
+ }
+
+}
19 years
JBoss Ajax4JSF SVN: r153 - trunk/cdk/generator/src/main/resources/META-INF/templates12.
by ajax4jsf-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-02 13:04:21 -0400 (Wed, 02 May 2007)
New Revision: 153
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates12/validator.vm
Log:
Bug AJSF-12, validators&converters stateHolder support
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/validator.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/validator.vm 2007-05-02 16:59:36 UTC (rev 152)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/validator.vm 2007-05-02 17:04:21 UTC (rev 153)
@@ -1,434 +1,232 @@
-package $package;
-package $package;
-
-#foreach($import in $imports)
-import $import ;
-#end
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.component.StateHolder;
-
-/**
- * Validator-Id ${validator.id}
- * ${validator.xmlEncodedDescription}
- */
-public class $validator.simpleClassName extends $validator.superclass #if(${validator.stateHolderRequired} && !${validator.superclassImplementsStateHolder})implements StateHolder#end
-{
-
- public static final String VALIDATOR_ID = "${validator.id}";
-
- /**
- * Default no-args contstructor
- */
- public $validator.simpleClassName ()
- {
- }
-
-// Validator properties fields
-#set( $fieldCounter = 0 )
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
- /**
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
-#if($prop.simpleType)
- private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
- /**
- * Flag indicated that $prop.name is set.
- */
- private boolean _${prop.name}Set = false;
-#set( $fieldCounter = $fieldCounter+2)
-#else
- private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
-#set( $fieldCounter = $fieldCounter+1)
-#end
-#end
-#end
-
-// Getters and setters
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
- /**
- * ${prop.xmlEncodedDescription}
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
-#if($prop.simpleType)
- this._${prop.name}Set = true;
-#end
- }
-
- /**
- * ${prop.xmlEncodedDescription}
- * Getter for $prop.name
- * @return $prop.name value from local variable or value binding
- */
- public $prop.simpleClassName ${prop.getterName}()
- {
- ValueBinding vb = getValueBinding(_${prop.name});
-#if($prop.simpleType)
- if(this._${prop.name}Set)
- {
- return this._${prop.name};
- }
- if (vb != null)
- {
- ${prop.boxingClass} value = (${prop.boxingClass}) vb.getValue(getFacesContext());
- if (null == value)
- {
- return this._${prop.name};
- }
- //return (value.${prop.classname}Value());
- } else
- {
- return (this._${prop.name});
- }
- }
-#else
- if (null != this._${prop.name})
- {
- return this._${prop.name};
- }
-#if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
- else if (null != vb)
- {
- return (${prop.simpleClassName})vb.getValue(getFacesContext());
- }
-#end
- else
- {
- return ${prop.defaultvalue};
- }
- }
-#end
-#if($prop.raw)
- /**
- * ${prop.xmlEncodedDescription}
- * Raw Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}Raw( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
- }
- /*
- * ${prop.xmlEncodedDescription}
- * Raw ( bypadd bindings ) Getter for $prop.name
- * @return $prop.name value from local variable
- */
- public $prop.simpleClassName ${prop.getterName}Raw()
- {
- return this._${prop.name};
- }
-#end
-#end
-#end
-
-
-#if($validator.stateHolderRequired)
-
- // Save state
- // ----------------------------------------------------- StateHolder Methods
-
- private boolean _transient;
-#if(${validator.superclassImplementsStateHolder})
-#set($currentField=1)
-#set( $fieldCounter = $fieldCounter+1)
-#else
-#set($currentField=0)
-#end
- public Object saveState(FacesContext context) {
-#if(${validator.superSaveStateMethodExists})
- Object values[] = new Object[${fieldCounter}];
- values[0] = super.saveState(context);
-#else
- Object values[] = new Object[${fieldCounter}];
-#end
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
-#if($prop.simpleType)
- values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
-#set( $currentField = $currentField+1)
- values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
-#set( $currentField = $currentField+1)
-#else
-#if(!${prop.attachedstate} )
- values[${currentField}] = _$prop.name;
-#else
- values[${currentField}] = saveAttachedState(context, _$prop.name );
-#end
-#set( $currentField = $currentField+1)
-#end
-#end
-#end
- return values;
- }
-
-#if(${validator.superclassImplementsStateHolder})
-#set($currentField=1)
-#else
-#set($currentField=0)
-#end
- public void restoreState(FacesContext context, Object state) {
-#if(${validator.superRestoreStateMethodExists})
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
-#else
- Object values[] = (Object[]) state;
-#end
-#foreach( $prop in $validator.properties )
-#if( !$prop.exist )
-#if($prop.simpleType)
- _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
-#set( $currentField = $currentField+1)
- _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
-#set( $currentField = $currentField+1)
-#else
-#if( !${prop.attachedstate} )
- _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
-#else
- _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
-#end
-#set( $currentField = $currentField+1)
-#end
-
-#end
-#end
- }
-
-#if(!$validator.superIsTransientMethodExists)
- public boolean isTransient()
- {
- return _transient;
- }
-#end
-
-#if(!$validator.superSetTransientMethodExists)
- public void setTransient(boolean newTransientValue)
- {
- this._transient = newTransientValue;
- }
-#end
-
-#end
-
-
-// Utilites
-
- private FacesContext getFacesContext()
- {
- return FacesContext.getCurrentInstance();
- }
-
- private ValueBinding getValueBinding(String name)
- {
- return getFacesContext().getApplication().createValueBinding(name);
- }
-
-}
-
-#foreach($import in $imports)
-import $import ;
-#end
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import java.io.IOException;
-import javax.faces.FacesException;
-import javax.faces.component.StateHolder;
-
-/**
- * Validator-Id ${validator.id}
- * ${validator.xmlEncodedDescription}
- */
-public class $validator.simpleClassName extends $validator.superclass implements StateHolder {
-
- public static final String VALIDATOR_ID = "${validator.id}";
-
- /**
- * Default no-args contstructor
- */
- public $validator.simpleClassName () {
- }
-
-// Validator properties fields
-#set( $fiedCounter = 0 )
-#foreach( $prop in $validator.properties )
- #if( !$prop.exist )
- /**
- * $prop.name
- * ${prop.xmlEncodedDescription}
- */
- #if($prop.simpleType)
- private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
- /**
- * Flag indicated that $prop.name is set.
- */
- private boolean _${prop.name}Set = false;
- #set( $fiedCounter = $fiedCounter+2)
- #else
- private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
- #set( $fiedCounter = $fiedCounter+1)
- #end
- #end
-#end
-
-// Getters and setters
-#foreach( $prop in $validator.properties )
- #if( !$prop.exist )
- /**
- * ${prop.xmlEncodedDescription}
- * Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
- #if($prop.simpleType)
- this._${prop.name}Set = true;
- #end
- }
-
- /**
- * ${prop.xmlEncodedDescription}
- * Getter for $prop.name
- * @return $prop.name value from local variable or value binding
- */
- public $prop.simpleClassName ${prop.getterName}()
- {
- ValueBinding vb = getValueBinding("${prop.name}");
- #if($prop.simpleType)
- if(this._${prop.name}Set)
- {
- return this._${prop.name};
- }
- if (vb != null)
- {
- ${prop.boxingClass} value = (${prop.boxingClass}) vb.getValue(getFacesContext());
- if (null == value)
- {
- return this._${prop.name};
- }
- //return (value.${prop.classname}Value());
- } else
- {
- return (this._${prop.name});
- }
- }
- #else
- if (null != this._${prop.name})
- {
- return this._${prop.name};
- }
- #if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
- else if (null != vb)
- {
- return (${prop.simpleClassName})vb.getValue(getFacesContext());
- }
- #end
- else
- {
- return ${prop.defaultvalue};
- }
- #end
- }
- #if($prop.raw)
-
- /**
- * ${prop.xmlEncodedDescription}
- * Raw Setter for $prop.name
- * @param $prop.name - new value
- */
- public void ${prop.setterName}Raw( $prop.simpleClassName __$prop.name )
- {
- this._${prop.name} = __$prop.name;
- }
- /*
- * ${prop.xmlEncodedDescription}
- * Raw ( bypadd bindings ) Getter for $prop.name
- * @return $prop.name value from local variable
- */
- public $prop.simpleClassName ${prop.getterName}Raw()
- {
- return this._${prop.name};
- }
- #end
- #end
-#end
-
-// Save state
-// ----------------------------------------------------- StateHolder Methods
-
-
- public Object saveState(FacesContext context) {
- Object values[] = new Object[${fiedCounter}];
-// values[0] = super.saveState(context);
-#set($currentField = 0)
-#foreach( $prop in $validator.properties )
- #if( !$prop.exist )
- #if($prop.simpleType)
- values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
- #set( $currentField = $currentField+1)
- values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
- #set( $currentField = $currentField+1)
- #else
- #if(!${prop.attachedstate} )
- values[${currentField}] = _$prop.name;
- #else
- values[${currentField}] = saveAttachedState(context, _$prop.name );
- #end
- #set( $currentField = $currentField+1)
- #end
- #end
-#end
- return values;
- }
-
-
- public void restoreState(FacesContext context, Object state) {
- Object values[] = (Object[]) state;
-// super.restoreState(context, values[0]);
-#set($currentField = 0)
-#foreach( $prop in $validator.properties )
- #if( !$prop.exist )
- #if($prop.simpleType)
- _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
- #set( $currentField = $currentField+1)
- _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
- #set( $currentField = $currentField+1)
- #else
- #if( !${prop.attachedstate} )
- _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
- #else
- _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
- #end
- #end
- #set( $currentField = $currentField+1)
- #end
-#end
-
- }
-
- public boolean isTransient() {
- return false;
- }
-
- public void setTransient(boolean newTransientValue){
- }
-
- // Utilites
-
- private FacesContext getFacesContext() {
- return FacesContext.getCurrentInstance();
- }
-
- private ValueBinding getValueBinding(String name) {
- return getFacesContext().getApplication().createValueBinding(name);
- }
-
-}
+package $package;
+
+#foreach($import in $imports)
+import $import ;
+#end
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.component.StateHolder;
+
+/**
+ * Validator-Id ${validator.id}
+ * ${validator.xmlEncodedDescription}
+ */
+public class $validator.simpleClassName extends $validator.superclass #if(${validator.stateHolderRequired} && !${validator.superclassImplementsStateHolder})implements StateHolder#end
+{
+
+ public static final String VALIDATOR_ID = "${validator.id}";
+
+ /**
+ * Default no-args contstructor
+ */
+ public $validator.simpleClassName ()
+ {
+ }
+
+// Validator properties fields
+#set( $fieldCounter = 0 )
+#foreach( $prop in $validator.properties )
+#if( !$prop.exist )
+ /**
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+#if($prop.simpleType)
+ private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
+ /**
+ * Flag indicated that $prop.name is set.
+ */
+ private boolean _${prop.name}Set = false;
+#set( $fieldCounter = $fieldCounter+2)
+#else
+ private $prop.simpleClassName _$prop.name = null; /* Default is ${prop.defaultvalue}*/
+#set( $fieldCounter = $fieldCounter+1)
+#end
+#end
+#end
+
+// Getters and setters
+#foreach( $prop in $validator.properties )
+#if( !$prop.exist )
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Setter for $prop.name
+ * @param $prop.name - new value
+ */
+ public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
+ {
+ this._${prop.name} = __$prop.name;
+#if($prop.simpleType)
+ this._${prop.name}Set = true;
+#end
+ }
+
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Getter for $prop.name
+ * @return $prop.name value from local variable or value binding
+ */
+ public $prop.simpleClassName ${prop.getterName}()
+ {
+ ValueBinding vb = getValueBinding(_${prop.name});
+#if($prop.simpleType)
+ if(this._${prop.name}Set)
+ {
+ return this._${prop.name};
+ }
+ if (vb != null)
+ {
+ ${prop.boxingClass} value = (${prop.boxingClass}) vb.getValue(getFacesContext());
+ if (null == value)
+ {
+ return this._${prop.name};
+ }
+ //return (value.${prop.classname}Value());
+ } else
+ {
+ return (this._${prop.name});
+ }
+ }
+#else
+ if (null != this._${prop.name})
+ {
+ return this._${prop.name};
+ }
+#if( !$prop.isInstanceof("javax.faces.el.MethodBinding") && !$prop.isInstanceof("javax.faces.el.ValueBinding"))
+ else if (null != vb)
+ {
+ return (${prop.simpleClassName})vb.getValue(getFacesContext());
+ }
+#end
+ else
+ {
+ return ${prop.defaultvalue};
+ }
+ }
+#end
+#if($prop.raw)
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Raw Setter for $prop.name
+ * @param $prop.name - new value
+ */
+ public void ${prop.setterName}Raw( $prop.simpleClassName __$prop.name )
+ {
+ this._${prop.name} = __$prop.name;
+ }
+ /*
+ * ${prop.xmlEncodedDescription}
+ * Raw ( bypadd bindings ) Getter for $prop.name
+ * @return $prop.name value from local variable
+ */
+ public $prop.simpleClassName ${prop.getterName}Raw()
+ {
+ return this._${prop.name};
+ }
+#end
+#end
+#end
+
+
+#if($validator.stateHolderRequired)
+
+ // Save state
+ // ----------------------------------------------------- StateHolder Methods
+
+ private boolean _transient;
+#if(${validator.superclassImplementsStateHolder})
+#set($currentField=1)
+#set( $fieldCounter = $fieldCounter+1)
+#else
+#set($currentField=0)
+#end
+ public Object saveState(FacesContext context) {
+#if(${validator.superSaveStateMethodExists})
+ Object values[] = new Object[${fieldCounter}];
+ values[0] = super.saveState(context);
+#else
+ Object values[] = new Object[${fieldCounter}];
+#end
+#foreach( $prop in $validator.properties )
+#if( !$prop.exist )
+#if($prop.simpleType)
+ values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
+#set( $currentField = $currentField+1)
+ values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
+#set( $currentField = $currentField+1)
+#else
+#if(!${prop.attachedstate} )
+ values[${currentField}] = _$prop.name;
+#else
+ values[${currentField}] = saveAttachedState(context, _$prop.name );
+#end
+#set( $currentField = $currentField+1)
+#end
+#end
+#end
+ return values;
+ }
+
+#if(${validator.superclassImplementsStateHolder})
+#set($currentField=1)
+#else
+#set($currentField=0)
+#end
+ public void restoreState(FacesContext context, Object state) {
+#if(${validator.superRestoreStateMethodExists})
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+#else
+ Object values[] = (Object[]) state;
+#end
+#foreach( $prop in $validator.properties )
+#if( !$prop.exist )
+#if($prop.simpleType)
+ _$prop.name = ((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
+#set( $currentField = $currentField+1)
+ _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
+#set( $currentField = $currentField+1)
+#else
+#if( !${prop.attachedstate} )
+ _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
+#else
+ _$prop.name = (${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
+#end
+#set( $currentField = $currentField+1)
+#end
+
+#end
+#end
+ }
+
+#if(!$validator.superIsTransientMethodExists)
+ public boolean isTransient()
+ {
+ return _transient;
+ }
+#end
+
+#if(!$validator.superSetTransientMethodExists)
+ public void setTransient(boolean newTransientValue)
+ {
+ this._transient = newTransientValue;
+ }
+#end
+
+#end
+
+
+// Utilites
+
+ private FacesContext getFacesContext()
+ {
+ return FacesContext.getCurrentInstance();
+ }
+
+ private ValueBinding getValueBinding(String name)
+ {
+ return getFacesContext().getApplication().createValueBinding(name);
+ }
+
+}
\ No newline at end of file
19 years