Author: alexsmirnov
Date: 2007-10-10 20:32:56 -0400 (Wed, 10 Oct 2007)
New Revision: 3323
Modified:
trunk/cdk/maven-archetype-jsf-component/src/main/resources/archetype-resources/pom.xml
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/RestoreViewPhase.java
Log:
fix
http://jira.jboss.org/jira/browse/RF-1095
Continue to work on portal support
Modified:
trunk/cdk/maven-archetype-jsf-component/src/main/resources/archetype-resources/pom.xml
===================================================================
---
trunk/cdk/maven-archetype-jsf-component/src/main/resources/archetype-resources/pom.xml 2007-10-10
21:34:49 UTC (rev 3322)
+++
trunk/cdk/maven-archetype-jsf-component/src/main/resources/archetype-resources/pom.xml 2007-10-11
00:32:56 UTC (rev 3323)
@@ -1,33 +1,47 @@
-<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">
- <modelVersion>4.0.0</modelVersion>
- <groupId>${groupId}</groupId>
- <artifactId>${artifactId}</artifactId>
- <name>${artifactId}</name>
- <version>${version}</version>
- <build>
- <plugins>
- <plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- <configuration>
- <library>
- <prefix>${groupId}</prefix>
- <taglib>
- <shortName>${artifactId}</shortName>
- </taglib>
- </library>
- </configuration>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <name>${artifactId}</name>
+ <version>${version}</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <configuration>
+ <library>
+ <prefix>${groupId}</prefix>
+ <taglib>
+ <shortName>${artifactId}</shortName>
+ </taglib>
+ </library>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>richfaces-impl</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/RestoreViewPhase.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/RestoreViewPhase.java 2007-10-10
21:34:49 UTC (rev 3322)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/lifecycle/RestoreViewPhase.java 2007-10-11
00:32:56 UTC (rev 3323)
@@ -3,16 +3,29 @@
*/
package org.ajax4jsf.portlet.lifecycle;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseId;
import javax.faces.lifecycle.Lifecycle;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* @author asmirnov
*
*/
public class RestoreViewPhase extends LifecyclePhase {
+ private static final Log _log = LogFactory.getLog(RestoreViewPhase.class);
+
private final LifecyclePhase nextPhase;
/**
@@ -34,10 +47,55 @@
* @see
org.ajax4jsf.portlet.lifecycle.LifecyclePhase#executePhase(javax.faces.context.FacesContext)
*/
protected void executePhase(FacesContext context) {
+ // Check pre-created ViewRoot.
+ UIViewRoot viewRoot = context.getViewRoot();
+ ELContext elContext = context.getELContext();
+ if(null != viewRoot){
+ if(_log.isDebugEnabled()){
+ _log.debug("Found created UIViewRoot in facesContext");
+ }
+ viewRoot.setLocale(context.getExternalContext().getRequestLocale());
+ processBindings(elContext,viewRoot);
+ } else {
+ // Restore or Create new view.
+ String viewId = calculateViewId(context);
+ ViewHandler viewHandler = context.getApplication().getViewHandler();
+ if(isFacesRequest(context)){
+ viewRoot = viewHandler.restoreView(context, viewId);
+ if(null != viewRoot){
+ processBindings(elContext, viewRoot);
+ }
+ } else {
+ viewRoot = viewHandler.createView(context, viewId);
+ }
+ context.setViewRoot(viewRoot);
+ }
+ }
+
+ private boolean isFacesRequest(FacesContext context) {
// TODO Auto-generated method stub
+ return false;
+ }
+ private String calculateViewId(FacesContext context) {
+ String viewId = context.getExternalContext().getRequestPathInfo();
+ if(null == viewId){
+ viewId = context.getExternalContext().getRequestServletPath();
+ }
+ return viewId;
}
+ private void processBindings(ELContext elContext, UIComponent component) {
+ ValueExpression binding = component.getValueExpression("binding");
+ if(null != binding){
+ binding.setValue(elContext, component);
+ }
+ for (Iterator<UIComponent> iterator = component.getFacetsAndChildren();
iterator.hasNext();) {
+ UIComponent child = iterator.next();
+ processBindings(elContext, child);
+ }
+ }
+
/* (non-Javadoc)
* @see org.ajax4jsf.portlet.lifecycle.LifecyclePhase#getPhaseId()
*/