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/08/12 20:19:29 UTC
svn commit: r565101 - in /myfaces/orchestra/trunk:
core/src/main/java/org/apache/myfaces/orchestra/conversation/
core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/
core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotation...
Author: imario
Date: Sun Aug 12 11:19:28 2007
New Revision: 565101
URL: http://svn.apache.org/viewvc?view=rev&rev=565101
Log:
added concept of "entryViewIds" to @ConversationRequire to avoid checking if a conversation is running if you are on the entry page ... better ideas?
Added:
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/annotations/MultiViewController.java
- copied, changed from r565013, myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/annotations/MutliViewController.java
myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page3.jsp
- copied, changed from r565013, myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page2.jsp
Modified:
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationUtils.java
myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/JsfFrameworkAdapter.java
myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotations/ConversationRequire.java
myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerManager.java
myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml
myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page1.jsp
myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page2.jsp
myfaces/orchestra/trunk/examples/src/main/webapp/start.jsp
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationUtils.java?view=diff&rev=565101&r1=565100&r2=565101
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationUtils.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/ConversationUtils.java Sun Aug 12 11:19:28 2007
@@ -62,15 +62,7 @@
{
try
{
- StringBuffer redir = new StringBuffer();
- if (redirectViewId.startsWith("/"))
- {
- redir.append(
- FrameworkAdapter.getInstance().getRequestContextPath());
- }
- redir.append(redirectViewId);
-
- FrameworkAdapter.getInstance().redirect(redir.toString());
+ FrameworkAdapter.getInstance().redirect(redirectViewId);
}
catch (IOException e)
{
Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/JsfFrameworkAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/JsfFrameworkAdapter.java?view=diff&rev=565101&r1=565100&r2=565101
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/JsfFrameworkAdapter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/frameworkAdapter/JsfFrameworkAdapter.java Sun Aug 12 11:19:28 2007
@@ -216,9 +216,18 @@
public void redirect(String url) throws IOException
{
+ StringBuffer redir = new StringBuffer();
+ if (url.startsWith("/"))
+ {
+ redir.append(getRequestContextPath());
+ }
+ redir.append(url);
+
+
FacesContext context = getFacesContext();
- context.getExternalContext().redirect(url);
+ String actionUrl = context.getExternalContext().encodeActionURL(redir.toString());
+ context.getExternalContext().redirect(actionUrl);
context.responseComplete();
}
Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotations/ConversationRequire.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotations/ConversationRequire.java?view=diff&rev=565101&r1=565100&r2=565101
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotations/ConversationRequire.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/conversation/annotations/ConversationRequire.java Sun Aug 12 11:19:28 2007
@@ -33,6 +33,16 @@
public @interface ConversationRequire
{
/**
+ * <p>
+ * The view(s) which acts as the entry point(s) to the conversation.
+ * For views configured here no check if the conversation is already running happens.
+ * You have to configure it to avoid endless redirects to the start page.
+ * </p>
+ * TODO: Is there a way to avoid this configuration option?
+ */
+ String[] entryPointViewIds();
+
+ /**
* One or many conversation names the view require as prerequesite.
* If one of the configured conversations is not active a redirect or
* navigationAction will be issued.
Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerManager.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerManager.java?view=diff&rev=565101&r1=565100&r2=565101
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerManager.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/viewController/AnnotationsViewControllerManager.java Sun Aug 12 11:19:28 2007
@@ -93,6 +93,22 @@
}
ConversationRequire conversationRequire = annotationInfo.getConversationRequire();
+
+ // check if we are on an entry-point-page
+ String[] entryPoints = conversationRequire.entryPointViewIds();
+ if (entryPoints != null && entryPoints.length > 0)
+ {
+ for (int i = 0; i<entryPoints.length; i++)
+ {
+ String entryPoint = entryPoints[i];
+ if (entryPoint.equals(viewId))
+ {
+ // yes ... no need to check
+ return;
+ }
+ }
+ }
+
String[] conversationNames = conversationRequire.conversationNames();
if (conversationNames == null || conversationNames.length < 1)
{
Copied: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/annotations/MultiViewController.java (from r565013, myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/annotations/MutliViewController.java)
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/annotations/MultiViewController.java?view=diff&rev=565101&p1=myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/annotations/MutliViewController.java&r1=565013&p2=myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/annotations/MultiViewController.java&r2=565101
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/annotations/MutliViewController.java (original)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/annotations/MultiViewController.java Sun Aug 12 11:19:28 2007
@@ -20,25 +20,45 @@
import org.apache.myfaces.orchestra.viewController.annotations.InitView;
import org.apache.myfaces.orchestra.viewController.annotations.ViewController;
+import org.apache.myfaces.orchestra.conversation.annotations.ConversationRequire;
+import org.apache.myfaces.orchestra.conversation.Conversation;
import javax.faces.context.FacesContext;
/**
* A viewController which is responsible for multiple views
*/
-@ViewController(viewIds={"/annotations/Page1.jsp", "/annotations/Page2.jsp"})
-public class MutliViewController
+@ConversationRequire(
+ conversationNames = "multiViewController",
+ entryPointViewIds = "/annotations/Page1.jsp",
+ redirect = "/annotations/Page1.faces")
+@ViewController(
+ viewIds={"/annotations/Page1.jsp", "/annotations/Page2.jsp", "/annotations/Page3.jsp"})
+public class MultiViewController
{
+ private String prevInitViewId;
private String initViewId;
@InitView
public void anyMethodName()
{
+ prevInitViewId = initViewId;
initViewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();
}
public String getInitViewId()
{
return initViewId;
+ }
+
+ public String getPrevInitViewId()
+ {
+ return prevInitViewId;
+ }
+
+ public String endConversationAction()
+ {
+ Conversation.getCurrentInstance().invalidate();
+ return null;
}
}
Modified: myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml?view=diff&rev=565101&r1=565100&r2=565101
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml Sun Aug 12 11:19:28 2007
@@ -309,8 +309,8 @@
</bean>
<bean
- name="mutliViewController"
- class="org.apache.myfaces.examples.annotations.MutliViewController"
+ name="multiViewController"
+ class="org.apache.myfaces.examples.annotations.MultiViewController"
scope="conversation">
<aop:scoped-proxy/>
Modified: myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page1.jsp
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page1.jsp?view=diff&rev=565101&r1=565100&r2=565101
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page1.jsp (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page1.jsp Sun Aug 12 11:19:28 2007
@@ -23,7 +23,7 @@
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s" %>
<%@ taglib uri="http://myfaces.apache.org/orchestra15" prefix="ox" %>
-<%--@elvariable id="mutliViewController" type="org.apache.myfaces.examples.annotations.MutliViewController"--%>
+<%--@elvariable id="multiViewController" type="org.apache.myfaces.examples.annotations.MultiViewController"--%>
<f:view>
<%@ include file="../header.jspf" %>
@@ -33,8 +33,19 @@
<t:htmlTag value="h3">
<h:outputText value="Page1"/>
</t:htmlTag>
+ <h:panelGrid columns="2">
+ <h:outputLink value="Page2.faces">
+ <h:outputText value="GoTo Page2" />
+ </h:outputLink>
+ <h:outputLink value="Page3.faces">
+ <h:outputText value="GoTo Page3" />
+ </h:outputLink>
+ </h:panelGrid>
- <h:outputText value="InitView called by view: #{mutliViewController.initViewId}" />
+ <h:panelGrid columns="1">
+ <h:outputText value="InitView called by view: #{multiViewController.initViewId}" />
+ <h:outputText value="Previous InitView: #{multiViewController.prevInitViewId}" />
+ </h:panelGrid>
</h:form>
Modified: myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page2.jsp
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page2.jsp?view=diff&rev=565101&r1=565100&r2=565101
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page2.jsp (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page2.jsp Sun Aug 12 11:19:28 2007
@@ -23,7 +23,7 @@
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s" %>
<%@ taglib uri="http://myfaces.apache.org/orchestra15" prefix="ox" %>
-<%--@elvariable id="mutliViewController" type="org.apache.myfaces.examples.annotations.MutliViewController"--%>
+<%--@elvariable id="multiViewController" type="org.apache.myfaces.examples.annotations.MultiViewController"--%>
<f:view>
<%@ include file="../header.jspf" %>
@@ -33,9 +33,27 @@
<t:htmlTag value="h3">
<h:outputText value="Page2"/>
</t:htmlTag>
+ <h:panelGrid columns="2">
+ <h:outputLink value="Page1.faces">
+ <h:outputText value="GoTo Page1" />
+ </h:outputLink>
+ <h:outputLink value="Page3.faces">
+ <h:outputText value="GoTo Page3" />
+ </h:outputLink>
+ </h:panelGrid>
- <h:outputText value="InitView called by view: #{mutliViewController.initViewId}" />
+ <h:panelGrid columns="1">
+ <h:outputText value="InitView called by view: #{multiViewController.initViewId}" />
+ <h:outputText value="Previous InitView: #{multiViewController.prevInitViewId}" />
+ </h:panelGrid>
+ <h:panelGrid columns="1">
+ <h:panelGrid columns="2">
+ <h:commandButton value="end conversation" action="#{multiViewController.endConversationAction}" />
+ <h:outputText value="this should direct you back to page1" />
+ </h:panelGrid>
+ </h:panelGrid>
+
</h:form>
<%@ include file="../footer.jspf" %>
Copied: myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page3.jsp (from r565013, myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page2.jsp)
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page3.jsp?view=diff&rev=565101&p1=myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page2.jsp&r1=565013&p2=myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page3.jsp&r2=565101
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page2.jsp (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/annotations/Page3.jsp Sun Aug 12 11:19:28 2007
@@ -23,7 +23,7 @@
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s" %>
<%@ taglib uri="http://myfaces.apache.org/orchestra15" prefix="ox" %>
-<%--@elvariable id="mutliViewController" type="org.apache.myfaces.examples.annotations.MutliViewController"--%>
+<%--@elvariable id="multiViewController" type="org.apache.myfaces.examples.annotations.MultiViewController"--%>
<f:view>
<%@ include file="../header.jspf" %>
@@ -31,11 +31,29 @@
<h:form>
<t:htmlTag value="h3">
- <h:outputText value="Page2"/>
+ <h:outputText value="Page3"/>
</t:htmlTag>
+ <h:panelGrid columns="2">
+ <h:outputLink value="Page1.faces">
+ <h:outputText value="GoTo Page1" />
+ </h:outputLink>
+ <h:outputLink value="Page2.faces">
+ <h:outputText value="GoTo Page2" />
+ </h:outputLink>
+ </h:panelGrid>
- <h:outputText value="InitView called by view: #{mutliViewController.initViewId}" />
+ <h:panelGrid columns="1">
+ <h:outputText value="InitView called by view: #{multiViewController.initViewId}" />
+ <h:outputText value="Previous InitView: #{multiViewController.prevInitViewId}" />
+ </h:panelGrid>
+ <h:panelGrid columns="1">
+ <h:panelGrid columns="2">
+ <h:commandButton value="end conversation" action="#{multiViewController.endConversationAction}" />
+ <h:outputText value="this should direct you back to page1" />
+ </h:panelGrid>
+ </h:panelGrid>
+
</h:form>
<%@ include file="../footer.jspf" %>
Modified: myfaces/orchestra/trunk/examples/src/main/webapp/start.jsp
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/start.jsp?view=diff&rev=565101&r1=565100&r2=565101
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/start.jsp (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/start.jsp Sun Aug 12 11:19:28 2007
@@ -56,6 +56,11 @@
<h:outputText value="Multiple Beans within the same conversation through special 'orchestra' configuration" />
</h:outputLink>
</t:htmlTag>
+ <t:htmlTag value="li">
+ <h:outputLink value="annotations/start.faces" >
+ <h:outputText value="Some annotation tests" />
+ </h:outputLink>
+ </t:htmlTag>
</t:htmlTag>
</h:form>