You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2007/10/20 20:51:12 UTC
svn commit: r586774 -
/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java
Author: imario
Date: Sat Oct 20 11:51:10 2007
New Revision: 586774
URL: http://svn.apache.org/viewvc?rev=586774&view=rev
Log:
ORCHESTRA-8: a proposal for this initView problem
Modified:
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java?rev=586774&r1=586773&r2=586774&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/viewController/jsf/ViewControllerPhaseListener.java Sat Oct 20 11:51:10 2007
@@ -28,6 +28,8 @@
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
+import java.util.Set;
+import java.util.TreeSet;
/**
* Causes lifecycle methods to be invoked on backing beans that are associated with
@@ -39,6 +41,15 @@
{
private static final long serialVersionUID = -3975277433747722402L;
+ public static class ViewControllerPhaseListenerState
+ {
+ private Set initedViews = new TreeSet();
+
+ protected ViewControllerPhaseListenerState()
+ {
+ }
+ }
+
public void beforePhase(PhaseEvent event)
{
if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId()) ||
@@ -52,6 +63,8 @@
}
}
+ executeInitView(event.getFacesContext());
+
if (PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
{
preRenderResponse(event.getFacesContext());
@@ -73,9 +86,9 @@
// we have a redirect ... stop now
return;
}
-
- postRestoreView(event.getFacesContext());
}
+
+ executeInitView(event.getFacesContext());
}
public PhaseId getPhaseId()
@@ -139,6 +152,14 @@
/**
* invokes the initView method on your view controller
*/
+ protected void executeInitView(FacesContext facesContext)
+ {
+ postRestoreView(facesContext);
+ }
+
+ /**
+ * @deprecated overload/use {@link #executeInitView(javax.faces.context.FacesContext)} instead
+ */
protected void postRestoreView(FacesContext facesContext)
{
ViewControllerManager manager = _ViewControllerUtils.getViewControllerManager(facesContext);
@@ -153,7 +174,27 @@
return;
}
+ ViewControllerPhaseListenerState state = getState(facesContext);
+
+ if (state.initedViews.contains(viewId))
+ {
+ // already inited
+ return;
+ }
+ state.initedViews.add(viewId);
+
manager.executeInitView(viewId);
+ }
+
+ protected ViewControllerPhaseListenerState getState(FacesContext facesContext)
+ {
+ ViewControllerPhaseListenerState state = (ViewControllerPhaseListenerState) facesContext.getExternalContext().getRequestMap().get(ViewControllerPhaseListenerState.class.getName());
+ if (state == null)
+ {
+ state = new ViewControllerPhaseListenerState();
+ facesContext.getExternalContext().getRequestMap().put(ViewControllerPhaseListenerState.class.getName(), state);
+ }
+ return state;
}
/**