You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2004/09/01 00:25:42 UTC
svn commit: rev 37265 - in incubator/beehive/trunk/netui: src/pageflow/org/apache/beehive/netui/pageflow test/webapps/drt/coreWeb/returnTo/returnToCurrentJsp test/webapps/drt/testRecorder/config test/webapps/drt/testRecorder/tests
Author: rich
Date: Tue Aug 31 15:25:40 2004
New Revision: 37265
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/returnTo/returnToCurrentJsp/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/returnTo/returnToCurrentJsp/ReturnToCurrentJspController.jpf
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/returnTo/returnToCurrentJsp/current.jsp
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/ReturnToCurrentPage.xml
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowJspFilter.java
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
Log:
Patch submitted by Carlin Rogers:
"a fix to allow a hit to a .JSP page directly, without going through the controller first, then hit an action that has a return-to:current page. The patch also adds a new test to the BVT suite."
DRT: netui (linux)
BB: self (WinXP)
Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowController.java Tue Aug 31 15:25:40 2004
@@ -395,16 +395,24 @@
protected String getCurrentForwardPath()
{
PreviousPageInfo curPageInfo = getCurrentPageInfo();
+ String path = null;
if ( curPageInfo != null )
{
ActionForward curForward = curPageInfo.getForward();
- return curForward != null ? curForward.getPath() : null;
- }
- else
- {
- return null;
+ if ( curForward != null )
+ {
+ if ( curForward.getContextRelative() )
+ {
+ path = curForward.getPath();
+ }
+ else
+ {
+ path = getModulePath() + curForward.getPath();
+ }
+ }
}
+ return path;
}
/**
@@ -765,5 +773,25 @@
void setImplicitObject( HttpServletRequest request )
{
request.setAttribute( InternalConstants.PAGE_FLOW_IMPLICIT_OBJECT_NAME, this );
+ }
+
+ final void beforePage()
+ {
+ HttpServletRequest request = getRequest();
+ String relativeUri = PageFlowUtils.getRelativeURI( request, null );
+
+ //
+ // We may need to save the previous page info if the JSP was called directly
+ // and we do not yet have the forward path in the page flow or it is a different
+ // path.
+ //
+ String path = getCurrentForwardPath();
+ if ( ( path == null ) || ! path.equals( relativeUri ) )
+ {
+ ActionForward actionForward = new ActionForward( relativeUri );
+ actionForward.setContextRelative( true );
+ actionForward.setRedirect( false );
+ savePreviousPageInfo( actionForward, null, null, request, getServletContext(), false );
+ }
}
}
Modified: incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowJspFilter.java
==============================================================================
--- incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowJspFilter.java (original)
+++ incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowJspFilter.java Tue Aug 31 15:25:40 2004
@@ -201,6 +201,13 @@
new FlowController.PerRequestState( httpRequest, httpResponse, null );
FlowController.PerRequestState prevState = curJpf.setPerRequestState( newState );
setImplicitObjects( httpRequest, httpResponse, curJpf );
+
+ //
+ // tell the page flow that we're about to display a JSP so it can
+ // manage settings, such as previous page information, if needed
+ // in advance.
+ //
+ curJpf.beforePage();
try
{
Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/returnTo/returnToCurrentJsp/ReturnToCurrentJspController.jpf
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/returnTo/returnToCurrentJsp/ReturnToCurrentJspController.jpf Tue Aug 31 15:25:40 2004
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package returnTo.returnToCurrentJsp;
+
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+@Jpf.Controller
+public class ReturnToCurrentJspController extends PageFlowController
+{
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(name="current", path="current.jsp")
+ }
+ )
+ protected Forward begin()
+ {
+ return new Forward("current");
+ }
+
+
+ @Jpf.Action(forwards = {
+ @Jpf.Forward(name = "currentPage",
+ navigateTo = Jpf.NavigateTo.currentPage)
+ })
+ protected Forward returnToPage()
+ {
+ Forward forward = new Forward("currentPage");
+ return forward;
+ }
+
+
+ @Jpf.Action(forwards = {
+ @Jpf.Forward(name = "success",
+ path = "current.jsp")
+ })
+ protected Forward forwardToSamePage()
+ {
+ Forward forward = new Forward("success");
+ return forward;
+ }
+}
+
Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/returnTo/returnToCurrentJsp/current.jsp
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/returnTo/returnToCurrentJsp/current.jsp Tue Aug 31 15:25:40 2004
@@ -0,0 +1,31 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
+
+
+<netui:html>
+ <head>
+ <netui:base/>
+ <title>Return-To Current JSP</title>
+ </head>
+ <netui:body>
+ <h3 align="center">Return-To Current JSP</h3>
+ <p>Allows a hit to a .JSP page directly, without going through the
+ controller first, then hit an action that has a return-to:current
+ page.</p>
+ <hr width="95%"/>
+ <br/>
+ <h3><font color="blue">
+ Instructions:
+ </font></h3>
+ <p>
+ Start the test by going directly to this JSP first without
+ going to the page flow.
+ <br/><br/>
+ First, to test a "return-to" this page, select Continue:
+ <netui:anchor action="returnToPage">Continue...</netui:anchor>
+ <br/><br/>Then, to test a "Forward" to this page, select Again:
+ <netui:anchor action="forwardToSamePage">Again...</netui:anchor><br>
+ </netui:body>
+</netui:html>
+
+
Modified: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Tue Aug 31 15:25:40 2004
@@ -3851,6 +3851,19 @@
</features>
</test>
<test>
+ <name>ReturnToCurrentPage</name>
+ <description>Allows a hit to a .JSP page directly, without going through the controller first, then hit an action that has a return-to:current page</description>
+ <webapp>coreWeb</webapp>
+ <categories>
+ <category>bvt</category>
+ <category>corePageFlow</category>
+ </categories>
+ <features>
+ <feature>PageFlow</feature>
+ <feature>Return-to</feature>
+ </features>
+ </test>
+ <test>
<name>ReturnToExceptions</name>
<description>Tests exceptions (NoPreviousPageException, NoPreviousActionException) caused by return-to="*".</description>
<webapp>coreWeb</webapp>
Added: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/ReturnToCurrentPage.xml
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/ReturnToCurrentPage.xml Tue Aug 31 15:25:40 2004
@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ses:recorderSession xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session">
+ <ses:sessionName>ReturnToCurrentPage</ses:sessionName>
+ <ses:tester>crogers</ses:tester>
+ <ses:startDate>31 Aug 2004, 01:02:34.110 PM MDT</ses:startDate>
+ <ses:description>Allows a hit to a .JSP page directly, without going through the controller first, then hit an action that has a return-to:current page.</ses:description>
+ <ses:tests>
+ <ses:test>
+ <ses:testNumber>1</ses:testNumber>
+ <ses:request>
+ <ses:protocol>HTTP</ses:protocol>
+ <ses:protocolVersion>1.1</ses:protocolVersion>
+ <ses:host>localhost</ses:host>
+ <ses:port>8080</ses:port>
+ <ses:uri>/coreWeb/returnTo/returnToCurrentJsp/current.jsp</ses:uri>
+ <ses:method>GET</ses:method>
+ <ses:parameters/>
+ <ses:cookies>
+ <ses:cookie>
+ <ses:name>JSESSIONID</ses:name>
+ <ses:value>4D5D0162753C1B879FD76F604B0798FF</ses:value>
+ </ses:cookie>
+ </ses:cookies>
+ <ses:headers>
+ <ses:header>
+ <ses:name>accept</ses:name>
+ <ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-charset</ses:name>
+ <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-encoding</ses:name>
+ <ses:value>gzip,deflate</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-language</ses:name>
+ <ses:value>en-us,en;q=0.5</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>connection</ses:name>
+ <ses:value>keep-alive</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>cookie</ses:name>
+ <ses:value>JSESSIONID=4D5D0162753C1B879FD76F604B0798FF</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>host</ses:name>
+ <ses:value>localhost:8080</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>keep-alive</ses:name>
+ <ses:value>300</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>user-agent</ses:name>
+ <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3</ses:value>
+ </ses:header>
+ </ses:headers>
+ </ses:request>
+ <ses:response>
+ <ses:statusCode>200</ses:statusCode>
+ <ses:reason/>
+ <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+ <base href="http://localhost:8080/coreWeb/returnTo/returnToCurrentJsp/current.jsp">
+ <title>Return-To Current JSP</title>
+ </head>
+ <body>
+ <h3 align="center">Return-To Current JSP</h3>
+ <p>Allows a hit to a .JSP page directly, without going through the
+ controller first, then hit an action that has a return-to:current
+ page.</p>
+ <hr width="95%"/>
+ <br/>
+ <h3><font color="blue">
+ Instructions:
+ </font></h3>
+ <p>
+ Start the test by going directly to this JSP first without
+ going to the page flow.
+ <br/><br/>
+ First, to test a "return-to" this page, select Continue:
+ <a href="/coreWeb/returnTo/returnToCurrentJsp/returnToPage.do">Continue...</a>
+ <br/><br/>Then, to test a "Forward" to this page, select Again:
+ <a href="/coreWeb/returnTo/returnToCurrentJsp/forwardToSamePage.do">Again...</a><br>
+ </body>
+</html>]]></ses:responseBody>
+ </ses:response>
+ </ses:test>
+ <ses:test>
+ <ses:testNumber>2</ses:testNumber>
+ <ses:request>
+ <ses:protocol>HTTP</ses:protocol>
+ <ses:protocolVersion>1.1</ses:protocolVersion>
+ <ses:host>localhost</ses:host>
+ <ses:port>8080</ses:port>
+ <ses:uri>/coreWeb/returnTo/returnToCurrentJsp/returnToPage.do</ses:uri>
+ <ses:method>GET</ses:method>
+ <ses:parameters/>
+ <ses:cookies>
+ <ses:cookie>
+ <ses:name>JSESSIONID</ses:name>
+ <ses:value>4D5D0162753C1B879FD76F604B0798FF</ses:value>
+ </ses:cookie>
+ </ses:cookies>
+ <ses:headers>
+ <ses:header>
+ <ses:name>accept</ses:name>
+ <ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-charset</ses:name>
+ <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-encoding</ses:name>
+ <ses:value>gzip,deflate</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-language</ses:name>
+ <ses:value>en-us,en;q=0.5</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>connection</ses:name>
+ <ses:value>keep-alive</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>cookie</ses:name>
+ <ses:value>JSESSIONID=4D5D0162753C1B879FD76F604B0798FF</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>host</ses:name>
+ <ses:value>localhost:8080</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>keep-alive</ses:name>
+ <ses:value>300</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>referer</ses:name>
+ <ses:value>http://localhost:8080/coreWeb/returnTo/returnToCurrentJsp/current.jsp</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>user-agent</ses:name>
+ <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3</ses:value>
+ </ses:header>
+ </ses:headers>
+ </ses:request>
+ <ses:response>
+ <ses:statusCode>200</ses:statusCode>
+ <ses:reason/>
+ <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+ <base href="http://localhost:8080/coreWeb/returnTo/returnToCurrentJsp/current.jsp">
+ <title>Return-To Current JSP</title>
+ </head>
+ <body>
+ <h3 align="center">Return-To Current JSP</h3>
+ <p>Allows a hit to a .JSP page directly, without going through the
+ controller first, then hit an action that has a return-to:current
+ page.</p>
+ <hr width="95%"/>
+ <br/>
+ <h3><font color="blue">
+ Instructions:
+ </font></h3>
+ <p>
+ Start the test by going directly to this JSP first without
+ going to the page flow.
+ <br/><br/>
+ First, to test a "return-to" this page, select Continue:
+ <a href="/coreWeb/returnTo/returnToCurrentJsp/returnToPage.do">Continue...</a>
+ <br/><br/>Then, to test a "Forward" to this page, select Again:
+ <a href="/coreWeb/returnTo/returnToCurrentJsp/forwardToSamePage.do">Again...</a><br>
+ </body>
+</html>]]></ses:responseBody>
+ </ses:response>
+ </ses:test>
+ <ses:test>
+ <ses:testNumber>3</ses:testNumber>
+ <ses:request>
+ <ses:protocol>HTTP</ses:protocol>
+ <ses:protocolVersion>1.1</ses:protocolVersion>
+ <ses:host>localhost</ses:host>
+ <ses:port>8080</ses:port>
+ <ses:uri>/coreWeb/returnTo/returnToCurrentJsp/forwardToSamePage.do</ses:uri>
+ <ses:method>GET</ses:method>
+ <ses:parameters/>
+ <ses:cookies>
+ <ses:cookie>
+ <ses:name>JSESSIONID</ses:name>
+ <ses:value>4D5D0162753C1B879FD76F604B0798FF</ses:value>
+ </ses:cookie>
+ </ses:cookies>
+ <ses:headers>
+ <ses:header>
+ <ses:name>accept</ses:name>
+ <ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-charset</ses:name>
+ <ses:value>ISO-8859-1,utf-8;q=0.7,*;q=0.7</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-encoding</ses:name>
+ <ses:value>gzip,deflate</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-language</ses:name>
+ <ses:value>en-us,en;q=0.5</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>connection</ses:name>
+ <ses:value>keep-alive</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>cookie</ses:name>
+ <ses:value>JSESSIONID=4D5D0162753C1B879FD76F604B0798FF</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>host</ses:name>
+ <ses:value>localhost:8080</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>keep-alive</ses:name>
+ <ses:value>300</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>referer</ses:name>
+ <ses:value>http://localhost:8080/coreWeb/returnTo/returnToCurrentJsp/returnToPage.do</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>user-agent</ses:name>
+ <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3</ses:value>
+ </ses:header>
+ </ses:headers>
+ </ses:request>
+ <ses:response>
+ <ses:statusCode>200</ses:statusCode>
+ <ses:reason/>
+ <ses:responseBody><![CDATA[<!DOCTYPE HTML PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+ <base href="http://localhost:8080/coreWeb/returnTo/returnToCurrentJsp/current.jsp">
+ <title>Return-To Current JSP</title>
+ </head>
+ <body>
+ <h3 align="center">Return-To Current JSP</h3>
+ <p>Allows a hit to a .JSP page directly, without going through the
+ controller first, then hit an action that has a return-to:current
+ page.</p>
+ <hr width="95%"/>
+ <br/>
+ <h3><font color="blue">
+ Instructions:
+ </font></h3>
+ <p>
+ Start the test by going directly to this JSP first without
+ going to the page flow.
+ <br/><br/>
+ First, to test a "return-to" this page, select Continue:
+ <a href="/coreWeb/returnTo/returnToCurrentJsp/returnToPage.do">Continue...</a>
+ <br/><br/>Then, to test a "Forward" to this page, select Again:
+ <a href="/coreWeb/returnTo/returnToCurrentJsp/forwardToSamePage.do">Again...</a><br>
+ </body>
+</html>]]></ses:responseBody>
+ </ses:response>
+ </ses:test>
+ </ses:tests>
+ <ses:endDate>31 Aug 2004, 01:03:02.073 PM MDT</ses:endDate>
+ <ses:testCount>3</ses:testCount>
+</ses:recorderSession>