Author: alexsmirnov
Date: 2008-05-16 17:04:44 -0400 (Fri, 16 May 2008)
New Revision: 8627
Added:
trunk/framework/api/src/main/java/org/ajax4jsf/model/KeepAlive.java
trunk/sandbox/samples/state-sample/
trunk/sandbox/samples/state-sample/.metadata/
trunk/sandbox/samples/state-sample/.metadata/src/
trunk/sandbox/samples/state-sample/.metadata/src/main/
trunk/sandbox/samples/state-sample/.metadata/src/main/webapp/
trunk/sandbox/samples/state-sample/.metadata/src/main/webapp/WEB-INF/
trunk/sandbox/samples/state-sample/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow
trunk/sandbox/samples/state-sample/.svnignore
trunk/sandbox/samples/state-sample/pom.xml
trunk/sandbox/samples/state-sample/src/
trunk/sandbox/samples/state-sample/src/main/
trunk/sandbox/samples/state-sample/src/main/java/
trunk/sandbox/samples/state-sample/src/main/java/org/
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/Bean.java
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/Config.java
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/LoginAction.java
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/RegisterAction.java
trunk/sandbox/samples/state-sample/src/main/webapp/
trunk/sandbox/samples/state-sample/src/main/webapp/META-INF/
trunk/sandbox/samples/state-sample/src/main/webapp/META-INF/MANIFEST.MF
trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/
trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/faces-config.xml
trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/lib/
trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/web.xml
trunk/sandbox/samples/state-sample/src/main/webapp/images/
trunk/sandbox/samples/state-sample/src/main/webapp/images/Canon.jpg
trunk/sandbox/samples/state-sample/src/main/webapp/images/Nikon.jpg
trunk/sandbox/samples/state-sample/src/main/webapp/images/Olympus.jpg
trunk/sandbox/samples/state-sample/src/main/webapp/images/collapse.gif
trunk/sandbox/samples/state-sample/src/main/webapp/images/expand.gif
trunk/sandbox/samples/state-sample/src/main/webapp/index.jsp
trunk/sandbox/samples/state-sample/src/main/webapp/pages/
trunk/sandbox/samples/state-sample/src/main/webapp/pages/index.jsp
trunk/sandbox/ui/state/src/main/java/org/richfaces/el/
trunk/sandbox/ui/state/src/main/java/org/richfaces/el/StateELResolver.java
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateApplication.java
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateExpressionFactory.java
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateNavigationHandler.java
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/StateImpl.java
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/States.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/KeepAlive.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
trunk/sandbox/ui/state/pom.xml
trunk/sandbox/ui/state/src/main/config/component/state.xml
trunk/sandbox/ui/state/src/main/config/component/states.xml
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/State.java
Log:
Attnotation for a KeepAlive beans have been created.
Draft implementation of the state component.
Added: trunk/framework/api/src/main/java/org/ajax4jsf/model/KeepAlive.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/model/KeepAlive.java
(rev 0)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/model/KeepAlive.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,22 @@
+/**
+ *
+ */
+package org.ajax4jsf.model;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation, to keep request-scope beans between requests in the view state.
+ * @author asmirnov
+ *
+ */
+(a)Target(ElementType.TYPE)
+(a)Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface KeepAlive {
+
+}
Property changes on: trunk/framework/api/src/main/java/org/ajax4jsf/model/KeepAlive.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2008-05-16
19:23:08 UTC (rev 8626)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -23,11 +23,15 @@
import java.io.IOException;
import java.lang.reflect.Constructor;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Map.Entry;
import javax.faces.FactoryFinder;
import javax.faces.application.StateManager;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
@@ -37,6 +41,7 @@
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.event.AjaxPhaseListener;
+import org.ajax4jsf.model.KeepAlive;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -306,11 +311,32 @@
}
protected Object getAdditionalState(FacesContext context) {
- return null;
+ Map<String, Object> keepAliveBeans=new HashMap<String, Object>();
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ // Save all objects form request map wich marked by @KeepAlive annotations
+ for (Entry<String, Object> requestEntry : requestMap.entrySet()) {
+ Object bean = requestEntry.getValue();
+ if (bean.getClass().isAnnotationPresent(KeepAlive.class)) {
+ keepAliveBeans.put(requestEntry.getKey(), bean);
+ }
+ }
+ if(keepAliveBeans.size()>0){
+ return UIComponentBase.saveAttachedState(context, keepAliveBeans);
+ } else {
+ return null;
+ }
}
+ @SuppressWarnings("unchecked")
protected void restoreAdditionalState(FacesContext context, Object state) {
-
+ if(null != state){
+ // Append all saved beans to the request map.
+ Map beansMap = (Map) UIComponentBase.restoreAttachedState(context, state);
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ for (Object key : beansMap.keySet()) {
+ requestMap.put((String) key, beansMap.get(key));
+ }
+ }
}
/**
Added:
trunk/sandbox/samples/state-sample/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow
===================================================================
---
trunk/sandbox/samples/state-sample/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow
(rev 0)
+++
trunk/sandbox/samples/state-sample/.metadata/src/main/webapp/WEB-INF/faces-config.pageflow 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pageflow:Pageflow
xmlns:pageflow="http://www.sybase.com/suade/pageflow"
id="pf12108743769720"
configfile="/state-sample/src/main/webapp/WEB-INF/faces-config.xml"/>
Added: trunk/sandbox/samples/state-sample/.svnignore
===================================================================
--- trunk/sandbox/samples/state-sample/.svnignore (rev 0)
+++ trunk/sandbox/samples/state-sample/.svnignore 2008-05-16 21:04:44 UTC (rev 8627)
@@ -0,0 +1,5 @@
+target
+
+.settings
+.classpath
+.project
Added: trunk/sandbox/samples/state-sample/pom.xml
===================================================================
--- trunk/sandbox/samples/state-sample/pom.xml (rev 0)
+++ trunk/sandbox/samples/state-sample/pom.xml 2008-05-16 21:04:44 UTC (rev 8627)
@@ -0,0 +1,32 @@
+<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.richfaces.sandbox</groupId>
+ <version>3.2.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces</groupId>
+ <artifactId>state-sample</artifactId>
+ <packaging>war</packaging>
+ <name>webapp Maven Webapp</name>
+ <build>
+ <finalName>state-sample</finalName>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.sandbox.ui</groupId>
+ <artifactId>state</artifactId>
+ <version>3.2.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui</artifactId>
+ <version>3.2.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.samples</groupId>
+ <artifactId>skins</artifactId>
+ <version>3.2.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Property changes on: trunk/sandbox/samples/state-sample/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/Bean.java
(rev 0)
+++ trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/Bean.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,62 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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.richfaces;
+
+import javax.faces.event.ActionEvent;
+
+
+/**
+ * @author $Autor$
+ */
+public class Bean {
+
+ private String name;
+
+ private String password;
+
+ private String confirmPassword;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getConfirmPassword() {
+ return confirmPassword;
+ }
+
+ public void setConfirmPassword(String confirmPassword) {
+ this.confirmPassword = confirmPassword;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/Bean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/Config.java
===================================================================
--- trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/Config.java
(rev 0)
+++ trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/Config.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,48 @@
+/**
+ *
+ */
+package org.richfaces;
+
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.ui.model.States;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class Config {
+
+ public States getStates(){
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ States states = new States();
+ states.setCurrentState("register");
+ states.put("showConfirm", Boolean.TRUE);
+ states.put("link", "To login");
+ states.put("okBtn", "Register");
+ ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
+ ValueExpression beanExpression =
expressionFactory.createValueExpression(facesContext.getELContext(),
"#{registerbean}", Bean.class);
+ states.put("bean", beanExpression);
+ beanExpression = expressionFactory.createValueExpression(facesContext.getELContext(),
"#{registeraction}", RegisterAction.class);
+ states.put("action", beanExpression);
+ MethodExpression okExpression =
expressionFactory.createMethodExpression(facesContext.getELContext(),
"#{registeraction.ok}", String.class, new Class[] {});
+ states.put("ok", okExpression);
+ states.setNavigation("switch", "login");
+ states.setCurrentState("login");
+ states.put("showConfirm", Boolean.FALSE);
+ states.put("link", "To register");
+ states.put("okBtn", "Login");
+ beanExpression = expressionFactory.createValueExpression(facesContext.getELContext(),
"#{loginbean}", Bean.class);
+ states.put("bean", beanExpression);
+ beanExpression = expressionFactory.createValueExpression(facesContext.getELContext(),
"#{loginaction}", LoginAction.class);
+ states.put("action", beanExpression);
+ okExpression = expressionFactory.createMethodExpression(facesContext.getELContext(),
"#{loginaction.ok}", String.class, new Class[] {});
+ states.put("ok", okExpression);
+ states.setNavigation("switch", "register");
+ return states;
+ }
+
+}
Property changes on:
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/Config.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/LoginAction.java
===================================================================
--- trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/LoginAction.java
(rev 0)
+++
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/LoginAction.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,39 @@
+package org.richfaces;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+
+
+
+
+public class LoginAction implements ActionListener
+{
+
+ private Bean bean;
+
+ public void processAction(ActionEvent event) throws AbortProcessingException
+ {
+ System.out.println("login action event");
+ }
+
+ public String ok() {
+ System.out.println("login action");
+ return "success";
+ }
+
+ /**
+ * @return the bean
+ */
+ public Bean getBean() {
+ return bean;
+ }
+
+ /**
+ * @param bean the bean to set
+ */
+ public void setBean(Bean bean) {
+ this.bean = bean;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/LoginAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/RegisterAction.java
===================================================================
--- trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/RegisterAction.java
(rev 0)
+++
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/RegisterAction.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,38 @@
+package org.richfaces;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+
+
+
+
+public class RegisterAction implements ActionListener
+{
+ private Bean bean;
+
+ public void processAction(ActionEvent event) throws AbortProcessingException
+ {
+ System.out.println("register action event");
+ }
+
+ public String ok() {
+ System.out.println("register action");
+ return "success";
+ }
+
+ /**
+ * @return the bean
+ */
+ public Bean getBean() {
+ return bean;
+ }
+
+ /**
+ * @param bean the bean to set
+ */
+ public void setBean(Bean bean) {
+ this.bean = bean;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/sandbox/samples/state-sample/src/main/java/org/richfaces/RegisterAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/samples/state-sample/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- trunk/sandbox/samples/state-sample/src/main/webapp/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/sandbox/samples/state-sample/src/main/webapp/META-INF/MANIFEST.MF 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on:
trunk/sandbox/samples/state-sample/src/main/webapp/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/faces-config.xml
(rev 0)
+++ trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/faces-config.xml 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+ version="1.2">
+ <application>
+ <navigation-handler>
+ org.richfaces.ui.application.StateNavigationHandler</navigation-handler>
+ <el-resolver>org.richfaces.el.StateELResolver</el-resolver>
+ </application>
+ <managed-bean>
+ <managed-bean-name>loginbean</managed-bean-name>
+ <managed-bean-class>org.richfaces.Bean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>registerbean</managed-bean-name>
+ <managed-bean-class>org.richfaces.Bean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>loginaction</managed-bean-name>
+ <managed-bean-class>org.richfaces.LoginAction</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ <managed-property>
+ <property-name>
+ bean</property-name>
+ <property-class>
+ org.richfaces.Bean</property-class>
+ <value>
+ #{loginbean}</value>
+ </managed-property>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>registeraction</managed-bean-name>
+ <managed-bean-class>org.richfaces.RegisterAction</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ <managed-property>
+ <property-name>
+ bean</property-name>
+ <property-class>
+ org.richfaces.Bean</property-class>
+ <value>
+ #{registerbean}</value>
+ </managed-property>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>skinBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.SkinBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>
+ state</managed-bean-name>
+ <managed-bean-class>
+ org.richfaces.ui.model.States</managed-bean-class>
+ <managed-bean-scope>
+ request</managed-bean-scope>
+ <managed-property>
+ <property-name>
+ states</property-name>
+ <property-class>
+ org.richfaces.ui.model.States</property-class>
+ <value>#{config.states}</value>
+ </managed-property>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>
+ config</managed-bean-name>
+ <managed-bean-class>
+ org.richfaces.Config</managed-bean-class>
+ <managed-bean-scope>
+ none</managed-bean-scope>
+ </managed-bean>
+</faces-config>
Property changes on:
trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/web.xml
(rev 0)
+++ trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/web.xml 2008-05-16 21:04:44
UTC (rev 8627)
@@ -0,0 +1,51 @@
+<?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>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/faces-config.xml</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.SKIN</param-name>
+ <param-value>#{skinBean.skin}</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>
+ <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>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Property changes on: trunk/sandbox/samples/state-sample/src/main/webapp/WEB-INF/web.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/samples/state-sample/src/main/webapp/images/Canon.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/sandbox/samples/state-sample/src/main/webapp/images/Canon.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/sandbox/samples/state-sample/src/main/webapp/images/Nikon.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/sandbox/samples/state-sample/src/main/webapp/images/Nikon.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/sandbox/samples/state-sample/src/main/webapp/images/Olympus.jpg
===================================================================
(Binary files differ)
Property changes on:
trunk/sandbox/samples/state-sample/src/main/webapp/images/Olympus.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/sandbox/samples/state-sample/src/main/webapp/images/collapse.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/sandbox/samples/state-sample/src/main/webapp/images/collapse.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/sandbox/samples/state-sample/src/main/webapp/images/expand.gif
===================================================================
(Binary files differ)
Property changes on: trunk/sandbox/samples/state-sample/src/main/webapp/images/expand.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/sandbox/samples/state-sample/src/main/webapp/index.jsp
===================================================================
--- trunk/sandbox/samples/state-sample/src/main/webapp/index.jsp
(rev 0)
+++ trunk/sandbox/samples/state-sample/src/main/webapp/index.jsp 2008-05-16 21:04:44 UTC
(rev 8627)
@@ -0,0 +1,8 @@
+<!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
Property changes on: trunk/sandbox/samples/state-sample/src/main/webapp/index.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/samples/state-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/state-sample/src/main/webapp/pages/index.jsp
(rev 0)
+++ trunk/sandbox/samples/state-sample/src/main/webapp/pages/index.jsp 2008-05-16 21:04:44
UTC (rev 8627)
@@ -0,0 +1,39 @@
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<html>
+<head>
+<title></title>
+
+<style type="text/css">
+.customHeader {
+ color: #000000;
+ background-image: url();
+ background-color: #32CD32;
+}
+</style>
+
+</head>
+
+<body>
+<f:view>
+ <h:form id="state_form">
+ <h:panelGrid columns="2">
+ <h:outputText value="username" />
+ <h:inputText value="#{state.bean.name}" />
+ <h:outputText value="password" />
+ <h:inputText value="#{state.bean.password}" />
+ <h:outputText value="confirm" rendered="#{state.showConfirm}"
/>
+ <h:inputText value="#{state.bean.confirmPassword}"
+ rendered="#{state.showConfirm}" />
+ <h:commandLink action="switch" value="#{state.link}"
immediate="true"/>
+ <h:panelGroup>
+ <h:commandButton action="#{state.action.ok}"
value="#{state.okBtn}"
+ />
+ <h:commandButton action="#{state.ok}" value="Action" />
+ </h:panelGroup>
+ </h:panelGrid>
+ <h:messages></h:messages>
+ </h:form>
+</f:view>
+</body>
+</html>
Property changes on: trunk/sandbox/samples/state-sample/src/main/webapp/pages/index.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/sandbox/ui/state/pom.xml
===================================================================
--- trunk/sandbox/ui/state/pom.xml 2008-05-16 19:23:08 UTC (rev 8626)
+++ trunk/sandbox/ui/state/pom.xml 2008-05-16 21:04:44 UTC (rev 8627)
@@ -5,7 +5,7 @@
<version>3.2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.ui</groupId>
+ <groupId>org.richfaces.sandbox.ui</groupId>
<artifactId>state</artifactId>
<name>state</name>
<build>
Modified: trunk/sandbox/ui/state/src/main/config/component/state.xml
===================================================================
--- trunk/sandbox/ui/state/src/main/config/component/state.xml 2008-05-16 19:23:08 UTC
(rev 8626)
+++ trunk/sandbox/ui/state/src/main/config/component/state.xml 2008-05-16 21:04:44 UTC
(rev 8627)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"http://labs.jboss.com/jbossrichfaces/component-config.dtd
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"http://labs.jboss.com/jbossrichfaces/component-config.dtd" >
<components>
<component>
<name>org.richfaces.ui.State</name>
Modified: trunk/sandbox/ui/state/src/main/config/component/states.xml
===================================================================
--- trunk/sandbox/ui/state/src/main/config/component/states.xml 2008-05-16 19:23:08 UTC
(rev 8626)
+++ trunk/sandbox/ui/state/src/main/config/component/states.xml 2008-05-16 21:04:44 UTC
(rev 8627)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"http://labs.jboss.com/jbossrichfaces/component-config.dtd
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"http://labs.jboss.com/jbossrichfaces/component-config.dtd" >
<components>
<component>
<name>org.richfaces.ui.States</name>
Added: trunk/sandbox/ui/state/src/main/java/org/richfaces/el/StateELResolver.java
===================================================================
--- trunk/sandbox/ui/state/src/main/java/org/richfaces/el/StateELResolver.java
(rev 0)
+++ trunk/sandbox/ui/state/src/main/java/org/richfaces/el/StateELResolver.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,222 @@
+/**
+ *
+ */
+package org.richfaces.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.ui.model.State;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class StateELResolver extends ELResolver {
+
+ private static final class ELContextWrapper extends ELContext {
+ private final ELContext context;
+
+ private boolean resolved = false;
+
+ private ELContextWrapper(ELContext context) {
+ this.context = context;
+ }
+
+ @Override
+ public ELResolver getELResolver() {
+ return context.getELResolver();
+ }
+
+ @Override
+ public FunctionMapper getFunctionMapper() {
+ return context.getFunctionMapper();
+ }
+
+ @Override
+ public VariableMapper getVariableMapper() {
+ return context.getVariableMapper();
+ }
+
+ /**
+ * @param key
+ * @return
+ * @see javax.el.ELContext#getContext(java.lang.Class)
+ */
+ public Object getContext(Class key) {
+ return context.getContext(key);
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getLocale()
+ */
+ public Locale getLocale() {
+ return context.getLocale();
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#isPropertyResolved()
+ */
+ public boolean isPropertyResolved() {
+ return resolved;
+ }
+
+ /**
+ * @param key
+ * @param contextObject
+ * @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
+ */
+ public void putContext(Class key, Object contextObject) {
+ context.putContext(key, contextObject);
+ }
+
+ /**
+ * @param locale
+ * @see javax.el.ELContext#setLocale(java.util.Locale)
+ */
+ public void setLocale(Locale locale) {
+ context.setLocale(locale);
+ }
+
+ /**
+ * @param resolved
+ * @see javax.el.ELContext#setPropertyResolved(boolean)
+ */
+ public void setPropertyResolved(boolean resolved) {
+ this.resolved = resolved;
+ }
+ }
+
+ private static List<FeatureDescriptor> stateFeatureDescriptors;
+ static {
+ FeatureDescriptor descriptor = new FeatureDescriptor();
+ descriptor.setDisplayName("Page state");
+ descriptor.setExpert(false);
+ descriptor.setName("state");
+ descriptor.setHidden(false);
+ stateFeatureDescriptors = Collections.singletonList(descriptor);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ELResolver#getCommonPropertyType(javax.el.ELContext, java.lang.Object)
+ */
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ if (null != base && base instanceof State) {
+ return String.class;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ELResolver#getFeatureDescriptors(javax.el.ELContext, java.lang.Object)
+ */
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
+ Object base) {
+ if (null != base && base instanceof State) {
+ return stateFeatureDescriptors.iterator();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ELResolver#getType(javax.el.ELContext, java.lang.Object,
java.lang.Object)
+ */
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property) {
+ if (null != base && base instanceof State) {
+ if (property == null) {
+ throw new PropertyNotFoundException("Null property");
+ }
+ State state = (State)base;
+ Object stateProperty = state.get(property.toString());
+ if (stateProperty == null) {
+ throw new PropertyNotFoundException("State Property
["+property+"] not found ");
+ }
+ context.setPropertyResolved(true);
+ if (stateProperty instanceof ValueExpression) {
+ ValueExpression propertyExpression = (ValueExpression) stateProperty;
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ return propertyExpression.getType(facesContext.getELContext());
+ }
+ return stateProperty.getClass();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ELResolver#getValue(javax.el.ELContext, java.lang.Object,
java.lang.Object)
+ */
+ @Override
+ public Object getValue(final ELContext context, Object base, Object property) {
+ if (null != base && base instanceof State) {
+ if (property == null) {
+ throw new PropertyNotFoundException("Null property");
+ }
+ State state = (State)base;
+ Object stateProperty = state.get(property.toString());
+ if (stateProperty == null) {
+ throw new PropertyNotFoundException("State Property
["+property+"] not found ");
+ }
+ context.setPropertyResolved(true);
+ if (stateProperty instanceof ValueExpression) {
+ ValueExpression propertyExpression = (ValueExpression) stateProperty;
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ELContext tempContext = new ELContextWrapper(context);
+ return propertyExpression.getValue(tempContext);
+ }
+ return stateProperty;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ELResolver#isReadOnly(javax.el.ELContext, java.lang.Object,
java.lang.Object)
+ */
+ @Override
+ public boolean isReadOnly(ELContext context, Object base, Object property) {
+ if (null != base && base instanceof State){
+ if (property == null) {
+ throw new PropertyNotFoundException("Null property");
+ }
+ State state = (State)base;
+ Object stateProperty = state.get(property.toString());
+ if (stateProperty == null) {
+ throw new PropertyNotFoundException("State Property
["+property+"] not found ");
+ }
+ context.setPropertyResolved(true);
+ return true;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ELResolver#setValue(javax.el.ELContext, java.lang.Object,
java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) {
+ if (null != base && base instanceof State){
+ if (property == null) {
+ throw new PropertyNotFoundException("Null property");
+ }
+ throw new PropertyNotWritableException((String) property);
+ }
+ }
+
+}
Property changes on:
trunk/sandbox/ui/state/src/main/java/org/richfaces/el/StateELResolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateApplication.java
===================================================================
---
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateApplication.java
(rev 0)
+++
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateApplication.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,445 @@
+/**
+ *
+ */
+package org.richfaces.ui.application;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.el.ELContextListener;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.application.NavigationHandler;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.PropertyResolver;
+import javax.faces.el.ReferenceSyntaxException;
+import javax.faces.el.ValueBinding;
+import javax.faces.el.VariableResolver;
+import javax.faces.event.ActionListener;
+import javax.faces.validator.Validator;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class StateApplication extends Application {
+
+ private final Application parent;
+ private final ExpressionFactory exprFactory;
+
+ /**
+ * @param parent
+ */
+ public StateApplication(Application parent) {
+ super();
+ this.parent = parent;
+ this.exprFactory = new StateExpressionFactory(parent.getExpressionFactory());
+ }
+
+ /**
+ * @param componentType
+ * @param componentClass
+ * @see javax.faces.application.Application#addComponent(java.lang.String,
java.lang.String)
+ */
+ public void addComponent(String componentType, String componentClass) {
+ parent.addComponent(componentType, componentClass);
+ }
+
+ /**
+ * @param targetClass
+ * @param converterClass
+ * @see javax.faces.application.Application#addConverter(java.lang.Class,
java.lang.String)
+ */
+ public void addConverter(Class targetClass, String converterClass) {
+ parent.addConverter(targetClass, converterClass);
+ }
+
+ /**
+ * @param converterId
+ * @param converterClass
+ * @see javax.faces.application.Application#addConverter(java.lang.String,
java.lang.String)
+ */
+ public void addConverter(String converterId, String converterClass) {
+ parent.addConverter(converterId, converterClass);
+ }
+
+ /**
+ * @param listener
+ * @see
javax.faces.application.Application#addELContextListener(javax.el.ELContextListener)
+ */
+ public void addELContextListener(ELContextListener listener) {
+ parent.addELContextListener(listener);
+ }
+
+ /**
+ * @param resolver
+ * @see javax.faces.application.Application#addELResolver(javax.el.ELResolver)
+ */
+ public void addELResolver(ELResolver resolver) {
+ parent.addELResolver(resolver);
+ }
+
+ /**
+ * @param validatorId
+ * @param validatorClass
+ * @see javax.faces.application.Application#addValidator(java.lang.String,
java.lang.String)
+ */
+ public void addValidator(String validatorId, String validatorClass) {
+ parent.addValidator(validatorId, validatorClass);
+ }
+
+ /**
+ * @param componentType
+ * @return
+ * @throws FacesException
+ * @see javax.faces.application.Application#createComponent(java.lang.String)
+ */
+ public UIComponent createComponent(String componentType)
+ throws FacesException {
+ return parent.createComponent(componentType);
+ }
+
+ /**
+ * @param componentBinding
+ * @param context
+ * @param componentType
+ * @return
+ * @throws FacesException
+ * @deprecated
+ * @see javax.faces.application.Application#createComponent(javax.faces.el.ValueBinding,
javax.faces.context.FacesContext, java.lang.String)
+ */
+ public UIComponent createComponent(ValueBinding componentBinding,
+ FacesContext context, String componentType) throws FacesException {
+ return parent.createComponent(componentBinding, context, componentType);
+ }
+
+ /**
+ * @param componentExpression
+ * @param context
+ * @param componentType
+ * @return
+ * @throws FacesException
+ * @see javax.faces.application.Application#createComponent(javax.el.ValueExpression,
javax.faces.context.FacesContext, java.lang.String)
+ */
+ public UIComponent createComponent(ValueExpression componentExpression,
+ FacesContext context, String componentType) throws FacesException {
+ return parent.createComponent(componentExpression, context,
+ componentType);
+ }
+
+ /**
+ * @param targetClass
+ * @return
+ * @see javax.faces.application.Application#createConverter(java.lang.Class)
+ */
+ public Converter createConverter(Class targetClass) {
+ return parent.createConverter(targetClass);
+ }
+
+ /**
+ * @param converterId
+ * @return
+ * @see javax.faces.application.Application#createConverter(java.lang.String)
+ */
+ public Converter createConverter(String converterId) {
+ return parent.createConverter(converterId);
+ }
+
+ /**
+ * @param ref
+ * @param params
+ * @return
+ * @throws ReferenceSyntaxException
+ * @deprecated
+ * @see javax.faces.application.Application#createMethodBinding(java.lang.String,
java.lang.Class[])
+ */
+ public MethodBinding createMethodBinding(String ref, Class[] params)
+ throws ReferenceSyntaxException {
+ return parent.createMethodBinding(ref, params);
+ }
+
+ /**
+ * @param validatorId
+ * @return
+ * @throws FacesException
+ * @see javax.faces.application.Application#createValidator(java.lang.String)
+ */
+ public Validator createValidator(String validatorId) throws FacesException {
+ return parent.createValidator(validatorId);
+ }
+
+ /**
+ * @param ref
+ * @return
+ * @throws ReferenceSyntaxException
+ * @deprecated
+ * @see javax.faces.application.Application#createValueBinding(java.lang.String)
+ */
+ public ValueBinding createValueBinding(String ref)
+ throws ReferenceSyntaxException {
+ return parent.createValueBinding(ref);
+ }
+
+ /**
+ * @param context
+ * @param expression
+ * @param expectedType
+ * @return
+ * @throws ELException
+ * @see
javax.faces.application.Application#evaluateExpressionGet(javax.faces.context.FacesContext,
java.lang.String, java.lang.Class)
+ */
+ public Object evaluateExpressionGet(FacesContext context,
+ String expression, Class expectedType) throws ELException {
+ return parent.evaluateExpressionGet(context, expression, expectedType);
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getActionListener()
+ */
+ public ActionListener getActionListener() {
+ return parent.getActionListener();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getComponentTypes()
+ */
+ public Iterator<String> getComponentTypes() {
+ return parent.getComponentTypes();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getConverterIds()
+ */
+ public Iterator<String> getConverterIds() {
+ return parent.getConverterIds();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getConverterTypes()
+ */
+ public Iterator<Class> getConverterTypes() {
+ return parent.getConverterTypes();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getDefaultLocale()
+ */
+ public Locale getDefaultLocale() {
+ return parent.getDefaultLocale();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getDefaultRenderKitId()
+ */
+ public String getDefaultRenderKitId() {
+ return parent.getDefaultRenderKitId();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getELContextListeners()
+ */
+ public ELContextListener[] getELContextListeners() {
+ return parent.getELContextListeners();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getELResolver()
+ */
+ public ELResolver getELResolver() {
+ return parent.getELResolver();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getExpressionFactory()
+ */
+ public ExpressionFactory getExpressionFactory() {
+ return this.exprFactory;
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getMessageBundle()
+ */
+ public String getMessageBundle() {
+ return parent.getMessageBundle();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getNavigationHandler()
+ */
+ public NavigationHandler getNavigationHandler() {
+ return parent.getNavigationHandler();
+ }
+
+ /**
+ * @return
+ * @deprecated
+ * @see javax.faces.application.Application#getPropertyResolver()
+ */
+ public PropertyResolver getPropertyResolver() {
+ return parent.getPropertyResolver();
+ }
+
+ /**
+ * @param ctx
+ * @param name
+ * @return
+ * @see
javax.faces.application.Application#getResourceBundle(javax.faces.context.FacesContext,
java.lang.String)
+ */
+ public ResourceBundle getResourceBundle(FacesContext ctx, String name) {
+ return parent.getResourceBundle(ctx, name);
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getStateManager()
+ */
+ public StateManager getStateManager() {
+ return parent.getStateManager();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getSupportedLocales()
+ */
+ public Iterator<Locale> getSupportedLocales() {
+ return parent.getSupportedLocales();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getValidatorIds()
+ */
+ public Iterator<String> getValidatorIds() {
+ return parent.getValidatorIds();
+ }
+
+ /**
+ * @return
+ * @deprecated
+ * @see javax.faces.application.Application#getVariableResolver()
+ */
+ public VariableResolver getVariableResolver() {
+ return parent.getVariableResolver();
+ }
+
+ /**
+ * @return
+ * @see javax.faces.application.Application#getViewHandler()
+ */
+ public ViewHandler getViewHandler() {
+ return parent.getViewHandler();
+ }
+
+ /**
+ * @param listener
+ * @see
javax.faces.application.Application#removeELContextListener(javax.el.ELContextListener)
+ */
+ public void removeELContextListener(ELContextListener listener) {
+ parent.removeELContextListener(listener);
+ }
+
+ /**
+ * @param listener
+ * @see
javax.faces.application.Application#setActionListener(javax.faces.event.ActionListener)
+ */
+ public void setActionListener(ActionListener listener) {
+ parent.setActionListener(listener);
+ }
+
+ /**
+ * @param locale
+ * @see javax.faces.application.Application#setDefaultLocale(java.util.Locale)
+ */
+ public void setDefaultLocale(Locale locale) {
+ parent.setDefaultLocale(locale);
+ }
+
+ /**
+ * @param renderKitId
+ * @see javax.faces.application.Application#setDefaultRenderKitId(java.lang.String)
+ */
+ public void setDefaultRenderKitId(String renderKitId) {
+ parent.setDefaultRenderKitId(renderKitId);
+ }
+
+ /**
+ * @param bundle
+ * @see javax.faces.application.Application#setMessageBundle(java.lang.String)
+ */
+ public void setMessageBundle(String bundle) {
+ parent.setMessageBundle(bundle);
+ }
+
+ /**
+ * @param handler
+ * @see
javax.faces.application.Application#setNavigationHandler(javax.faces.application.NavigationHandler)
+ */
+ public void setNavigationHandler(NavigationHandler handler) {
+ parent.setNavigationHandler(handler);
+ }
+
+ /**
+ * @param resolver
+ * @deprecated
+ * @see
javax.faces.application.Application#setPropertyResolver(javax.faces.el.PropertyResolver)
+ */
+ public void setPropertyResolver(PropertyResolver resolver) {
+ parent.setPropertyResolver(resolver);
+ }
+
+ /**
+ * @param manager
+ * @see
javax.faces.application.Application#setStateManager(javax.faces.application.StateManager)
+ */
+ public void setStateManager(StateManager manager) {
+ parent.setStateManager(manager);
+ }
+
+ /**
+ * @param locales
+ * @see javax.faces.application.Application#setSupportedLocales(java.util.Collection)
+ */
+ public void setSupportedLocales(Collection<Locale> locales) {
+ parent.setSupportedLocales(locales);
+ }
+
+ /**
+ * @param resolver
+ * @deprecated
+ * @see
javax.faces.application.Application#setVariableResolver(javax.faces.el.VariableResolver)
+ */
+ public void setVariableResolver(VariableResolver resolver) {
+ parent.setVariableResolver(resolver);
+ }
+
+ /**
+ * @param handler
+ * @see
javax.faces.application.Application#setViewHandler(javax.faces.application.ViewHandler)
+ */
+ public void setViewHandler(ViewHandler handler) {
+ parent.setViewHandler(handler);
+ }
+
+}
Property changes on:
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateApplication.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateExpressionFactory.java
===================================================================
---
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateExpressionFactory.java
(rev 0)
+++
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateExpressionFactory.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,76 @@
+/**
+ *
+ */
+package org.richfaces.ui.application;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class StateExpressionFactory extends ExpressionFactory {
+
+ ExpressionFactory defaultFactory;
+
+ /**
+ * @param defaultFactory
+ */
+ public StateExpressionFactory(ExpressionFactory defaultFactory) {
+ super();
+ this.defaultFactory = defaultFactory;
+ }
+
+ /**
+ * @param obj
+ * @param targetType
+ * @return
+ * @see javax.el.ExpressionFactory#coerceToType(java.lang.Object, java.lang.Class)
+ */
+ public Object coerceToType(Object obj, Class<?> targetType) {
+ return defaultFactory.coerceToType(obj, targetType);
+ }
+
+ /**
+ * @param context
+ * @param expression
+ * @param expectedReturnType
+ * @param expectedParamTypes
+ * @return
+ * @see javax.el.ExpressionFactory#createMethodExpression(javax.el.ELContext,
java.lang.String, java.lang.Class, java.lang.Class<?>[])
+ */
+ public MethodExpression createMethodExpression(ELContext context,
+ String expression, Class<?> expectedReturnType,
+ Class<?>[] expectedParamTypes) {
+ return defaultFactory.createMethodExpression(context, expression,
+ expectedReturnType, expectedParamTypes);
+ }
+
+ /**
+ * @param context
+ * @param expression
+ * @param expectedType
+ * @return
+ * @see javax.el.ExpressionFactory#createValueExpression(javax.el.ELContext,
java.lang.String, java.lang.Class)
+ */
+ public ValueExpression createValueExpression(ELContext context,
+ String expression, Class<?> expectedType) {
+ return defaultFactory.createValueExpression(context, expression,
+ expectedType);
+ }
+
+ /**
+ * @param instance
+ * @param expectedType
+ * @return
+ * @see javax.el.ExpressionFactory#createValueExpression(java.lang.Object,
java.lang.Class)
+ */
+ public ValueExpression createValueExpression(Object instance,
+ Class<?> expectedType) {
+ return defaultFactory.createValueExpression(instance, expectedType);
+ }
+
+}
Property changes on:
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateExpressionFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateNavigationHandler.java
===================================================================
---
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateNavigationHandler.java
(rev 0)
+++
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateNavigationHandler.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,52 @@
+/**
+ *
+ */
+package org.richfaces.ui.application;
+
+import java.util.Map;
+
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.ui.model.States;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class StateNavigationHandler extends NavigationHandler {
+
+ private NavigationHandler parent;
+
+ /**
+ * @param parent
+ */
+ public StateNavigationHandler(NavigationHandler parent) {
+ super();
+ this.parent = parent;
+ }
+
+ /**
+ * @param context
+ * @param fromAction
+ * @param outcome
+ * @see
javax.faces.application.NavigationHandler#handleNavigation(javax.faces.context.FacesContext,
java.lang.String, java.lang.String)
+ */
+ public void handleNavigation(FacesContext context, String fromAction,
+ String outcome) {
+ if(null != outcome){
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ for (Object bean : requestMap.values()) {
+ if (bean instanceof States) {
+ States state = (States) bean;
+ String navigation = state.getNavigation(outcome);
+ if(null != navigation){
+ state.setCurrentState(navigation);
+ }
+ }
+ }
+ }
+ parent.handleNavigation(context, fromAction, outcome);
+ }
+
+}
Property changes on:
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/application/StateNavigationHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/State.java
===================================================================
--- trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/State.java 2008-05-16
19:23:08 UTC (rev 8626)
+++ trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/State.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -3,18 +3,18 @@
*/
package org.richfaces.ui.model;
-import javax.faces.el.MethodBinding;
+import java.util.Map;
+import javax.el.MethodExpression;
+
/**
* @author asmirnov
*
*/
-public interface State {
+public interface State extends Map<String, Object>{
+
+ public String getNavigation(String outcome);
- public Object getProperty(String name);
+ public void setNavigation(String outcome, String navigation);
- public MethodBinding getAction(String name);
-
- public String getNavigation(String outcome);
-
}
Added: trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/StateImpl.java
===================================================================
--- trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/StateImpl.java
(rev 0)
+++ trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/StateImpl.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,41 @@
+/**
+ *
+ */
+package org.richfaces.ui.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.el.MethodExpression;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class StateImpl extends HashMap<String, Object> implements State {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5521648998682443502L;
+
+ private Map<String,String>navigations = new HashMap<String, String>();
+
+
+
+ /* (non-Javadoc)
+ * @see org.richfaces.ui.model.State#getNavigation(java.lang.String)
+ */
+ public String getNavigation(String outcome) {
+ // TODO Auto-generated method stub
+ return navigations.get(outcome);
+ }
+
+
+ public void setNavigation(String outcome, String navigation) {
+ navigations.put(outcome, navigation);
+
+ }
+
+
+}
Property changes on:
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/StateImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/States.java
===================================================================
--- trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/States.java
(rev 0)
+++ trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/States.java 2008-05-16
21:04:44 UTC (rev 8627)
@@ -0,0 +1,134 @@
+/**
+ *
+ */
+package org.richfaces.ui.model;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import javax.el.MethodExpression;
+
+import org.ajax4jsf.model.KeepAlive;
+
+/**
+ * @author asmirnov
+ *
+ */
+@KeepAlive
+public class States implements State {
+
+ private static final String DEFAULT_STATE = "DEFAULT";
+ private final Map<String, State> states;
+
+ private State currentState;
+
+ private String currentStateName;
+
+ public States() {
+ states = new HashMap<String, State>();
+ }
+
+ /**
+ * HACK - bean property setter for a initialisation from faces-config.xml.
+ * @param stateConfig
+ */
+ public void setConfig(String stateConfig){
+ // TODO - parse configuration.
+ }
+
+ /**
+ * Copy all states from an initial state configuration. Use to init state bean from
faces-config.xml
+ * @param initial
+ */
+ public void setStates(States initial){
+ this.states.clear();
+ this.states.putAll(initial.states);
+ this.currentState = initial.currentState;
+ this.currentStateName = initial.currentStateName;
+ }
+
+ public void setCurrentState(String name) {
+ State state = states.get(name);
+ if (null == state) {
+ state = new StateImpl();
+ states.put(name, state);
+ }
+ currentStateName = name;
+ currentState = state;
+ }
+
+ public String getCurrentState(){
+ return currentStateName;
+ }
+
+ public void setState(String name, State state) {
+ states.put(name, state);
+ currentStateName = name;
+ currentState = state;
+ }
+
+ public void clear() {
+ currentState.clear();
+ }
+
+ public boolean containsKey(Object key) {
+ return currentState.containsKey(key);
+ }
+
+ public boolean containsValue(Object value) {
+ return currentState.containsValue(value);
+ }
+
+ public Set<Entry<String, Object>> entrySet() {
+ return currentState.entrySet();
+ }
+
+ public Object get(Object key) {
+ return currentState.get(key);
+ }
+
+ public String getNavigation(String outcome) {
+ return currentState.getNavigation(outcome);
+ }
+
+ /**
+ * @param outcome
+ * @param navigation
+ * @see org.richfaces.ui.model.State#setNavigation(java.lang.String, java.lang.String)
+ */
+ public void setNavigation(String outcome, String navigation) {
+ currentState.setNavigation(outcome, navigation);
+ }
+
+ public boolean isEmpty() {
+ return currentState.isEmpty();
+ }
+
+ public Set<String> keySet() {
+ return currentState.keySet();
+ }
+
+ public Object put(String key, Object value) {
+ return currentState.put(key, value);
+ }
+
+ public void putAll(Map<? extends String, ? extends Object> t) {
+ currentState.putAll(t);
+ }
+
+ public Object remove(Object key) {
+ return currentState.remove(key);
+ }
+
+ public int size() {
+ return currentState.size();
+ }
+
+ public Collection<Object> values() {
+ return currentState.values();
+ }
+
+}
Property changes on:
trunk/sandbox/ui/state/src/main/java/org/richfaces/ui/model/States.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/core/src/main/java/org/ajax4jsf/component/KeepAlive.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/KeepAlive.java
(rev 0)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/KeepAlive.java 2008-05-16 21:04:44
UTC (rev 8627)
@@ -0,0 +1,25 @@
+/**
+ *
+ */
+package org.ajax4jsf.component;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class KeepAlive extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.KeepAlive";
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.KeepAlive";
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+}
Property changes on: trunk/ui/core/src/main/java/org/ajax4jsf/component/KeepAlive.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain