You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by at...@apache.org on 2007/09/25 12:21:44 UTC

svn commit: r579172 [2/3] - in /wicket/trunk: ./ jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ jdk-1.4/wicket/ jdk-1.4/wicket/src/main/java/org/apache/wicket/ jdk-1.4/wicket/src/main/java/org/apache/wicket...

Added: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java Tue Sep 25 03:21:35 2007
@@ -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);
+    }
+}

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java Tue Sep 25 03:21:35 2007
@@ -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);
+	}
+}

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java Tue Sep 25 03:21:35 2007
@@ -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);
+    }
+}

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketFilterPortletContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java Tue Sep 25 03:21:35 2007
@@ -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());
+			}
+		}
+	}
+}

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketPortlet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java Tue Sep 25 03:21:35 2007
@@ -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;
+	}
+}

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/WicketResponseState.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java Tue Sep 25 03:21:35 2007
@@ -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);
-		}
-		// fallthough for non-default request targets
-		else
-		{
-			url = doEncode(requestCycle, 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);
+			}
 		}
 
 		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());
-
-			// 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)
+			String result = null;
+			
+			if (!sharedResourceURL && portletRequest)
 			{
-				result = "./";
+				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());
+
+				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);
 		}
@@ -284,6 +353,15 @@
 	}
 
 	/**
+	 * @see org.apache.wicket.request.IRequestCodingStrategy#encode(java.lang.CharSequence)
+	 */
+	public CharSequence encode(CharSequence url)
+	{
+		// no further encoding needed
+		return url;
+	}
+
+	/**
 	 * @see org.apache.wicket.request.IRequestTargetMountsInfo#listMounts()
 	 */
 	public IRequestTargetUrlCodingStrategy[] listMounts()
@@ -824,6 +902,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;
 	}
 

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebCodingStrategy.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebCodingStrategy.java?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebCodingStrategy.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/request/urlcompressing/UrlCompressingWebCodingStrategy.java Tue Sep 25 03:21:35 2007
@@ -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;
@@ -130,6 +131,10 @@
 		if (params != null && params.getUrlDepth() != 0)
 		{
 			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);
 	}

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java Tue Sep 25 03:21:35 2007
@@ -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,14 +314,28 @@
 				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(getHttpServletRequest().getServletPath());
+			prepender.prepend(getHttpServletRequest().getContextPath());
+		}
+		else
 		{
-			prepender.prepend("../");
+			for (int i = 0; i < depthRelativeToWicketHandler; i++)
+			{
+				prepender.prepend("../");
+			}
 		}
 
 		return relativePathPrefixToWicketHandler = prepender.toString();

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/RedirectRequestTarget.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/RedirectRequestTarget.java?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/RedirectRequestTarget.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/request/target/basic/RedirectRequestTarget.java Tue Sep 25 03:21:35 2007
@@ -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://"))
 		{

Modified: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult-1.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult-1.html?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult-1.html (original)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult-1.html Tue Sep 25 03:21:35 2007
@@ -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

Modified: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult.html?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult.html (original)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/ajax/markup/html/componentMap/SimpleTestPageExpectedResult.html Tue Sep 25 03:21:35 2007
@@ -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>

Modified: wicket/trunk/jdk-1.5/wicket-examples/pom.xml
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/pom.xml?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/pom.xml (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/pom.xml Tue Sep 25 03:21:35 2007
@@ -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>

Modified: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.html?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.html (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.html Tue Sep 25 03:21:35 2007
@@ -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

Modified: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.java?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleHeader.java Tue Sep 25 03:21:35 2007
@@ -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")

Modified: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.html?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.html (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.html Tue Sep 25 03:21:35 2007
@@ -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>

Modified: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.java?rev=579172&r1=579171&r2=579172&view=diff
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.java (original)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/dates/DatesPage.java Tue Sep 25 03:21:35 2007
@@ -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

Added: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html (added)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html Tue Sep 25 03:21:35 2007
@@ -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>

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java (added)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java Tue Sep 25 03:21:35 2007
@@ -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);
+	}
+	
+}

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/EditPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java (added)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java Tue Sep 25 03:21:35 2007
@@ -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);
+	}
+	
+	
+}

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/ExampleApplication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html (added)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html Tue Sep 25 03:21:35 2007
@@ -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>

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java (added)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java Tue Sep 25 03:21:35 2007
@@ -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);
+			}
+		});
+	}
+}

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/HeaderPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html (added)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html Tue Sep 25 03:21:35 2007
@@ -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>

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java (added)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java Tue Sep 25 03:21:35 2007
@@ -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()));
+			}
+		});
+	}
+}

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java?rev=579172&view=auto
==============================================================================
--- wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java (added)
+++ wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java Tue Sep 25 03:21:35 2007
@@ -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();
+	}
+
+}

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/WicketExamplesMenuApplication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain