[
https://issues.apache.org/jira/browse/ORCHESTRA-8?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536457
]
Mario Ivankovits commented on ORCHESTRA-8:
------------------------------------------
committed a proposal to fix this. Please review r586774
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 [EMAIL PROTECTED]
#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;
}
/**
> Orchestra do not send an @InitView notification to the ViewController during
> a non redirect navigation
> ------------------------------------------------------------------------------------------------------
>
> Key: ORCHESTRA-8
> URL: https://issues.apache.org/jira/browse/ORCHESTRA-8
> Project: MyFaces Orchestra
> Issue Type: Bug
> Components: ViewController
> Affects Versions: 1.0
> Environment: JSF 1.1 & Facelets
> Reporter: Mario Ivankovits
> Assignee: Mario Ivankovits
>
> The lifecycle is as follows:
> BEFORE RESTORE_VIEW(1): null
> AFTER RESTORE_VIEW(1): /all.xhtml
> BEFORE APPLY_REQUEST_VALUES(2): /all.xhtml
> AFTER APPLY_REQUEST_VALUES(2): /all.xhtml
> BEFORE PROCESS_VALIDATIONS(3): /all.xhtml
> AFTER PROCESS_VALIDATIONS(3): /all.xhtml
> BEFORE UPDATE_MODEL_VALUES(4): /all.xhtml
> AFTER UPDATE_MODEL_VALUES(4): /all.xhtml
> BEFORE INVOKE_APPLICATION(5): /all.xhtml
> AFTER INVOKE_APPLICATION(5): /edit1.xhtml
> as you can see, the viewId changes during INVOKE_APPLICATION. Now, that we do
> not see a RESTORE_VIEW no InitView will be sent.
> InitView was meant to be sent after the view has been created, regardless if
> this is a restoreView or createView. Since we sit in the PhaseListener we do
> not see the ViewHandler invokes but just those from the PhaseListener where
> the RESTORE_VIEW is missing then.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.