Index: jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
===================================================================
--- jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java	(revision 578013)
+++ jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java	(working copy)
@@ -956,6 +956,7 @@
 			{
 				throw new WicketRuntimeException("Error creating page for modal dialog.");
 			}
+			RequestCycle.get().setUrlForNewWindowEncoding();
 			buffer.append("settings.src=\"" + RequestCycle.get().urlFor(page) + "\";\n");
 
 			if (getPageMapName() != null)
Index: jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult-1.html
===================================================================
--- jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult-1.html	(revision 578013)
+++ jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult-1.html	(working copy)
@@ -5,4 +5,4 @@
 /*-->]^]^>*/</script>
 
 <script type="text/javascript" src="resources/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax-debug.js"></script>
-</head>]]></header-contribution><component id="linja11" ><![CDATA[<span wicket:id="linja1" id="linja11">1</span>]]></component><evaluate><![CDATA[setTimeout("var wcall=wicketAjaxGet('?wicket:interface=:0:testPanel:baseSpan:linja1::IBehaviorListener:0:&amp;wicket:ignoreIfNotActive=true',null,null, function() {var c = Wicket.$('linja11'); return typeof(c) != 'undefined' && c != null}.bind(this));", 2000);]]></evaluate></ajax-response>
\ No newline at end of file
+</head>]]></header-contribution><component id="linja11" ><![CDATA[<span wicket:id="linja1" id="linja11">1</span>]]></component><evaluate><![CDATA[setTimeout("var wcall=wicketAjaxGet('?wicket:interface=:0:testPanel:baseSpan:linja1::IActivePageBehaviorListener:0:&amp;wicket:ignoreIfNotActive=true',null,null, function() {var c = Wicket.$('linja11'); return typeof(c) != 'undefined' && c != null}.bind(this));", 2000);]]></evaluate></ajax-response>
\ No newline at end of file
Index: jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult.html
===================================================================
--- jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult.html	(revision 578013)
+++ jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult.html	(working copy)
@@ -9,7 +9,7 @@
 
 <script type="text/javascript" src="resources/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax-debug.js"></script>
 <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
-Wicket.Event.add(window, "load", function() { setTimeout("var wcall=wicketAjaxGet('?wicket:interface=:0:testPanel:baseSpan:linja1::IBehaviorListener:0:&amp;wicket:ignoreIfNotActive=true',null,null, function() {var c = Wicket.$('linja11'); return typeof(c) != 'undefined' && c != null}.bind(this));", 2000);;});
+Wicket.Event.add(window, "load", function() { setTimeout("var wcall=wicketAjaxGet('?wicket:interface=:0:testPanel:baseSpan:linja1::IActivePageBehaviorListener:0:&amp;wicket:ignoreIfNotActive=true',null,null, function() {var c = Wicket.$('linja11'); return typeof(c) != 'undefined' && c != null}.bind(this));", 2000);;});
 /*-->]]>*/</script>
 
 </head>
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java	(working copy)
@@ -24,6 +24,7 @@
 
 import org.apache.wicket.Application;
 import org.apache.wicket.IRedirectListener;
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.RequestListenerInterface;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.protocol.http.RequestUtils;
@@ -151,6 +152,11 @@
 			return relativePathPrefixToContextRoot;
 		}
 
+		if (RequestContext.get().isPortletRequest())
+		{
+			return relativePathPrefixToContextRoot = getHttpServletRequest().getContextPath()+"/";
+		}
+		
 		// Prepend to get back to the wicket handler.
 		String tmp = getRelativePathPrefixToWicketHandler();
 		PrependingStringBuffer prepender = new PrependingStringBuffer(tmp);
@@ -220,11 +226,13 @@
 			return relativePathPrefixToWicketHandler;
 		}
 
+		boolean portletRequest = RequestContext.get().isPortletRequest();
+		
 		PrependingStringBuffer prepender = new PrependingStringBuffer();
 
 		// For AJAX requests, we need to make the URLs relative to the
 		// original page.
-		if (isAjax())
+		if (!portletRequest && isAjax())
 		{
 			for (int i = 0; i < getRequestParameters().getUrlDepth(); i++)
 			{
@@ -292,9 +300,11 @@
 			relativeUrl = wicketRedirectUrl;
 		}
 
+		int lastPathPos = -1;
 		if (depthRelativeToWicketHandler == -1)
 		{
 			int depth = 0;
+			int ajaxUrlDepth = isAjax() ? getRequestParameters().getUrlDepth() : -1;
 			for (int i = 0; i < relativeUrl.length(); i++)
 			{
 				if (relativeUrl.charAt(i) == '?')
@@ -304,15 +314,29 @@
 				if (relativeUrl.charAt(i) == '/')
 				{
 					depth++;
+					lastPathPos = i;
+					if (depth == ajaxUrlDepth)
+					{
+						return relativeUrl.substring(0,lastPathPos+1);
+					}
 				}
 			}
 			depthRelativeToWicketHandler = depth;
 		}
 
-		for (int i = 0; i < depthRelativeToWicketHandler; i++)
+		if (portletRequest)
 		{
-			prepender.prepend("../");
+			prepender.prepend("/");
+			prepender.prepend(getHttpServletRequest().getServletPath());
+			prepender.prepend(getHttpServletRequest().getContextPath());
 		}
+		else
+		{
+			for (int i = 0; i < depthRelativeToWicketHandler; i++)
+			{
+				prepender.prepend("../");
+			}
+		}
 
 		return relativePathPrefixToWicketHandler = prepender.toString();
 	}
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java	(revision 0)
@@ -0,0 +1,537 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.PortletResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.portals.bridges.common.PortletResourceURLFactory;
+import org.apache.portals.bridges.common.ServletContextProvider;
+
+/**
+ * @author Ate Douma
+ */
+public class WicketPortlet extends GenericPortlet
+{
+	public static final String WICKET_URL_PORTLET_PARAMETER = "_wu";
+	public static final String PORTLET_RESOURCE_URL_PARAMETER = "_ru";
+	public static final String PORTLET_RESOURCE_URL_ATTR = "_ru";
+	public static final String WICKET_FILTER_PATH_PARAM = "wicketFilterPath";
+	public static final String PARAM_SERVLET_CONTEXT_PROVIDER = "ServletContextProvider";
+	public static final String PARAM_PORTLET_RESOURCE_URL_FACTORY = "PortletResourceURLFactory";
+	public static final String ACTION_REQUEST = "ACTION";
+	public static final String VIEW_REQUEST = "VIEW";
+	public static final String RESOURCE_REQUEST = "RESOURCE";
+	public static final String CUSTOM_REQUEST = "CUSTOM";
+	public static final String EDIT_REQUEST = "EDIT";
+	public static final String HELP_REQUEST = "HELP";
+	public static final String REQUEST_TYPE_ATTR = WicketPortlet.class.getName() + ".REQUEST_TYPE";
+	public static final String WICKET_URL_PORTLET_PARAMETER_ATTR = WicketPortlet.class.getName() + ".WICKET_URL_PORTLET_PARAMETER";
+	public static final String CONFIG_PARAM_PREFIX = WicketPortlet.class.getName() + ".";
+	public static final String RESPONSE_STATE_ATTR = WicketResponseState.class.getName();
+	public static final String RESOURCE_URL_FACTORY_ATTR = PortletResourceURLFactory.class.getName();
+	public static final String WICKET_PORTLET_PROPERTIES = WicketPortlet.class.getName().replace('.', '/')+".properties";
+	public static final String WICKET_FILTER_PATH = WicketPortlet.class.getName() + ".FILTERPATH";
+	public static final String WICKET_FILTER_QUERY = WicketPortlet.class.getName() + ".FILTERQUERY";
+	
+    /**
+     * Name of portlet init parameter for Action page
+     */
+    public static final String PARAM_ACTION_PAGE = "actionPage";
+    /**
+     * Name of portlet  init parameterfor Custom page
+     */
+    public static final String PARAM_CUSTOM_PAGE = "customPage";
+    /**
+     * Name of portlet  init parameterfor Edit page
+     */
+    public static final String PARAM_EDIT_PAGE = "editPage";
+    /**
+     * Name of portlet  init parameter for Edit page
+     */
+    public static final String PARAM_HELP_PAGE = "helpPage";
+    /**
+     * Name of portlet  init parameter for View page
+     */
+    public static final String PARAM_VIEW_PAGE = "viewPage";
+
+	private ServletContextProvider servletContextProvider;
+	private PortletResourceURLFactory resourceURLFactory;
+	private String wicketFilterPath;
+	private String wicketFilterQuery;
+	private HashMap defaultPages = new HashMap();
+
+	public void init(PortletConfig config) throws PortletException
+	{
+		super.init(config);
+		Properties wicketPortletProperties = null;
+		String contextProviderClassName = getContextProviderClassNameParameter(config);
+		if (contextProviderClassName == null)
+		{
+			contextProviderClassName = config.getPortletContext().getInitParameter(
+					ServletContextProvider.class.getName());
+		}
+		if (contextProviderClassName == null)
+		{
+			wicketPortletProperties = getWicketPortletProperties(wicketPortletProperties);
+			contextProviderClassName = wicketPortletProperties.getProperty(ServletContextProvider.class.getName());
+		}
+		if (contextProviderClassName == null)
+		{
+			throw new PortletException("Portlet " + config.getPortletName()
+					+ " is incorrectly configured. Init parameter "
+					+ PARAM_SERVLET_CONTEXT_PROVIDER + " not specified, nor as context parameter "
+					+ ServletContextProvider.class.getName() + " or as property in "+WICKET_PORTLET_PROPERTIES + " in the classpath.");
+		}
+		try
+		{
+			Class clazz = Class.forName(contextProviderClassName);
+			servletContextProvider = (ServletContextProvider)clazz.newInstance();
+		}
+		catch (Exception e)
+		{
+			if (e instanceof PortletException)
+			{
+				throw (PortletException)e;
+			}
+			throw new PortletException("Initialization failure", e);
+		}
+		
+		String resourceURLFactoryClassName = getPortletResourceURLFactoryClassNameParameter(config);
+		if (resourceURLFactoryClassName == null)
+		{
+			resourceURLFactoryClassName = config.getPortletContext().getInitParameter(
+					PortletResourceURLFactory.class.getName());
+		}
+		if (resourceURLFactoryClassName == null)
+		{
+			wicketPortletProperties = getWicketPortletProperties(wicketPortletProperties);
+			resourceURLFactoryClassName = wicketPortletProperties.getProperty(PortletResourceURLFactory.class.getName());
+		}
+		if (resourceURLFactoryClassName == null)
+		{
+			throw new PortletException("Portlet " + config.getPortletName()
+					+ " is incorrectly configured. Init parameter "
+					+ PARAM_PORTLET_RESOURCE_URL_FACTORY + " not specified, nor as context parameter "
+					+ PortletResourceURLFactory.class.getName() + " or as property in "+WICKET_PORTLET_PROPERTIES + " in the classpath.");
+		}
+		try
+		{
+			Class clazz = Class.forName(resourceURLFactoryClassName);
+			resourceURLFactory = (PortletResourceURLFactory)clazz.newInstance();
+		}
+		catch (Exception e)
+		{
+			if (e instanceof PortletException)
+			{
+				throw (PortletException)e;
+			}
+			throw new PortletException("Initialization failure", e);
+		}
+		
+		wicketFilterPath = buildWicketFilterPath(config.getInitParameter(WICKET_FILTER_PATH_PARAM));
+		wicketFilterQuery = buildWicketFilterQuery(wicketFilterPath);
+		
+		defaultPages.put(PARAM_VIEW_PAGE,config.getInitParameter(PARAM_VIEW_PAGE));
+		defaultPages.put(PARAM_ACTION_PAGE,config.getInitParameter(PARAM_ACTION_PAGE));
+		defaultPages.put(PARAM_CUSTOM_PAGE,config.getInitParameter(PARAM_CUSTOM_PAGE));
+		defaultPages.put(PARAM_HELP_PAGE,config.getInitParameter(PARAM_HELP_PAGE));
+		defaultPages.put(PARAM_EDIT_PAGE,config.getInitParameter(PARAM_EDIT_PAGE));
+        
+		validateDefaultPages(defaultPages, wicketFilterPath, wicketFilterQuery);
+	}
+	
+	public void destroy()
+	{
+		resourceURLFactory = null;
+		servletContextProvider = null;
+		super.destroy();
+	}
+	
+	protected String getDefaultPage(String pageType)
+	{
+		return (String)defaultPages.get(pageType);
+	}
+	
+	protected String buildWicketFilterPath(String filterPath)
+	{
+		if (filterPath == null || filterPath.length() == 0)
+		{
+			filterPath = "/";
+		}
+		else
+		{
+			if (!filterPath.startsWith("/"))
+			{
+				filterPath = "/" + filterPath;
+			}
+			if (filterPath.endsWith("*"))
+			{
+				filterPath = filterPath.substring(0, filterPath.length() - 1);
+			}
+			if (!filterPath.endsWith("/"))
+			{
+				filterPath += "/";
+			}
+		}
+		return filterPath;
+	}
+	
+	protected String buildWicketFilterQuery(String wicketFilterPath)
+	{
+		if (wicketFilterPath.equals("/"))
+		{
+			return "?";
+		}
+		else
+		{
+			return wicketFilterPath.substring(0,wicketFilterPath.length()-1)+"?";
+		}
+	}
+	
+	protected String fixWicketUrl(String url, String wicketFilterPath, String wicketFilterQuery)
+	{
+		if (url == null)
+		{
+			return wicketFilterPath;
+		}
+		else if (!url.startsWith(wicketFilterPath))
+		{
+			if ((url+"/").equals(wicketFilterPath))
+			{
+				// hack around "old" style wicket home url's without trailing '/' which would lead to a redirect to the real home path anyway
+				url = wicketFilterPath;
+			}
+			else if (url.startsWith(wicketFilterQuery))
+			{
+				// correct url: path?query -> path/?query
+				url = wicketFilterPath + "?" + url.substring(wicketFilterQuery.length());
+			}
+		}			
+		return url;
+	}
+	
+	protected void validateDefaultPages(Map defaultPages, String wicketFilterPath, String wicketFilterQuery)
+	{
+		String viewPage = fixWicketUrl((String)defaultPages.get(PARAM_VIEW_PAGE), wicketFilterPath, wicketFilterQuery);
+		defaultPages.put(PARAM_VIEW_PAGE, viewPage.startsWith(wicketFilterPath) ? viewPage : wicketFilterPath);
+
+		String defaultPage = (String)defaultPages.get(PARAM_ACTION_PAGE);
+		if (defaultPage == null)
+		{
+			defaultPages.put(PARAM_ACTION_PAGE, viewPage);
+		}
+		else
+		{
+			defaultPage = fixWicketUrl(defaultPage, wicketFilterPath, wicketFilterQuery);
+			defaultPages.put(PARAM_ACTION_PAGE, defaultPage.startsWith(wicketFilterPath) ? defaultPage : viewPage);
+		}
+		
+		defaultPage = (String)defaultPages.get(PARAM_CUSTOM_PAGE);
+		if (defaultPage == null)
+		{
+			defaultPages.put(PARAM_CUSTOM_PAGE, viewPage);
+		}
+		else
+		{
+			defaultPage = fixWicketUrl(defaultPage, wicketFilterPath, wicketFilterQuery);
+			defaultPages.put(PARAM_CUSTOM_PAGE, defaultPage.startsWith(wicketFilterPath) ? defaultPage : viewPage);
+		}
+		
+		defaultPage = (String)defaultPages.get(PARAM_HELP_PAGE);
+		if (defaultPage == null)
+		{
+			defaultPages.put(PARAM_HELP_PAGE, viewPage);
+		}
+		else
+		{
+			defaultPage = fixWicketUrl(defaultPage, wicketFilterPath, wicketFilterQuery);
+			defaultPages.put(PARAM_HELP_PAGE, defaultPage.startsWith(wicketFilterPath) ? defaultPage : viewPage);
+		}
+
+		defaultPage = (String)defaultPages.get(PARAM_EDIT_PAGE);
+		if (defaultPage == null)
+		{
+			defaultPages.put(PARAM_EDIT_PAGE, viewPage);
+		}
+		else
+		{
+			defaultPage = fixWicketUrl(defaultPage, wicketFilterPath, wicketFilterQuery);
+			defaultPages.put(PARAM_EDIT_PAGE, defaultPage.startsWith(wicketFilterPath) ? defaultPage : viewPage);
+		}		
+	}
+
+	protected Properties getWicketPortletProperties(Properties properties) throws PortletException
+	{
+		if (properties == null)
+		{
+			properties = new Properties();
+		}
+		InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(WICKET_PORTLET_PROPERTIES);
+		if (is != null)
+		{
+			try
+			{
+				properties.load(is);
+			}
+			catch (IOException e)
+			{
+				throw new PortletException("Failed to load WicketPortlet.properties from classpath", e);
+			}
+		}
+		return properties;
+	}
+	
+	protected String getContextProviderClassNameParameter(PortletConfig config)
+	{
+		return config.getInitParameter(PARAM_SERVLET_CONTEXT_PROVIDER);
+	}
+
+	protected String getPortletResourceURLFactoryClassNameParameter(PortletConfig config)
+	{
+		return config.getInitParameter(PARAM_PORTLET_RESOURCE_URL_FACTORY);
+	}
+
+	protected ServletContextProvider getServletContextProvider()
+	{
+		return servletContextProvider;
+	}
+
+	protected ServletContext getServletContext(GenericPortlet portlet, PortletRequest request,
+			PortletResponse response)
+	{
+		return getServletContextProvider().getServletContext(portlet);
+	}
+
+	protected HttpServletRequest getHttpServletRequest(GenericPortlet portlet,
+			PortletRequest request, PortletResponse response)
+	{
+		return getServletContextProvider().getHttpServletRequest(portlet, request);
+	}
+
+	protected HttpServletResponse getHttpServletResponse(GenericPortlet portlet,
+			PortletRequest request, PortletResponse response)
+	{
+		return getServletContextProvider().getHttpServletResponse(portlet, response);
+	}
+	
+	protected String getWicketConfigParameter(PortletRequest request, String paramName, String defaultValue)
+	{
+		return defaultValue;
+	}
+	
+	protected String getWicketUrlPortletParameter(PortletRequest request)
+	{
+		return WICKET_URL_PORTLET_PARAMETER;
+	}
+	
+	protected String getWicketFilterPath()
+	{
+		return wicketFilterPath;
+	}
+	
+	protected String getWicketURL(PortletRequest request, String pageType, String defaultPage)
+	{
+		String wicketURL = null;
+		if (request instanceof ActionRequest)
+		{
+			wicketURL = request.getParameter((String)request.getAttribute(WicketPortlet.WICKET_URL_PORTLET_PARAMETER_ATTR));
+		}
+		else
+		{
+			wicketURL = request.getParameter((String)request.getAttribute(WicketPortlet.WICKET_URL_PORTLET_PARAMETER_ATTR)+request.getPortletMode().toString());
+		}
+        if (wicketURL == null)
+        {
+        	wicketURL = getWicketConfigParameter(request, CONFIG_PARAM_PREFIX+pageType, defaultPage);
+        }
+        return wicketURL;
+	}
+
+	protected void doView(RenderRequest request, RenderResponse response) throws PortletException,
+			IOException
+	{
+		processRequest(request, response, VIEW_REQUEST, PARAM_VIEW_PAGE);
+	}
+
+	protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException,
+			IOException
+	{
+		processRequest(request, response, EDIT_REQUEST, PARAM_EDIT_PAGE);
+	}
+
+	protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException,
+			IOException
+	{
+		processRequest(request, response, HELP_REQUEST, PARAM_HELP_PAGE);
+	}
+
+	protected void doCustom(RenderRequest request, RenderResponse response) throws PortletException,
+			IOException
+	{
+		processRequest(request, response, CUSTOM_REQUEST, PARAM_CUSTOM_PAGE);
+	}
+
+	public void processAction(ActionRequest request, ActionResponse response)
+			throws PortletException, IOException
+	{
+		processRequest(request, response, ACTION_REQUEST, PARAM_ACTION_PAGE);
+	}
+
+	protected void processRequest(PortletRequest request, PortletResponse response,
+			String requestType, String pageType) throws PortletException, IOException
+	{
+		String wicketURL = null;
+		String wicketFilterPath = null;
+		String wicketFilterQuery = null;
+		
+		request.setAttribute(WICKET_URL_PORTLET_PARAMETER_ATTR, getWicketUrlPortletParameter(request));
+		
+		wicketURL = getWicketURL(request, pageType, getDefaultPage(pageType));
+		wicketFilterPath = getWicketConfigParameter(request, WICKET_FILTER_PATH, this.wicketFilterPath);			
+		wicketFilterQuery = getWicketConfigParameter(request, WICKET_FILTER_QUERY, this.wicketFilterQuery);
+		
+		boolean actionRequest = ACTION_REQUEST.equals(requestType);
+		
+		WicketResponseState responseState = new WicketResponseState();
+
+		request.setAttribute(RESPONSE_STATE_ATTR, responseState);
+		request.setAttribute(RESOURCE_URL_FACTORY_ATTR, resourceURLFactory);
+		request.setAttribute(REQUEST_TYPE_ATTR, requestType);
+		String portletResourceURL = request.getParameter(PORTLET_RESOURCE_URL_PARAMETER);
+		if (portletResourceURL != null)
+		{
+			request.setAttribute(PORTLET_RESOURCE_URL_ATTR,portletResourceURL);
+		}
+
+		if (actionRequest)
+		{
+			ServletContext servletContext = getServletContext(this, request, response);
+			HttpServletRequest req = getHttpServletRequest(this, request, response);
+			HttpServletResponse res = getHttpServletResponse(this, request, response);
+			RequestDispatcher rd = servletContext.getRequestDispatcher(wicketURL);
+
+			if (rd != null)
+			{
+				// http://issues.apache.org/jira/browse/PB-2:
+				// provide servlet access to the Portlet components even from
+				// an actionRequest in extension to the JSR-168 requirement
+				// PLT.16.3.2 which (currently) only covers renderRequest
+				// servlet inclusion.
+				if (req.getAttribute("javax.portlet.config") == null)
+				{
+					req.setAttribute("javax.portlet.config", getPortletConfig());
+				}
+				if (req.getAttribute("javax.portlet.request") == null)
+				{
+					req.setAttribute("javax.portlet.request", request);
+				}
+				if (req.getAttribute("javax.portlet.response") == null)
+				{
+					req.setAttribute("javax.portlet.response", response);
+				}
+				try
+				{
+					rd.include(req, res);
+					processActionResponseState(wicketURL, wicketFilterPath, wicketFilterQuery, (ActionRequest)request, (ActionResponse)response, responseState);
+				}
+				catch (ServletException e)
+				{
+					throw new PortletException(e);
+				}
+			}
+		}
+		else
+		{
+			PortletRequestDispatcher rd = null;
+			String previousURL = null;
+			while (true)
+			{
+				rd = getPortletContext().getRequestDispatcher(wicketURL);
+				if (rd != null)
+				{
+					rd.include((RenderRequest)request, (RenderResponse)response);
+					String redirectLocation = responseState.getRedirectLocation();
+					if (redirectLocation != null)
+					{
+						redirectLocation = fixWicketUrl(redirectLocation, wicketFilterPath, wicketFilterQuery);
+						boolean validWicketUrl = redirectLocation.startsWith(wicketFilterPath);
+						if (portletResourceURL != null)
+						{
+							if (validWicketUrl)
+							{
+								HashMap parameters = new HashMap(2);
+								parameters.put((String)request.getAttribute(WicketPortlet.WICKET_URL_PORTLET_PARAMETER_ATTR)+request.getPortletMode().toString(), new String[]{redirectLocation});
+								parameters.put(PORTLET_RESOURCE_URL_PARAMETER, new String[]{"true"});
+								redirectLocation = resourceURLFactory.createResourceURL(getPortletConfig(), (RenderRequest)request, (RenderResponse)response, parameters);
+							}
+							getHttpServletResponse(this, request, response).sendRedirect(redirectLocation);
+						}
+						else if (validWicketUrl && ((previousURL == null || previousURL != redirectLocation)))
+						{
+							previousURL = wicketURL;
+							wicketURL = redirectLocation;
+							((RenderResponse)response).reset();
+							responseState.reset();
+							continue;
+						}
+						else
+						{
+							// TODO: unhandled/unsupport RenderResponse redirect
+						}
+					}
+				}
+				break;
+			}
+		}
+	}
+	
+	protected void processActionResponseState(String wicketURL, String wicketFilterPath, String wicketFilterQuery, ActionRequest request, ActionResponse response, WicketResponseState responseState) throws PortletException, IOException
+	{
+		if ( responseState.getRedirectLocation() != null )
+		{
+			wicketURL = fixWicketUrl(responseState.getRedirectLocation(), wicketFilterPath, wicketFilterQuery);
+			if (wicketURL.startsWith(wicketFilterPath))
+			{
+				response.setRenderParameter((String)request.getAttribute(WicketPortlet.WICKET_URL_PORTLET_PARAMETER_ATTR)+request.getPortletMode().toString(), wicketURL);
+			}
+			else
+			{
+				response.sendRedirect(responseState.getRedirectLocation());
+			}
+		}
+	}
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/FilterRequestContext.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/FilterRequestContext.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/FilterRequestContext.java	(revision 0)
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public final class FilterRequestContext
+{
+	private HttpServletRequest request;
+	private HttpServletResponse response;
+
+	public FilterRequestContext(HttpServletRequest request, HttpServletResponse response)
+	{
+		this.request = request;
+		this.response = response;
+	}
+	
+	public HttpServletRequest getRequest()
+	{
+		return request;
+	}
+	public void setRequest(HttpServletRequest request)
+	{
+		this.request = request;
+	}
+	public HttpServletResponse getResponse()
+	{
+		return response;
+	}
+	public void setResponse(HttpServletResponse response)
+	{
+		this.response = response;
+	}
+}
\ No newline at end of file

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/FilterRequestContext.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletInvalidMarkupFilter.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletInvalidMarkupFilter.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletInvalidMarkupFilter.java	(revision 0)
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+import org.apache.wicket.IResponseFilter;
+import org.apache.wicket.RequestContext;
+import org.apache.wicket.util.string.AppendingStringBuffer;
+
+
+/**
+ * This filter removes html page top level markup elements like <html>, <head> and <body>.
+ * The filter is configured automatically by WicketFilter if it detects the application is (potentially) invoked as a Portlet.
+ * 
+ * @author Ate Douma
+ */
+public class PortletInvalidMarkupFilter implements IResponseFilter
+{
+	/**
+	 * @see org.apache.wicket.IResponseFilter#filter(AppendingStringBuffer)
+	 */
+	public AppendingStringBuffer filter(AppendingStringBuffer responseBuffer)
+	{
+		RequestContext rc = RequestContext.get();
+		if (rc.isPortletRequest() && ((PortletRequestContext)rc).isEmbedded())
+		{
+			deleteFragment(responseBuffer, "<?xml", "?>");
+			deleteFragment(responseBuffer, "<!DOCTYPE", ">");
+			deleteOpenTag(responseBuffer, "html");
+			deleteOpenTag(responseBuffer, "head");
+			deleteOpenTag(responseBuffer, "body");
+		}
+		
+		return responseBuffer;
+	}
+	
+	private void deleteFragment(AppendingStringBuffer responseBuffer, String prefix, String postfix)
+	{
+		int startIndex, endIndex;
+		if ((startIndex = responseBuffer.indexOf(prefix)) > -1) 
+		{
+			if ((endIndex = responseBuffer.indexOf(postfix, startIndex)) >-1)
+			{
+				responseBuffer.delete(startIndex, endIndex+postfix.length());
+			}				
+		}
+	}
+	
+	private void deleteOpenTag(AppendingStringBuffer responseBuffer, String tagName)
+	{
+		int startIndex, endIndex;
+		// find and remove opening tag
+		if ((startIndex = responseBuffer.indexOf("<"+tagName)) > -1) 
+		{
+			if ((endIndex = responseBuffer.indexOf(">", startIndex)) >-1)
+			{
+				responseBuffer.delete(startIndex, endIndex+1);
+			}
+			// remove closing tag
+			if ((startIndex = responseBuffer.indexOf("</"+tagName+">")) > -1) 
+			{
+				responseBuffer.delete(startIndex, startIndex+tagName.length()+3);
+			}
+		}
+	}
+}
\ No newline at end of file

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletInvalidMarkupFilter.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java	(revision 0)
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+/**
+ * @author Ate Douma
+ */
+public class WicketResponseState
+{
+	private int errorCode;
+	private String errorMessage;
+	private int statusCode;
+	private String redirectLocation;
+
+	/**
+	 * Gets errorCode.
+	 * @return errorCode
+	 */
+	public int getErrorCode()
+	{
+		return errorCode;
+	}
+
+	/**
+	 * Sets errorCode.
+	 * @param errorCode errorCode
+	 */
+	public void setErrorCode(int errorCode)
+	{
+		this.errorCode = errorCode;
+	}
+	
+	/**
+	 * Gets errorMessage.
+	 * @return errorMessage
+	 */
+	public String getErrorMessage()
+	{
+		return errorMessage;
+	}
+	
+	/**
+	 * Sets errorMessage.
+	 * @param errorMessage errorMessage
+	 */
+	public void setErrorMessage(String errorMessage)
+	{
+		this.errorMessage = errorMessage;
+	}
+	
+	/**
+	 * Gets redirectLocation.
+	 * @return redirectLocation
+	 */
+	public String getRedirectLocation()
+	{
+		return redirectLocation;
+	}
+	
+	/**
+	 * Sets redirectLocation.
+	 * @param redirectLocation redirectLocation
+	 */
+	public void setRedirectLocation(String redirectLocation)
+	{
+		this.redirectLocation = redirectLocation;
+	}
+	
+	/**
+	 * Gets statusCode.
+	 * @return statusCode
+	 */
+	public int getStatusCode()
+	{
+		return statusCode;
+	}
+	
+	/**
+	 * Sets statusCode.
+	 * @param statusCode statusCode
+	 */
+	public void setStatusCode(int statusCode)
+	{
+		this.statusCode = statusCode;
+	}
+	
+	public void reset()
+	{
+		errorCode = 0;
+		errorMessage = null;
+		statusCode = 0;
+		redirectLocation = null;
+	}
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java	(revision 0)
@@ -0,0 +1,275 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+import java.util.HashMap;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletURL;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.portals.bridges.common.PortletResourceURLFactory;
+import org.apache.portals.bridges.util.PortletWindowUtils;
+import org.apache.wicket.RequestContext;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.Response;
+import org.apache.wicket.markup.html.IHeaderResponse;
+import org.apache.wicket.protocol.http.WebRequest;
+import org.apache.wicket.protocol.http.WebResponse;
+import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
+
+/**
+ * @author Ate Douma
+ */
+public class PortletRequestContext extends RequestContext
+{
+	private final WicketFilterPortletContext filterContext;
+	private final PortletConfig portletConfig;
+	private final PortletRequest portletRequest;
+	private final PortletResponse portletResponse;
+	// needed for JSR-168 support which only allows PortletURLs to be created by RenderResponse, with JSR-286 PortletResponse can do that too
+	private final RenderResponse renderResponse;
+	private final PortletResourceURLFactory resourceURLFactory;
+	private final IHeaderResponse headerResponse;	
+	private String portletWindowId;
+	private String wicketUrlPortletParameter;
+	private final boolean ajax;
+	private final boolean embedded;
+	private final boolean resourceRequest;
+	private String[] lastEncodedUrl = new String[2];
+
+    public PortletRequestContext(WicketFilterPortletContext filterContext, ServletWebRequest request, WebResponse response)
+    {
+    	this.filterContext = filterContext;
+    	HttpServletRequest servletRequest = request.getHttpServletRequest();
+    	this.portletConfig = (PortletConfig)servletRequest.getAttribute("javax.portlet.config");
+    	this.portletRequest = (PortletRequest)servletRequest.getAttribute("javax.portlet.request");
+    	this.portletResponse = (PortletResponse)servletRequest.getAttribute("javax.portlet.response");
+		this.renderResponse = (portletResponse instanceof RenderResponse) ? (RenderResponse)portletResponse : null;
+       	this.resourceURLFactory = (PortletResourceURLFactory)portletRequest.getAttribute(WicketPortlet.RESOURCE_URL_FACTORY_ATTR);
+       	this.wicketUrlPortletParameter = (String)portletRequest.getAttribute(WicketPortlet.WICKET_URL_PORTLET_PARAMETER_ATTR);
+    	this.ajax = request.isAjax();
+    	this.resourceRequest = "true".equals(servletRequest.getAttribute(WicketPortlet.PORTLET_RESOURCE_URL_ATTR));
+    	this.embedded = !(ajax || resourceRequest);
+    	this.headerResponse =  embedded ? newPortletHeaderResponse(response) : null;
+    }
+    
+	protected IHeaderResponse newPortletHeaderResponse(Response response)
+	{
+		return new EmbeddedPortletHeaderResponse(response);
+	}
+
+    public String getLastEncodedPath()
+    {
+        if (lastEncodedUrl != null)
+        {
+            return lastEncodedUrl[1];
+        }
+        return null;
+    }
+    
+	public String getLastEncodedPath(String url)
+	{
+		if (url != null && lastEncodedUrl != null && url.equals(lastEncodedUrl[0]))
+		{
+			return lastEncodedUrl[1];
+		}
+		return null;
+	}
+	
+	protected String saveLastEncodedUrl(String url, String path)
+	{
+		lastEncodedUrl[0] = url;
+		lastEncodedUrl[1] = path;
+		return url;
+	}
+	
+	/**
+	 * @see org.apache.wicket.RequestContext#encodeActionURL(java.lang.CharSequence)
+	 */
+	public CharSequence encodeActionURL(CharSequence path)
+	{
+        return encodeActionURL(path, false);
+    }
+    
+    public CharSequence encodeActionURL(CharSequence path, boolean forceActionURL)
+    {
+        if ((!forceActionURL && resourceRequest) || RequestCycle.get().isUrlForNewWindowEncoding())
+		{
+			return encodeResourceURL(path);
+		}
+		if ( path != null )
+		{
+			path = getQualifiedPath(path);
+			if (renderResponse != null)
+			{
+				PortletURL url = renderResponse.createActionURL();
+				url.setParameter(wicketUrlPortletParameter, path.toString());
+				path = saveLastEncodedUrl(url.toString(), path.toString());
+			}
+		}
+		return path;
+	}
+
+	/**
+	 * @see org.apache.wicket.RequestContext#encodeMarkupId(java.lang.String)
+	 */
+	public String encodeMarkupId(String markupId)
+	{
+		if ( markupId != null )
+		{
+			markupId = getNamespace() + "_" + markupId;
+		}
+		return markupId;
+	}
+
+	/**
+	 * @see org.apache.wicket.RequestContext#encodeRenderURL(java.lang.CharSequence)
+	 */
+	public CharSequence encodeRenderURL(CharSequence path)
+	{
+        return encodeRenderURL(path, false);
+    }
+    
+    public CharSequence encodeRenderURL(CharSequence path, boolean forceRenderURL)
+    {
+        if ((!forceRenderURL && resourceRequest) || RequestCycle.get().isUrlForNewWindowEncoding())
+		{
+			return encodeResourceURL(path);
+		}
+		if ( path != null )
+		{			
+			path = getQualifiedPath(path);
+			if (renderResponse != null)
+			{
+				PortletURL url = renderResponse.createRenderURL();
+				url.setParameter(wicketUrlPortletParameter+portletRequest.getPortletMode().toString(), path.toString());
+				path = saveLastEncodedUrl(url.toString(), path.toString());
+				path = url.toString();
+			}
+		}
+		return path;
+	}
+
+	/**
+	 * @see org.apache.wicket.RequestContext#encodeResourceURL(java.lang.CharSequence)
+	 */
+	public CharSequence encodeResourceURL(CharSequence path)
+	{
+		if ( path != null )
+		{
+			path = getQualifiedPath(path);
+			if (renderResponse != null)
+			{
+				try
+				{
+					HashMap parameters = new HashMap(2);
+					parameters.put(wicketUrlPortletParameter+portletRequest.getPortletMode().toString(), new String[]{path.toString()});
+					parameters.put(WicketPortlet.PORTLET_RESOURCE_URL_PARAMETER, new String[]{"true"});
+					path = saveLastEncodedUrl(resourceURLFactory.createResourceURL(portletConfig, (RenderRequest)portletRequest, renderResponse, parameters), path.toString());
+				}
+				catch (PortletException e)
+				{
+					throw new RuntimeException(e);
+				}
+			}
+		}
+		return path;
+	}
+
+	/**
+	 * @see org.apache.wicket.RequestContext#encodeSharedResourceURL(java.lang.CharSequence)
+	 */
+	public CharSequence encodeSharedResourceURL(CharSequence path)
+	{
+		if ( path != null )
+		{
+			String url = filterContext.encodeWindowIdInPath(getPortletWindowId(), path);
+			return saveLastEncodedUrl(url,url);
+		}
+		return null;
+	}
+
+	/**
+	 * @see org.apache.wicket.RequestContext#getHeaderResponse()
+	 */
+	public IHeaderResponse getHeaderResponse()
+	{
+		return headerResponse;
+	}
+
+	/**
+	 * @see org.apache.wicket.RequestContext#getNamespace()
+	 */
+	public CharSequence getNamespace()
+	{
+		return renderResponse != null ? renderResponse.getNamespace() : "";
+	}
+	
+	/**
+	 * @see org.apache.wicket.RequestContext#isPortletRequest()
+	 */
+	public boolean isPortletRequest()
+	{
+		return true;
+	}
+	
+	public boolean isEmbedded()
+	{
+		return embedded;
+	}
+	
+	protected String getQualifiedPath(CharSequence path)
+	{		
+		HttpServletRequest request = ((WebRequest)RequestCycle.get().getRequest()).getHttpServletRequest();
+		return request.getServletPath() + "/" + path;
+	}
+	
+	protected String getPortletWindowId()
+	{
+		if (portletWindowId == null)
+		{
+	    	portletWindowId = PortletWindowUtils.getPortletWindowId(portletRequest.getPortletSession());
+		}
+		return portletWindowId;
+	}
+	
+	public PortletConfig getPortletConfig()
+	{
+		return portletConfig;
+	}
+
+	public PortletRequest getPortletRequest()
+	{
+		return portletRequest;
+	}
+
+	public PortletResponse getPortletResponse()
+	{
+		return portletResponse;
+	}
+
+	public boolean isAjax()
+	{
+		return ajax;
+	}
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java	(revision 0)
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author Ate Douma
+ */
+public class PortletServletRequestWrapper extends HttpServletRequestWrapper
+{
+    private ServletContext context;
+    private String contextPath;
+    private String servletPath;
+    private String pathInfo;
+    private String requestURI;
+    private String queryString;
+    private HttpSession session;
+    
+    private static String decodePathInfo(HttpServletRequest request, String filterPath)
+    {
+    	String pathInfo = request.getRequestURI().substring(request.getContextPath().length()+filterPath.length());
+    	return pathInfo == null || pathInfo.length() < 2 ? null : pathInfo;
+    }
+    
+    private static String makeServletPath(String filterPath)
+    {
+    	return "/"+filterPath.substring(0,filterPath.length()-1);
+    }
+    
+    protected PortletServletRequestWrapper(ServletContext context, HttpSession proxiedSession, HttpServletRequest request, String filterPath)
+    {
+    	super(request);
+        this.context = context;
+        this.session = proxiedSession;
+        if ( proxiedSession == null )
+        {
+            this.session = request.getSession(false);
+        }
+    	this.servletPath = makeServletPath(filterPath);
+        if ((this.contextPath = (String) request.getAttribute("javax.servlet.include.context_path")) != null)
+        {
+        	this.requestURI = (String) request.getAttribute("javax.servlet.include.request_uri");
+        	this.queryString = (String) request.getAttribute("javax.servlet.include.query_string");
+        }
+        else if ((this.contextPath = (String) request.getAttribute("javax.servlet.forward.context_path")) != null)
+        {
+        	this.requestURI = (String) request.getAttribute("javax.servlet.forward.request_uri");
+        	this.queryString = (String) request.getAttribute("javax.servlet.forward.query_string");
+        }
+        else
+        {
+        	this.contextPath = request.getContextPath();
+        	this.requestURI = request.getRequestURI();
+        	this.queryString = request.getQueryString();
+        }
+    }
+
+    public PortletServletRequestWrapper(ServletContext context, HttpServletRequest request, HttpSession proxiedSession, String filterPath)
+    {
+    	this(context, proxiedSession, request, filterPath);
+
+    	String pathInfo = this.requestURI.substring(this.contextPath.length()+filterPath.length());
+    	this.pathInfo = pathInfo == null || pathInfo.length() < 2 ? null : pathInfo;
+    }
+
+    public PortletServletRequestWrapper(ServletContext context, HttpServletRequest request, HttpSession proxiedSession, String filterPath, String pathInfo)
+    {
+    	this(context, proxiedSession, request, filterPath);
+
+    	this.pathInfo = pathInfo;
+    	// override requestURI
+        this.requestURI = this.contextPath+this.servletPath+(pathInfo!=null?pathInfo:"");
+    }
+    
+    public String getContextPath()
+    {
+    	return contextPath;
+    }
+    
+	public String getServletPath()
+    {
+        return servletPath;
+    }
+
+    public String getPathInfo()
+    {
+        return pathInfo;
+    }
+
+    public String getRequestURI()
+    {
+        return requestURI;
+    }
+    
+    public String getQueryString()
+    {
+    	return queryString;
+    }
+    
+    public HttpSession getSession()
+    {
+        return getSession(true);
+    }
+    
+    public HttpSession getSession(boolean create)
+    {
+        return session != null ? session : super.getSession(create);
+    }
+    
+    public Object getAttribute(String name)
+    {
+    	// TODO: check if these can possibly be set/handled
+    	// nullifying these for now to prevent Wicket ServletWebRequest.getRelativePathPrefixToWicketHandler() going the wrong route
+    	if ("javax.servlet.error.request_uri".equals(name) || "javax.servlet.forward.servlet_path".equals(name))
+    	{
+    		return null;
+    	}
+    	return super.getAttribute(name);
+    }
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/EmbeddedPortletHeaderResponse.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/EmbeddedPortletHeaderResponse.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/EmbeddedPortletHeaderResponse.java	(revision 0)
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.wicket.RequestContext;
+import org.apache.wicket.Response;
+import org.apache.wicket.markup.html.internal.HeaderResponse;
+import org.apache.wicket.response.StringResponse;
+
+/**
+ * @author Ate Douma
+ */
+public class EmbeddedPortletHeaderResponse extends HeaderResponse
+{
+	private Response realResponse;
+	private StringResponse bufferedResponse;
+	
+	public EmbeddedPortletHeaderResponse(Response realResponse)
+	{
+		this.realResponse = realResponse;
+		bufferedResponse = new StringResponse();
+	}
+
+	public void renderCSSReference(String url, String media)
+	{
+		if (!isClosed())
+		{
+			List token = Arrays.asList(new Object[] { "css", url, media });
+			if (wasRendered(token) == false)
+			{
+				getResponse().write("<script type=\"text/javascript\">");
+				getResponse().write("var elem=document.createElement(\"link\");");
+				getResponse().write("elem.setAttribute(\"rel\",\"stylesheet\");");
+				getResponse().write("elem.setAttribute(\"type\",\"text/css\");");
+				getResponse().write("elem.setAttribute(\"href\",\""+url+"\");");
+				if (media != null)
+				{
+					getResponse().write("elem.setAttribute(\"media\",\""+media+"\");");
+				}
+				getResponse().write("document.getElementsByTagName(\"head\")[0].appendChild(elem);");
+				getResponse().println("</script>");
+				markRendered(token);
+			}
+		}
+	}
+
+	
+	/**
+	 * @see org.apache.wicket.markup.html.internal.HeaderResponse#close()
+	 */
+	public void close()
+	{
+		super.close();
+		// Automatically add <head> if necessary
+		CharSequence output = bufferedResponse.getBuffer();
+		if (output.length() > 0)
+		{
+			if (output.charAt(0) == '\r')
+			{
+				for (int i = 2; i < output.length(); i += 2)
+				{
+					char ch = output.charAt(i);
+					if (ch != '\r')
+					{
+						output = output.subSequence(i - 2, output.length());
+						break;
+					}
+				}
+			}
+			else if (output.charAt(0) == '\n')
+			{
+				for (int i = 1; i < output.length(); i++)
+				{
+					char ch = output.charAt(i);
+					if (ch != '\n')
+					{
+						output = output.subSequence(i - 1, output.length());
+						break;
+					}
+				}
+			}
+		}
+		if (output.length() > 0)
+		{
+			realResponse.write("<span id=\""+RequestContext.get().getNamespace()+"_embedded_head\" style=\"display:none\">");
+			realResponse.write(output);
+			realResponse.write("</span>");
+		}
+		bufferedResponse.reset();
+	}
+
+	/**
+	 * @see org.apache.wicket.markup.html.internal.HeaderResponse#getRealResponse()
+	 */
+	protected Response getRealResponse()
+	{
+		return bufferedResponse;
+	}
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/EmbeddedPortletHeaderResponse.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java	(revision 0)
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+import java.io.IOException;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.RenderResponse;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.portals.bridges.util.ServletPortletSessionProxy;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebRequest;
+import org.apache.wicket.protocol.http.WebResponse;
+import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
+import org.apache.wicket.settings.IRequestCycleSettings;
+
+/**
+ * @author Ate Douma
+ */
+public class WicketFilterPortletContext
+{
+	private static final String SERVLET_RESOURCE_URL_PORTLET_WINDOW_ID_PREFIX = "/ps:";
+	
+	public void initFilter(FilterConfig filterConfig, WebApplication webApplication) throws ServletException
+    {
+        webApplication.getRequestCycleSettings().setRenderStrategy(IRequestCycleSettings.REDIRECT_TO_RENDER);
+        webApplication.getRequestCycleSettings().addResponseFilter(new PortletInvalidMarkupFilter());
+    }
+
+    public boolean setupFilter(FilterConfig config, FilterRequestContext filterRequestContext, String filterPath) throws IOException, ServletException
+    {
+    	boolean inPortletContext = false;
+    	PortletConfig portletConfig = (PortletConfig)filterRequestContext.getRequest().getAttribute("javax.portlet.config");
+        if ( portletConfig != null )
+        {
+        	inPortletContext = true;
+        	WicketResponseState responseState = (WicketResponseState)filterRequestContext.getRequest().getAttribute(WicketPortlet.RESPONSE_STATE_ATTR);
+        	filterRequestContext.setRequest(new PortletServletRequestWrapper(config.getServletContext(),filterRequestContext.getRequest(), ServletPortletSessionProxy.createProxy(filterRequestContext.getRequest()), filterPath));
+            if ( WicketPortlet.ACTION_REQUEST.equals(filterRequestContext.getRequest().getAttribute(WicketPortlet.REQUEST_TYPE_ATTR)))
+            {
+            	filterRequestContext.setResponse(new PortletActionServletResponseWrapper(filterRequestContext.getResponse(), responseState));
+            }
+            else
+            {   
+            	filterRequestContext.setResponse(new PortletRenderServletResponseWrapper(filterRequestContext.getResponse(), (RenderResponse)filterRequestContext.getRequest().getAttribute("javax.portlet.response"),responseState));
+            }            
+        }
+        else
+        {
+        	ServletContext context = config.getServletContext();
+        	HttpServletRequest request = filterRequestContext.getRequest();
+        	String pathInfo = request.getRequestURI().substring(request.getContextPath().length()+filterPath.length());
+        	String portletWindowId = decodePortletWindowId(pathInfo);
+        	if (portletWindowId != null)
+        	{
+            	HttpSession proxiedSession = ServletPortletSessionProxy.createProxy(request, portletWindowId);        
+            	pathInfo = stripWindowIdFromPathInfo(pathInfo);
+            	filterRequestContext.setRequest(new PortletServletRequestWrapper(context,request,proxiedSession, filterPath, pathInfo));        	
+        	}
+        }
+        return inPortletContext;
+    }
+    
+    public boolean createPortletRequestContext(WebRequest request, WebResponse response)
+    {
+    	if (request.getHttpServletRequest().getAttribute("javax.portlet.config") != null)
+    	{
+    		newPortletRequestContext((ServletWebRequest)request, response);
+    		return true;
+    	}
+        return false;
+    }
+    
+    public String getServletResourceUrlPortletWindowIdPrefix()
+    {
+    	return SERVLET_RESOURCE_URL_PORTLET_WINDOW_ID_PREFIX;
+    }
+
+    public String decodePortletWindowId(String pathInfo)
+    {
+		String portletWindowId = null;
+    	if (pathInfo != null && pathInfo.startsWith(getServletResourceUrlPortletWindowIdPrefix()))
+    	{
+    		int nextPath = pathInfo.indexOf('/',1);
+    		if (nextPath > -1)
+    		{
+    			portletWindowId = pathInfo.substring(getServletResourceUrlPortletWindowIdPrefix().length(),nextPath);
+    		}
+    		else
+    		{
+    			portletWindowId = pathInfo.substring(getServletResourceUrlPortletWindowIdPrefix().length());
+    		}
+    	}
+    	return portletWindowId;
+    }
+    
+    public String stripWindowIdFromPathInfo(String pathInfo)
+    {
+    	if (pathInfo != null && pathInfo.startsWith(getServletResourceUrlPortletWindowIdPrefix()))
+    	{
+    		int nextPath = pathInfo.indexOf('/',1);
+    		pathInfo = nextPath > -1 ? pathInfo.substring(nextPath) : null;
+    	}
+    	return pathInfo;
+    }
+    
+    public String encodeWindowIdInPath(String windowId, CharSequence path)
+    {
+		return (getServletResourceUrlPortletWindowIdPrefix().substring(1) + windowId + "/" + path);
+    }
+
+    protected void newPortletRequestContext(ServletWebRequest request, WebResponse response)
+    {
+		new PortletRequestContext(this, request, response);
+    }
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletActionServletResponseWrapper.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletActionServletResponseWrapper.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletActionServletResponseWrapper.java	(revision 0)
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author Ate Douma
+ */
+public class PortletActionServletResponseWrapper extends PortletServletResponseWrapper
+{
+
+	public PortletActionServletResponseWrapper(HttpServletResponse response, WicketResponseState responseState)
+    {
+        super(response, responseState);
+	}
+
+	public void addCookie(Cookie cookie)
+	{
+	}
+
+	public void addDateHeader(String s, long l)
+	{
+	}
+
+	public void addHeader(String s, String s1)
+	{
+	}
+
+	public void addIntHeader(String s, int i)
+	{
+	}
+
+	public String encodeRedirectUrl(String s)
+	{
+		return s;
+	}
+
+	public String encodeRedirectURL(String s)
+	{
+		return s;
+	}
+
+	public String encodeUrl(String s)
+	{
+		return s;
+	}
+
+	public String encodeURL(String s)
+	{
+		return s;
+	}
+
+	public void flushBuffer() throws IOException
+	{
+	}
+
+	public int getBufferSize()
+	{
+		return 0;
+	}
+
+	public ServletOutputStream getOutputStream() throws IOException
+	{
+		return null;
+	}
+
+	public PrintWriter getWriter() throws IOException
+	{
+		return null;
+	}
+
+	public boolean isCommitted()
+	{
+		return false;
+	}
+
+	public void reset()
+	{
+	}
+
+	public void resetBuffer()
+	{
+	}
+
+	public void setBufferSize(int i)
+	{
+	}
+
+	public void setCharacterEncoding(String charset)
+	{
+	}
+
+	public void setContentLength(int i)
+	{
+	}
+
+	public void setContentType(String s)
+	{
+	}
+
+	public void setDateHeader(String s, long l)
+	{
+	}
+
+	public void setHeader(String s, String s1)
+	{
+	}
+
+	public void setIntHeader(String s, int i)
+	{
+	}
+
+	public void setLocale(Locale locale)
+	{
+	}
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletActionServletResponseWrapper.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRenderServletResponseWrapper.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRenderServletResponseWrapper.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRenderServletResponseWrapper.java	(revision 0)
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+import java.io.IOException;
+
+import javax.portlet.RenderResponse;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.wicket.RequestContext;
+
+/**
+ * @author Ate Douma
+ */
+public class PortletRenderServletResponseWrapper extends PortletServletResponseWrapper
+{
+	RenderResponse renderResponse;
+    
+    public PortletRenderServletResponseWrapper(HttpServletResponse response, RenderResponse renderResponse, WicketResponseState responseState)
+    {
+        super(response, responseState);
+        this.renderResponse = renderResponse;
+    }
+
+	/**
+	 * @see javax.servlet.ServletResponseWrapper#setContentType(java.lang.String)
+	 */
+	public void setContentType(String arg0)
+	{
+		renderResponse.setContentType(arg0);
+	}
+
+    public void sendRedirect(String redirectLocation) throws IOException
+	{
+    	RequestContext rc = RequestContext.get();
+    	if (rc instanceof PortletRequestContext)
+    	{
+    		String wicketUrl = ((PortletRequestContext)rc).getLastEncodedPath(redirectLocation);
+    		if (wicketUrl != null)
+    		{
+    			redirectLocation = wicketUrl;
+    		}
+    		else
+    		{
+    			String contextPath = ((PortletRequestContext)rc).getPortletRequest().getContextPath();
+    			if (redirectLocation.startsWith(contextPath+"/"))
+    			{
+    				redirectLocation = redirectLocation.substring(contextPath.length());
+    				if (redirectLocation.length() == 0)
+    				{
+    					redirectLocation = "/";
+    				}
+    			}
+    		}
+    	}
+		super.sendRedirect(redirectLocation);
+	}
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRenderServletResponseWrapper.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java	(revision 0)
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.protocol.http.portlet;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+/**
+ * @author Ate Douma
+ */
+public class PortletServletResponseWrapper extends HttpServletResponseWrapper
+{
+	private WicketResponseState responseState;
+	
+	public PortletServletResponseWrapper(HttpServletResponse response, WicketResponseState responseState)
+	{
+		super(response);
+		this.responseState = responseState;
+	}
+
+	/**
+	 * @see javax.servlet.http.HttpServletResponseWrapper#sendError(int, java.lang.String)
+	 */
+	public void sendError(int errorCode, String errorMessage) throws IOException
+	{
+		responseState.setErrorCode(errorCode);
+		responseState.setErrorMessage(errorMessage);
+	}
+	
+	/**
+	 * @see javax.servlet.http.HttpServletResponseWrapper#sendError(int)
+	 */
+	public void sendError(int errorCode) throws IOException
+	{
+		responseState.setErrorCode(errorCode);
+		responseState.setErrorMessage(null);
+	}
+
+	/**
+	 * @see javax.servlet.http.HttpServletResponseWrapper#sendRedirect(java.lang.String)
+	 */
+	public void sendRedirect(String redirectLocation) throws IOException
+	{
+		responseState.setRedirectLocation(redirectLocation);
+	}
+
+	/**
+	 * @see javax.servlet.http.HttpServletResponseWrapper#setStatus(int)
+	 */
+	public void setStatus(int statusCode)
+	{
+		responseState.setStatusCode(statusCode);
+	}
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebCodingStrategy.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebCodingStrategy.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebCodingStrategy.java	(working copy)
@@ -22,6 +22,7 @@
 import org.apache.wicket.Page;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.RequestListenerInterface;
+import org.apache.wicket.behavior.IActivePageBehaviorListener;
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
 import org.apache.wicket.request.RequestParameters;
@@ -131,6 +132,10 @@
 		{
 			url.append(params.getUrlDepth());
 		}
+		if (IActivePageBehaviorListener.INTERFACE.getName().equals(listenerName))
+		{
+			url.append(url.indexOf("?") > -1 ? "&amp;" : "?").append(IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME).append("=true");
+		}
 		return requestCycle.getOriginalResponse().encodeURL(url);
 	}
 }
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java	(working copy)
@@ -19,6 +19,7 @@
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.TreeSet;
@@ -29,15 +30,22 @@
 import org.apache.wicket.IPageMap;
 import org.apache.wicket.IRedirectListener;
 import org.apache.wicket.IRequestTarget;
+import org.apache.wicket.IResourceListener;
 import org.apache.wicket.Page;
 import org.apache.wicket.PageMap;
 import org.apache.wicket.PageParameters;
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.Request;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.RequestListenerInterface;
 import org.apache.wicket.Session;
 import org.apache.wicket.WicketRuntimeException;
+import org.apache.wicket.behavior.AbstractAjaxBehavior;
+import org.apache.wicket.behavior.IActivePageBehaviorListener;
+import org.apache.wicket.behavior.IBehaviorListener;
 import org.apache.wicket.protocol.http.UnitTestSettings;
+import org.apache.wicket.protocol.http.WebRequestCycle;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
 import org.apache.wicket.request.IRequestCodingStrategy;
 import org.apache.wicket.request.IRequestTargetMountsInfo;
 import org.apache.wicket.request.RequestParameters;
@@ -228,52 +236,113 @@
 		// First check to see whether the target is mounted
 		CharSequence url = pathForTarget(requestTarget);
 
-		if (url != null)
+		RequestContext requestContext = RequestContext.get();
+		boolean portletRequest = requestContext.isPortletRequest();
+		boolean sharedResourceURL = false;
+		
+		if (url != null && !portletRequest)
 		{
 			// Do nothing - we've found the URL and it's mounted.
 		}
 		else if (requestTarget instanceof IBookmarkablePageRequestTarget)
 		{
-			url = encode(requestCycle, (IBookmarkablePageRequestTarget)requestTarget);
+			url = requestContext.encodeRenderURL(url == null ? encode(requestCycle, (IBookmarkablePageRequestTarget)requestTarget) : url);
 		}
 		else if (requestTarget instanceof ISharedResourceRequestTarget)
 		{
-			url = encode(requestCycle, (ISharedResourceRequestTarget)requestTarget);
+			url = requestContext.encodeSharedResourceURL(url == null ? encode(requestCycle, (ISharedResourceRequestTarget)requestTarget) : url);
+			sharedResourceURL = true;
 		}
 		else if (requestTarget instanceof IListenerInterfaceRequestTarget)
 		{
-			url = encode(requestCycle, (IListenerInterfaceRequestTarget)requestTarget);
+			if (url == null)
+			{
+				url = encode(requestCycle, (IListenerInterfaceRequestTarget)requestTarget);
+			}
+			if (portletRequest)
+			{
+				IListenerInterfaceRequestTarget iliRequestTarget = (IListenerInterfaceRequestTarget)requestTarget;
+				RequestListenerInterface rli = iliRequestTarget.getRequestListenerInterface();
+				if (IResourceListener.class.isAssignableFrom(rli.getMethod().getDeclaringClass())
+					|| IBehaviorListener.class.isAssignableFrom(rli.getMethod().getDeclaringClass()))
+				{
+					url = requestContext.encodeResourceURL(url);
+				}
+				else if (IRedirectListener.class.isAssignableFrom(rli.getMethod().getDeclaringClass()))
+				{
+					if (((WebRequestCycle)requestCycle).getWebRequest().isAjax())
+					{
+                        // TODO: Probably not all Ajax based redirects need to break out of ResourceURL encoding
+						// Need to findout and/or provide some kind of extension how to indicate this
+						url = ((PortletRequestContext)requestContext).encodeRenderURL(url,true);
+					}
+					else
+					{
+						url = requestContext.encodeRenderURL(url);
+					}
+				}
+				else
+				{
+					PortletRequestContext prc = (PortletRequestContext)requestContext;
+					boolean forceActionURL = prc.isAjax();
+					if (forceActionURL)
+					{
+						List behaviors = iliRequestTarget.getTarget().getBehaviors();
+						for (int i = 0, size = behaviors.size(); i<size; i++)
+						{
+							if (AbstractAjaxBehavior.class.isAssignableFrom(behaviors.get(i).getClass()))
+							{
+								forceActionURL = false;
+								break;
+							}
+						}
+					}
+					url = prc.encodeActionURL(url, forceActionURL);
+				}
+			}
 		}
-		else if (requestTarget instanceof IPageRequestTarget)
+		else if (url == null)
 		{
-			// This calls page.urlFor(IRedirectListener.INTERFACE), which calls
-			// the function we're in again. We therefore need to jump out here
-			// and return the url immediately, otherwise we end up prefixing it
-			// with relative path or absolute prefixes twice.
-			return encode(requestCycle, (IPageRequestTarget)requestTarget);
+			if (requestTarget instanceof IPageRequestTarget)
+			{
+				// This calls page.urlFor(IRedirectListener.INTERFACE), which calls
+				// the function we're in again. We therefore need to jump out here
+				// and return the url immediately, otherwise we end up prefixing it
+				// with relative path or absolute prefixes twice.
+				return encode(requestCycle, (IPageRequestTarget)requestTarget);
+			}
+			// fallthough for non-default request targets
+			else
+			{
+				url = doEncode(requestCycle, requestTarget);
+			}
 		}
-		// fallthough for non-default request targets
-		else
-		{
-			url = doEncode(requestCycle, requestTarget);
-		}
 
 		if (url != null)
 		{
-			// Add the actual URL. This will be relative to the Wicket
-			// Servlet/Filter, with no leading '/'.
-			PrependingStringBuffer prepender = new PrependingStringBuffer(url.toString());
+			String result = null;
+			
+			if (!sharedResourceURL && portletRequest)
+			{
+				result = url.toString();
+			}
+			else
+			{
+				// Add the actual URL. This will be relative to the Wicket
+			    // Servlet/Filter, with no leading '/'.
+				PrependingStringBuffer prepender = new PrependingStringBuffer(url.toString());
 
-			// Prepend prefix to the URL to make it relative to the current
-			// request.
-			prepender.prepend(requestCycle.getRequest().getRelativePathPrefixToWicketHandler());
+				// Prepend prefix to the URL to make it relative to the current
+				// request.
+				prepender.prepend(requestCycle.getRequest().getRelativePathPrefixToWicketHandler());
 
-			String result = prepender.toString();
-			// We need to special-case links to the home page if we're at the
-			// same level.
-			if (result.length() == 0)
-			{
-				result = "./";
+				result = prepender.toString();
+				// We need to special-case links to the home page if we're at the
+				// same level.
+				if (result.length() == 0)
+				{
+					result = "./";
+				}
 			}
 			return requestCycle.getOriginalResponse().encodeURL(result);
 		}
@@ -824,6 +893,10 @@
 			url.append(params.getUrlDepth());
 		}
 
+		if (IActivePageBehaviorListener.INTERFACE.getName().equals(listenerName))
+		{
+			url.append(url.indexOf("?") > -1 ? "&amp;" : "?").append(IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME).append("=true");
+		}
 		return url;
 	}
 
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WicketFilter.java	(working copy)
@@ -33,12 +33,15 @@
 
 import org.apache.wicket.AbortException;
 import org.apache.wicket.Application;
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.Resource;
 import org.apache.wicket.Session;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.parser.XmlPullParser;
 import org.apache.wicket.markup.parser.XmlTag;
+import org.apache.wicket.protocol.http.portlet.FilterRequestContext;
+import org.apache.wicket.protocol.http.portlet.WicketFilterPortletContext;
 import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
 import org.apache.wicket.session.ISessionStore;
 import org.apache.wicket.settings.IRequestCycleSettings;
@@ -92,6 +95,22 @@
 	private boolean servletMode = false;
 
 	/**
+	 * The name of the optional filter parameter indicating it may/can only be accessed from within a Portlet context.
+	 * Value should be true
+	 */
+	private final String PORTLET_ONLY_FILTER = "portletOnlyFilter";
+	
+	/* init marker if running in a portlet container context */
+	private Boolean portletContextAvailable;
+	
+	/* Delegate for handling Portlet specific filtering. Not instantiated if not running in a portlet container context */
+	private WicketFilterPortletContext filterPortletContext;
+	
+	/* Flag if this filter may only process request from within a Portlet context.
+	 */
+	private boolean portletOnlyFilter;
+	
+	/**
 	 * Servlet cleanup.
 	 */
 	public void destroy()
@@ -110,7 +129,29 @@
 	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
 			throws IOException, ServletException
 	{
-		HttpServletRequest httpServletRequest = (HttpServletRequest)request;
+		HttpServletRequest httpServletRequest;
+		HttpServletResponse httpServletResponse;
+		
+		boolean inPortletContext = false;
+        if (filterPortletContext != null)
+        {
+        	FilterRequestContext filterRequestContext = new FilterRequestContext((HttpServletRequest)request,(HttpServletResponse)response);
+        	inPortletContext = filterPortletContext.setupFilter(getFilterConfig(), filterRequestContext, getFilterPath((HttpServletRequest)request));
+        	httpServletRequest = filterRequestContext.getRequest();
+        	httpServletResponse = filterRequestContext.getResponse();
+        }
+        else
+        {
+    		httpServletRequest = (HttpServletRequest)request;
+			httpServletResponse = (HttpServletResponse)response;
+        }
+
+        if ( portletOnlyFilter && !inPortletContext )
+		{
+			chain.doFilter(request, response);
+			return;
+		}
+		        
 		String relativePath = getRelativePath(httpServletRequest);
 
 		if (isWicketRequest(relativePath))
@@ -120,7 +161,6 @@
 				// Set the webapplication for this thread
 				Application.set(webApplication);
 
-				HttpServletResponse httpServletResponse = (HttpServletResponse)response;
 				long lastModified = getLastModified(httpServletRequest);
 				if (lastModified == -1)
 				{
@@ -268,6 +308,8 @@
 				response.setCharacterEncoding(webApplication.getRequestCycleSettings()
 						.getResponseRequestEncoding());
 
+	            createRequestContext(request, response);
+	            
 				// Create request cycle
 				final RequestCycle cycle = webApplication.newRequestCycle(request, response);
 
@@ -444,6 +486,26 @@
 
 			// Give the application the option to log that it is started
 			webApplication.logStarted();
+
+			this.portletOnlyFilter = Boolean.valueOf(filterConfig.getInitParameter(PORTLET_ONLY_FILTER)).booleanValue();
+			
+	        if ( portletContextAvailable == null )
+	        {
+	        	try
+				{
+					Class portletClass = Class.forName("javax.portlet.PortletContext");
+					portletContextAvailable = Boolean.TRUE;
+					filterPortletContext = newWicketFilterPortletContext();
+				}
+				catch (ClassNotFoundException e)
+				{
+					portletContextAvailable = Boolean.FALSE;
+				}
+	        }
+	        if (filterPortletContext != null)
+	        {
+	        	filterPortletContext.initFilter(filterConfig, this.webApplication);
+	        }
 		}
 		finally
 		{
@@ -455,6 +517,19 @@
 		}
 	}
 
+	protected WicketFilterPortletContext newWicketFilterPortletContext()
+	{
+		return new WicketFilterPortletContext();
+	}
+
+    protected void createRequestContext(WebRequest request, WebResponse response)
+    {
+        if (filterPortletContext == null || !filterPortletContext.createPortletRequestContext(request, response))
+        {
+        	new RequestContext();
+        }
+    }
+    
 	private String getFilterPath(String filterName, InputStream is) throws ServletException
 	{
 		String prefix = servletMode ? "servlet" : "filter";
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js	(working copy)
@@ -719,7 +719,7 @@
 		if (this.randomURL == false)
 			return this.url;
 		else
-			return this.url + "&random=" + Math.random();
+			return this.url + (this.url.indexOf("?")>-1 ? "&" : "?") + "random=" + Math.random();
 	},
 	
 	log: function(method, url) {
@@ -736,6 +736,26 @@
 	
 	// Executes a get request
 	get: function() {
+        // first check if a query string is provided
+        var qs = this.url.indexOf('?');
+        if (qs==-1) {
+            qs = this.url.indexOf('&');
+        }
+        if (qs>-1) {
+            var query = this.url.substring(qs+1);
+            // ensure the query is not empty
+            if (query && query.length > 0) {
+                // cut off query part from original url
+                this.url = this.url.substring(0,qs);
+                // ensure query ends with &
+                if (query.charAt(query.length-1)!='&') {
+                    query += "&";
+                }
+                // post the query string instead to support portlets
+                // for which you cannot modify/append to the url
+                return this.post(query);
+            }
+        }
 		if (this.channel != null) {
 			var res = Wicket.channelManager.schedule(this.channel, this.doGet.bind(this));
 			return res != null ? res : true;
@@ -844,22 +864,28 @@
 				if (typeof(redirectUrl) != "undefined" && redirectUrl != null && redirectUrl != "") {
 					t.onreadystatechange = Wicket.emptyFunction;
 					
-					var urlDepth = 0;
-					while (redirectUrl.substring(0, 3) == "../") {
-						urlDepth++;
-						redirectUrl = redirectUrl.substring(3);
+                    // support/check for non-relative redirectUrl like as provided and needed in a portlet context
+					if (redirectUrl.charAt(0)==('/')||redirectUrl.match("^http://")=="http://"||redirectUrl.match("^https://")=="https://") {
+					    window.location = redirectUrl;
 					}
-					// Make this a string.
-					var calculatedRedirect = window.location.pathname;
-					while (urlDepth > -1) {
-						urlDepth--;
-						i = calculatedRedirect.lastIndexOf("/");
-						if (i > -1) {
-							calculatedRedirect = calculatedRedirect.substring(0, i);
-						}
+					else {
+					    var urlDepth = 0;
+					    while (redirectUrl.substring(0, 3) == "../") {
+						    urlDepth++;
+						    redirectUrl = redirectUrl.substring(3);
+					    }
+					    // Make this a string.
+					    var calculatedRedirect = window.location.pathname;
+					    while (urlDepth > -1) {
+						    urlDepth--;
+						    i = calculatedRedirect.lastIndexOf("/");
+						    if (i > -1) {
+							    calculatedRedirect = calculatedRedirect.substring(0, i);
+						    }
+					    }
+					    calculatedRedirect += "/" + redirectUrl;
+					    window.location = calculatedRedirect;
 					}
-					calculatedRedirect += "/" + redirectUrl;
-					window.location = calculatedRedirect;
 				}
 				else {
 					// no redirect, just regular response
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java	(working copy)
@@ -860,7 +860,7 @@
 			}
 		}
 
-		public Response getResponse()
+		protected Response getRealResponse()
 		{
 			return RequestCycle.get().getResponse();
 		}
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/RedirectRequestTarget.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/RedirectRequestTarget.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/RedirectRequestTarget.java	(working copy)
@@ -17,9 +17,11 @@
 package org.apache.wicket.request.target.basic;
 
 import org.apache.wicket.IRequestTarget;
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.Response;
 import org.apache.wicket.markup.html.pages.RedirectPage;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
 
 /**
  * A RequestTarget that will sent a redirect url to the browser. Use this if you 
@@ -68,7 +70,16 @@
 		response.reset();
 		if (redirectUrl.startsWith("/"))
 		{
-			response.redirect(RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot() + redirectUrl.substring(1));	
+			RequestContext rc = RequestContext.get();
+			String continueTo = null;
+			if (rc.isPortletRequest() && ((PortletRequestContext)rc).isEmbedded())
+			{
+				response.redirect(redirectUrl);	
+			}
+			else
+			{
+				response.redirect(RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot() + redirectUrl.substring(1));	
+			}
 		}
 		else if (redirectUrl.startsWith("http://") || redirectUrl.startsWith("https://"))
 		{
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/AbstractAjaxBehavior.java	(working copy)
@@ -22,8 +22,6 @@
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.html.IHeaderContributor;
 import org.apache.wicket.markup.html.IHeaderResponse;
-import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
-import org.apache.wicket.util.string.AppendingStringBuffer;
 
 /**
  * Abstract class for handling Ajax roundtrips. This class serves as a base for
@@ -105,16 +103,16 @@
 		
 		final RequestListenerInterface rli;
 		
-		rli = IBehaviorListener.INTERFACE;
-		
-		AppendingStringBuffer url = new AppendingStringBuffer(getComponent().urlFor(this, rli));
-		
 		if (onlyTargetActivePage)
 		{
-			url.append("&amp;").append(WebRequestCodingStrategy.IGNORE_IF_NOT_ACTIVE_PARAMETER_NAME).append("=true");
+			rli = IActivePageBehaviorListener.INTERFACE;
 		}
-
-		return url;
+		else
+		{
+			rli = IBehaviorListener.INTERFACE;
+		}
+				
+		return getComponent().urlFor(this, rli);
 	}
 
 	/**
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java	(revision 0)
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.behavior;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.IRequestTarget;
+import org.apache.wicket.Page;
+import org.apache.wicket.RequestListenerInterface;
+import org.apache.wicket.request.RequestParameters;
+import org.apache.wicket.request.target.component.listener.BehaviorRequestTarget;
+
+/**
+ * An extended {@link IBehaviorListener} which will be ignored if the page is not the last one the user accessed.
+ * @see AbstractAjaxBehavior#getCallbackUrl(boolean)
+ * 
+ * @author Ate Douma
+ */
+public interface IActivePageBehaviorListener extends IBehaviorListener
+{
+	public static final RequestListenerInterface INTERFACE = new RequestListenerInterface(
+			IActivePageBehaviorListener.class)
+	{
+		public IRequestTarget newRequestTarget(Page page, Component component,
+				RequestListenerInterface listener, RequestParameters requestParameters)
+		{
+			return new BehaviorRequestTarget(page, component, listener, requestParameters);
+		}
+	};
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/behavior/IActivePageBehaviorListener.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java	(working copy)
@@ -1205,7 +1205,7 @@
 			// {
 			// if not in the markup, generate one
 
-			markupId = getId() + page.getAutoIndex();
+            markupId = RequestContext.get().encodeMarkupId(getId() + page.getAutoIndex());
 			// make sure id is compliant with w3c requirements (starts with a
 			// letter)
 			char c = markupId.charAt(0);
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java	(working copy)
@@ -23,6 +23,7 @@
 
 import org.apache.wicket.Component;
 import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.Response;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.MarkupStream;
@@ -126,12 +127,19 @@
 			final StringResponse response = new StringResponse();
 			this.getRequestCycle().setResponse(response);
 
+			IHeaderResponse headerResponse = getHeaderResponse();
+			if (!response.equals(headerResponse.getResponse()))
+			{
+				this.getRequestCycle().setResponse(headerResponse.getResponse());
+			}
+			
 			// In any case, first render the header section directly associated
 			// with the markup
 			super.onComponentTagBody(markupStream, openTag);
 
 			// Render all header sections of all components on the page
 			renderHeaderSections(getPage(), this);
+			getHeaderResponse().close();
 
 			// Automatically add <head> if necessary
 			CharSequence output = response.getBuffer();
@@ -276,12 +284,19 @@
 	 */
 	protected IHeaderResponse newHeaderResponse()
 	{
-		return new HeaderResponse() {
-			public Response getResponse()
-			{
-				return HtmlHeaderContainer.this.getResponse();
-			}
-		};
+		IHeaderResponse headerResponse = RequestContext.get().getHeaderResponse();
+		if ( headerResponse == null )
+		{
+			// no (portlet) headerResponse override, create a default one
+			headerResponse =
+				new HeaderResponse() {
+					protected Response getRealResponse()
+					{
+						return HtmlHeaderContainer.this.getResponse();
+					}
+				};
+		}
+		return headerResponse;
 	}
 
 	/**
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/internal/HeaderResponse.java	(working copy)
@@ -24,8 +24,10 @@
 import org.apache.wicket.Application;
 import org.apache.wicket.RequestCycle;
 import org.apache.wicket.ResourceReference;
+import org.apache.wicket.Response;
 import org.apache.wicket.markup.html.IHeaderResponse;
 import org.apache.wicket.markup.html.WicketEventReference;
+import org.apache.wicket.response.NullResponse;
 import org.apache.wicket.util.string.JavascriptUtils;
 
 
@@ -41,6 +43,8 @@
 
 	private final Set rendered = new HashSet();
 
+	private boolean closed;
+
 	/**
 	 * Creates a new header response instance.
 	 */
@@ -65,8 +69,11 @@
 	 */
 	public void renderCSSReference(ResourceReference reference)
 	{
-		CharSequence url = RequestCycle.get().urlFor(reference);
-		renderCSSReference(url.toString(), null);
+		if (!closed)
+		{
+			CharSequence url = RequestCycle.get().urlFor(reference);
+			renderCSSReference(url.toString(), null);
+		}
 	}
 
 	/**
@@ -75,8 +82,11 @@
 	 */
 	public void renderCSSReference(ResourceReference reference, String media)
 	{
-		CharSequence url = RequestCycle.get().urlFor(reference);
-		renderCSSReference(url.toString(), media);
+		if (!closed)
+		{
+			CharSequence url = RequestCycle.get().urlFor(reference);
+			renderCSSReference(url.toString(), media);
+		}
 	}
 
 	/**
@@ -84,7 +94,10 @@
 	 */
 	public void renderCSSReference(String url)
 	{
-		renderCSSReference(url, null);
+		if (!closed)
+		{
+			renderCSSReference(url, null);
+		}
 	}
 
 	/**
@@ -93,20 +106,23 @@
 	 */
 	public void renderCSSReference(String url, String media)
 	{
-		List token = Arrays.asList(new Object[] { "css", url, media });
-		if (wasRendered(token) == false)
+		if (!closed)
 		{
-			getResponse().write("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
-			getResponse().write(url);
-			getResponse().write("\"");
-			if (media != null)
+			List token = Arrays.asList(new Object[] { "css", url, media });
+			if (wasRendered(token) == false)
 			{
-				getResponse().write(" media=\"");
-				getResponse().write(media);
+				getResponse().write("<link rel=\"stylesheet\" type=\"text/css\" href=\"");
+				getResponse().write(url);
 				getResponse().write("\"");
+				if (media != null)
+				{
+					getResponse().write(" media=\"");
+					getResponse().write(media);
+					getResponse().write("\"");
+				}
+				getResponse().println(" />");
+				markRendered(token);
 			}
-			getResponse().println(" />");
-			markRendered(token);
 		}
 	}
 
@@ -115,8 +131,11 @@
 	 */
 	public void renderJavascriptReference(ResourceReference reference)
 	{
-		CharSequence url = RequestCycle.get().urlFor(reference);
-		renderJavascriptReference(url.toString());
+		if (!closed)
+		{
+			CharSequence url = RequestCycle.get().urlFor(reference);
+			renderJavascriptReference(url.toString());
+		}
 	}
 
 	/**
@@ -125,8 +144,11 @@
 	 */
 	public void renderJavascriptReference(ResourceReference reference, String id)
 	{
-		CharSequence url = RequestCycle.get().urlFor(reference);
-		renderJavascriptReference(url.toString(), id);
+		if (!closed)
+		{
+			CharSequence url = RequestCycle.get().urlFor(reference);
+			renderJavascriptReference(url.toString(), id);
+		}
 	}
 
 	/**
@@ -134,11 +156,14 @@
 	 */
 	public void renderJavascriptReference(String url)
 	{
-		List token = Arrays.asList(new Object[] { "javascript", url });
-		if (wasRendered(token) == false)
+		if (!closed)
 		{
-			JavascriptUtils.writeJavascriptUrl(getResponse(), url);
-			markRendered(token);
+			List token = Arrays.asList(new Object[] { "javascript", url });
+			if (wasRendered(token) == false)
+			{
+				JavascriptUtils.writeJavascriptUrl(getResponse(), url);
+				markRendered(token);
+			}
 		}
 	}
 
@@ -148,13 +173,16 @@
 	 */
 	public void renderJavascriptReference(String url, String id)
 	{
-		List token1 = Arrays.asList(new Object[] { "javascript", url });
-		List token2 = Arrays.asList(new Object[] { "javascript", id });
-		if (wasRendered(token1) == false && wasRendered(token2))
+		if (!closed)
 		{
-			JavascriptUtils.writeJavascriptUrl(getResponse(), url, id);
-			markRendered(token1);
-			markRendered(token2);
+			List token1 = Arrays.asList(new Object[] { "javascript", url });
+			List token2 = Arrays.asList(new Object[] { "javascript", id });
+			if (wasRendered(token1) == false && wasRendered(token2))
+			{
+				JavascriptUtils.writeJavascriptUrl(getResponse(), url, id);
+				markRendered(token1);
+				markRendered(token2);
+			}
 		}
 	}
 
@@ -164,11 +192,14 @@
 	 */
 	public void renderJavascript(CharSequence javascript, String id)
 	{
-		List token = Arrays.asList(new Object[] { javascript.toString(), id });
-		if (wasRendered(token) == false)
+		if (!closed)
 		{
-			JavascriptUtils.writeJavascript(getResponse(), javascript, id);
-			markRendered(token);
+			List token = Arrays.asList(new Object[] { javascript.toString(), id });
+			if (wasRendered(token) == false)
+			{
+				JavascriptUtils.writeJavascript(getResponse(), javascript, id);
+				markRendered(token);
+			}
 		}
 	}
 
@@ -177,11 +208,14 @@
 	 */
 	public void renderString(CharSequence string)
 	{
-		String token = string.toString();
-		if (wasRendered(token) == false)
+		if (!closed)
 		{
-			getResponse().write(string);
-			markRendered(token);
+			String token = string.toString();
+			if (wasRendered(token) == false)
+			{
+				getResponse().write(string);
+				markRendered(token);
+			}
 		}
 	}
 
@@ -198,7 +232,10 @@
 	 */
 	public void renderOnDomReadyJavascript(String javascript)
 	{
-		renderOnEventJavacript("window", "domready", javascript);
+		if (!closed)
+		{
+			renderOnEventJavacript("window", "domready", javascript);
+		}
 	}
 
 	/**
@@ -206,7 +243,10 @@
 	 */
 	public void renderOnLoadJavascript(String javascript)
 	{
-		renderOnEventJavacript("window", "load", javascript);
+		if (!closed)
+		{
+			renderOnEventJavacript("window", "load", javascript);
+		}
 	}
 
 	/**
@@ -216,13 +256,48 @@
 	 */
 	public void renderOnEventJavacript(String target, String event, String javascript)
 	{
-		List token = Arrays.asList(new Object[] { "javascript-event", target, event, javascript });
-		if (wasRendered(token) == false)
+		if (!closed)
 		{
-			renderJavascriptReference(WicketEventReference.INSTANCE);
-			JavascriptUtils.writeJavascript(getResponse(), "Wicket.Event.add(" + target + ", \"" +
-					event + "\", function() { " + javascript + ";});");
-			markRendered(token);
+			List token = Arrays.asList(new Object[] { "javascript-event", target, event, javascript });
+			if (wasRendered(token) == false)
+			{
+				renderJavascriptReference(WicketEventReference.INSTANCE);
+				JavascriptUtils.writeJavascript(getResponse(), "Wicket.Event.add(" + target + ", \"" +
+						event + "\", function() { " + javascript + ";});");
+				markRendered(token);
+			}
 		}
 	}
+	
+	/**
+	 * @see org.apache.wicket.markup.html.IHeaderResponse#close()
+	 */
+	public void close()
+	{
+		this.closed = true;
+	}
+
+	/**
+	 * @see org.apache.wicket.markup.html.IHeaderResponse#getResponse()
+	 */
+	public final Response getResponse()
+	{
+		return closed ? NullResponse.getInstance() : getRealResponse();
+	}
+
+	/**
+	 * @see org.apache.wicket.markup.html.IHeaderResponse#isClosed()
+	 */
+	public boolean isClosed()
+	{
+		return closed;
+	}
+	
+	/**
+	 * Once the HeaderResponse is closed, no output may be written to it anymore. To enforce that,
+	 * the {@link #getResponse()} is defined final in this class and will return a NullResponse instance once closed or otherwise
+	 * the Response provided by this method.
+	 * @return Response
+	 */
+	protected abstract Response getRealResponse();
 }
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/Link.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/Link.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/Link.java	(working copy)
@@ -402,6 +402,10 @@
 		// Default handling for tag
 		super.onComponentTag(tag);
 
+		if (popupSettings != null)
+		{
+			RequestCycle.get().setUrlForNewWindowEncoding();
+		}
 		// Set href to link to this link's linkClicked method
 		CharSequence url = getURL();
 
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/IHeaderResponse.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/IHeaderResponse.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/IHeaderResponse.java	(working copy)
@@ -190,4 +190,15 @@
 	 * @param javascript
 	 */
 	public void renderOnEventJavacript(String target, String event, String javascript);
+
+	/**
+	 * Mark Header rendering is completed and subsequent usage will be ignored.
+	 * If some kind of buffering is used internally, this action will mark that the contents has to be flushed out.
+	 */
+	public void close();
+	
+	/**
+	 * @return if header rendering is completed and subsequent usage will be ignored
+	 */
+	boolean isClosed();
 }
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/Check.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/Check.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/Check.java	(working copy)
@@ -19,10 +19,12 @@
 import java.util.Collection;
 
 import org.apache.wicket.Component;
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
 
 
 /**
@@ -145,18 +147,26 @@
 		if (group.wantOnSelectionChangedNotifications())
 		{
 			// url that points to this components IOnChangeListener method
-			final CharSequence url = group.urlFor(IOnChangeListener.INTERFACE);
+			CharSequence url = group.urlFor(IOnChangeListener.INTERFACE);
 
 			Form form = (Form)group.findParent(Form.class);
 			if (form != null)
 			{
+				RequestContext rc = RequestContext.get();
+				if (rc.isPortletRequest())
+				{
+					// restore url back to real wicket path as its going to be interpreted by the form itself
+					url = ((PortletRequestContext)rc).getLastEncodedPath();
+				}
 				tag.put("onclick", form.getJsForInterfaceUrl(url));
 			}
 			else
 			{
+				// TODO: following doesn't work with portlets, should be posted to a dynamic hidden form
+				// with an ActionURL or something
 				// NOTE: do not encode the url as that would give invalid
 				// JavaScript
-				tag.put("onclick", "window.location.href='" + url + "&amp;" + group.getInputName()
+				tag.put("onclick", "window.location.href='" + url + (url.toString().indexOf('?')>-1 ? "&amp;" : "?") + group.getInputName()
 						+ "=' + this.value;");
 			}
 		}
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/Radio.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/Radio.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/Radio.java	(working copy)
@@ -17,10 +17,12 @@
 package org.apache.wicket.markup.html.form;
 
 import org.apache.wicket.Component;
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
 import org.apache.wicket.util.lang.Objects;
 
 /**
@@ -128,18 +130,26 @@
 		if (group.wantOnSelectionChangedNotifications())
 		{
 			// url that points to this components IOnChangeListener method
-			final CharSequence url = group.urlFor(IOnChangeListener.INTERFACE);
+			CharSequence url = group.urlFor(IOnChangeListener.INTERFACE);
 
 			Form form = (Form)group.findParent(Form.class);
 			if (form != null)
 			{
+				RequestContext rc = RequestContext.get();
+				if (rc.isPortletRequest())
+				{
+					// restore url back to real wicket path as its going to be interpreted by the form itself
+					url = ((PortletRequestContext)rc).getLastEncodedPath();
+				}				
 				tag.put("onclick", form.getJsForInterfaceUrl(url));
 			}
 			else
 			{
+				// TODO: following doesn't work with portlets, should be posted to a dynamic hidden form
+				// with an ActionURL or something
 				// NOTE: do not encode the url as that would give invalid
 				// JavaScript
-				tag.put("onclick", "window.location.href='" + url + "&amp;" + group.getInputName()
+				tag.put("onclick", "window.location.href='" + url + (url.toString().indexOf('?')>-1 ? "&amp;" : "?") + group.getInputName()
 						+ "=' + this.value;");
 			}
 		}
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/DropDownChoice.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/DropDownChoice.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/DropDownChoice.java	(working copy)
@@ -18,9 +18,11 @@
 
 import java.util.List;
 
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
 
 
 /**
@@ -171,16 +173,24 @@
 		if (wantOnSelectionChangedNotifications())
 		{
 			// url that points to this components IOnChangeListener method
-			final CharSequence url = urlFor(IOnChangeListener.INTERFACE);
+			CharSequence url = urlFor(IOnChangeListener.INTERFACE);
 
 			Form form = (Form)findParent(Form.class);
 			if (form != null)
 			{
+				RequestContext rc = RequestContext.get();
+				if (rc.isPortletRequest())
+				{
+					// restore url back to real wicket path as its going to be interpreted by the form itself
+					url = ((PortletRequestContext)rc).getLastEncodedPath();
+				}				
 				tag.put("onchange", form.getJsForInterfaceUrl(url));
 			}
 			else
 			{
-				tag.put("onchange", "window.location.href='" + url + "&amp;" + getInputName()
+				// TODO: following doesn't work with portlets, should be posted to a dynamic hidden form
+				// with an ActionURL or something
+				tag.put("onchange", "window.location.href='" + url + (url.toString().indexOf('?')>-1 ? "&amp;" : "?") + getInputName()
 						+ "=' + this.options[this.selectedIndex].value;");
 			}
 		}
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java	(working copy)
@@ -19,9 +19,11 @@
 import java.util.List;
 
 import org.apache.wicket.Page;
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.MarkupStream;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.version.undo.Change;
@@ -460,20 +462,28 @@
 				// when the option is clicked?
 				if (wantOnSelectionChangedNotifications())
 				{
-					final CharSequence url = urlFor(IOnChangeListener.INTERFACE);
+					CharSequence url = urlFor(IOnChangeListener.INTERFACE);
 
 					Form form = (Form)findParent(Form.class);
 					if (form != null)
 					{
+						RequestContext rc = RequestContext.get();
+						if (rc.isPortletRequest())
+						{
+							// restore url back to real wicket path as its going to be interpreted by the form itself
+							url = ((PortletRequestContext)rc).getLastEncodedPath();
+						}				
 						buffer.append(" onclick=\"").append(form.getJsForInterfaceUrl(url)).append(
 								";\"");
 					}
 					else
 					{
+						// TODO: following doesn't work with portlets, should be posted to a dynamic hidden form
+						// with an ActionURL or something
 						// NOTE: do not encode the url as that would give
 						// invalid JavaScript
 						buffer.append(" onclick=\"window.location.href='").append(url).append(
-								"&amp;" + getInputName()).append("=").append(id).append("';\"");
+								(url.toString().indexOf('?')>-1 ? "&amp;" : "?") + getInputName()).append("=").append(id).append("';\"");
 					}
 				}
 
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBox.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBox.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/form/CheckBox.java	(working copy)
@@ -16,9 +16,11 @@
  */
 package org.apache.wicket.markup.html.form;
 
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
 import org.apache.wicket.util.convert.ConversionException;
 import org.apache.wicket.util.string.StringValueConversionException;
 import org.apache.wicket.util.string.Strings;
@@ -159,18 +161,26 @@
 		// checkbox is clicked?
 		if (wantOnSelectionChangedNotifications())
 		{
-			final CharSequence url = urlFor(IOnChangeListener.INTERFACE);
+			CharSequence url = urlFor(IOnChangeListener.INTERFACE);
 
 			Form form = (Form)findParent(Form.class);
 			if (form != null)
 			{
+				RequestContext rc = RequestContext.get();
+				if (rc.isPortletRequest())
+				{
+					// restore url back to real wicket path as its going to be interpreted by the form itself
+					url = ((PortletRequestContext)rc).getLastEncodedPath();
+				}
 				tag.put("onclick", form.getJsForInterfaceUrl(url));
 			}
 			else
 			{
+				// TODO: following doesn't work with portlets, should be posted to a dynamic hidden form
+				// with an ActionURL or something
 				// NOTE: do not encode the url as that would give invalid
 				// JavaScript
-				tag.put("onclick", "window.location.href='" + url + "&amp;" + getInputName()
+				tag.put("onclick", "window.location.href='" + url + (url.toString().indexOf('?')>-1 ? "&amp;" : "?") + getInputName()
 						+ "=' + this.checked;");
 			}
 
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/AttributeModifier.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/AttributeModifier.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/AttributeModifier.java	(working copy)
@@ -21,6 +21,7 @@
 import org.apache.wicket.markup.parser.XmlTag;
 import org.apache.wicket.model.IComponentAssignedModel;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
 import org.apache.wicket.util.value.IValueMap;
 
 /**
@@ -281,7 +282,7 @@
 						final String newValue = newValue(value, toStringOrNull(replacementValue));
 						if (newValue != null)
 						{
-							attributes.put(attribute, newValue);
+							attributes.put(attribute, getContextRelativeValue(newValue));
 						}
 					}
 				}
@@ -290,12 +291,32 @@
 					final String newValue = newValue(null, toStringOrNull(replacementValue));
 					if (newValue != null)
 					{
-						attributes.put(attribute, newValue);
+						attributes.put(attribute, getContextRelativeValue(newValue));
 					}
 				}
 			}
 		}
 	}
+	
+	protected String getContextRelativeValue(String value)
+	{
+		if ("href".equals(attribute) || "src".equals(attribute))
+		{
+			RequestContext rc = RequestContext.get();
+			if (rc.isPortletRequest() && !(value.startsWith("http://") || value.startsWith("https://")))
+			{
+				if ("href".equals(attribute))
+				{
+					value = ((PortletRequestContext)rc).encodeRenderURL(value).toString();
+				}
+				else
+				{
+					value = ((PortletRequestContext)rc).encodeSharedResourceURL(value).toString();
+				}
+			}
+		}
+		return value;
+	}
 
 	/**
 	 * Sets whether this attribute modifier is enabled or not.
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java	(revision 578013)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestCycle.java	(working copy)
@@ -26,7 +26,6 @@
 import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
 import org.apache.wicket.request.AbstractRequestCycleProcessor;
 import org.apache.wicket.request.ClientInfo;
-import org.apache.wicket.request.IRequestCodingStrategy;
 import org.apache.wicket.request.IRequestCycleProcessor;
 import org.apache.wicket.request.RequestParameters;
 import org.apache.wicket.request.target.component.BookmarkableListenerInterfaceRequestTarget;
@@ -257,6 +256,13 @@
 	protected Response response;
 
 	/**
+	 * Boolean if the next to be encoded url is targetting a new window (ModalWindow, popup, tab).
+	 * This temporary flag is specifically needed for portlet-support as then such a page needs a special target (Resource) url.
+	 * After each urlFor call, this flag is reset to false.
+	 */
+	private transient boolean urlForNewWindowEncoding;
+
+	/**
 	 * Constructor. This instance will be set as the current one for this thread.
 	 * 
 	 * @param application
@@ -666,6 +672,38 @@
 	}
 
 	/**
+	 * @return true if the next to be encoded url is targetting a new window (ModalWindow, popup, tab).
+	 */
+	public final boolean isUrlForNewWindowEncoding()
+	{
+		return urlForNewWindowEncoding;
+	}
+	
+	/**
+	 * Indicate if the next to be encoded url is targetting a new window (ModalWindow, popup, tab).
+	 * This temporary flag is specifically needed for portlet-support as then such a page needs a special target (Resource) url.
+	 * After each urlFor call, this flag is reset to false.
+	 */
+	public final void setUrlForNewWindowEncoding()
+	{
+		urlForNewWindowEncoding = true;
+	}
+	
+	/**
+	 * Returns an encoded URL that references the given request target and clears the urlForNewWindowEncoding flag.
+	 * 
+	 * @param requestTarget
+	 *            the request target to reference
+	 * @return a URL that references the given request target
+	 */
+	private final CharSequence encodeUrlFor(final IRequestTarget requestTarget)
+	{
+		CharSequence url = getProcessor().getRequestCodingStrategy().encode(this, requestTarget);
+		urlForNewWindowEncoding = false;
+		return url;
+	}
+	
+	/**
 	 * Returns a bookmarkable URL that references a given page class using a given set of page
 	 * parameters. Since the URL which is returned contains all information necessary to instantiate
 	 * and render the page, it can be stored in a user's browser as a stable bookmark.
@@ -720,9 +758,7 @@
 
 		final IRequestTarget target = new BehaviorRequestTarget(component.getPage(), component,
 				listener, params);
-		final IRequestCodingStrategy requestCodingStrategy = getProcessor()
-				.getRequestCodingStrategy();
-		return requestCodingStrategy.encode(this, target);
+		return encodeUrlFor(target);
 	}
 
 	/**
@@ -762,9 +798,7 @@
 			// Get the listener interface name
 			target = new ListenerInterfaceRequestTarget(page, component, listener);
 		}
-		final IRequestCodingStrategy requestCodingStrategy = getProcessor()
-				.getRequestCodingStrategy();
-		return requestCodingStrategy.encode(this, target);
+		return encodeUrlFor(target);
 	}
 
 	/**
@@ -786,9 +820,7 @@
 		final IRequestTarget target = new BookmarkablePageRequestTarget(pageMap == null
 				? PageMap.DEFAULT_NAME
 				: pageMap.getName(), pageClass, parameters);
-		final IRequestCodingStrategy requestCodingStrategy = getProcessor()
-				.getRequestCodingStrategy();
-		return requestCodingStrategy.encode(this, target);
+		return encodeUrlFor(target);
 	}
 
 	/**
@@ -800,8 +832,7 @@
 	 */
 	public final CharSequence urlFor(final IRequestTarget requestTarget)
 	{
-		IRequestCodingStrategy requestCodingStrategy = getProcessor().getRequestCodingStrategy();
-		return requestCodingStrategy.encode(this, requestTarget);
+		return encodeUrlFor(requestTarget);
 	}
 
 	/**
@@ -817,7 +848,7 @@
 	{
 		IRequestTarget target = new PageRequestTarget(page);
 		getSession().touch(((IPageRequestTarget)target).getPage());
-		return urlFor(target);
+		return encodeUrlFor(target);
 	}
 
 	/**
@@ -860,9 +891,7 @@
 		}
 
 		requestParameters.setParameters(parameters);
-		CharSequence url = getProcessor().getRequestCodingStrategy().encode(this,
-				new SharedResourceRequestTarget(requestParameters));
-		return url;
+		return encodeUrlFor(new SharedResourceRequestTarget(requestParameters));
 	}
 
 	/**
Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestContext.java
===================================================================
--- jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestContext.java	(revision 0)
+++ jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestContext.java	(revision 0)
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket;
+
+import org.apache.wicket.markup.html.IHeaderResponse;
+
+/**
+ * @author Ate Douma
+ */
+public class RequestContext
+{
+	/** Thread-local that holds the current request context. */
+	private static final ThreadLocal current = new ThreadLocal();
+	
+	public RequestContext()
+	{
+		set(this);
+	}
+	
+	public static final RequestContext get()
+	{
+		RequestContext context = (RequestContext)current.get();
+		if (context == null)
+		{
+			context = new RequestContext();
+		}
+		return context;
+	}
+	
+	protected static final void set(RequestContext context)
+	{
+		current.set(context);
+	}
+
+	public CharSequence getNamespace()
+	{
+		return "";
+	}
+	
+	public String encodeMarkupId(String markupId)
+	{
+		return markupId;
+	}
+	
+	public CharSequence encodeActionURL(CharSequence path)
+	{
+		return path;
+	}
+	
+	public CharSequence encodeRenderURL(CharSequence path)
+	{
+		return path;
+	}
+	
+	public CharSequence encodeResourceURL(CharSequence path)
+	{
+		return path;
+	}
+	
+	public CharSequence encodeSharedResourceURL(CharSequence path)
+	{
+		return path;
+	}
+	
+	public IHeaderResponse getHeaderResponse()
+	{
+		return null;
+	}
+	
+	public boolean isPortletRequest()
+	{
+		return false;
+	}
+}

Property changes on: jdk-1.4/wicket/src/main/java/org/apache/wicket/RequestContext.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.4/wicket/pom.xml
===================================================================
--- jdk-1.4/wicket/pom.xml	(revision 578013)
+++ jdk-1.4/wicket/pom.xml	(working copy)
@@ -39,6 +39,20 @@
 		component model backed by POJO data beans that can easily be 
 		persisted using your favorite technology.
 	</description>
+	<dependencies>
+		<dependency>
+			<groupId>javax.portlet</groupId>
+			<artifactId>portlet-api</artifactId>
+			<scope>provided</scope>
+			<optional>true</optional>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.portals.bridges</groupId>
+			<artifactId>portals-bridges-common</artifactId>
+			<scope>provided</scope>
+			<optional>true</optional>
+		</dependency>
+	</dependencies>
 	<build>
 		<plugins>
 			<plugin>
Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java	(revision 0)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java	(revision 0)
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.examples.portlet.menu;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * @author Ate Douma
+ */
+public class ExampleApplication implements Serializable
+{
+	private final String displayName;
+	private final String filterPath;
+	private final String filterQuery;
+	private final Map initParameters;
+	private final String description;
+	
+	public ExampleApplication(String displayName, String filterPath, String filterQuery, Map initParameters, String description)
+	{
+		this.displayName = displayName;
+		this.filterPath = filterPath;
+		this.filterQuery = filterQuery;
+		this.initParameters = initParameters;
+		this.description = description;
+	}
+
+	/**
+	 * Gets displayName.
+	 * @return displayName
+	 */
+	public String getDisplayName()
+	{
+		return displayName;
+	}
+
+	/**
+	 * Gets description.
+	 * @return description
+	 */
+	public String getDescription()
+	{
+		return description;
+	}
+
+	/**
+	 * Gets filterPath.
+	 * @return filterPath
+	 */
+	public String getFilterPath()
+	{
+		return filterPath;
+	}
+
+	/**
+	 * Gets filterQuery.
+	 * @return filterQuery
+	 */
+	public String getFilterQuery()
+	{
+		return filterQuery;
+	}
+
+	/**
+	 * Gets initParameter.
+	 * @param name initParameter name
+	 * @return initParameter
+	 */
+	public String getInitParameter(String name)
+	{
+		return (String)initParameters.get(name);
+	}
+	
+	
+}

Property changes on: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java	(revision 0)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java	(revision 0)
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.examples.portlet.menu;
+
+import javax.portlet.PortletSession;
+
+import org.apache.wicket.RequestContext;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.list.Loop;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
+
+/**
+ * @author ate
+ */
+public class MenuPage extends WebPage
+{
+	public MenuPage()
+	{
+		add(new Loop("examples", WicketExamplesMenuApplication.getExamples().size()-1)
+		{
+			
+			@Override
+			protected void populateItem(LoopItem item)
+			{
+				final int index = item.getIteration();
+				ExampleApplication ea = (ExampleApplication)WicketExamplesMenuApplication.getExamples().get(index+1);
+				Link link = new Link("example")
+				{
+					@Override
+					public void onClick()
+					{
+						int index = ((LoopItem)getParent()).getIteration();
+						ExampleApplication ea = (ExampleApplication)WicketExamplesMenuApplication.getExamples().get(index+1);
+						PortletSession session = ((PortletRequestContext)RequestContext.get()).getPortletRequest().getPortletSession();
+						session.setAttribute(WicketExamplesMenuPortlet.EXAMPLE_APPLICATION_ATTR, ea);
+					}
+				};
+				link.add(new Label("name", ea.getDisplayName()));
+				item.add(link);
+				item.add(new Label("description", ea.getDescription()));
+			}
+		});
+	}
+}

Property changes on: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java	(revision 0)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java	(revision 0)
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.examples.portlet.menu;
+
+import java.util.List;
+
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+
+import org.apache.wicket.RequestContext;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Button;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.IChoiceRenderer;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
+
+/**
+ * @author Ate Douma
+ */
+public class EditPage extends WebPage
+{
+	private static final IChoiceRenderer exampleChoiceRenderer = new IChoiceRenderer()
+	{
+		/**
+		 * @see org.apache.wicket.markup.html.form.IChoiceRenderer#getDisplayValue(java.lang.Object)
+		 */
+		public Object getDisplayValue(Object object)
+		{
+			return ((ExampleApplication)object).getDisplayName();
+		}
+
+		/**
+		 * @see org.apache.wicket.markup.html.form.IChoiceRenderer#getIdValue(java.lang.Object, int)
+		 */
+		public String getIdValue(Object object, int index)
+		{
+			return Integer.toString(index);
+		}
+	};
+	
+	private DropDownChoice ddc;
+	
+	public EditPage()
+	{
+		Form form = new Form("form")
+		{
+			/**
+			 * @see org.apache.wicket.markup.html.form.Form#onSubmit()
+			 */
+			@Override
+			protected void onSubmit()
+			{
+				ExampleApplication selected = (ExampleApplication)ddc.getModelObject();
+				PortletRequestContext prc = (PortletRequestContext)RequestContext.get();
+				PortletPreferences prefs = prc.getPortletRequest().getPreferences();				
+				prc.getPortletRequest().getPortletSession().setAttribute(WicketExamplesMenuPortlet.EXAMPLE_APPLICATION_ATTR, selected);
+				try
+				{
+					((ActionResponse)prc.getPortletResponse()).setPortletMode(PortletMode.VIEW);
+					prefs.setValue(WicketExamplesMenuPortlet.EXAMPLE_APPLICATION_PREF,selected.getFilterPath());
+					prefs.store();
+				}
+				catch (Exception pe)
+				{
+					throw new RuntimeException(pe);
+				}
+			}			
+		};
+		List examples = WicketExamplesMenuApplication.getExamples();
+		ddc = new DropDownChoice("examples", examples, exampleChoiceRenderer);
+		ddc.setNullValid(false);
+		PortletRequestContext prc = (PortletRequestContext)RequestContext.get();
+		String eaFilterPath = prc.getPortletRequest().getPreferences().getValue(WicketExamplesMenuPortlet.EXAMPLE_APPLICATION_PREF, null);
+		Model selected = new Model((ExampleApplication)examples.get(0));
+		if (eaFilterPath != null)
+		{
+			for (int i = 0, size = examples.size(); i < size; i++)
+			{
+				if (((ExampleApplication)examples.get(i)).getFilterPath().equals(eaFilterPath))
+				{
+					selected.setObject((ExampleApplication)examples.get(i));
+					break;
+				}
+			}
+		}		
+		ddc.setModel(selected);
+		form.add(ddc);
+		form.add(new Button("setButton"));
+		add(form);
+	}
+	
+}

Property changes on: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html	(revision 0)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html	(revision 0)
@@ -0,0 +1,21 @@
+<html xmlns:wicket="http://wicket.apache.org/">
+  <head>
+    <link rel="stylesheet" type="text/css" href="style.css" />
+  </head>
+	<body>
+    <p>
+	<h1>Wicket Portlet Examples</h1>
+    <p id="titleblock">
+        <b><font size="+1">menu</font></b>
+    </p>
+    <p>
+      The following examples demonstrate both core functionality and also functionality in other modules (e.g. wicket-extensions):
+    </p>
+	<table>
+      <tr wicket:id="examples">
+        <td align="right"><a style="color: #E9601A" wicket:id="example"><span wicket:id="name">[name]</span></a></td>
+        <td> - <span wicket:id="description">[description]</span></td>
+      </tr>
+    </table>
+  </body>
+</html>

Property changes on: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuPortlet.java
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuPortlet.java	(revision 0)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuPortlet.java	(revision 0)
@@ -0,0 +1,309 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.examples.portlet.menu;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletSession;
+
+import org.apache.wicket.markup.parser.XmlPullParser;
+import org.apache.wicket.markup.parser.XmlTag;
+import org.apache.wicket.protocol.http.portlet.WicketPortlet;
+
+/**
+ * @author Ate Douma
+ */
+public class WicketExamplesMenuPortlet extends WicketPortlet
+{
+	public static final String EXAMPLE_APPLICATION_PREF = "exampleApplication";
+	public static final String EXAMPLES = WicketExamplesMenuPortlet.class.getName() + ".examples";
+	public static final String EXAMPLE_APPLICATION_ATTR = WicketExamplesMenuPortlet.class.getName() + "." + EXAMPLE_APPLICATION_PREF;
+	private static final String MENU_APPLICATION_URL_PORTLET_PARAMETER = "_wmu";
+	private static final String PROCESS_MENU_APPLICATION = WicketExamplesMenuPortlet.class.getName() + ".processMenuApplication";
+	private static final String PROCESS_HEADER_PAGE = WicketExamplesMenuPortlet.class.getName() + ".renderHeaderPage";
+    /**
+     * Name of portlet init Parameter for the ExampleHeader page
+     */
+    public static final String PARAM_HEADER_PAGE = "headerPage";
+	
+	private static List examples;
+	
+	/**
+	 * @see org.apache.wicket.protocol.http.portlet.WicketPortlet#init(javax.portlet.PortletConfig)
+	 */
+	@Override
+	public void init(PortletConfig config) throws PortletException
+	{
+		super.init(config);
+		if (examples == null)
+		{
+			examples = discoverExamples(config.getPortletContext());
+			if (examples == null)
+			{
+				examples = Collections.EMPTY_LIST;
+			}
+			else
+			{
+				examples = Collections.unmodifiableList(examples);
+			}
+			config.getPortletContext().setAttribute(EXAMPLES, examples);
+		}
+	}
+
+	/**
+	 * @see org.apache.wicket.protocol.http.portlet.WicketPortlet#getWicketConfigParameter(javax.portlet.PortletRequest, java.lang.String, java.lang.String)
+	 */
+	@Override
+	protected String getWicketConfigParameter(PortletRequest request, String paramName, String defaultValue)
+	{
+		if (paramName.equals(WICKET_FILTER_PATH))
+		{
+			return ((ExampleApplication)request.getAttribute(EXAMPLE_APPLICATION_ATTR)).getFilterPath();
+		}
+		else if (paramName.equals(WICKET_FILTER_QUERY))
+		{
+			return ((ExampleApplication)request.getAttribute(EXAMPLE_APPLICATION_ATTR)).getFilterQuery();
+		}
+		return super.getWicketConfigParameter(request, paramName, defaultValue);
+	}
+
+	/**
+	 * @see org.apache.wicket.protocol.http.portlet.WicketPortlet#getWicketUrlPortletParameter(javax.portlet.PortletRequest)
+	 */
+	@Override
+	protected String getWicketUrlPortletParameter(PortletRequest request)
+	{
+		return request.getAttribute(PROCESS_MENU_APPLICATION) != null ? MENU_APPLICATION_URL_PORTLET_PARAMETER : super.getWicketUrlPortletParameter(request);
+	}
+	
+	/**
+	 * @see org.apache.wicket.protocol.http.portlet.WicketPortlet#getWicketURL(javax.portlet.PortletRequest, java.lang.String, java.lang.String)
+	 */
+	@Override
+	protected String getWicketURL(PortletRequest request, String pageType, String defaultPage)
+	{		
+		ExampleApplication ea = (ExampleApplication)request.getAttribute(EXAMPLE_APPLICATION_ATTR);
+		if (request.getAttribute(PROCESS_HEADER_PAGE) != null)
+		{
+			return ea.getInitParameter(PARAM_HEADER_PAGE);				
+		}
+		return super.getWicketURL(request, pageType, ea.getInitParameter(pageType));
+	}
+
+	/**
+	 * @see org.apache.wicket.protocol.http.portlet.WicketPortlet#processRequest(javax.portlet.PortletRequest, javax.portlet.PortletResponse, java.lang.String, java.lang.String, java.lang.String)
+	 */
+	@Override
+	protected void processRequest(PortletRequest request, PortletResponse response, String requestType, String pageType) throws PortletException, IOException
+	{
+		PortletSession session = request.getPortletSession();
+		ExampleApplication ea = (ExampleApplication)session.getAttribute(EXAMPLE_APPLICATION_ATTR);
+		if (ea == null)
+		{
+			String eaFilterPath = request.getPreferences().getValue(EXAMPLE_APPLICATION_PREF, null);
+			if (eaFilterPath != null)
+			{
+				Iterator iter = examples.iterator();
+				while (iter.hasNext())
+				{
+					ea = (ExampleApplication)iter.next();
+					if (ea.getFilterPath().equals(eaFilterPath))
+					{
+						break;
+					}
+					ea = null;
+				}
+			}
+			if (ea == null && examples.size() > 0)
+			{
+				ea = (ExampleApplication)examples.get(0);
+			}
+			session.setAttribute(EXAMPLE_APPLICATION_ATTR, ea);
+		}
+		if (ea == null || ea.getFilterPath().equals(getWicketFilterPath()) || !PortletMode.VIEW.equals(request.getPortletMode()))
+		{
+			request.setAttribute(PROCESS_MENU_APPLICATION, Boolean.TRUE);
+			request.setAttribute(EXAMPLE_APPLICATION_ATTR, examples.get(0));
+			super.processRequest(request, response, requestType, pageType);
+		}
+		else
+		{
+			if (WicketPortlet.ACTION_REQUEST.equals(requestType) || request.getParameter(PORTLET_RESOURCE_URL_PARAMETER) != null)
+			{
+				if (request.getParameter(MENU_APPLICATION_URL_PORTLET_PARAMETER) != null)
+				{
+					request.setAttribute(PROCESS_MENU_APPLICATION, Boolean.TRUE);
+					request.setAttribute(EXAMPLE_APPLICATION_ATTR, examples.get(0));
+					super.processRequest(request, response, requestType, pageType);
+				}
+				else
+				{
+					request.setAttribute(EXAMPLE_APPLICATION_ATTR, ea);
+					super.processRequest(request, response, requestType, pageType);
+				}
+			}
+			else
+			{
+				request.setAttribute(PROCESS_MENU_APPLICATION, Boolean.TRUE);
+				request.setAttribute(PROCESS_HEADER_PAGE, Boolean.TRUE);
+				request.setAttribute(EXAMPLE_APPLICATION_ATTR, examples.get(0));
+				super.processRequest(request, response, requestType, pageType);
+				request.removeAttribute(PROCESS_MENU_APPLICATION);
+				request.removeAttribute(PROCESS_HEADER_PAGE);
+				request.setAttribute(EXAMPLE_APPLICATION_ATTR, ea);
+				super.processRequest(request, response, requestType, pageType);
+			}
+		}
+	}
+	
+	protected List discoverExamples(PortletContext portletContext)
+	{		
+		ArrayList examples = new ArrayList();
+		InputStream is = portletContext.getResourceAsStream("/WEB-INF/portlet.xml");
+		if (is != null)
+		{
+			try
+			{
+				XmlPullParser parser = new XmlPullParser();
+				parser.parse(is);
+				while (true)
+				{
+					XmlTag elem;
+					String name;
+					int level;
+					
+					do
+					{
+						elem = (XmlTag)parser.nextTag();
+					}
+					while (elem != null && (!(elem.getName().equals("portlet") && elem.isOpen())));
+
+					if (elem == null)
+					{
+						break;
+					}
+
+					String description = null;
+					String filterPath = null;
+					String filterQuery = null;
+					String displayName = null;
+					HashMap initParameters = new HashMap();
+					
+					level = 0;
+					
+					do
+					{
+						elem = (XmlTag)parser.nextTag();
+						name = elem.getName();
+						level = elem.isOpen() ? (level+1) : (level-1);
+						
+						if (level == 1)
+						{
+							if (name.equals("description")||name.equals("display-name"))
+							{
+								parser.setPositionMarker();
+							}
+							
+							else if (name.equals("init-param"))
+							{
+								String initParamName = null;
+								String initParamValue = null;
+								do
+								{
+									elem = (XmlTag)parser.nextTag();
+									name = elem.getName();
+									level = elem.isOpen() ? (level+1) : (level-1);
+									if (level == 2)
+									{
+										if (name.equals("name")||name.equals("value"))
+										{
+											parser.setPositionMarker();
+										}
+									}
+									else if (level == 1)
+									{
+										if (name.equals("name"))
+										{
+											initParamName = parser.getInputFromPositionMarker(elem.getPos()).toString();
+										}
+										else if (name.equals("value"))
+										{
+											initParamValue = parser.getInputFromPositionMarker(elem.getPos()).toString();
+										}
+									}
+								}
+								while (level > 0);
+								if (initParamName != null && initParamValue != null)
+								{
+									initParameters.put(initParamName, initParamValue);
+								}
+							}
+						}
+						else if (level == 0)
+						{							
+							if (name.equals("description"))
+							{
+								description = parser.getInputFromPositionMarker(elem.getPos()).toString();
+							}
+							else if (name.equals("display-name"))
+							{
+								displayName = parser.getInputFromPositionMarker(elem.getPos()).toString();
+							}
+						}
+					}
+					while (level > -1);
+					filterPath = buildWicketFilterPath((String)initParameters.get(WICKET_FILTER_PATH_PARAM));					
+					if (displayName != null && filterPath != null && description != null)
+					{
+						filterQuery = buildWicketFilterQuery(filterPath);
+						validateDefaultPages(initParameters, filterPath, filterQuery);
+						ExampleApplication exampleApplication = new ExampleApplication(displayName, filterPath, filterQuery, initParameters, description);
+						if (exampleApplication.getFilterPath().equals(getWicketFilterPath()))
+						{
+							examples.add(0, exampleApplication);
+						}
+						else
+						{
+							examples.add(exampleApplication);
+						}
+					}
+				}
+			}
+			catch (RuntimeException e)
+			{
+				throw e;
+			}
+			catch (Exception e)
+			{
+				throw new RuntimeException(e);
+			}
+		}
+		return examples;
+	}
+}

Property changes on: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuPortlet.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html	(revision 0)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html	(revision 0)
@@ -0,0 +1,15 @@
+<html xmlns:wicket="http://wicket.apache.org/">
+  <head>
+    <link rel="stylesheet" type="text/css" href="style.css"/>
+  </head>
+  <body>
+    <form wicket:id="form">
+      <p>
+        Select the default Wicket Example to display: <select wicket:id="examples"/>
+      </p>
+      <p>
+        <input type="submit" wicket:id="setButton" value="set"/>
+      </p>
+    </form>    
+  </body>
+</html>

Property changes on: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java	(revision 0)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java	(revision 0)
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.examples.portlet.menu;
+
+import javax.portlet.PortletSession;
+
+import org.apache.wicket.RequestContext;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
+
+/**
+ * @author Ate Douma
+ */
+public class HeaderPage extends WebPage
+{
+	public HeaderPage()
+	{
+		add(new Link("menu")
+		{
+			@Override
+			public void onClick()
+			{
+				this.setResponsePage(MenuPage.class);
+				ExampleApplication ea = (ExampleApplication)WicketExamplesMenuApplication.getExamples().get(0);
+				PortletSession session = ((PortletRequestContext)RequestContext.get()).getPortletRequest().getPortletSession();
+				session.setAttribute(WicketExamplesMenuPortlet.EXAMPLE_APPLICATION_ATTR, ea);
+			}
+		});
+	}
+}

Property changes on: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html	(revision 0)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html	(revision 0)
@@ -0,0 +1,9 @@
+<html xmlns:wicket="http://wicket.apache.org/">
+  <head>
+    <link rel="stylesheet" type="text/css" href="style.css"/>
+  </head>
+  <body>
+    <h1>
+      <a style="color: #E9601A" wicket:id="menu">Wicket Examples</a></h1>
+  </body>
+</html>

Property changes on: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java	(revision 0)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java	(revision 0)
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.wicket.examples.portlet.menu;
+
+import java.util.Collections;
+import java.util.List;
+
+import javax.portlet.PortletMode;
+import javax.servlet.ServletContext;
+
+import org.apache.wicket.RequestContext;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
+
+/**
+ * @author Ate Douma
+ */
+public class WicketExamplesMenuApplication extends WebApplication
+{
+	private static List examples;
+	private static ServletContext servletContext;
+
+	public static List getExamples()
+	{		
+		if (examples == null)
+		{
+			examples = (List)servletContext.getAttribute(WicketExamplesMenuPortlet.EXAMPLES);
+		}
+		return examples != null ? examples : Collections.EMPTY_LIST;
+	}
+	
+	/**
+	 * @see org.apache.wicket.Application#getHomePage()
+	 */
+	@Override
+	public Class getHomePage()
+	{
+		PortletRequestContext prc = (PortletRequestContext)RequestContext.get();
+		if (PortletMode.EDIT.equals(prc.getPortletRequest().getPortletMode()))
+		{
+			return EditPage.class;
+		}
+		return MenuPage.class;
+	}
+	
+	/**
+	 * @see org.apache.wicket.protocol.http.WebApplication#init()
+	 */
+	@Override
+	protected void init()
+	{
+		mountBookmarkablePage("/menu", MenuPage.class);
+		mountBookmarkablePage("/header", HeaderPage.class);
+		mountBookmarkablePage("/edit", EditPage.class);
+		servletContext = getWicketFilter().getFilterConfig().getServletContext();
+	}
+
+}

Property changes on: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.html
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.html	(revision 578013)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.html	(working copy)
@@ -11,8 +11,10 @@
 </head>
 <body>
 <span wicket:id="mainNavigation" />
+<form wicket:id="localeForm">
 <p><select wicket:id="localeSelect" /> [<a href="#"
 	wicket:id="localeUSLink">set to english</a>]</p>
+</form>
 <p>
 <form wicket:id="form"><input type="text"
 	wicket:id="dateTextField" /> <input type="submit" value="submit" /></form>
Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.java
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.java	(revision 578013)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.java	(working copy)
@@ -138,7 +138,17 @@
 	public DatesPage()
 	{
 		selectedLocale = Session.get().getLocale();
-		add(new LocaleDropDownChoice("localeSelect"));
+		Form localeForm = new Form("localeForm");		
+		localeForm.add(new LocaleDropDownChoice("localeSelect"));
+		localeForm.add(new Link("localeUSLink")
+		{
+			@Override
+			public void onClick()
+			{
+				selectedLocale = LOCALE_EN;
+			}
+		});
+		add(localeForm);
 		DateTextField dateTextField = new DateTextField("dateTextField", new PropertyModel(this,
 				"date"), new StyleDateConverter("S-", true))
 		{
@@ -148,14 +158,6 @@
 				return selectedLocale;
 			}
 		};
-		add(new Link("localeUSLink")
-		{
-			@Override
-			public void onClick()
-			{
-				selectedLocale = LOCALE_EN;
-			}
-		});
 		Form form = new Form("form")
 		{
 			@Override
Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.html
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.html	(revision 578013)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.html	(working copy)
@@ -1,12 +1,13 @@
 <html xmlns:wicket>
 <body>
   <wicket:panel>
-    <h1><span wicket:id="inspector"/><a href="index.html" style="color: #E9601A" target="_top">Wicket Examples</a></h1>	
-    <div id="titleblock" style="font-size:larger;height:1.5em;vertical-align:center;">
+    <h1 wicket:id="hideInPortlet"><a href="index.html" style="color: #E9601A" target="_top">Wicket Examples</a></h1>	
+      <span wicket:id="inspector"/>
+      <div id="titleblock" style="font-size:larger;height:1.5em;vertical-align:center;">
         <div style="float:left;"><span wicket:id="exampleTitle">Example Title Goes Here</span></div>
-	    <div style="float:right;padding-right:10px"><a href="#" wicket:id="sources">Source code</a></div>
+	      <div style="float:right;padding-right:10px"><a href="#" wicket:id="sources">Source code</a></div>
     </div>
     <br/>
   </wicket:panel>
 </body>
-</html>
+</html>
\ No newline at end of file
Index: jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.java
===================================================================
--- jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.java	(revision 578013)
+++ jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.java	(working copy)
@@ -17,8 +17,10 @@
 package org.apache.wicket.examples;
 
 import org.apache.wicket.PageMap;
+import org.apache.wicket.RequestContext;
 import org.apache.wicket.examples.debug.InspectorBug;
 import org.apache.wicket.examples.source.SourcesPage;
+import org.apache.wicket.markup.html.WebMarkupContainer;
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.link.Link;
@@ -46,6 +48,17 @@
 	public WicketExampleHeader(String id, String exampleTitle, WebPage page)
 	{
 		super(id);
+		add(new WebMarkupContainer("hideInPortlet")
+		{
+			/**
+			 * @see org.apache.wicket.Component#isVisible()
+			 */
+			@Override
+			public boolean isVisible()
+			{
+				return !RequestContext.get().isPortletRequest();
+			}
+		});		
 		add(new InspectorBug("inspector", page));
 		add(new Label("exampleTitle", exampleTitle));
 		Link link = new Link("sources")
Index: jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/portlet.xml	(revision 0)
+++ jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/portlet.xml	(revision 0)
@@ -0,0 +1,688 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.
+-->
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
+  <portlet>
+    <description>Menu to the available Wicket portlet examples</description>
+    <portlet-name>WicketExamplesMenuApplication</portlet-name>
+    <display-name>wicket examples</display-name>
+    <portlet-class>org.apache.wicket.examples.portlet.menu.WicketExamplesMenuPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/examples</value>
+    </init-param>
+    <init-param>
+      <name>viewPage</name>
+      <value>/examples/menu</value>
+    </init-param>
+    <init-param>
+      <name>editPage</name>
+      <value>/examples/edit</value>
+    </init-param>
+    <init-param>
+      <name>headerPage</name>
+      <value>/examples/header</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+      <portlet-mode>EDIT</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Portlet Examples</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>As simple as it gets.</description>
+    <portlet-name>HelloWorldApplication</portlet-name>
+    <display-name>helloworld</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/helloworld</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket HelloWorld Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Trivial input form.</description>
+    <portlet-name>EchoApplication</portlet-name>
+    <display-name>echo</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/echo</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Echo Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Basic form processing.</description>
+    <portlet-name>FormInputApplication</portlet-name>
+    <display-name>forminput</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/forminput</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket FormInput Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Component Reference.</description>
+    <portlet-name>ComponentReferenceApplication</portlet-name>
+    <display-name>compref</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/compref</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket ComponentReference Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Various kinds of images.</description>
+    <portlet-name>ImagesApplication</portlet-name>
+    <display-name>images</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/images</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Images Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Different kinds of links.</description>
+    <portlet-name>LinkomaticApplication</portlet-name>
+    <display-name>linkomatic</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/linkomatic</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Linkomatic Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Page navigation</description>
+    <portlet-name>NavomaticApplication</portlet-name>
+    <display-name>navomatic</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/navomatic</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Navomatic Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Localization.</description>
+    <portlet-name>PubApplication</portlet-name>
+    <display-name>pub</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/pub</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Pub Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Converts input using some model magic.</description>
+    <portlet-name>UnicodeConverterApplication</portlet-name>
+    <display-name>unicode converter</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/unicodeconverter</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket UnicodeConverter Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Demonstrates the use of "nice" URLs.</description>
+    <portlet-name>NiceUrlApplication</portlet-name>
+    <display-name>niceurl</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/niceurl</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket NiceUrl Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Examples using wicket's built-in AJAX.</description>
+    <portlet-name>AjaxApplication</portlet-name>
+    <display-name>ajax</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/ajax</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Ajax Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Trees and nested lists.</description>
+    <portlet-name>NestedApplication</portlet-name>
+    <display-name>nested</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/nested</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Nested Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>DataView, DataTable, GridView component examples.</description>
+    <portlet-name>RepeaterExamplesApplication</portlet-name>
+    <display-name>repeaters</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/repeater</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Repeaters Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>A simple sign-in page.</description>
+    <portlet-name>SignInApplication</portlet-name>
+    <display-name>signin</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/signin</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket SignIn Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>An advanced sign-in page (using cookies).</description>
+    <portlet-name>SignIn2Application</portlet-name>
+    <display-name>signin2</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/signin2</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket SignIn2 Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Single file upload.</description>
+    <portlet-name>UploadSingleApplication</portlet-name>
+    <display-name>upload single</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/upload</value>
+    </init-param>
+    <init-param>
+      <name>viewPage</name>
+      <value>/upload/single</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket UploadSingle Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Multiple file upload.</description>
+    <portlet-name>UploadMultiApplication</portlet-name>
+    <display-name>upload multi</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/upload</value>
+    </init-param>
+    <init-param>
+      <name>viewPage</name>
+      <value>/upload/multi</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket UploadMulti Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Templating example.</description>
+    <portlet-name>TemplateApplication</portlet-name>
+    <display-name>template</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/template</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Template Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Demonstrates stateless pages/sessions.</description>
+    <portlet-name>StatelessApplication</portlet-name>
+    <display-name>stateless</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/stateless</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Stateless Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Examples for serving static files.</description>
+    <portlet-name>StaticPagesApplication</portlet-name>
+    <display-name>staticpages</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/staticpages</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket StaticPages Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Browser snooper.</description>
+    <portlet-name>HelloBrowserApplication</portlet-name>
+    <display-name>hellobrowser</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/hellobrowser</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket HelloBrowser Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Demonstrates the wizard component.</description>
+    <portlet-name>WizardApplication</portlet-name>
+    <display-name>abacadabra</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/wizard</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Wizard Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Demonstrates custom template loading.</description>
+    <portlet-name>CustomResourceLoadingApplication</portlet-name>
+    <display-name>custom template loading</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/customresourceloading</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket CustomResourceLoading Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Don't get lost, use bread-crumbs.</description>
+    <portlet-name>BreadCrumbApplication</portlet-name>
+    <display-name>breadcrumb</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/breadcrumb</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket BreadCrumb Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Image-based "captcha" to distinguish humans from spammers.</description>
+    <portlet-name>CaptchaApplication</portlet-name>
+    <display-name>captcha</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/captcha</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Captcha Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Demonstrates authentication for pages.</description>
+    <portlet-name>MyAuthenticatedWebApplication</portlet-name>
+    <display-name>authentication</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/authentication</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Authentication Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Demonstrates authorization for pages and components.</description>
+    <portlet-name>RolesAuthApplication</portlet-name>
+    <display-name>authorization</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/authorization</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Authorization Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Date component example from the wicket-date project.</description>
+    <portlet-name>DatesApplication</portlet-name>
+    <display-name>dates</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/dates</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Dates Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Stock quote example.</description>
+    <portlet-name>StockQuoteApplication</portlet-name>
+    <display-name>stockquote</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/stock</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket StockQuote Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>A blog-like multi-user guestbook.</description>
+    <portlet-name>GuestBookApplication</portlet-name>
+    <display-name>guestbook</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/guestbook</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket GuestBook Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>The game of hangman.</description>
+    <portlet-name>HangmanApplication</portlet-name>
+    <display-name>hangman</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/hangman</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Hangman Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>A simple application.</description>
+    <portlet-name>LibraryApplication</portlet-name>
+    <display-name>library</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/library</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Library Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Demonstrates integration options with the Spring framework.</description>
+    <portlet-name>SpringExample</portlet-name>
+    <display-name>spring</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/spring</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Spring Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Integration with the Google Guice IoC container.</description>
+    <portlet-name>GuiceApplication</portlet-name>
+    <display-name>guice</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/guice</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket Quice Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+  <portlet>
+    <description>Shows a Velocity panel in action.</description>
+    <portlet-name>VelocityTemplateApplication</portlet-name>
+    <display-name>velocity</display-name>
+    <portlet-class>org.apache.wicket.protocol.http.portlet.WicketPortlet</portlet-class>
+    <init-param>
+      <name>wicketFilterPath</name>
+      <value>/velocity</value>
+    </init-param>
+    <supports>
+      <mime-type>*/*</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <portlet-info>
+      <title>Wicket VelocityTemplate Example</title>
+      <keywords>Wicket</keywords>
+    </portlet-info>
+  </portlet>
+</portlet-app>
\ No newline at end of file

Property changes on: jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/portlet.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml
===================================================================
--- jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml	(revision 578013)
+++ jdk-1.5/wicket-examples/src/main/webapp/WEB-INF/web.xml	(working copy)
@@ -15,12 +15,11 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
-<!DOCTYPE web-app
-	  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
-	  "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
 
-<web-app>
-
 	<display-name>Wicket Examples</display-name>
 	
 	<!-- only available with servlet spec. 2.4 
@@ -52,6 +51,19 @@
 	</context-param>
 
 	<filter>
+		<filter-name>WicketExamplesMenuApplication</filter-name>
+		<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
+		<init-param>
+            <param-name>applicationClassName</param-name>
+            <param-value>org.apache.wicket.examples.portlet.menu.WicketExamplesMenuApplication</param-value>
+		</init-param>
+		<init-param>
+            <param-name>portletOnlyFilter</param-name>
+            <param-value>true</param-value>
+		</init-param>
+	</filter>
+
+	<filter>
 		<filter-name>AjaxPrototypeApplication</filter-name>
 		<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
 		<init-param>
@@ -399,15 +411,26 @@
 		</init-param>
 	</filter>
 
+	<filter-mapping>
+		<filter-name>WicketExamplesMenuApplication</filter-name>
+        <url-pattern>/examples/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
+	</filter-mapping>
+
 	<!-- couple the session filter to the helloworld servlet -->
 	<filter-mapping>
 		<filter-name>WicketSessionFilter</filter-name>
 		<url-pattern>/helloworldservlet/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>AjaxApplication</filter-name>
 		<url-pattern>/ajax/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
@@ -418,111 +441,155 @@
 	<filter-mapping>
 		<filter-name>RepeaterExamplesApplication</filter-name>
 		<url-pattern>/repeater/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>NiceUrlApplication</filter-name>
 		<url-pattern>/niceurl/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>	
 
 	<filter-mapping>
 		<filter-name>SignInApplication</filter-name>
 		<url-pattern>/signin/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
     <filter-mapping>
         <filter-name>StockQuoteApplication</filter-name>
         <url-pattern>/stock/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
     </filter-mapping>
     
 	<filter-mapping>
 		<filter-name>SignIn2Application</filter-name>
 		<url-pattern>/signin2/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>HangmanApplication</filter-name>
 		<url-pattern>/hangman/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>NestedApplication</filter-name>
 		<url-pattern>/nested/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 	 
 	<filter-mapping>
 		<filter-name>PubApplication</filter-name>
 		<url-pattern>/pub/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>NavomaticApplication</filter-name>
 		<url-pattern>/navomatic/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>LinkomaticApplication</filter-name>
 		<url-pattern>/linkomatic/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>LibraryApplication</filter-name>
 		<url-pattern>/library/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>ImagesApplication</filter-name>
 		<url-pattern>/images/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>HelloWorldApplication</filter-name>
 		<url-pattern>/helloworld/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>EchoApplication</filter-name>
 		<url-pattern>/echo/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>UnicodeConverterApplication</filter-name>
 		<url-pattern>/unicodeconverter/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 	
 	<filter-mapping>
 		<filter-name>HelloBrowserApplication</filter-name>
 		<url-pattern>/hellobrowser/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>FormInputApplication</filter-name>
 		<url-pattern>/forminput/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>GuestBookApplication</filter-name>
 		<url-pattern>/guestbook/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>UploadApplication</filter-name>
 		<url-pattern>/upload/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>EncodingsApplication</filter-name>
 		<url-pattern>/encodings/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>TemplateApplication</filter-name>
 		<url-pattern>/template/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>ComponentReferenceApplication</filter-name>
 		<url-pattern>/compref/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
@@ -533,61 +600,85 @@
 	<filter-mapping>
 		<filter-name>CustomResourceLoadingApplication</filter-name>
 		<url-pattern>/customresourceloading/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>WizardApplication</filter-name>
 		<url-pattern>/wizard/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>CaptchaApplication</filter-name>
 		<url-pattern>/captcha/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>BreadCrumbApplication</filter-name>
 		<url-pattern>/breadcrumb/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>StatelessApplication</filter-name>
 		<url-pattern>/stateless/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>StaticPagesApplication</filter-name>
 		<url-pattern>/staticpages/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>RolesAuthApplication</filter-name>
 		<url-pattern>/authorization/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>MyAuthenticatedWebApplication</filter-name>
 		<url-pattern>/authentication/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>SpringExample</filter-name>
         <url-pattern>/spring/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>GuiceApplication</filter-name>
         <url-pattern>/guice/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<filter-mapping>
 		<filter-name>VelocityTemplateApplication</filter-name>
         <url-pattern>/velocity/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>	
 
 	<filter-mapping>
 		<filter-name>DatesApplication</filter-name>
         <url-pattern>/dates/*</url-pattern>
+        <dispatcher>REQUEST</dispatcher>
+        <dispatcher>INCLUDE</dispatcher>
 	</filter-mapping>
 
 	<listener>
Index: jdk-1.5/wicket-examples/pom.xml
===================================================================
--- jdk-1.5/wicket-examples/pom.xml	(revision 578013)
+++ jdk-1.5/wicket-examples/pom.xml	(working copy)
@@ -104,6 +104,11 @@
 			<groupId>org.slf4j</groupId>
 			<artifactId>slf4j-log4j12</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>javax.portlet</groupId>
+			<artifactId>portlet-api</artifactId>
+			<scope>provided</scope>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>
Index: pom.xml
===================================================================
--- pom.xml	(revision 578013)
+++ pom.xml	(working copy)
@@ -421,6 +421,20 @@
 				<version>1.4-rc3</version>
 				<scope>test</scope>
 			</dependency>
+			<dependency>
+				<groupId>javax.portlet</groupId>
+				<artifactId>portlet-api</artifactId>
+				<version>1.0</version>
+				<scope>provided</scope>
+				<optional>true</optional>
+			</dependency>
+			<dependency>
+				<groupId>org.apache.portals.bridges</groupId>
+				<artifactId>portals-bridges-common</artifactId>
+				<version>1.0.3</version>
+				<scope>provided</scope>
+				<optional>true</optional>
+			</dependency>
 		</dependencies>
 	</dependencyManagement>
 	<dependencies>
