JBoss Ajax4JSF SVN: r152 - trunk/cdk/generator/src/main/resources/META-INF/templates12.
by ajax4jsf-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-02 12:59:36 -0400 (Wed, 02 May 2007)
New Revision: 152
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates12/converter.vm
Log:
Bug AJSF-12, validators&converters stateHolder support
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/converter.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/converter.vm 2007-05-02 14:22:54 UTC (rev 151)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/converter.vm 2007-05-02 16:59:36 UTC (rev 152)
@@ -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);
+ }
+
+ }
17 years, 8 months
JBoss Ajax4JSF SVN: r151 - trunk/docs/userguide/en/modules.
by ajax4jsf-svn-commits@lists.jboss.org
Author: afedosik
Date: 2007-05-02 10:22:54 -0400 (Wed, 02 May 2007)
New Revision: 151
Modified:
trunk/docs/userguide/en/modules/a4jUGstart.xml
Log:
Modified: trunk/docs/userguide/en/modules/a4jUGstart.xml
===================================================================
--- trunk/docs/userguide/en/modules/a4jUGstart.xml 2007-05-02 14:22:37 UTC (rev 150)
+++ trunk/docs/userguide/en/modules/a4jUGstart.xml 2007-05-02 14:22:54 UTC (rev 151)
@@ -187,7 +187,7 @@
<section id="Web.xml">
<?dbhtml filename="Web.xml.html"?>
<title>Web.xml</title>
- <para>It is also necessary to add jar files (see <ulink url="Installation.html">installation chapter</ulink>) and modify the "web.xml" file:
+ <para>It is also necessary to add jar files (see <ulink url="GettingStartedWithAjax4jsf.html#Installation">installation chapter</ulink>) and modify the "web.xml" file:
</para>
<programlisting role="XML"> <![CDATA[<?xml version="1.0"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
17 years, 8 months
JBoss Ajax4JSF SVN: r150 - trunk/docs/userguide/en/modules.
by ajax4jsf-svn-commits@lists.jboss.org
Author: afedosik
Date: 2007-05-02 10:22:37 -0400 (Wed, 02 May 2007)
New Revision: 150
Modified:
trunk/docs/userguide/en/modules/a4jUGusingAJAX.xml
Log:
Modified: trunk/docs/userguide/en/modules/a4jUGusingAJAX.xml
===================================================================
--- trunk/docs/userguide/en/modules/a4jUGusingAJAX.xml 2007-05-02 13:06:45 UTC (rev 149)
+++ trunk/docs/userguide/en/modules/a4jUGusingAJAX.xml 2007-05-02 14:22:37 UTC (rev 150)
@@ -171,7 +171,7 @@
<property>"reRender attribute"</property>
</emphasis> 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="FAQ.html">FAQ chapter</ulink>).
+ server side (see <ulink url="index.html#FAQ">FAQ chapter</ulink>).
</listitem>
<listitem>
<emphasis role="italic">
17 years, 8 months
JBoss Ajax4JSF SVN: r149 - trunk/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter.
by ajax4jsf-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-05-02 09:06:45 -0400 (Wed, 02 May 2007)
New Revision: 149
Modified:
trunk/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContentTest.java
Log:
Build fixed, test updated
Modified: trunk/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContentTest.java
===================================================================
--- trunk/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContentTest.java 2007-05-02 02:10:44 UTC (rev 148)
+++ trunk/test/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContentTest.java 2007-05-02 13:06:45 UTC (rev 149)
@@ -28,7 +28,6 @@
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
-import java.io.StringWriter;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.shale.test.mock.MockPrintWriter;
@@ -70,8 +69,7 @@
*/
public void testGetOutputStream() throws IOException {
CacheContent content = new CacheContent();
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- OutputStream outputStream = content.getOutputStream(out);
+ OutputStream outputStream = content.getOutputStream();
byte[] bytes = "Test".getBytes();
outputStream.write(bytes);
outputStream.flush();
@@ -100,8 +98,7 @@
*/
public void testGetWriter() throws IOException {
CacheContent content = new CacheContent();
- StringWriter out = new StringWriter();
- PrintWriter outputStream = content.getWriter(out);
+ PrintWriter outputStream = content.getWriter();
outputStream.write("Test");
outputStream.flush();
outputStream.close();
17 years, 8 months
JBoss Ajax4JSF SVN: r148 - in trunk: framework/src/main/java/org/ajax4jsf/framework/ajax and 19 other directories.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-05-01 22:10:44 -0400 (Tue, 01 May 2007)
New Revision: 148
Added:
trunk/samples/seamIntegration/
trunk/samples/seamIntegration/pom.xml
trunk/samples/seamIntegration/src/
trunk/samples/seamIntegration/src/main/
trunk/samples/seamIntegration/src/main/java/
trunk/samples/seamIntegration/src/main/java/org/
trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/
trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java
trunk/samples/seamIntegration/src/main/resources/
trunk/samples/seamIntegration/src/main/resources/hibernate.cfg.xml
trunk/samples/seamIntegration/src/main/resources/import.sql
trunk/samples/seamIntegration/src/main/resources/logging.properties
trunk/samples/seamIntegration/src/main/resources/seam.properties
trunk/samples/seamIntegration/src/main/webapp/
trunk/samples/seamIntegration/src/main/webapp/WEB-INF/
trunk/samples/seamIntegration/src/main/webapp/WEB-INF/components.xml
trunk/samples/seamIntegration/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/seamIntegration/src/main/webapp/WEB-INF/faces-config.xml.l4t
trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml
trunk/samples/seamIntegration/src/main/webapp/index.jsp
trunk/samples/seamIntegration/src/main/webapp/pages/
trunk/samples/seamIntegration/src/main/webapp/pages/index.jsp
trunk/samples/seamIntegration/src/main/webapp/pages/index.xhtml
trunk/samples/seamIntegration/src/main/webapp/pages/repeater.xhtml
trunk/samples/seamIntegration/src/test/
trunk/samples/seamIntegration/src/test/java/
trunk/samples/seamIntegration/src/test/java/org/
trunk/samples/seamIntegration/src/test/java/org/ajax4jsf/
trunk/samples/seamIntegration/src/test/java/org/ajax4jsf/BeanTest.java
trunk/samples/useCases/src/main/webapp/pages/ajaxdata.xhtml
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates/tag.vm
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewHandler.java
trunk/framework/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java
trunk/framework/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java
trunk/framework/src/test/java/org/ajax4jsf/framework/util/javascript/ScriptUtilsTest.java
trunk/samples/createProject.sh
trunk/samples/pom.xml
trunk/samples/useCases/src/main/java/org/ajax4jsf/Bean.java
Log:
Create sample for Jboss Seam ajax support.
Fixed issues : AJSF-10 , 15 , 18 , 45, 48
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates/tag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/tag.vm 2007-05-02 01:26:49 UTC (rev 147)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/tag.vm 2007-05-02 02:10:44 UTC (rev 148)
@@ -84,7 +84,7 @@
#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}")
+ throw new IllegalArgumentException("Component ${component.name} with Id " + component.getClientId(getFacesContext()) +" not allowed EL expression for property ${prop.name}");
}
#end
#if($prop.name == "action")
Modified: trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewHandler.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewHandler.java 2007-05-02 01:26:49 UTC (rev 147)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewHandler.java 2007-05-02 02:10:44 UTC (rev 148)
@@ -178,6 +178,7 @@
}
actionURL = externalContext.encodeActionURL(actionURL);
externalContext.redirect(actionURL);
+ context.responseComplete();
} catch (IOException e) {
throw new FacesException(
"Error on redirect for reload expired page", e);
Modified: trunk/framework/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java 2007-05-02 01:26:49 UTC (rev 147)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/util/javascript/JSEncoder.java 2007-05-02 02:10:44 UTC (rev 148)
@@ -73,6 +73,7 @@
(c == 0x27) || // [']
(c == 0x5c) || // [\]
(c == 0x03) || // [esc]
+ (c == ']') || // ] - to avoid conflicts in CDATA
(c < 0x20) || // See <http://www.w3.org/TR/REC-xml#charsets>
((c > 0xd7ff) && (c < 0xe000)) || (c > 0xfffd)|| (c > 0xff)) {
return (false);
Modified: trunk/framework/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java 2007-05-02 01:26:49 UTC (rev 147)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/util/javascript/ScriptUtils.java 2007-05-02 02:10:44 UTC (rev 148)
@@ -66,7 +66,7 @@
ret.append(toScript(element));
first = false;
}
- return ret.append(']').toString();
+ return ret.append("] ").toString();
} else if (obj instanceof Collection) {
// Collections put as JavaScript array.
Collection collection = (Collection) obj;
@@ -80,7 +80,7 @@
ret.append(toScript(element));
first = false;
}
- return ret.append(']').toString();
+ return ret.append("] ").toString();
} else if (obj instanceof Map) {
// Maps put as JavaScript hash.
Map map = (Map) obj;
@@ -97,7 +97,7 @@
ret.append(toScript(map.get(key)));
first = false;
}
- return ret.append('}').toString();
+ return ret.append("} ").toString();
} else if (obj instanceof Number || obj instanceof Boolean) {
// numbers and boolean put as-is, without conversion
return obj.toString();
@@ -127,7 +127,7 @@
ret.append(toScript(PropertyUtils.getProperty(obj, key)));
first = false;
}
- return ret.append('}').toString();
+ return ret.append("} ").toString();
} catch (Exception e) {
throw new FacesException(
"Error in conversion Java Object to JavaScript", e);
Modified: trunk/framework/src/test/java/org/ajax4jsf/framework/util/javascript/ScriptUtilsTest.java
===================================================================
--- trunk/framework/src/test/java/org/ajax4jsf/framework/util/javascript/ScriptUtilsTest.java 2007-05-02 01:26:49 UTC (rev 147)
+++ trunk/framework/src/test/java/org/ajax4jsf/framework/util/javascript/ScriptUtilsTest.java 2007-05-02 02:10:44 UTC (rev 148)
@@ -122,12 +122,30 @@
*/
public void testArrayToScript() {
int[] obj = {1,2,3,4,5};
- assertEquals("[1,2,3,4,5]", ScriptUtils.toScript(obj));
+ assertEquals("[1,2,3,4,5] ", ScriptUtils.toScript(obj));
}
+ /**
+ * Test method for {@link org.ajax4jsf.framework.util.javascript.ScriptUtils#toScript(java.lang.Object)}.
+ */
+ public void testTwoDimentionalArrayToScript() {
+ int[][] obj = {{1,2},{3,4}};
+ assertEquals("[[1,2] ,[3,4] ] ", ScriptUtils.toScript(obj));
+ }
/**
* Test method for {@link org.ajax4jsf.framework.util.javascript.ScriptUtils#toScript(java.lang.Object)}.
*/
+ public void testTwoDimentionalStringArrayToScript() {
+ String[][] obj = {{"one","two"},{"three","four"}};
+ assertEquals("[['one','two'] ,['three','four'] ] ", ScriptUtils.toScript(obj));
+ HashMap map = new HashMap();
+ map.put("a", obj);
+ map.put("b", "c");
+ assertEquals("{'a':[['one','two'] ,['three','four'] ] ,'b':'c'} ", ScriptUtils.toScript(map));
+ }
+ /**
+ * Test method for {@link org.ajax4jsf.framework.util.javascript.ScriptUtils#toScript(java.lang.Object)}.
+ */
public void testListToScript() {
List obj = new ArrayList();
obj.add(new Integer(1));
@@ -135,7 +153,7 @@
obj.add(new Integer(3));
obj.add(new Integer(4));
obj.add(new Integer(5));
- assertEquals("[1,2,3,4,5]", ScriptUtils.toScript(obj));
+ assertEquals("[1,2,3,4,5] ", ScriptUtils.toScript(obj));
}
/**
@@ -148,14 +166,14 @@
obj.add(new Integer(3));
obj.add(new Integer(4));
obj.add(new Integer(5));
- assertEquals("[1,2,3,4,5]", ScriptUtils.toScript(obj));
+ assertEquals("[1,2,3,4,5] ", ScriptUtils.toScript(obj));
}
/**
* Test method for {@link org.ajax4jsf.framework.util.javascript.ScriptUtils#toScript(java.lang.Object)}.
*/
public void testObjectArrayToScript() {
Bean[] obj = {new Bean(1,true,"foo"),new Bean(2,false,"bar")};
- assertEquals("[{'bool':true,'foo':'foo',\'integer\':1},{'bool':false,'foo':'bar','integer':2}]", ScriptUtils.toScript(obj));
+ assertEquals("[{'bool':true,'foo':'foo',\'integer\':1} ,{'bool':false,'foo':'bar','integer':2} ] ", ScriptUtils.toScript(obj));
}
/**
@@ -164,7 +182,7 @@
public void testObjectListToScript() {
Bean[] array = {new Bean(1,true,"foo"),new Bean(2,false,"bar")};
List obj = Arrays.asList(array);
- assertEquals("[{'bool':true,'foo':'foo',\'integer\':1},{'bool':false,'foo':'bar','integer':2}]", ScriptUtils.toScript(obj));
+ assertEquals("[{'bool':true,'foo':'foo',\'integer\':1} ,{'bool':false,'foo':'bar','integer':2} ] ", ScriptUtils.toScript(obj));
}
/**
@@ -175,7 +193,7 @@
obj.put("a", "foo");
obj.put("b", "bar");
obj.put("c", "baz");
- assertEquals("{'a':'foo','b':'bar','c':'baz'}", ScriptUtils.toScript(obj));
+ assertEquals("{'a':'foo','b':'bar','c':'baz'} ", ScriptUtils.toScript(obj));
}
/**
* Test method for {@link org.ajax4jsf.framework.util.javascript.ScriptUtils#addEncodedString(java.lang.StringBuffer, java.lang.Object)}.
Modified: trunk/samples/createProject.sh
===================================================================
--- trunk/samples/createProject.sh 2007-05-02 01:26:49 UTC (rev 147)
+++ trunk/samples/createProject.sh 2007-05-02 02:10:44 UTC (rev 148)
@@ -1,2 +1,2 @@
-#!/bin/sh
+#!/bin/sh
mvn archetype:create -e -DarchetypeGroupId=org.ajax4jsf.cdk -DarchetypeArtifactId=maven-archetype-jsfwebapp -DarchetypeVersion=1.1.1-SNAPSHOT -DartifactId=${1}
\ No newline at end of file
Modified: trunk/samples/pom.xml
===================================================================
--- trunk/samples/pom.xml 2007-05-02 01:26:49 UTC (rev 147)
+++ trunk/samples/pom.xml 2007-05-02 02:10:44 UTC (rev 148)
@@ -14,6 +14,7 @@
<module>ajaxPortlet</module>
<module>tomahawkCompability</module>
<module>useCases</module>
+ <module>seamIntegration</module>
</modules>
<build>
<plugins>
Added: trunk/samples/seamIntegration/pom.xml
===================================================================
--- trunk/samples/seamIntegration/pom.xml (rev 0)
+++ trunk/samples/seamIntegration/pom.xml 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>samples</artifactId>
+ <groupId>org.ajax4jsf</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.ajax4jsf</groupId>
+ <artifactId>seamIntegration</artifactId>
+ <packaging>war</packaging>
+ <name>seamIntegration Maven Webapp</name>
+ <build>
+ <finalName>seamIntegration</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <version>3.2.1.ga</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ <version>3.2.3.ga</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>seam</artifactId>
+ <version>1.2.1.ga</version>
+ <systemPath>${seamHome}/jboss-seam.jar</systemPath>
+ <scope>system</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>seam-ui</artifactId>
+ <version>1.2.1.ga</version>
+ <systemPath>${seamHome}/jboss-seam-ui.jar</systemPath>
+ <scope>system</scope>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.ga</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>el-impl</groupId>
+ <artifactId>el-impl</artifactId>
+ <version>1.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java
===================================================================
--- trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java (rev 0)
+++ trunk/samples/seamIntegration/src/main/java/org/ajax4jsf/Bean.java 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,80 @@
+/**
+ * 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;
+
+import java.io.Serializable;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpSession;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.End;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+/**
+ * @author $Autor$
+ *
+ */
+@Name("seamBean") @Scope(ScopeType.CONVERSATION) public class Bean implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4209339000953631111L;
+ private String text;
+
+ /**
+ * @return the text
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ @Begin
+ public String start() {
+ return "start";
+ }
+
+ @End
+ public String stop() {
+ return "stop";
+ }
+
+ public String clearSession(){
+ ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+ HttpSession session = (HttpSession) externalContext.getSession(false);
+ if(null != session){
+ session.setMaxInactiveInterval(10);
+ }
+ return null;
+ }
+}
\ No newline at end of file
Added: trunk/samples/seamIntegration/src/main/resources/hibernate.cfg.xml
===================================================================
--- trunk/samples/seamIntegration/src/main/resources/hibernate.cfg.xml (rev 0)
+++ trunk/samples/seamIntegration/src/main/resources/hibernate.cfg.xml 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,17 @@
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory name="java:/bookingDatabase">
+ <property name="show_sql">false</property>
+ <property name="connection.datasource">java:/DefaultDS</property>
+ <property name="hbm2ddl.auto">create-drop</property>
+ <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
+ <property name="transaction.flush_before_completion">true</property>
+ <property name="connection.release_mode">after_statement</property>
+ <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+ <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
+
+ </session-factory>
+</hibernate-configuration>
Added: trunk/samples/seamIntegration/src/main/resources/import.sql
===================================================================
--- trunk/samples/seamIntegration/src/main/resources/import.sql (rev 0)
+++ trunk/samples/seamIntegration/src/main/resources/import.sql 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,22 @@
+insert into Customer (username, password, name) values ('gavin', 'foobar', 'Gavin King')
+insert into Customer (username, password, name) values ('demo', 'demo', 'Demo User')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (1, 120, 'Marriott Courtyard', 'Tower Place, Buckhead', 'Atlanta', 'GA', '30305', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (2, 180, 'Doubletree', 'Tower Place, Buckhead', 'Atlanta', 'GA', '30305', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (3, 450, 'W Hotel', 'Union Square, Manhattan', 'NY', 'NY', '10011', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (4, 450, 'W Hotel', 'Lexington Ave, Manhattan', 'NY', 'NY', '10011', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (5, 250, 'Hotel Rouge', '1315 16th Street NW', 'Washington', 'DC', '20036', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (6, 300, '70 Park Avenue Hotel', '70 Park Avenue', 'NY', 'NY', '10011', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (8, 300, 'Conrad Miami', '1395 Brickell Ave', 'Miami', 'FL', '33131', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (9, 80, 'Sea Horse Inn', '2106 N Clairemont Ave', 'Eau Claire', 'WI', '54703', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (10, 90, 'Super 8 Eau Claire Campus Area', '1151 W Macarthur Ave', 'Eau Claire', 'WI', '54701', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (11, 160, 'Marriot Downtown', '55 Fourth Street', 'San Francisco', 'CA', '94103', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (12, 200, 'Hilton Diagonal Mar', 'Passeig del Taulat 262-264', 'Barcelona', 'Catalunya', '08019', 'Spain')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (13, 210, 'Hilton Tel Aviv', 'Independence Park', 'Tel Aviv', '', '63405', 'Israel')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (14, 240, 'InterContinental Tokyo Bay', 'Takeshiba Pier', 'Tokyo', '', '105', 'Japan')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (15, 130, 'Hotel Beaulac', ' Esplanade L�opold-Robert 2', 'Neuchatel', '', '2000', 'Switzerland')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (16, 140, 'Conrad Treasury Place', 'William & George Streets', 'Brisbane', 'QLD', '4001', 'Australia')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (17, 230, 'Ritz Carlton', '1228 Sherbrooke St', 'West Montreal', 'Quebec', 'H3G1H6', 'Canada')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (18, 460, 'Ritz Carlton', 'Peachtree Rd, Buckhead', 'Atlanta', 'GA', '30326', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (19, 220, 'Swissotel', '68 Market Street', 'Sydney', 'NSW', '2000', 'Australia')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (20, 250, 'Meli� White House', 'Albany Street', 'Regents Park London', '', 'NW13UP', 'Great Britain')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (21, 210, 'Hotel Allegro', '171 West Randolph Street', 'Chicago', 'IL', '60601', 'USA')
Added: trunk/samples/seamIntegration/src/main/resources/logging.properties
===================================================================
--- trunk/samples/seamIntegration/src/main/resources/logging.properties (rev 0)
+++ trunk/samples/seamIntegration/src/main/resources/logging.properties 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,22 @@
+handlers org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+org.apache.juli.FileHandler.level ALL
+org.apache.juli.FileHandler.directory ${catalina.base}/logs
+org.apache.juli.FileHandler.prefix ajax4jsf.
+
+java.util.logging.ConsoleHandler.level ALL
+java.util.logging.ConsoleHandler.formatter java.util.logging.SimpleFormatter
+
+facelets.level=ALL
+com.sun.faces.level=INFO
+org.apache.myfaces.level=ALL
+org.ajax4jsf.level=ALL
+javax.enterprise.resource.webcontainer.jsf.level=INFO
+com.exadel.level=ALL
+org.jboss.seam.level=FINE
+
\ No newline at end of file
Added: trunk/samples/seamIntegration/src/main/resources/seam.properties
===================================================================
Added: trunk/samples/seamIntegration/src/main/webapp/WEB-INF/components.xml
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/WEB-INF/components.xml (rev 0)
+++ trunk/samples/seamIntegration/src/main/webapp/WEB-INF/components.xml 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://jboss.com/products/seam/components"
+ xmlns:core="http://jboss.com/products/seam/core"
+ xmlns:security="http://jboss.com/products/seam/security"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.2.xsd
+ http://jboss.com/products/seam/security http://jboss.com/products/seam/security-1.2.xsd
+ http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.2.xsd">
+
+ <core:init debug="true" />
+
+ <core:manager conversation-timeout="120000"
+ concurrent-request-timeout="500" conversation-id-parameter="cid"
+ conversation-is-long-running-parameter="clr" />
+ <!--
+ <core:hibernate-session-factory name="hibernateSessionFactory"/>
+ -->
+ <core:microcontainer installed="false" />
+
+</components>
Added: trunk/samples/seamIntegration/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/WEB-INF/faces-config.xml (rev 0)
+++ trunk/samples/seamIntegration/src/main/webapp/WEB-INF/faces-config.xml 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+<faces-config>
+ <managed-bean>
+ <managed-bean-name>bean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.Bean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+ <lifecycle>
+ <phase-listener>
+ org.jboss.seam.jsf.SeamPhaseListener
+ </phase-listener>
+ </lifecycle>
+ <application>
+ <!-- el-resolver>org.jboss.seam.jsf.SeamELResolver</el-resolver-->
+ </application>
+
+</faces-config>
Added: trunk/samples/seamIntegration/src/main/webapp/WEB-INF/faces-config.xml.l4t
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/WEB-INF/faces-config.xml.l4t (rev 0)
+++ trunk/samples/seamIntegration/src/main/webapp/WEB-INF/faces-config.xml.l4t 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PROCESS ENTITY="JSFProcess"/>
Added: trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>Archetype Created Web Application</display-name>
+ <context-param>
+ <param-name>facelets.REFRESH_PERIOD</param-name>
+ <param-value>2</param-value>
+ </context-param>
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>com.sun.faces.validateXml</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>com.sun.faces.verifyObjects</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
+ <param-value>com.sun.facelets.FaceletViewHandler</param-value>
+ </context-param>
+ <context-param>
+ <param-name>facelets.VIEW_MAPPINGS</param-name>
+ <param-value>*.xhtml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <!--
+ -->
+ <filter>
+ <display-name>Ajax4jsf Filter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>ajax4jsf</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+ <filter>
+ <filter-name>Seam Filter</filter-name>
+ <filter-class>org.jboss.seam.web.SeamFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>Seam Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <listener>
+ <listener-class>
+ org.jboss.seam.servlet.SeamListener
+ </listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <servlet>
+ <servlet-name>Seam Resource Servlet</servlet-name>
+ <servlet-class>
+ org.jboss.seam.servlet.ResourceServlet
+ </servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Seam Resource Servlet</servlet-name>
+ <url-pattern>/seam/resource/*</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Added: trunk/samples/seamIntegration/src/main/webapp/index.jsp
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/index.jsp (rev 0)
+++ trunk/samples/seamIntegration/src/main/webapp/index.jsp 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,11 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+
+<html>
+
+<head></head>
+
+ <body>
+ <jsp:forward page="/pages/index.jsf" />
+ </body>
+
+</html>
\ No newline at end of file
Added: trunk/samples/seamIntegration/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/pages/index.jsp (rev 0)
+++ trunk/samples/seamIntegration/src/main/webapp/pages/index.jsp 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,12 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+
+ </f:view>
+ </body>
+</html>
Added: trunk/samples/seamIntegration/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/pages/index.xhtml (rev 0)
+++ trunk/samples/seamIntegration/src/main/webapp/pages/index.xhtml 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,12 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ >
+ <f:view>
+
+ </f:view>
+</html>
\ No newline at end of file
Added: trunk/samples/seamIntegration/src/main/webapp/pages/repeater.xhtml
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/pages/repeater.xhtml (rev 0)
+++ trunk/samples/seamIntegration/src/main/webapp/pages/repeater.xhtml 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,37 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html">
+ <head><title>Simple repeater in seam</title></head>
+ <body>
+ <h1>Simple ajax repeater</h1>
+ <h:form>
+ <h:panelGrid columns="3" border="1">
+ <h:inputText value="#{seamBean.text}">
+ <a4j:support reRender="out,conversation" event="onkeyup"></a4j:support>
+ </h:inputText>
+ <h:outputText id="out" value="#{seamBean.text}"></h:outputText>
+ <h:outputText value="All form submit."></h:outputText>
+ <h:inputText value="#{bean.text}">
+ <a4j:support reRender="out,outs,conversation" event="onkeyup"></a4j:support>
+ </h:inputText>
+ <h:outputText id="outs" value="#{bean.text}"></h:outputText>
+ <h:outputText value="AJAX Single submit."></h:outputText>
+ <h:outputText id="conversation" value="Conversation ID: #{conversation.id}"></h:outputText>
+ <a4j:commandButton action="#{seamBean.start}" value="Start conversation" reRender="out,conversation"></a4j:commandButton>
+ <a4j:commandButton action="#{seamBean.stop}" value="Stop conversation" reRender="out,conversation"></a4j:commandButton>
+ </h:panelGrid>
+ <a4j:commandButton action="#{seamBean.clearSession}" value="Set session expiration to 10 sec" reRender="out,conversation"></a4j:commandButton>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:messages></h:messages>
+ </a4j:outputPanel>
+ <a4j:status startText="Request..." stopText=""></a4j:status>
+ <h2>Non-Ajax conversation</h2>
+ <h:commandButton action="#{seamBean.start}" value="Start conversation" reRender="out,conversation"></h:commandButton>
+ <h:commandButton action="#{seamBean.stop}" value="Stop conversation" reRender="out,conversation"></h:commandButton>
+ <h:commandButton value="Refresh" reRender="out,conversation"></h:commandButton>
+ </h:form>
+ <a4j:log hotkey="M"></a4j:log>
+ </body>
+</html>
Added: trunk/samples/seamIntegration/src/test/java/org/ajax4jsf/BeanTest.java
===================================================================
--- trunk/samples/seamIntegration/src/test/java/org/ajax4jsf/BeanTest.java (rev 0)
+++ trunk/samples/seamIntegration/src/test/java/org/ajax4jsf/BeanTest.java 2007-05-02 02:10:44 UTC (rev 148)
@@ -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;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+*/
+public class BeanTest
+ extends TestCase
+{
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public BeanTest( String testName )
+ {
+ super( testName );
+ }
+
+ public void testStub() throws Exception {
+
+ }
+}
Modified: trunk/samples/useCases/src/main/java/org/ajax4jsf/Bean.java
===================================================================
--- trunk/samples/useCases/src/main/java/org/ajax4jsf/Bean.java 2007-05-02 01:26:49 UTC (rev 147)
+++ trunk/samples/useCases/src/main/java/org/ajax4jsf/Bean.java 2007-05-02 02:10:44 UTC (rev 148)
@@ -34,8 +34,12 @@
public class Bean {
private java.lang.String text;
+
+ private String[] array = {"one]","two]]>"};
- public java.lang.String getText() {
+ private String[][] array2 = {{"one","two"},{"three","four"}};
+
+ public java.lang.String getText() {
return text;
}
@@ -68,5 +72,33 @@
}
return null;
}
+
+ /**
+ * @return the array
+ */
+ public String[] getArray() {
+ return array;
+ }
+
+ /**
+ * @param array the array to set
+ */
+ public void setArray(String[] array) {
+ this.array = array;
+ }
+
+ /**
+ * @return the array2
+ */
+ public String[][] getArray2() {
+ return array2;
+ }
+
+ /**
+ * @param array2 the array2 to set
+ */
+ public void setArray2(String[][] array2) {
+ this.array2 = array2;
+ }
}
\ No newline at end of file
Added: trunk/samples/useCases/src/main/webapp/pages/ajaxdata.xhtml
===================================================================
--- trunk/samples/useCases/src/main/webapp/pages/ajaxdata.xhtml (rev 0)
+++ trunk/samples/useCases/src/main/webapp/pages/ajaxdata.xhtml 2007-05-02 02:10:44 UTC (rev 148)
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ >
+ <head>
+ <title>AJAX Data transfer</title>
+ <script type="text/javascript">
+ function inspect(data){
+ LOG.info("Data is "+data);
+ }
+ </script>
+ </head>
+ <body>
+ <f:view>
+ <h1>Sample of the data transfer from server to client</h1>
+ <h:form>
+ <h:panelGrid columns="2">
+ <a4j:commandButton value="Send" oncomplete="inspect(data);" data="#{bean.array}"></a4j:commandButton>
+ <h:outputText value="Data is String[]"></h:outputText>
+ <a4j:commandButton value="Send" oncomplete="inspect(data);" data="#{bean.array2}"></a4j:commandButton>
+ <h:outputText value="Data is String[][]"></h:outputText>
+ <a4j:commandButton value="Send" oncomplete="inspect(data);" data="#{bean}"></a4j:commandButton>
+ <h:outputText value="Data is JavaBean"></h:outputText>
+ </h:panelGrid>
+ </h:form>
+ <a4j:log popup='false' level="INFO"/>
+ </f:view>
+ </body>
+</html>
\ No newline at end of file
17 years, 8 months
JBoss Ajax4JSF SVN: r147 - in trunk/framework/src: test/java/org/ajax4jsf/cache and 1 other directory.
by ajax4jsf-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-05-01 21:26:49 -0400 (Tue, 01 May 2007)
New Revision: 147
Modified:
trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java
trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java
Log:
LRUMapCache.java modified for better strategy
Modified: trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java 2007-05-02 01:14:48 UTC (rev 146)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java 2007-05-02 01:26:49 UTC (rev 147)
@@ -43,13 +43,13 @@
private Map futures = new HashMap();
- public Object get(Object key, Object context) throws CacheException {
+ public synchronized Object get(Object key, Object context) throws CacheException {
try {
LRUMapFuture activeFuture = null;
LRUMapFuture future = null;
- synchronized (this) {
+ synchronized (futures) {
future = (LRUMapFuture) futures.get(key);
if (future == null) {
activeFuture = new LRUMapFuture();
@@ -64,19 +64,20 @@
return future.getResult();
}
} else {
- synchronized (this) {
- synchronized (activeFuture) {
- try {
- if (!containsKey(key)) {
- load(key, context);
- }
+ try {
+ if (!containsKey(key)) {
+ load(key, context);
+ }
- Object result = peek(key);
- activeFuture.setResult(result);
+ Object result = peek(key);
+ activeFuture.setResult(result);
- return result;
- } finally {
- this.futures.remove(key);
+ return result;
+ } finally {
+ synchronized (futures) {
+ this.futures.remove(key);
+
+ synchronized (activeFuture) {
activeFuture.notifyAll();
}
}
Modified: trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java
===================================================================
--- trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java 2007-05-02 01:14:48 UTC (rev 146)
+++ trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java 2007-05-02 01:26:49 UTC (rev 147)
@@ -27,24 +27,31 @@
};
private static final int COUNT = 2000;
+ private static final int PASS_COUNT = 200;
- private final Cache cache = new LRUMapCache(cacheLoader, COUNT);
public void testCache() throws Exception {
- Thread[] threads = new Thread[COUNT];
+ long millis = System.currentTimeMillis();
- try {
+ for (int k = 0; k < PASS_COUNT; k++) {
+ Cache cache = new LRUMapCache(cacheLoader, COUNT);
+ Thread[] threads = new Thread[COUNT];
+
+ try {
+ for (int i = 0; i < COUNT; i++) {
+ threads[i] = new TestThread(cache, new Integer(new Random().nextInt(10)));
+ threads[i].start();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
for (int i = 0; i < COUNT; i++) {
- threads[i] = new TestThread(cache, new Integer(new Random().nextInt(10)));
- threads[i].start();
+ threads[i].join();
}
- } catch (Exception e) {
- e.printStackTrace();
}
-
- for (int i = 0; i < COUNT; i++) {
- threads[i].join();
- }
+
+ System.out.println((double) (System.currentTimeMillis() - millis) / PASS_COUNT);
}
}
17 years, 8 months
JBoss Ajax4JSF SVN: r146 - in trunk: framework/src/main/java/org/ajax4jsf/cache and 5 other directories.
by ajax4jsf-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-05-01 21:14:48 -0400 (Tue, 01 May 2007)
New Revision: 146
Added:
trunk/framework/src/main/java/org/ajax4jsf/cache/
trunk/framework/src/main/java/org/ajax4jsf/cache/Cache.java
trunk/framework/src/main/java/org/ajax4jsf/cache/CacheEntry.java
trunk/framework/src/main/java/org/ajax4jsf/cache/CacheException.java
trunk/framework/src/main/java/org/ajax4jsf/cache/CacheFactory.java
trunk/framework/src/main/java/org/ajax4jsf/cache/CacheListener.java
trunk/framework/src/main/java/org/ajax4jsf/cache/CacheLoader.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/CacheKey.java
trunk/framework/src/test/java/org/ajax4jsf/cache/
trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java
Modified:
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java
trunk/framework/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java
trunk/framework/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java
trunk/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java
Log:
Switching from OsCache to pluggable caches based on modified JSR-107 API has started
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/Cache.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/Cache.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/Cache.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,180 @@
+package org.ajax4jsf.cache;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * <p>
+ * A cache, being a mechanism for efficient temporary storage of objects
+ * for the purpose of improving the overall performance of an application
+ * system, should not be necessary for the application to function correctly,
+ * it only improves the performance.
+ * <p>
+ * A cache could be scoped, for examples to a JVM, all JVMs on a node, all
+ * nodes in a cluster, etc. Operations that are scoped to a cache such as put
+ * or load would affect all JVMs in the cache. So the object loaded in 1 JVM
+ * would be equally available to all other JVMs in the cache.
+ * <p>
+ * Objects are identified in the cache by a key. A key can be any Java
+ * object that implements the equals and hashcode methods. If the object is
+ * to be distributed or persisted (if supported) it must implement
+ * serializable.
+ * <p/>
+ * Each object in the cache will have a <code>CacheEntry<code> object associated with
+ * it. This object will encapsulate the metadata associated with the cached
+ * object. Mainly it represents the object statistics.
+ * <p/>
+ * "CacheStatistics" represents the read-only statistics of the cache,
+ * while "CacheAttributes" represents the user settable attributes of the
+ * cache.
+ */
+public interface Cache
+{
+ /**
+ * Returns true if the cache contains the specified key. The search is
+ * scoped to the cache. Other caches in the system will not be searched
+ * and a CacheLoader will not be called.
+ * @return true, if the cache contains the specified key.
+ */
+ public boolean containsKey(Object key);
+
+ /**
+ * @return true if the cache contains one or more keys to the specified value.
+ */
+ public boolean containsValue(Object value);
+
+ /**
+ * Returns a set view of the objects currently contained in the cache.
+ * A CacheLoader will not be called. The behavior is unspecified for the
+ * case when an object is remove from the cache while the return set is
+ * being traversed.
+ */
+ public Set entrySet();
+
+ /**
+ * Equality is based on the Set returned by entrySet. Equal will return
+ * true if the two objects are referencing the same object or
+ * entrySet.equals(((Map)o).entrySet()) returns true.
+ */
+ public boolean equals(Object o);
+
+ /**
+ * @param ht a hashtable which holds a pointer pointing to the
+ * declarative cache description.
+ * @throws CacheException if any error occurs.
+ */
+
+ /**
+ * @return the hash code value for this the cache.
+ */
+ public int hashCode();
+
+ /**
+ * @return true if entrySet().isEmpty() returns true.
+ */
+ public boolean isEmpty();
+
+ /**
+ * Returns a set view of the keys currently contained in the cache. A
+ * CacheLoader will not be called. The behavior is unspecified for the
+ * case when an object is remove from the cache while the return set is
+ * being traversed.
+ */
+ public Set keySet();
+
+ /**
+ * Copies all of the mappings from the specified map to the cache. This
+ * would be equivalent to t.entrySet() then iterating through the Set and
+ * calling put with each key value pair.
+ */
+ public void putAll(Map t);
+
+ /**
+ * @return the number of objects in the cache. This should be the same
+ * value as entrySet().size();
+ */
+ public int size();
+
+ /**
+ * @return a collection view of the values contained in the cache.
+ */
+ public Collection values();
+
+ /**
+ * The get method will return, from the cache, the object associated with
+ * the argument "key". If the object is not in the cache, the associated
+ * cache loader will be called. If no loader is associated with the object,
+ * a null is returned. If a problem is encountered during the retrieving
+ * or loading of the object, an exception (to be defined) will be thrown.
+ * If the "arg" argument is set, the arg object will be passed to the
+ * CacheLoader.load method. The cache will not dereference the object.
+ * If no "arg" value is provided a null will be passed to the load method.
+ * The storing of null values in the cache is permitted, however, the get
+ * method will not distinguish returning a null stored in the cache and
+ * not finding the object in the cache. In both cases a null is returned.
+ * @throws CacheException
+ */
+ public Object get(Object key, Object context) throws CacheException;
+
+ /**
+ * The load method provides a means to "pre load" the cache. This method
+ * will, asynchronously, load the specified object into the cache using
+ * the associated cacheloader. If the object already exists in the cache,
+ * no action is taken. If no loader is associated with the object, no object
+ * will be loaded into the cache. If a problem is encountered during the
+ * retrieving or loading of the object, an exception should
+ * be logged.
+ * If the "arg" argument is set, the arg object will be passed to the
+ * CacheLoader.load method. The cache will not dereference the object. If
+ * no "arg" value is provided a null will be passed to the load method.
+ * The storing of null values in the cache is permitted, however, the get
+ * method will not distinguish returning a null stored in the cache and not
+ * finding the object in the cache. In both cases a null is returned.
+ */
+ public void load(Object key, Object context) throws CacheException;
+
+ /**
+ * The peek method will return the object associated with "key" if it
+ * currently exists (and is valid) in the cache. If not, a null is
+ * returned. With "peek" the CacheLoader will not be invoked and other
+ * caches in the system will not be searched.
+ */
+ public Object peek(Object key);
+
+ /**
+ * The put method adds the object "value" to the cache identified by the
+ * object "key".
+ */
+ public Object put(Object key, Object value);
+
+ /**
+ * Returns the CacheEntry object associated with the object identified by
+ * "key". If the object is not in the cache a null is returned.
+ */
+ public CacheEntry getCacheEntry(Object key);
+
+ /**
+ * The remove method will delete the object from the cache including the
+ * key, the associated value and the associated CacheStatistics object.
+ */
+ public Object remove(Object key);
+
+ /**
+ * The clear method will remove all objects from the cache including the
+ * key, the associated value and the associated CacheStatistics object.
+ */
+ public void clear();
+
+ /**
+ * The evict method will remove objects from the cache that are no longer
+ * valid. Objects where the specified expiration time has been reached.
+ */
+ public void evict();
+
+ /** Add a listener to the list of cache listeners */
+ public void addListener(CacheListener listener);
+
+ /** Remove a listener from the list of cache listeners */
+ public void removeListener(CacheListener listener);
+}
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/CacheEntry.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/CacheEntry.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/CacheEntry.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,29 @@
+package org.ajax4jsf.cache;
+
+import java.util.Map;
+
+/**
+ * CacheEntry
+ *
+ * @author Brian Goetz
+ */
+public interface CacheEntry extends Map.Entry {
+
+ int getHits();
+
+ long getLastAccessTime();
+ long getLastUpdateTime();
+ long getCreationTime();
+ long getExpirationTime();
+
+ /**
+ * Returns a version counter.
+ * An implementation may use timestamps for this or an incrementing
+ * number. Timestamps usually have issues with granularity and are harder
+ * to use across clusteres or threads, so an incrementing counter is often safer.
+ */
+ long getVersion();
+
+ boolean isValid();
+ long getCost();
+}
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/CacheException.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/CacheException.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/CacheException.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,43 @@
+package org.ajax4jsf.cache;
+
+
+/**
+ * CacheException is a generic exception, which indicates
+ * a cache error has occurred. All the other cache exceptions are the
+ * subclass of this class. All the methods in the cache package only
+ * throw CacheException or the sub class of it.
+ * <P>
+ *
+ */
+public class CacheException extends Exception
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6712594794189413065L;
+
+ /**
+ * Constructs a new CacheException.
+ */
+ public CacheException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs a new CacheException with a message string.
+ */
+ public CacheException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Constructs a CacheException with a message string, and
+ * a base exception
+ */
+ public CacheException(String s, Throwable ex)
+ {
+ super(s, ex);
+ }
+}
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/CacheFactory.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/CacheFactory.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/CacheFactory.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,21 @@
+package org.ajax4jsf.cache;
+
+import java.util.Map;
+
+/**
+ * CacheFactory is a service provider specific interface.
+ * Service provider should implement CacheFactory to provide
+ * the functionality to create a new implementation specific Cache object.
+ */
+public interface CacheFactory
+{
+ /**
+ * creates a new implementation specific Cache object using the env parameters.
+ * @param env implementation specific environment parameters passed to the
+ * CacheFactory.
+ * @param cacheLoader implementation of the {@link CacheLoader} to use
+ * @return an implementation specific Cache object.
+ * @throws CacheException if any error occurs.
+ */
+ public Cache createCache(Map env, CacheLoader cacheLoader) throws CacheException;
+}
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/CacheListener.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/CacheListener.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/CacheListener.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,20 @@
+package org.ajax4jsf.cache;
+
+/** Interface describing various events that can happen as elements are added to
+ * or removed from a cache
+ */
+public interface CacheListener {
+ /** Triggered when a cache mapping is created due to the cache loader being consulted */
+ public void onLoad(Object key);
+
+ /** Triggered when a cache mapping is created due to calling Cache.put() */
+ public void onPut(Object key);
+
+ /** Triggered when a cache mapping is removed due to eviction */
+ public void onEvict(Object key);
+
+ /** Triggered when a cache mapping is removed due to calling Cache.remove() */
+ public void onRemove(Object key);
+
+ public void onClear();
+}
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/CacheLoader.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/CacheLoader.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/CacheLoader.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,24 @@
+package org.ajax4jsf.cache;
+
+
+/**
+ * User should implement this CacheLoader interface to
+ * provide a loader object to load the objects into cache.
+ */
+public interface CacheLoader
+{
+ /**
+ * loads an object. Application writers should implement this
+ * method to customize the loading of cache object. This method is called
+ * by the caching service when the requested object is not in the cache.
+ * <P>
+ *
+ * @param key the key identifying the object being loaded
+ *
+ * @return The object that is to be stored in the cache.
+ * @throws CacheException
+ *
+ */
+ public Object load(Object key, Object context) throws CacheException;
+
+}
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/CacheManager.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,113 @@
+package org.ajax4jsf.cache;
+
+import java.io.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * CacheManager is used in J2SE environments for looking up named caches.
+ */
+public class CacheManager {
+
+ private static final String FACTORY_PROPERTY_NAME = "org.ajax4jsf.cache.CacheFactory";
+ private static final String DEFAULT_FACTORY_NAME = "org.ajax4jsf.cache.OSCacheCacheFactory";
+
+ protected static CacheManager instance = new CacheManager();
+
+ // REVIEW brian(a)quiotix.com
+ // Should this be a HashMap<String, WeakReference<Cache>>?
+ private final Map caches = Collections.synchronizedMap(new HashMap());
+
+ /**
+ * Returns the singleton CacheManager
+ */
+ public static CacheManager getInstance() {
+ return instance;
+ }
+
+ public Cache getCache(String cacheName) {
+ return (Cache) caches.get(cacheName);
+ }
+
+ public void registerCache(String cacheName, Cache cache) {
+ caches.put(cacheName, cache);
+ }
+
+ public CacheFactory getCacheFactory() throws CacheException {
+ String factoryName = findFactory(FACTORY_PROPERTY_NAME);
+
+ try {
+ ClassLoader cl = findClassLoader();
+ Class spiClass = Class.forName(factoryName, true, cl);
+ return (CacheFactory) spiClass.newInstance();
+ } catch (ClassNotFoundException cnfe) {
+ throw new CacheException("Could not find class: '" + factoryName + "'");
+ } catch (ClassCastException cce) {
+ throw new CacheException("Class: '" + factoryName + "' does not implement CacheFactory");
+ } catch (InstantiationException ie) {
+ throw new CacheException("Could not instantiate: '" + factoryName + "'");
+ } catch (IllegalAccessException iae) {
+ throw new CacheException("Could not find public default constructor for: '" + factoryName + "'");
+ }
+ }
+
+ private ClassLoader findClassLoader() {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null) cl = ClassLoader.getSystemClassLoader();
+ return cl;
+ }
+
+ private boolean isEmptyString(String s) {
+ return s == null || "".equals(s);
+ }
+
+ String findFactory(String factoryId) {
+
+ // Use the system property first
+ try {
+ String factoryClass = System.getProperty(factoryId);
+ if (!isEmptyString(factoryClass)) return factoryClass;
+ } catch (SecurityException ignore) {
+ }
+
+ // try to read from $java.home/lib/jcache.properties
+ try {
+ String configFile = System.getProperty("java.home") +
+ File.separator + "lib" + File.separator + "jcache.properties";
+ File f = new File(configFile);
+ if (f.exists()) {
+ InputStream in = new FileInputStream(f);
+ try {
+ Properties props = new Properties();
+ props.load(in);
+ String factoryClass = props.getProperty(factoryId);
+ if (!isEmptyString(factoryClass)) return factoryClass;
+ } finally {
+ in.close();
+ }
+ }
+ } catch (SecurityException ignore) {
+ } catch (IOException ignore) {
+ }
+
+ // try to find services in CLASSPATH
+ try {
+ ClassLoader cl = findClassLoader();
+ InputStream is = cl.getResourceAsStream("META-INF/services/" + factoryId);
+ if (is != null) {
+ BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ try {
+ String factoryName = r.readLine();
+ if (!isEmptyString(factoryName)) return factoryName;
+ } finally {
+ r.close();
+ }
+ }
+ } catch (IOException ignore) {
+ }
+
+ return DEFAULT_FACTORY_NAME;
+ }
+}
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCache.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,120 @@
+/**
+ *
+ */
+package org.ajax4jsf.cache;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.collections.map.LRUMap;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 01.05.2007
+ *
+ */
+public class LRUMapCache extends LRUMap implements Cache {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3236528957956574490L;
+ private CacheLoader cacheLoader;
+
+ public LRUMapCache(CacheLoader cacheLoader, int initialSize) {
+ super(initialSize);
+ this.cacheLoader = cacheLoader;
+ }
+
+ public LRUMapCache(CacheLoader cacheLoader) {
+ super();
+ this.cacheLoader = cacheLoader;
+ }
+
+ public void addListener(CacheListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void evict() {
+ // TODO Auto-generated method stub
+
+ }
+
+ private Map futures = new HashMap();
+
+ public Object get(Object key, Object context) throws CacheException {
+
+ try {
+ LRUMapFuture activeFuture = null;
+ LRUMapFuture future = null;
+
+ synchronized (this) {
+ future = (LRUMapFuture) futures.get(key);
+ if (future == null) {
+ activeFuture = new LRUMapFuture();
+ futures.put(key, activeFuture);
+ }
+
+ }
+
+ if (future != null) {
+ synchronized (future) {
+ future.wait();
+ return future.getResult();
+ }
+ } else {
+ synchronized (this) {
+ synchronized (activeFuture) {
+ try {
+ if (!containsKey(key)) {
+ load(key, context);
+ }
+
+ Object result = peek(key);
+ activeFuture.setResult(result);
+
+ return result;
+ } finally {
+ this.futures.remove(key);
+ activeFuture.notifyAll();
+ }
+ }
+ }
+ }
+
+ } catch (InterruptedException e) {
+ throw new CacheException(e.getMessage(), e);
+ }
+ }
+
+ public CacheEntry getCacheEntry(Object key) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public synchronized void load(Object key, Object context) throws CacheException {
+ put(key, cacheLoader.load(key, context));
+ }
+
+ public synchronized Object peek(Object key) {
+ return this.get(key);
+ }
+
+ public void removeListener(CacheListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+}
+
+class LRUMapFuture {
+ private Object result;
+
+ public Object getResult() {
+ return result;
+ }
+
+ public void setResult(Object result) {
+ this.result = result;
+ }
+}
\ No newline at end of file
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,21 @@
+/**
+ *
+ */
+package org.ajax4jsf.cache;
+
+import java.util.Map;
+
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 01.05.2007
+ *
+ */
+public class LRUMapCacheFactory implements CacheFactory {
+
+ public Cache createCache(Map env, CacheLoader cacheLoader)
+ throws CacheException {
+ return new LRUMapCache(cacheLoader);
+ }
+
+}
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCache.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCache.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCache.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,196 @@
+/**
+ *
+ */
+package org.ajax4jsf.cache;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+
+import com.opensymphony.oscache.base.NeedsRefreshException;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 01.05.2007
+ *
+ */
+public class OSCacheCache implements Cache {
+
+ private com.opensymphony.oscache.base.Cache cache;
+ private CacheLoader cacheLoader;
+
+ public OSCacheCache(com.opensymphony.oscache.base.Cache cache,
+ CacheLoader cacheLoader) {
+ super();
+ this.cache = cache;
+ this.cacheLoader = cacheLoader;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#addListener(org.ajax4jsf.framework.resource.cache.CacheListener)
+ */
+ public void addListener(CacheListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#clear()
+ */
+ public void clear() {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#containsKey(java.lang.Object)
+ */
+ public boolean containsKey(Object key) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#containsValue(java.lang.Object)
+ */
+ public boolean containsValue(Object value) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#entrySet()
+ */
+ public Set entrySet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#evict()
+ */
+ public void evict() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#get(java.lang.Object, java.lang.Object)
+ */
+ public Object get(Object key, Object context) throws CacheException {
+ String keyString = key.toString();
+
+ try {
+ return cache.getFromCache(keyString);
+ } catch (NeedsRefreshException e) {
+ Object object = cacheLoader.load(key, context);
+ try {
+ cache.putInCache(keyString, object);
+ } catch (Exception e1) {
+ cache.cancelUpdate(keyString);
+ throw new CacheException(e1.getMessage(), e1);
+ }
+ return object;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#getCacheEntry(java.lang.Object)
+ */
+ public CacheEntry getCacheEntry(Object key) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#isEmpty()
+ */
+ public boolean isEmpty() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#keySet()
+ */
+ public Set keySet() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#load(java.lang.Object, java.lang.Object)
+ */
+ public void load(Object key, Object context) throws CacheException {
+ cacheLoader.load(key, context);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#peek(java.lang.Object)
+ */
+ public Object peek(Object key) {
+ String keyString = key.toString();
+
+ try {
+ return cache.getFromCache(keyString);
+ } catch (NeedsRefreshException e) {
+ cache.cancelUpdate(keyString);
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#put(java.lang.Object, java.lang.Object)
+ */
+ public Object put(Object key, Object value) {
+ cache.putInCache(key.toString(), value);
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#putAll(java.util.Map)
+ */
+ public void putAll(Map t) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#remove(java.lang.Object)
+ */
+ public Object remove(Object key) {
+ String keyString = key.toString();
+
+ try {
+ return this.peek(keyString);
+ } finally {
+ cache.removeEntry(keyString);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#removeListener(org.ajax4jsf.framework.resource.cache.CacheListener)
+ */
+ public void removeListener(CacheListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#size()
+ */
+ public int size() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.cache.Cache#values()
+ */
+ public Collection values() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,27 @@
+/**
+ *
+ */
+package org.ajax4jsf.cache;
+
+import java.util.Map;
+
+
+import com.opensymphony.oscache.general.GeneralCacheAdministrator;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 01.05.2007
+ *
+ */
+public class OSCacheCacheFactory implements CacheFactory {
+
+ /* (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)
+ throws CacheException {
+ GeneralCacheAdministrator cacheAdministrator = new GeneralCacheAdministrator();
+ return new OSCacheCache(cacheAdministrator.getCache(), cacheLoader);
+ }
+
+}
Modified: trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java 2007-05-01 01:27:27 UTC (rev 145)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/CacheContent.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -172,7 +172,7 @@
* @param responseStream
* @return
*/
- public OutputStream getOutputStream(final OutputStream responseStream) {
+ public OutputStream getOutputStream() {
if (null == servletStream) {
outputStream = new FastBufferOutputStream(1024);
servletStream = new ServletOutputStream() {
@@ -185,7 +185,6 @@
public void close() throws IOException {
filledOutputStream = true;
// / content = outputStream.toByteArray();
- responseStream.close();
content = null;
}
@@ -195,7 +194,6 @@
* @see java.io.OutputStream#flush()
*/
public void flush() throws IOException {
- responseStream.flush();
}
/*
@@ -206,7 +204,6 @@
public void write(byte[] b, int off, int len)
throws IOException {
outputStream.write(b, off, len);
- responseStream.write(b, off, len);
}
/*
@@ -216,12 +213,10 @@
*/
public void write(byte[] b) throws IOException {
outputStream.write(b);
- responseStream.write(b);
}
public void write(int b) throws IOException {
outputStream.write(b);
- responseStream.write(b);
}
};
@@ -229,23 +224,20 @@
return servletStream;
}
- public PrintWriter getWriter(final Writer responseWriter) {
+ 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 {
- responseWriter.write(cbuf, off, len);
stringOutputWriter.write(cbuf, off, len);
}
public void flush() throws IOException {
- responseWriter.flush();
}
public void close() throws IOException {
- responseWriter.close();
// / writerContent = stringOutputWriter.toString();
filledOutputWriter = true;
writerContent = null;
Added: trunk/framework/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java (rev 0)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,41 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.resource;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 01.05.2007
+ *
+ */
+public class CacheKey {
+ private Object resourceData;
+ private HttpServletRequest request;
+ private HttpServletResponse response;
+ private InternetResource resource;
+ public CacheKey(Object resourceData,
+ HttpServletRequest request, HttpServletResponse response,
+ InternetResource resource) {
+ super();
+ this.resourceData = resourceData;
+ this.request = request;
+ this.response = response;
+ this.resource = resource;
+ }
+ public Object getResourceData() {
+ return resourceData;
+ }
+ public HttpServletRequest getRequest() {
+ return request;
+ }
+ public HttpServletResponse getResponse() {
+ return response;
+ }
+ public InternetResource getResource() {
+ return resource;
+ }
+
+}
Modified: trunk/framework/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java 2007-05-01 01:27:27 UTC (rev 145)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -51,7 +51,7 @@
* @see org.ajax4jsf.framework.resource.ResourceContext#getOutputStream()
*/
public OutputStream getOutputStream() throws IOException {
- return content.getOutputStream(this.parent.getOutputStream());
+ return content.getOutputStream();
}
/* (non-Javadoc)
@@ -94,7 +94,6 @@
*/
public void setDateHeader(String name, long value) {
this.content.setDateHeader(name,value);
- this.parent.setDateHeader(name, value);
}
/* (non-Javadoc)
@@ -102,7 +101,6 @@
*/
public void setHeader(String name, String value) {
this.content.setHeader(name,value);
- this.parent.setHeader(name, value);
}
/* (non-Javadoc)
@@ -110,7 +108,6 @@
*/
public void setIntHeader(String name, int value) {
this.content.setIntHeader(name,value);
- this.parent.setIntHeader(name, value);
}
/**
@@ -124,17 +121,14 @@
* @see org.ajax4jsf.framework.resource.ResourceContext#getWriter()
*/
public PrintWriter getWriter() throws IOException {
- // TODO Auto-generated method stub
- return content.getWriter(this.parent.getWriter());
+ return content.getWriter();
}
public void setContentType(String contentType) {
- this.parent.setContentType(contentType);
this.content.setContentType(contentType);
}
public Object getResourceData() {
- // TODO Auto-generated method stub
return parent.getResourceData();
}
@@ -148,13 +142,11 @@
}
public String getServletPath() {
- // TODO Auto-generated method stub
return parent.getServletPath();
}
public void release() {
super.release();
- parent.release();
}
}
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-01 01:27:27 UTC (rev 145)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -23,7 +23,10 @@
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;
import javax.faces.FacesException;
@@ -38,6 +41,10 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.ajax4jsf.cache.Cache;
+import org.ajax4jsf.cache.CacheException;
+import org.ajax4jsf.cache.CacheLoader;
+import org.ajax4jsf.cache.CacheManager;
import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
import org.ajax4jsf.framework.util.config.WebXml;
@@ -45,11 +52,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import com.opensymphony.oscache.base.Cache;
-import com.opensymphony.oscache.base.NeedsRefreshException;
-import com.opensymphony.oscache.web.ServletCacheAdministrator;
-public class InternetResourceService {
+public class InternetResourceService implements CacheLoader {
private static final Log log = LogFactory
.getLog(InternetResourceService.class);
@@ -61,7 +65,9 @@
private boolean cacheEnabled = true;
- private ServletCacheAdministrator cacheAdmin;
+ private Cache cache = null;
+
+ //private ServletCacheAdministrator cacheAdmin;
private FacesContextFactory contextFactory;
@@ -88,13 +94,20 @@
.getInitParameter(ENABLE_CACHING_PARAMETER))) {
setCacheEnabled(false);
// this.cacheEnabled = false;
- this.cacheAdmin = null;
+ //this.cacheAdmin = null;
} else {
// Load our implementation properties
Properties cacheProperties = getProperties("oscache.properties");
cacheProperties.putAll(getProperties("/oscache.properties"));
- this.cacheAdmin = ServletCacheAdministrator.getInstance(
- servletContext, cacheProperties);
+ //this.cacheAdmin = ServletCacheAdministrator.getInstance(
+ // servletContext, cacheProperties);
+ Map env = new HashMap();
+ try {
+ this.cache = CacheManager.getInstance().getCacheFactory().createCache(env, this);
+ } catch (CacheException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
// Create Resource-specific Faces Lifecycle instance.
lifecycleClass = servletContext
@@ -169,48 +182,57 @@
String cacheKey = resourceKey;// + "?" +
// request.getQueryString();
// TODO - select session/application scope.
- Cache cache = cacheAdmin.getAppScopeCache(getServletContext());
- try {
+ //Cache cache = cacheAdmin.getAppScopeCache(getServletContext());
+// try {
// TODO - use last modified/expires time
- CacheContent content = (CacheContent) cache
- .getFromCache(cacheKey);
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.GET_CONTENT_FROM_CACHE_INFO, cacheKey));
- }
- content.sendHeaders(response);
- // Correct expires date for resource.
- Date expired = resource.getExpired(null);
- if (expired != null) {
- response.setDateHeader("Expires", expired.getTime());
- } else {
- response.setDateHeader("Expires", System
- .currentTimeMillis()
- + InternetResource.DEFAULT_EXPIRE);
- }
- if (!request.getMethod().equals("HEAD")) {
- content.send(response);
- }
- } catch (NeedsRefreshException e) {
+
+ CacheKey key = new CacheKey(resourceDataForKey, request, response, resource);
+
+ CacheContent content;
try {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.CONTENT_NOT_FOUND_ERROR, cacheKey));
- }
- CachedResourceContext context = (CachedResourceContext) sendResource(
- resource, request, response, resourceDataForKey);
- // TODO - set refresh interval ?
- cache.putInCache(cacheKey, context.getContent());
- } catch (Exception ex) {
- cache.cancelUpdate(cacheKey);
- log.error(
- Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
- ex);
- throw new ServletException(Messages.getMessage(
- Messages.SEND_RESOURCE_ERROR_2, ex.getMessage()),
- ex);
+ content = (CacheContent) cache
+ .get(cacheKey, key);
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.GET_CONTENT_FROM_CACHE_INFO, cacheKey));
+ }
+ content.sendHeaders(response);
+ // Correct expires date for resource.
+ Date expired = resource.getExpired(null);
+ if (expired != null) {
+ response.setDateHeader("Expires", expired.getTime());
+ } else {
+ response.setDateHeader("Expires", System
+ .currentTimeMillis()
+ + InternetResource.DEFAULT_EXPIRE);
+ }
+ if (!request.getMethod().equals("HEAD")) {
+ content.send(response);
+ }/*
+ } catch (NeedsRefreshException e) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.CONTENT_NOT_FOUND_ERROR, cacheKey));
+ }
+ CachedResourceContext context = (CachedResourceContext) sendResource(
+ resource, request, response, resourceDataForKey);
+ // TODO - set refresh interval ?
+ cache.put(cacheKey, context.getContent());
+ } catch (Exception ex) {
+ //cache.cancelUpdate(cacheKey);
+ log.error(
+ Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
+ ex);
+ throw new ServletException(Messages.getMessage(
+ Messages.SEND_RESOURCE_ERROR_2, ex.getMessage()),
+ ex);
+ }
+ }*/
+ } catch (CacheException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- }
} else {
sendResource(resource, request, response, resourceDataForKey);
}
@@ -331,4 +353,31 @@
return resourceBuilder;
}
+ public Object load(Object key, Object context) throws CacheException {
+ CacheKey cacheKey = (CacheKey) context;
+
+ CachedResourceContext resourceContext = (CachedResourceContext) getResourceContext(cacheKey.getResource(), cacheKey.getRequest(),
+ cacheKey.getResponse());
+ 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();
+ }
+ resourceContext.release();
+
+ // TODO - set refresh interval ?
+ //cache.put(cacheKey, resourceContext.getContent());
+ return resourceContext.getContent();
+ }
+
+ public Map loadAll(Collection keys, Object context) throws CacheException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Added: trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java
===================================================================
--- trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java (rev 0)
+++ trunk/framework/src/test/java/org/ajax4jsf/cache/LRUMapCacheThreadedTest.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -0,0 +1,75 @@
+/**
+ *
+ */
+package org.ajax4jsf.cache;
+
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 02.05.2007
+ *
+ */
+public class LRUMapCacheThreadedTest extends TestCase {
+ private CacheLoader cacheLoader = new CacheLoader() {
+
+ public Object load(Object key, Object context) throws CacheException {
+ try {
+ Thread.sleep(new Random().nextInt(100) + 1);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return key;
+ }
+ };
+
+ private static final int COUNT = 2000;
+
+ private final Cache cache = new LRUMapCache(cacheLoader, COUNT);
+
+ public void testCache() throws Exception {
+ Thread[] threads = new Thread[COUNT];
+
+ try {
+ for (int i = 0; i < COUNT; i++) {
+ threads[i] = new TestThread(cache, new Integer(new Random().nextInt(10)));
+ threads[i].start();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ for (int i = 0; i < COUNT; i++) {
+ threads[i].join();
+ }
+ }
+}
+
+class TestThread extends Thread {
+ private Cache cache;
+ private Integer idx;
+
+ public TestThread(Cache cache, Integer idx) {
+ super();
+ this.cache = cache;
+ this.idx = idx;
+ }
+
+ public void run() {
+ super.run();
+
+ try {
+ if (!idx.equals(cache.get(idx, null))) {
+ throw new IllegalStateException();
+ } else {
+ // System.out.println("TestThread.run(): " + idx);
+ }
+ } catch (CacheException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java
===================================================================
--- trunk/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java 2007-05-01 01:27:27 UTC (rev 145)
+++ trunk/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java 2007-05-02 01:14:48 UTC (rev 146)
@@ -146,9 +146,6 @@
assertTrue("Resource was generated "+counter+" times", counter<= 10);
}
- /**
- * Test method for {@link org.ajax4jsf.framework.resource.InternetResourceService#sendResource(org.ajax4jsf.framework.resource.InternetResource, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)}.
- */
public void testSendResource() {
// fail("Not yet implemented");
}
17 years, 8 months
JBoss Ajax4JSF SVN: r145 - trunk.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-30 21:27:27 -0400 (Mon, 30 Apr 2007)
New Revision: 145
Modified:
trunk/pom.xml
Log:
Default build put versions numbers to manifest of a all generated jar's RF-29
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2007-05-01 01:07:48 UTC (rev 144)
+++ trunk/pom.xml 2007-05-01 01:27:27 UTC (rev 145)
@@ -10,7 +10,36 @@
<url>http://labs.jboss.com/jbossajax4jsf</url>
<properties>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
- </properties>
+ </properties>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <index>true</index>
+ <manifest>
+ <addDefaultSpecificationEntries>
+ true
+ </addDefaultSpecificationEntries>
+ <addDefaultImplementationEntries>
+ true
+ </addDefaultImplementationEntries>
+ </manifest>
+ <manifestEntries>
+ <mode>development</mode>
+ <Build-Number>
+ ${buildNumber}
+ </Build-Number>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
<licenses>
<license>
<name>LGPL 2.1</name>
@@ -174,7 +203,7 @@
<module>framework</module>
<module>test</module>
<module>cdk</module>
- <module>a4j-portlet</module>
+ <module>a4j-portlet</module>
</modules>
<profiles>
<profile>
@@ -200,29 +229,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <index>true</index>
- <manifest>
- <addDefaultSpecificationEntries>
- true
- </addDefaultSpecificationEntries>
- <addDefaultImplementationEntries>
- true
- </addDefaultImplementationEntries>
- </manifest>
- <manifestEntries>
- <mode>development</mode>
- <Build-Number>
- ${buildNumber}
- </Build-Number>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
- <plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
17 years, 8 months
JBoss Ajax4JSF SVN: r144 - in trunk: framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter and 13 other directories.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-30 21:07:48 -0400 (Mon, 30 Apr 2007)
New Revision: 144
Added:
trunk/samples/tomahawkCompability/src/main/java/org/ajax4jsf/TestTreeModel.java
trunk/samples/tomahawkCompability/src/main/java/org/ajax4jsf/TreeBacker.java
trunk/samples/tomahawkCompability/src/main/webapp/pages/tabbedPanel.jsp
trunk/samples/tomahawkCompability/src/main/webapp/pages/tree2.jsp
trunk/samples/useCases/src/main/java/org/ajax4jsf/RepeatData.java
trunk/samples/useCases/src/main/resources/logging.properties
trunk/samples/useCases/src/main/webapp/pages/repeat.jsp
trunk/samples/useCases/src/main/webapp/pages/repeat.xhtml
trunk/samples/useCases/src/main/webapp/pages/setCookie.xhtml
trunk/samples/useCases/src/main/webapp/pages/testCookie.xhtml
Removed:
trunk/samples/tomahawkCompability/src/main/webapp/pages/index.jsp
trunk/samples/useCases/src/main/java/logging.properties
Modified:
trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/FilterServletResponseWrapper.java
trunk/framework/src/main/java/org/ajax4jsf/framework/util/message/Messages.java
trunk/framework/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
trunk/framework/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
trunk/framework/src/main/resources/org/ajax4jsf/framework/util/message/messages.properties
trunk/samples/tomahawkCompability/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/tomahawkCompability/src/main/webapp/index.jsp
trunk/samples/useCases/src/main/java/org/ajax4jsf/Bean.java
trunk/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml.l4t
trunk/samples/useCases/src/main/webapp/WEB-INF/web.xml
trunk/samples/useCases/src/main/webapp/pages/prependId.xhtml
Log:
Fix bugs :
AJSF-9 , AJSF-14 , AJSF-16, AJSF-27, AJSF-31, AJSF-35, AJSF-36, AJSF-46.
Modified: trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -1216,6 +1216,10 @@
private Set ajaxKeys;
+ public String rowKeyVar;
+
+ public String stateVar;
+
}
/**
@@ -1249,6 +1253,8 @@
super.restoreState(faces, state.superState);
this._ajaxKeys = state.ajaxKeys;
this._statesMap = new HashMap();
+ this._rowKeyVar = state.rowKeyVar;
+ this._stateVar = state.stateVar;
// Restore serializable models and component states for all rows of
// parent UIData ( single if this
// component not child of iterable )
@@ -1276,6 +1282,8 @@
DataState state = new DataState();
state.superState = super.saveState(faces);
state.ajaxKeys = this._ajaxKeys;
+ state.rowKeyVar = this._rowKeyVar;
+ state.stateVar = this._stateVar;
Set encodedIds = getEncodedIds();
// Save all states of component and data model for all valies of
// clientId, encoded in this request.
Modified: trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -115,7 +115,7 @@
parameters.append(name).append(" : '").append(config.getInitParameter(name)).append('\n');
}
log.debug(parameters);
- log.debug("Stack Trace", new Exception());
+// log.debug("Stack Trace", new Exception());
}
// Save config
filterConfig = config;
Modified: trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseXMLFilter.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -34,6 +34,7 @@
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;
@@ -141,6 +142,11 @@
+ 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
Modified: trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/FilterServletResponseWrapper.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/FilterServletResponseWrapper.java 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/FilterServletResponseWrapper.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -61,11 +61,15 @@
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;
@@ -112,6 +116,8 @@
private String redirectLocation = null;
private boolean useNullStream = false;
+
+ private List cookies = new ArrayList();
public FilterServletResponseWrapper(HttpServletResponse response) {
super(response);
@@ -635,4 +641,13 @@
+ public void addCookie(Cookie cookie) {
+ cookies.add(cookie);
+ super.addCookie(cookie);
+ }
+
+ public Collection getCookies() {
+ return cookies;
+ }
+
}
Modified: trunk/framework/src/main/java/org/ajax4jsf/framework/util/message/Messages.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/framework/util/message/Messages.java 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/framework/src/main/java/org/ajax4jsf/framework/util/message/Messages.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -302,6 +302,7 @@
public static final String STRING_CONVERSION_ERROR = "STRING_CONVERSION_ERROR";
public static final String UTF_CONVERSION_ERROR = "UTF_CONVERSION_ERROR";
public static final String READ_ONLY_NODE_ERROR = "READ_ONLY_NODE_ERROR";
+ public static final String NOT_PARENT_AJAX_COMPONENT_ERROR = "NOT_PARENT_AJAX_COMPONENT_ERROR";
public static void main(String[] args) {
String m = getMessage(INVALID_ATTRIBUTE_VALUE, "A", "B");
Modified: trunk/framework/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/framework/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -113,7 +113,7 @@
src.addAjaxListener(listener);
}
} else {
- throw new TagException(this.tag, Messages.getMessage(Messages.NOT_PARENT_AJAX_CONTAINER_ERROR, parent));
+ throw new TagException(this.tag, Messages.getMessage(Messages.NOT_PARENT_AJAX_COMPONENT_ERROR, parent));
}
}
}
Modified: trunk/framework/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/framework/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -117,7 +117,7 @@
}
((AjaxSource) component).addAjaxListener(listener);
} else {
- throw new JspException(Messages.getMessage(Messages.NOT_AJAX_CONTAINER_ERROR, component.getId()));
+ throw new JspException(Messages.getMessage(Messages.NOT_PARENT_AJAX_COMPONENT_ERROR, component.getId()));
}
}
Modified: trunk/framework/src/main/resources/org/ajax4jsf/framework/util/message/messages.properties
===================================================================
--- trunk/framework/src/main/resources/org/ajax4jsf/framework/util/message/messages.properties 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/framework/src/main/resources/org/ajax4jsf/framework/util/message/messages.properties 2007-05-01 01:07:48 UTC (rev 144)
@@ -231,6 +231,7 @@
COMMAND_LINK_NOT_IN_FORM_WARNING=CommandLink {0} not enclosed in form
MUST_BE_EXPRESSION_ERROR=Must be expression to modifyable property
NOT_PARENT_AJAX_CONTAINER_ERROR=Parent is not of type AjaxContainer, type is\: {0}
+NOT_PARENT_AJAX_COMPONENT_ERROR=Parent component {0} for a ajaxListener is not source of AjaxEvent's
MUST_BE_LITERAL_ERROR=Must be literal
FACET_TAG_MANY_CHILDREN_ERROR=Facet Tag can only have one child UIComponent
NO_UI_COMPONENT_TAG_ANCESTOR_ERROR={0} has no UIComponentTag ancestor
@@ -247,4 +248,5 @@
READ_ONLY_NODE_ERROR=Node is read only
AJAX_VIEW_EXPIRED=View state could't be restored - reload page ?
SKIN_CYCLIC_REFERENCE=Cyclic reference in Skin configuration for property \: {0}
-SKIN_ILLEGAL_REFERENCE=Reference for property "{0}" not present in Skin configuration
\ No newline at end of file
+SKIN_ILLEGAL_REFERENCE=Reference for property "{0}" not present in Skin configuration
+NULL_ATTRIBUTE_ERROR="Requied attribute {0} for component {1} is null
\ No newline at end of file
Added: trunk/samples/tomahawkCompability/src/main/java/org/ajax4jsf/TestTreeModel.java
===================================================================
--- trunk/samples/tomahawkCompability/src/main/java/org/ajax4jsf/TestTreeModel.java (rev 0)
+++ trunk/samples/tomahawkCompability/src/main/java/org/ajax4jsf/TestTreeModel.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -0,0 +1,88 @@
+package org.ajax4jsf;
+import org.apache.myfaces.custom.tree2.TreeNodeBase;
+
+/**
+ *
+ */
+
+/**
+ * @author asmirnov
+ *
+ */
+public class TestTreeModel extends TreeNodeBase {
+
+ private String url;
+
+ private String target="/xxx";
+ private String description="Node";
+ private boolean urlNode=true;
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8653793302556194481L;
+
+
+ public TestTreeModel() {
+ super();
+ setLeaf(false);
+ setType("desktop");
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return the target
+ */
+ public String getTarget() {
+ return target;
+ }
+
+ /**
+ * @param target the target to set
+ */
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ /**
+ * @return the url
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ * @param url the url to set
+ */
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ /**
+ * @return the urlNode
+ */
+ public boolean isUrlNode() {
+ return urlNode;
+ }
+
+ /**
+ * @param urlNode the urlNode to set
+ */
+ public void setUrlNode(boolean urlNode) {
+ this.urlNode = urlNode;
+ }
+
+}
Added: trunk/samples/tomahawkCompability/src/main/java/org/ajax4jsf/TreeBacker.java
===================================================================
--- trunk/samples/tomahawkCompability/src/main/java/org/ajax4jsf/TreeBacker.java (rev 0)
+++ trunk/samples/tomahawkCompability/src/main/java/org/ajax4jsf/TreeBacker.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -0,0 +1,65 @@
+/**
+ *
+ */
+package org.ajax4jsf;
+
+import javax.faces.component.UIComponent;
+
+import org.apache.myfaces.custom.tree2.TreeModel;
+import org.apache.myfaces.custom.tree2.TreeModelBase;
+import org.apache.myfaces.custom.tree2.TreeNode;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class TreeBacker {
+
+ UIComponent tree;
+
+ TreeModel treeModel;
+
+ /**
+ * @return the tree
+ */
+ public UIComponent getTree() {
+ return tree;
+ }
+
+ /**
+ * @param tree the tree to set
+ */
+ public void setTree(UIComponent tree) {
+ this.tree = tree;
+ }
+
+ /**
+ * @return the treeModel
+ */
+ public TreeModel getTreeModel() {
+ if (treeModel == null) {
+ TreeNode rootNode = new TestTreeModel();
+ for(int i=0;i<5;i++){
+ rootNode.getChildren().add(new TestTreeModel());
+ }
+ treeModel = new TreeModelBase(rootNode );
+ }
+
+ return treeModel;
+ }
+
+ /**
+ * @param treeModel the treeModel to set
+ */
+ public void setTreeModel(TreeModel treeModel) {
+ this.treeModel = treeModel;
+ }
+
+ /**
+ *
+ */
+ public TreeBacker() {
+ // TODO Auto-generated constructor stub
+ }
+
+}
Modified: trunk/samples/tomahawkCompability/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/tomahawkCompability/src/main/webapp/WEB-INF/faces-config.xml 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/samples/tomahawkCompability/src/main/webapp/WEB-INF/faces-config.xml 2007-05-01 01:07:48 UTC (rev 144)
@@ -12,6 +12,11 @@
<managed-bean-class>org.ajax4jsf.Bean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>treeBacker</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.TreeBacker</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
<render-kit>
<renderer>
<component-family>javax.faces.Form</component-family>
Modified: trunk/samples/tomahawkCompability/src/main/webapp/index.jsp
===================================================================
--- trunk/samples/tomahawkCompability/src/main/webapp/index.jsp 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/samples/tomahawkCompability/src/main/webapp/index.jsp 2007-05-01 01:07:48 UTC (rev 144)
@@ -5,7 +5,7 @@
<head></head>
<body>
- <jsp:forward page="/faces/pages/index.jsp" />
+ <jsp:forward page="/faces/pages/tabbedPanel.jsp" />
</body>
</html>
\ No newline at end of file
Deleted: trunk/samples/tomahawkCompability/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/tomahawkCompability/src/main/webapp/pages/index.jsp 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/samples/tomahawkCompability/src/main/webapp/pages/index.jsp 2007-05-01 01:07:48 UTC (rev 144)
@@ -1,46 +0,0 @@
-<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
-<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
-<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
-<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
-<html>
-<head>
-<title>A4J form sample page</title>
-</head>
-<body>
-<h1>Ajax submitted form with Tomahawk components</h1>
-<f:view>
- <a4j:form id="ajaxform-with-defis" ajaxSubmit="true" reRender="tabs,counter">
- <h:panelGrid columns="2" border="1">
- <h:commandButton action="#{bean.inc}" value="Increment" />
- <h:commandLink value="Decrement" action="#{bean.dec}"></h:commandLink>
- <h:outputText value="Counter:" />
- <h:outputText id="counter" value="#{bean.counter}" />
- </h:panelGrid>
- <h:panelGroup id="tabs">
- <t:panelTabbedPane serverSideTabSwitch="true">
- <t:panelTab label="A">
- <h:inputText id="a" value="First" />
- <h:outputLabel value="First tab input" for="a"></h:outputLabel>
- </t:panelTab>
- <t:panelTab label="B">
- <h:inputText id="b" value="First" />
- <h:outputLabel value="Second tab input" for="b"></h:outputLabel>
- </t:panelTab>
- </t:panelTabbedPane>
- </h:panelGroup>
- </a4j:form>
- <h2>Same form without user-provided ID</h2>
- <f:subview id="subview">
- <a4j:form ajaxSubmit="true" reRender="counterB">
- <h:panelGrid columns="2" border="1">
- <h:commandButton action="#{beanB.inc}" value="Increment" />
- <h:commandLink value="Decrement" action="#{beanB.dec}"></h:commandLink>
- <h:outputText value="Counter:" />
- <h:outputText id="counterB" value="#{beanB.counter}" />
- </h:panelGrid>
- </a4j:form>
- </f:subview>
- <a4j:log hotkey="M"/>
-</f:view>
-</body>
-</html>
Added: trunk/samples/tomahawkCompability/src/main/webapp/pages/tabbedPanel.jsp
===================================================================
--- trunk/samples/tomahawkCompability/src/main/webapp/pages/tabbedPanel.jsp (rev 0)
+++ trunk/samples/tomahawkCompability/src/main/webapp/pages/tabbedPanel.jsp 2007-05-01 01:07:48 UTC (rev 144)
@@ -0,0 +1,46 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
+<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
+<html>
+<head>
+<title>A4J form sample page</title>
+</head>
+<body>
+<h1>Ajax submitted form with Tomahawk components</h1>
+<f:view>
+ <a4j:form id="ajaxform-with-defis" ajaxSubmit="true" reRender="tabs,counter">
+ <h:panelGrid columns="2" border="1">
+ <h:commandButton action="#{bean.inc}" value="Increment" />
+ <h:commandLink value="Decrement" action="#{bean.dec}"></h:commandLink>
+ <h:outputText value="Counter:" />
+ <h:outputText id="counter" value="#{bean.counter}" />
+ </h:panelGrid>
+ <h:panelGroup id="tabs">
+ <t:panelTabbedPane serverSideTabSwitch="true">
+ <t:panelTab label="A">
+ <h:inputText id="a" value="First" />
+ <h:outputLabel value="First tab input" for="a"></h:outputLabel>
+ </t:panelTab>
+ <t:panelTab label="B">
+ <h:inputText id="b" value="First" />
+ <h:outputLabel value="Second tab input" for="b"></h:outputLabel>
+ </t:panelTab>
+ </t:panelTabbedPane>
+ </h:panelGroup>
+ </a4j:form>
+ <h2>Same form without user-provided ID</h2>
+ <f:subview id="subview">
+ <a4j:form ajaxSubmit="true" reRender="counterB">
+ <h:panelGrid columns="2" border="1">
+ <h:commandButton action="#{beanB.inc}" value="Increment" />
+ <h:commandLink value="Decrement" action="#{beanB.dec}"></h:commandLink>
+ <h:outputText value="Counter:" />
+ <h:outputText id="counterB" value="#{beanB.counter}" />
+ </h:panelGrid>
+ </a4j:form>
+ </f:subview>
+ <a4j:log hotkey="M"/>
+</f:view>
+</body>
+</html>
Added: trunk/samples/tomahawkCompability/src/main/webapp/pages/tree2.jsp
===================================================================
--- trunk/samples/tomahawkCompability/src/main/webapp/pages/tree2.jsp (rev 0)
+++ trunk/samples/tomahawkCompability/src/main/webapp/pages/tree2.jsp 2007-05-01 01:07:48 UTC (rev 144)
@@ -0,0 +1,37 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
+<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
+
+<html>
+<head>
+<title>Response page</title>
+</head>
+<body>
+<f:view>
+ <a4j:form id="menuForm" ajaxSubmit="true" requestDelay="100"
+ reRender="treePanel" ignoreDupResponses="true">
+ <a4j:log hotkey="M" popup="true" level="ALL" />
+ <a4j:outputPanel ajaxRendered="true" layout="inline" id="treePanel">
+ <t:tree2 binding="#{treeBacker.tree}" id="serverTree"
+ showRootNode="true" showNav="true" value="#{treeBacker.treeModel}"
+ var="node" varNodeToggler="t" clientSideToggle="false">
+ <f:facet name="desktop">
+ <h:panelGroup>
+ <t:graphicImage value="/resources/images/desktop.png" border="0" />
+ <a4j:commandLink rendered="#{node.urlNode}"
+ styleClass="#{t.nodeSelected ? 'nodeSelected':'node'}"
+ actionListener="#{t.setNodeSelected}">
+ <h:outputLink value="#{node.url}" target="#{node.target}">
+ <h:outputText value="#{node.description}"
+ styleClass="nodeFolder" />
+ </h:outputLink>
+ </a4j:commandLink>
+ </h:panelGroup>
+ </f:facet>
+ </t:tree2>
+ </a4j:outputPanel>
+ </a4j:form>
+</f:view>
+</body>
+</html>
Deleted: trunk/samples/useCases/src/main/java/logging.properties
===================================================================
--- trunk/samples/useCases/src/main/java/logging.properties 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/samples/useCases/src/main/java/logging.properties 2007-05-01 01:07:48 UTC (rev 144)
@@ -1,21 +0,0 @@
-handlers org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
-
-############################################################
-# Handler specific properties.
-# Describes specific configuration info for Handlers.
-############################################################
-
-org.apache.juli.FileHandler.level ALL
-org.apache.juli.FileHandler.directory ${catalina.base}/logs
-org.apache.juli.FileHandler.prefix ajax4jsf.
-
-java.util.logging.ConsoleHandler.level ALL
-java.util.logging.ConsoleHandler.formatter java.util.logging.SimpleFormatter
-
-facelets.level=ALL
-com.sun.faces.level=ALL
-org.apache.myfaces.level=ALL
-org.ajax4jsf.level=ALL
-javax.enterprise.resource.webcontainer.jsf.level=ALL
-com.exadel.level=ALL
-
\ No newline at end of file
Modified: trunk/samples/useCases/src/main/java/org/ajax4jsf/Bean.java
===================================================================
--- trunk/samples/useCases/src/main/java/org/ajax4jsf/Bean.java 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/samples/useCases/src/main/java/org/ajax4jsf/Bean.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -20,6 +20,13 @@
*/
package org.ajax4jsf;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* @author $Autor$
*
@@ -40,5 +47,26 @@
System.out.println("Button pressed");
return null;
}
+
+ public String setCookie() {
+ ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+ HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
+ Cookie cookie = new Cookie("test", "Setted at time "+System.currentTimeMillis());
+ cookie.setMaxAge(60 * 60 * 24 * 365);
+ response.addCookie(cookie);
+ return "verify_cookie";
+ }
+
+ public String getTestCookie(){
+ ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+ HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
+ Cookie[] cookies = request.getCookies();
+ for (int i = 0; i < cookies.length; i++) {
+ if("test".equals(cookies[i].getName())){
+ return cookies[i].getValue();
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
Added: trunk/samples/useCases/src/main/java/org/ajax4jsf/RepeatData.java
===================================================================
--- trunk/samples/useCases/src/main/java/org/ajax4jsf/RepeatData.java (rev 0)
+++ trunk/samples/useCases/src/main/java/org/ajax4jsf/RepeatData.java 2007-05-01 01:07:48 UTC (rev 144)
@@ -0,0 +1,40 @@
+/**
+ *
+ */
+package org.ajax4jsf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class RepeatData {
+
+ private List data;
+
+ public RepeatData() {
+ data = new ArrayList(10);
+ for(int i=0;i<10;i++){
+ Bean bean = new Bean();
+ bean.setText("Row "+i);
+ data.add(bean);
+ }
+ }
+
+ /**
+ * @return the data
+ */
+ public List getData() {
+ return data;
+ }
+
+ /**
+ * @param data the data to set
+ */
+ public void setData(List data) {
+ this.data = data;
+ }
+
+}
Added: trunk/samples/useCases/src/main/resources/logging.properties
===================================================================
--- trunk/samples/useCases/src/main/resources/logging.properties (rev 0)
+++ trunk/samples/useCases/src/main/resources/logging.properties 2007-05-01 01:07:48 UTC (rev 144)
@@ -0,0 +1,21 @@
+handlers org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
+
+############################################################
+# Handler specific properties.
+# Describes specific configuration info for Handlers.
+############################################################
+
+org.apache.juli.FileHandler.level ALL
+org.apache.juli.FileHandler.directory ${catalina.base}/logs
+org.apache.juli.FileHandler.prefix ajax4jsf.
+
+java.util.logging.ConsoleHandler.level ALL
+java.util.logging.ConsoleHandler.formatter java.util.logging.SimpleFormatter
+
+facelets.level=ALL
+com.sun.faces.level=INFO
+org.apache.myfaces.level=ALL
+org.ajax4jsf.level=ALL
+javax.enterprise.resource.webcontainer.jsf.level=INFO
+com.exadel.level=ALL
+
\ No newline at end of file
Modified: trunk/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml 2007-05-01 01:07:48 UTC (rev 144)
@@ -12,4 +12,16 @@
<null-value/>
</managed-property>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>repeatData</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.RepeatData</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <navigation-rule>
+ <navigation-case>
+ <from-outcome>verify_cookie</from-outcome>
+ <to-view-id>/pages/testCookie.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+ </navigation-rule>
</faces-config>
Modified: trunk/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml.l4t
===================================================================
--- trunk/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml.l4t 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/samples/useCases/src/main/webapp/WEB-INF/faces-config.xml.l4t 2007-05-01 01:07:48 UTC (rev 144)
@@ -1,2 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
-<PROCESS ENTITY="JSFProcess"/>
+<PROCESS ENTITY="JSFProcess">
+ <PROCESS-ITEM ENTITY="JSFProcessGroup" NAME="rules:" SHAPE="32,17,0,0">
+ <PROCESS-ITEM ENTITY="JSFProcessItem" ID="rules::0" NAME="item">
+ <PROCESS-ITEM-OUTPUT ENTITY="JSFProcessItemOutput"
+ ID="verify_cookie::#pages#testCookie.xhtml" NAME="output"
+ PATH="/pages/testCookie.xhtml"
+ TARGET="rules:#pages#testCookie.xhtml" TITLE="verify_cookie"/>
+ </PROCESS-ITEM>
+ </PROCESS-ITEM>
+ <PROCESS-ITEM ENTITY="JSFProcessGroup"
+ NAME="rules:#pages#testCookie.xhtml" PATH="/pages/testCookie.xhtml" SHAPE="240,33,0,0"/>
+</PROCESS>
Modified: trunk/samples/useCases/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/useCases/src/main/webapp/WEB-INF/web.xml 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/samples/useCases/src/main/webapp/WEB-INF/web.xml 2007-05-01 01:07:48 UTC (rev 144)
@@ -16,7 +16,7 @@
</context-param>
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
- <param-value>false</param-value>
+ <param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
Modified: trunk/samples/useCases/src/main/webapp/pages/prependId.xhtml
===================================================================
--- trunk/samples/useCases/src/main/webapp/pages/prependId.xhtml 2007-04-30 21:09:07 UTC (rev 143)
+++ trunk/samples/useCases/src/main/webapp/pages/prependId.xhtml 2007-05-01 01:07:48 UTC (rev 144)
@@ -12,6 +12,11 @@
</h:inputText>
<h:outputText id="repeater" value="#{bean.text}" />
<h:commandButton action="#{bean.ok}" value="Ok"></h:commandButton>
+ <h:dataTable value="single" var="v">
+ <h:column>
+ <h:commandButton action="#{bean.ok}" value="Ok in table"></h:commandButton>
+ </h:column>
+ </h:dataTable>
</h:form>
<a4j:log hotkey="M"></a4j:log>
</body>
Added: trunk/samples/useCases/src/main/webapp/pages/repeat.jsp
===================================================================
--- trunk/samples/useCases/src/main/webapp/pages/repeat.jsp (rev 0)
+++ trunk/samples/useCases/src/main/webapp/pages/repeat.jsp 2007-05-01 01:07:48 UTC (rev 144)
@@ -0,0 +1,20 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
+<html>
+ <head>
+ <title>Repeater with input components</title>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <a4j:repeat value="#{repeatData.data}" var="row">
+ <h:selectBooleanCheckbox selected="true" />
+ <h:inputText value="Text"></h:inputText>
+ <h:inputText value="#{row.text}"></h:inputText>
+ <h:outputText escape="false" value="<br>" ></h:outputText>
+ </a4j:repeat>
+ </h:form>
+ </f:view>
+ </body>
+</html>
Added: trunk/samples/useCases/src/main/webapp/pages/repeat.xhtml
===================================================================
--- trunk/samples/useCases/src/main/webapp/pages/repeat.xhtml (rev 0)
+++ trunk/samples/useCases/src/main/webapp/pages/repeat.xhtml 2007-05-01 01:07:48 UTC (rev 144)
@@ -0,0 +1,26 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+ <head>
+ <title>Repeater with input components</title>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <h:panelGroup id="repeat">
+ <a4j:repeat value="#{repeatData.data}" var="row">
+ <h:selectBooleanCheckbox selected="true" />
+ <h:inputText value="Text"></h:inputText>
+ <h:inputText value="#{row.text}"></h:inputText>
+ <h:outputText escape="false" value="<br />" ></h:outputText>
+ </a4j:repeat>
+ </h:panelGroup>
+ <h:commandButton action="#{bean.ok}" value="Ok"></h:commandButton>
+ <a4j:commandButton action="#{bean.ok}" value="Ok ajax" reRender="repeat"></a4j:commandButton>
+
+ </h:form>
+ </f:view>
+ </body>
+</html>
Added: trunk/samples/useCases/src/main/webapp/pages/setCookie.xhtml
===================================================================
--- trunk/samples/useCases/src/main/webapp/pages/setCookie.xhtml (rev 0)
+++ trunk/samples/useCases/src/main/webapp/pages/setCookie.xhtml 2007-05-01 01:07:48 UTC (rev 144)
@@ -0,0 +1,22 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
+<f:view>
+ <head>
+ <meta http-equiv="content-type" content="text/xhtml; charset=UTF-8"/>
+ <meta http-equiv="pragma" content="no-cache"/>
+ <meta http-equiv="cache-control" content="no-cache"/>
+ <meta http-equiv="expires" content="0"/>
+ <title>Set Cookie</title>
+ </head>
+ <body>
+ <a4j:form>
+ <a4j:commandButton action="#{bean.setCookie}" value="Set Cookie by AJAX"/>
+ <h:commandButton action="#{bean.setCookie}" value="Set Cookie in POST"/>
+ </a4j:form>
+ </body>
+</f:view>
+</html>
Added: trunk/samples/useCases/src/main/webapp/pages/testCookie.xhtml
===================================================================
--- trunk/samples/useCases/src/main/webapp/pages/testCookie.xhtml (rev 0)
+++ trunk/samples/useCases/src/main/webapp/pages/testCookie.xhtml 2007-05-01 01:07:48 UTC (rev 144)
@@ -0,0 +1,21 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
+<f:view>
+ <head>
+ <meta http-equiv="content-type" content="text/xhtml; charset=UTF-8"/>
+ <meta http-equiv="pragma" content="no-cache"/>
+ <meta http-equiv="cache-control" content="no-cache"/>
+ <meta http-equiv="expires" content="0"/>
+ <title>Test Cookie</title>
+ </head>
+ <body>
+ <a4j:form>
+ <h:outputText value="Cookie value: #{bean.testCookie}"/>
+ </a4j:form>
+ </body>
+</f:view>
+</html>
17 years, 8 months