You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by uk...@apache.org on 2007/04/30 10:52:59 UTC
svn commit: r533627 [1/2] - in /portals/pluto/branches/1.1-286-COMPATIBILITY:
pluto-container/src/main/java/org/apache/pluto/internal/
pluto-container/src/main/java/org/apache/pluto/internal/impl/
pluto-portal-driver-impl/src/main/java/org/apache/pluto...
Author: ukuester
Date: Mon Apr 30 01:52:57 2007
New Revision: 533627
URL: http://svn.apache.org/viewvc?view=rev&rev=533627
Log:
This patch is for solving the problems with the tests on the testsuites's 'Preference In Action Test' and 'Preference In Render Test' pages.
It was also added the new functionality for the Taglib from the Java(TM) Portlet Specification Version 2.0 Early Draft 2, Rev. 13.
Added:
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalResourceRequest.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalResourceResponse.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/BaseURLTag.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/PortletURLTag.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ResourceURLTag.java
Removed:
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/BasicURLTag.java
Modified:
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletRequest.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletResponse.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalRenderRequest.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalRenderResponse.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletEntityImpl.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestDispatcherImpl.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletResponseImpl.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderRequestImpl.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderResponseImpl.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceResponseImpl.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedModesServiceImpl.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/pom.xml
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ActionURLTag.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/DefineObjectsTag.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/NamespaceTag.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ParamTag.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/RenderURLTag.java
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/resources/META-INF/portlet-el.tld
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/resources/META-INF/portlet.tld
portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/site/site.xml
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletRequest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletRequest.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletRequest.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletRequest.java Mon Apr 30 01:52:57 2007
@@ -27,6 +27,7 @@
*
* @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
* @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @author <a href="mailto:dettborn@minet.uni-jena.de">Torsten Dettborn</a>
*/
public interface InternalPortletRequest extends PortletRequest {
@@ -53,6 +54,19 @@
public HttpServletRequest getHttpServletRequest();
+ /**
+ * Is set true when a jsp, servlet is included.
+ * @param included true when included
+ */
+ public void setIncluded(boolean included);
+
+ /**
+ * Returns true if a jsp or servlet is included.
+ * @return true if a jsp or servlet is included.
+ */
+ public boolean isIncluded();
+
+ public void setIncludedQueryString(String queryString);
}
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletResponse.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletResponse.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletResponse.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalPortletResponse.java Mon Apr 30 01:52:57 2007
@@ -23,9 +23,23 @@
*
* @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
* @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @author <a href="mailto:dettborn@minet.uni-jena.de">Torsten Dettborn</a>
*/
public interface InternalPortletResponse extends PortletResponse {
public InternalPortletWindow getInternalPortletWindow();
+
+
+ /**
+ * Is set true when a jsp, servlet is included.
+ * @param included true when included
+ */
+ public void setIncluded(boolean included);
+
+ /**
+ * Returns true if a jsp or servlet is included.
+ * @return true if a jsp or servlet is included.
+ */
+ public boolean isIncluded();
}
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalRenderRequest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalRenderRequest.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalRenderRequest.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalRenderRequest.java Mon Apr 30 01:52:57 2007
@@ -23,10 +23,4 @@
*/
public interface InternalRenderRequest extends InternalPortletRequest {
- public void setIncluded(boolean included);
-
- public boolean isIncluded();
-
- public void setIncludedQueryString(String queryString);
-
}
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalRenderResponse.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalRenderResponse.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalRenderResponse.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalRenderResponse.java Mon Apr 30 01:52:57 2007
@@ -23,8 +23,4 @@
*/
public interface InternalRenderResponse extends InternalPortletResponse {
- public void setIncluded(boolean included);
-
- public boolean isIncluded();
-
}
Added: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalResourceRequest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalResourceRequest.java?view=auto&rev=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalResourceRequest.java (added)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalResourceRequest.java Mon Apr 30 01:52:57 2007
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.internal;
+
+/**
+ * The internal resource request interface extends the internal portlet request
+ * interface and provides some resource-specific methods.
+ * @author <a href="mailto:dettborn@minet.uni-jena.de">Torsten Dettborn</a>
+ * @since 2.0
+ */
+public interface InternalResourceRequest extends InternalPortletRequest {
+
+}
Added: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalResourceResponse.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalResourceResponse.java?view=auto&rev=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalResourceResponse.java (added)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/InternalResourceResponse.java Mon Apr 30 01:52:57 2007
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pluto.internal;
+
+/**
+ * The internal render response interface extends the internal portlet response
+ * interface and provides some render-specific methods.
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @since 2006-02-17
+ */
+public interface InternalResourceResponse extends InternalPortletResponse {
+
+}
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletEntityImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletEntityImpl.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletEntityImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletEntityImpl.java Mon Apr 30 01:52:57 2007
@@ -121,9 +121,11 @@
it.hasNext(); ) {
PortletPreferenceDD prefDD = (PortletPreferenceDD) it.next();
String[] values = null;
- if (prefDD.getValues().size() > 0) {
- values = (String[]) prefDD.getValues().toArray(
- new String[prefDD.getValues().size()]);
+ if (prefDD.getValues()!=null){
+ if (prefDD.getValues().size() > 0) {
+ values = (String[]) prefDD.getValues().toArray(
+ new String[prefDD.getValues().size()]);
+ }
}
PortletPreferenceImpl pref = new PortletPreferenceImpl(
prefDD.getName(), values, prefDD.isReadOnly());
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletPreferencesImpl.java Mon Apr 30 01:52:57 2007
@@ -113,9 +113,11 @@
// Put default portlet preferences into preferences map.
PortletEntity entity = window.getPortletEntity();
defaultPreferences = entity.getDefaultPreferences();
- for (int i = 0; i < defaultPreferences.length; i++) {
- preferences.put(defaultPreferences[i].getName(),
- (InternalPortletPreference) defaultPreferences[i].clone());
+ if (defaultPreferences!=null){
+ for (int i = 0; i < defaultPreferences.length; i++) {
+ preferences.put(defaultPreferences[i].getName(),
+ (InternalPortletPreference) defaultPreferences[i].clone());
+ }
}
if (LOG.isDebugEnabled()) {
LOG.debug("Loaded default preferences: " + toString());
@@ -137,7 +139,8 @@
// Portlet preferences are stored everytime when a
// PortletPreferencesImpl instance is created.
// So here we do not check the portlet request method ID.
- internalStore();
+ if (storedPreferences.length >0)
+ internalStore();
} catch (PortletContainerException ex) {
LOG.error("Error retrieving preferences.", ex);
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestDispatcherImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestDispatcherImpl.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestDispatcherImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestDispatcherImpl.java Mon Apr 30 01:52:57 2007
@@ -36,8 +36,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.internal.InternalActionRequest;
+import org.apache.pluto.internal.InternalActionResponse;
+import org.apache.pluto.internal.InternalEventRequest;
+import org.apache.pluto.internal.InternalEventResponse;
import org.apache.pluto.internal.InternalRenderRequest;
import org.apache.pluto.internal.InternalRenderResponse;
+import org.apache.pluto.internal.InternalResourceRequest;
+import org.apache.pluto.internal.InternalResourceResponse;
/**
* Implementation of the <code>PortletRequestDispatcher</code> interface.
@@ -129,18 +135,93 @@
}
public void include(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("This method needs to be implemented.");
+ InternalResourceRequest internalRequest = (InternalResourceRequest)
+ InternalImplConverter.getInternalRequest(request);
+ InternalResourceResponse internalResponse = (InternalResourceResponse)
+ InternalImplConverter.getInternalResponse(response);
+
+ boolean isIncluded = (internalRequest.isIncluded()
+ || internalResponse.isIncluded());
+ try {
+ internalRequest.setIncluded(true);
+ internalRequest.setIncludedQueryString(queryString);
+ internalResponse.setIncluded(true);
+
+ requestDispatcher.include(
+ (HttpServletRequest) internalRequest,
+ (HttpServletResponse) internalResponse);
+ } catch (IOException ex) {
+ throw ex;
+ } catch (ServletException ex) {
+ if (ex.getRootCause() != null) {
+ throw new PortletException(ex.getRootCause());
+ } else {
+ throw new PortletException(ex);
+ }
+ } finally {
+ internalRequest.setIncluded(isIncluded);
+ internalResponse.setIncluded(isIncluded);
+ }
}
public void include(ActionRequest request, ActionResponse response) throws PortletException, IOException {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("This method needs to be implemented.");
+ InternalActionRequest internalRequest = (InternalActionRequest)
+ InternalImplConverter.getInternalRequest(request);
+ InternalActionResponse internalResponse = (InternalActionResponse)
+ InternalImplConverter.getInternalResponse(response);
+
+ boolean isIncluded = (internalRequest.isIncluded()
+ || internalResponse.isIncluded());
+ try {
+ internalRequest.setIncluded(true);
+ internalRequest.setIncludedQueryString(queryString);
+ internalResponse.setIncluded(true);
+
+ requestDispatcher.include(
+ (HttpServletRequest) internalRequest,
+ (HttpServletResponse) internalResponse);
+ } catch (IOException ex) {
+ throw ex;
+ } catch (ServletException ex) {
+ if (ex.getRootCause() != null) {
+ throw new PortletException(ex.getRootCause());
+ } else {
+ throw new PortletException(ex);
+ }
+ } finally {
+ internalRequest.setIncluded(isIncluded);
+ internalResponse.setIncluded(isIncluded);
+ }
}
public void include(EventRequest request, EventResponse response) throws PortletException, IOException {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("This method needs to be implemented.");
+ InternalEventRequest internalRequest = (InternalEventRequest)
+ InternalImplConverter.getInternalRequest(request);
+ InternalEventResponse internalResponse = (InternalEventResponse)
+ InternalImplConverter.getInternalResponse(response);
+
+ boolean isIncluded = (internalRequest.isIncluded()
+ || internalResponse.isIncluded());
+ try {
+ internalRequest.setIncluded(true);
+ internalRequest.setIncludedQueryString(queryString);
+ internalResponse.setIncluded(true);
+
+ requestDispatcher.include(
+ (HttpServletRequest) internalRequest,
+ (HttpServletResponse) internalResponse);
+ } catch (IOException ex) {
+ throw ex;
+ } catch (ServletException ex) {
+ if (ex.getRootCause() != null) {
+ throw new PortletException(ex.getRootCause());
+ } else {
+ throw new PortletException(ex);
+ }
+ } finally {
+ internalRequest.setIncluded(isIncluded);
+ internalResponse.setIncluded(isIncluded);
+ }
}
public void forward(ResourceRequest request, ResourceResponse response) throws PortletException, IOException, IllegalStateException {
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java Mon Apr 30 01:52:57 2007
@@ -51,6 +51,7 @@
import java.io.IOException;
import java.util.Collections;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@@ -106,6 +107,8 @@
* Flag indicating if the HTTP-Body has been accessed. */
private boolean bodyAccessed = false;
+ /** True if we are in an include call. */
+ private boolean included = false;
// Constructors ------------------------------------------------------------
@@ -666,4 +669,39 @@
}
+// InternalRenderRequest Impl ----------------------------------------------
+
+ public void setIncluded(boolean included) {
+ this.included = included;
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Portlet request's included mode: " + included);
+ }
+ }
+
+ public boolean isIncluded() {
+ return included;
+ }
+
+ public void setIncludedQueryString(String queryString)
+ throws IllegalStateException {
+ if (!included) {
+ throw new IllegalStateException("Parameters cannot be appended to "
+ + "render request which is not included in a dispatch.");
+ }
+ if (queryString != null && queryString.trim().length() > 0) {
+ // Copy all the original render parameters.
+ //parameters = new HashMap(super.getParameterMap());
+ // Merge the appended parameters to the render parameter map.
+ // The original render parameters should not be overwritten.
+ //mergeQueryString(parameters, queryString);
+ // Log the new render parameter map.
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Merged parameters: ");
+ }
+ } else {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("No query string appended to the included request.");
+ }
+ }
+ }
}
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletResponseImpl.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletResponseImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletResponseImpl.java Mon Apr 30 01:52:57 2007
@@ -64,6 +64,8 @@
private NamespaceMapper mapper = new NamespaceMapperImpl();
+ /** True if we are in an include call. */
+ private boolean included = false;
// Constructor -------------------------------------------------------------
@@ -266,4 +268,14 @@
}
return validNamespace.toString();
}
+
+// InternalRenderResponse Impl ---------------------------------------------
+
+ public void setIncluded(boolean included) {
+ this.included = included;
+ }
+
+ public boolean isIncluded() {
+ return included;
+ }
}
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderRequestImpl.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderRequestImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderRequestImpl.java Mon Apr 30 01:52:57 2007
@@ -54,8 +54,7 @@
// Private Member Variables ------------------------------------------------
- /** True if we are in an include call. */
- private boolean included = false;
+
/** The parameters including parameters appended to the dispatching URI. */
private Map parameters = null;
@@ -99,7 +98,7 @@
* flag is set to true, this method returns null.
*/
public String getContentType() {
- return included ? null : super.getContentType();
+ return super.isIncluded() ? null : super.getContentType();
}
/**
@@ -107,7 +106,7 @@
* flag is set to true, this method returns 0.
*/
public int getContentLength() {
- return included ? 0 : super.getContentLength();
+ return super.isIncluded() ? 0 : super.getContentLength();
}
/**
@@ -116,7 +115,7 @@
*/
public BufferedReader getReader()
throws UnsupportedEncodingException, IOException {
- return included ? null : super.getReader();
+ return super.isIncluded() ? null : super.getReader();
}
/**
@@ -124,14 +123,14 @@
* response. If the included flag is set to true, this method returns null.
*/
public ServletInputStream getInputStream() throws IOException {
- return included ? null : super.getInputStream();
+ return super.isIncluded() ? null : super.getInputStream();
}
// PortletRequestImpl Overwriting ------------------------------------------
protected Map baseGetParameterMap() {
- if (included && parameters != null) {
+ if (super.isIncluded() && parameters != null) {
super.setBodyAccessed();
return parameters;
} else {
@@ -143,7 +142,7 @@
// InternalRenderRequest Impl ----------------------------------------------
public void setIncluded(boolean included) {
- this.included = included;
+ super.setIncluded(included);
if (!included) {
this.parameters = null;
}
@@ -151,14 +150,10 @@
LOG.debug("Render request's included mode: " + included);
}
}
-
- public boolean isIncluded() {
- return included;
- }
public void setIncludedQueryString(String queryString)
throws IllegalStateException {
- if (!included) {
+ if (!super.isIncluded()) {
throw new IllegalStateException("Parameters cannot be appended to "
+ "render request which is not included in a dispatch.");
}
@@ -200,13 +195,13 @@
public String getPathInfo() {
String attr = (String) super.getAttribute(
"javax.servlet.include.path_info");
- return (included && attr != null) ? attr : super.getPathInfo();
+ return (super.isIncluded() && attr != null) ? attr : super.getPathInfo();
}
public String getQueryString() {
String attr = (String) super.getAttribute(
"javax.servlet.include.query_string");
- return (included && attr != null) ? attr : super.getQueryString();
+ return (super.isIncluded() && attr != null) ? attr : super.getQueryString();
}
/**
@@ -221,13 +216,13 @@
public String getRequestURI() {
String attr = (String) super.getAttribute(
"javax.servlet.include.request_uri");
- return (included && attr != null) ? attr : super.getRequestURI();
+ return (super.isIncluded() && attr != null) ? attr : super.getRequestURI();
}
public String getServletPath() {
String attr = (String) super.getAttribute(
"javax.servlet.include.servlet_path");
- return (included && attr != null) ? attr : super.getServletPath();
+ return (super.isIncluded() && attr != null) ? attr : super.getServletPath();
}
/*
@@ -244,23 +239,23 @@
*/
public String getProtocol() {
- return included ? null : super.getProtocol();
+ return super.isIncluded() ? null : super.getProtocol();
}
public String getRemoteAddr() {
- return included ? null : super.getRemoteAddr();
+ return super.isIncluded() ? null : super.getRemoteAddr();
}
public String getRemoteHost() {
- return included ? null : super.getRemoteHost();
+ return super.isIncluded() ? null : super.getRemoteHost();
}
public String getRealPath(String path) {
- return included ? null : super.getRealPath(path);
+ return super.isIncluded() ? null : super.getRealPath(path);
}
public StringBuffer getRequestURL() {
- return included ? null : super.getRequestURL();
+ return super.isIncluded() ? null : super.getRequestURL();
}
/*
@@ -279,12 +274,12 @@
*/
public String getCharacterEncoding() {
- return included ? null : super.getCharacterEncoding();
+ return super.isIncluded() ? null : super.getCharacterEncoding();
}
public void setCharacterEncoding(String encoding)
throws UnsupportedEncodingException {
- if (!included) {
+ if (!super.isIncluded()) {
super.setCharacterEncoding(encoding);
}
}
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderResponseImpl.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderResponseImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/RenderResponseImpl.java Mon Apr 30 01:52:57 2007
@@ -61,8 +61,7 @@
// Private Member Variables ------------------------------------------------
- /** True if we are in an include call. */
- private boolean included = false;
+
/** The current content type. */
private String currentContentType = null;
@@ -174,15 +173,7 @@
}
- // InternalRenderResponse Impl ---------------------------------------------
- public void setIncluded(boolean included) {
- this.included = included;
- }
-
- public boolean isIncluded() {
- return included;
- }
// Included HttpServletResponse (Limited) Impl -----------------------------
@@ -191,7 +182,7 @@
* TODO
*/
public String encodeRedirectUrl(String url) {
- if (included) {
+ if (super.isIncluded()) {
return null;
} else {
return super.encodeRedirectUrl(url);
@@ -202,7 +193,7 @@
* TODO
*/
public String encodeRedirectURL(String url) {
- if (included) {
+ if (super.isIncluded()) {
return null;
} else {
return super.encodeRedirectURL(url);
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceRequestImpl.java Mon Apr 30 01:52:57 2007
@@ -27,11 +27,11 @@
import org.apache.commons.logging.LogFactory;
import org.apache.pluto.Constants;
import org.apache.pluto.PortletContainer;
-import org.apache.pluto.internal.InternalActionRequest;
import org.apache.pluto.internal.InternalPortletWindow;
+import org.apache.pluto.internal.InternalResourceRequest;
public class ResourceRequestImpl extends PortletRequestImpl
-implements ResourceRequest, InternalActionRequest {
+implements ResourceRequest, InternalResourceRequest {
/** Logger. */
private static final Log LOG = LogFactory.getLog(ResourceRequestImpl.class);
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceResponseImpl.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceResponseImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceResponseImpl.java Mon Apr 30 01:52:57 2007
@@ -26,12 +26,12 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.pluto.PortletContainer;
-import org.apache.pluto.internal.InternalActionResponse;
import org.apache.pluto.internal.InternalPortletWindow;
+import org.apache.pluto.internal.InternalResourceResponse;
import org.apache.pluto.spi.PortalCallbackService;
public class ResourceResponseImpl extends StateAwareResponseImpl
-implements ResourceResponse, InternalActionResponse {
+implements ResourceResponse, InternalResourceResponse {
/**
* Is it still allowed to invoke the method sendRedirect() ?
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedModesServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedModesServiceImpl.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedModesServiceImpl.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/SupportedModesServiceImpl.java Mon Apr 30 01:52:57 2007
@@ -202,14 +202,16 @@
while (supports.hasNext())
{
SupportsDD supportsDD = (SupportsDD)supports.next();
- Iterator portletModes = supportsDD.getPortletModes().iterator();
+ if (supportsDD.getPortletModes()!=null){
+ Iterator portletModes = supportsDD.getPortletModes().iterator();
- while (portletModes.hasNext())
- {
- PortletMode pMode = new PortletMode((String)portletModes.next());
- LOG.debug("Adding mode [" + pMode + "]");
- pModes.add(pMode);
- }
+ while (portletModes.hasNext())
+ {
+ PortletMode pMode = new PortletMode((String)portletModes.next());
+ LOG.debug("Adding mode [" + pMode + "]");
+ pModes.add(pMode);
+ }
+ }
}
supportedPortletModesByPortlet.put(
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/pom.xml
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/pom.xml?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/pom.xml (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/pom.xml Mon Apr 30 01:52:57 2007
@@ -1,78 +1,86 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright 2005-2006 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.apache.pluto</groupId>
- <artifactId>pluto</artifactId>
- <version>1.1.0-286-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>pluto-taglib</artifactId>
- <packaging>jar</packaging>
- <name>Pluto Portlet Tag Library</name>
- <description>Pluto's Java Portlet Specification Tag Library implementation</description>
-
- <dependencies>
- <dependency>
- <groupId>javax.portlet</groupId>
- <artifactId>portlet-api</artifactId>
- <version>${portlet-api.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>${servlet-api.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- <version>${jsp-api.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-
- <build>
- <plugins>
- <!-- Assembly Plugin - Create Distributions -->
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptor>src/assemble/bin.xml</descriptor>
- <finalName>pluto-taglib-${pom.currentVersion}</finalName>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <resourcesDirectory>${basedir}/../pluto-site/src/site/resources</resourcesDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2005-2006 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>pluto</artifactId>
+ <version>1.1.0-286-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>pluto-taglib</artifactId>
+ <packaging>jar</packaging>
+ <name>Pluto Portlet Tag Library</name>
+ <description>Pluto's Java Portlet Specification Tag Library implementation</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>${portlet-api.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>${servlet-api.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>${jsp-api.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <!-- Assembly Plugin - Create Distributions -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptor>src/assemble/bin.xml</descriptor>
+ <finalName>pluto-taglib-${pom.currentVersion}</finalName>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-site-plugin</artifactId>
+ <configuration>
+ <resourcesDirectory>${basedir}/../pluto-site/src/site/resources</resourcesDirectory>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ActionURLTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ActionURLTag.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ActionURLTag.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ActionURLTag.java Mon Apr 30 01:52:57 2007
@@ -25,61 +25,30 @@
*/
package org.apache.pluto.tags;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletModeException;
-import javax.portlet.PortletSecurityException;
-import javax.portlet.RenderResponse;
-import javax.portlet.WindowState;
-import javax.portlet.WindowStateException;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletURL;
/**
- * Supporting class for the <CODE>actionURL</CODE> tag. Creates a url that
+ *
+ * A tag handler for the <CODE>actionURL</CODE> tag,which creates a url that
* points to the current Portlet and triggers an action request with the
* supplied parameters.
+ *
+ * @author <a href="mailto:olisp_jena@yahoo.de">Oliver Spindler</a> (since Nov 01, 2006)
+ * @version 2.0
*/
-public class ActionURLTag extends BasicURLTag {
+public class ActionURLTag extends PortletURLTag {
- /* (non-Javadoc)
- * @see javax.servlet.jsp.tagext.Tag#doStartTag()
+ /**
+ * Creates an actionURL
+ * @param portletResponse PortletResponse
+ * @return PortletURL
*/
- public int doStartTag() throws JspException {
- if (var != null) {
- pageContext.removeAttribute(var, PageContext.PAGE_SCOPE);
- }
- RenderResponse renderResponse = (RenderResponse) pageContext.getRequest()
- .getAttribute("javax.portlet.response");
-
- if (renderResponse != null) {
- setUrl(renderResponse.createActionURL());
- if (portletMode != null) {
- try {
- url.setPortletMode(
- (PortletMode) TEI.portletModes.get(
- portletMode.toUpperCase()));
- } catch (PortletModeException e) {
- throw new JspException(e);
- }
- }
- if (windowState != null) {
- try {
- url.setWindowState(
- (WindowState) TEI.definedWindowStates.get(
- windowState.toUpperCase()));
- } catch (WindowStateException e) {
- throw new JspException(e);
- }
- }
- if (secure != null) {
- try {
- url.setSecure(getSecureBoolean());
- } catch (PortletSecurityException e) {
- throw new JspException(e);
- }
- }
- }
- return EVAL_PAGE;
- }
+ protected PortletURL createPortletUrl(PortletResponse portletResponse)
+ {
+ return portletResponse.createActionURL();
+ }
+
+
}
Added: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/BaseURLTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/BaseURLTag.java?view=auto&rev=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/BaseURLTag.java (added)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/BaseURLTag.java Mon Apr 30 01:52:57 2007
@@ -0,0 +1,255 @@
+package org.apache.pluto.tags;
+
+import java.util.*;
+
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.servlet.jsp.tagext.TagSupport;
+import javax.servlet.jsp.tagext.VariableInfo;
+import javax.servlet.jsp.JspException;
+
+import javax.portlet.BaseURL;
+
+
+/**
+ * Abstract supporting class for actionURL tag, renderURL tag and resourceURL tag.
+ *
+ * @author <a href="mailto:olisp_jena@yahoo.de">Oliver Spindler</a> (since Nov 01, 2006)
+ * @version 2.0
+ *
+ */
+
+public abstract class BaseURLTag extends TagSupport {
+
+ /**
+ * TagExtraInfo class for BaseUrlTag.
+ */
+ public static class TEI extends TagExtraInfo {
+
+ public VariableInfo[] getVariableInfo(TagData tagData) {
+ VariableInfo vi[] = null;
+ String var = tagData.getAttributeString("var");
+ if (var != null) {
+ vi = new VariableInfo[1];
+ vi[0] =
+ new VariableInfo(var, "java.lang.String", true,
+ VariableInfo.AT_BEGIN);
+ }
+ return vi;
+ }
+
+ }
+
+ protected String secure;
+ protected Boolean secureBoolean;
+ protected String var;
+ //TODO: not the default value (should be true)
+ protected Boolean escapeXml=false;
+
+ protected Map<String,List<String>> parameters=new HashMap<String,List<String>> ();
+
+
+ /**
+ * Process the start tag for this instance.
+ * @throws JspException
+ * @return int
+ */
+ public abstract int doStartTag() throws JspException;
+
+
+ /**
+ * Process the end tag for this instance.
+ * @throws JspException
+ * @return int
+ */
+ public abstract int doEndTag() throws JspException;
+
+
+ /**
+ * Releases state of the tag handler.
+ * @return void
+ */
+ //Called at the end of the lifecycle.
+ public void release()
+ {
+ super.release();
+ parameters=null;
+ secureBoolean=null;
+ }
+
+
+ /**
+ * Returns secure property as String.
+ * @return String
+ */
+ public String getSecure() {
+ return secure;
+ }
+
+
+ /**
+ * Returns secure property as Boolean.
+ * @return boolean
+ */
+ public boolean getSecureBoolean() {
+ return this.secureBoolean.booleanValue();
+ }
+
+
+ /**
+ * Returns the var property.
+ * @return String
+ */
+ public String getVar() {
+ return var;
+ }
+
+
+ /**
+ * Returns escapeXml property.
+ * @return Boolean
+ */
+ public Boolean getEscapeXml() {
+ return escapeXml;
+ }
+
+
+ /**
+ * Sets secure property to boolean value of the string.
+ * @param secure
+ * @return void
+ */
+ public void setSecure(String secure) {
+ this.secure = secure;
+ this.secureBoolean = new Boolean(secure);
+ }
+
+
+ /**
+ * Sets the var property.
+ * @param var The var to set
+ * @return void
+ */
+ public void setVar(String var) {
+ this.var = var;
+ }
+
+
+ /**
+ * Sets the escapeXml property.
+ * @param escapeXml
+ * @return void
+ */
+ public void setEscapeXml(Boolean escapeXml) {
+ this.escapeXml = escapeXml;
+ }
+
+
+ /**
+ * Adds a key,value pair to the parameter map.
+ * @param key String
+ * @param value String
+ * @return void
+ */
+ public void addParameter(String key,String value)
+ {
+ /*if (escapeXml)
+ {
+ value=escapeXml(value);
+ }*/
+ List<String> values;
+ if(parameters.containsKey(key))
+ {
+ values=(List<String>)parameters.get(key);//get old value list
+ }
+ else
+ {
+ values=new ArrayList<String>();// create new value list
+ }
+ values.add(value);
+ parameters.put(key, values);
+ }
+
+
+ /**
+ * Copies parameters from map to url.
+ * @param url BaseURL
+ * @return void
+ */
+ protected void setUrlParameters(BaseURL url)
+ {
+ Set<String> keys=parameters.keySet();
+ Iterator i=keys.iterator();
+ while(i.hasNext())
+ {
+ String key=(String) i.next();
+ List<String> values=parameters.get(key);
+ String[] valarr=values.toArray(new String[0]);
+ url.setParameter(key, valarr);
+ }
+ }
+
+
+ /**
+ * Replaces in String str the characters &,>,<,",'
+ * with their corresponding character entity codes.
+ * @param str - the String where to replace
+ * @return String
+ */
+ protected String doEscapeXml(String str) {
+ str = replace(str,"&","&");
+ str = replace(str,"<","<");
+ str = replace(str,">",">");
+ str = replace(str,"\"",""");
+ str = replace(str,"'","'");
+ return str;
+ }
+
+
+ /**
+ * Checks if string is empty.
+ * This method has been copied from <code>org.apache.commons.lang.StringUtils</code> class.
+ * @param str String
+ * @return boolean
+ */
+ private boolean isEmpty(String str) {
+ return str == null || str.length() == 0;
+ }
+
+
+ /**
+ * Replaces String repl with String with in String text.
+ * This method has been copied from <code>org.apache.commons.lang.StringUtils</code> class.
+ * @param text - the String where to replace
+ * @param repl - the sub-String what to replace
+ * @param with - the sub-String what to replace repl with
+ * @return String
+ */
+ private String replace(String text, String repl, String with) {
+ int max=-1;
+ if (isEmpty(text) || isEmpty(repl) || with == null || max == 0) {
+ return text;
+ }
+ int start = 0;
+ int end = text.indexOf(repl, start);
+ if (end == -1) {
+ return text;
+ }
+ int replLength = repl.length();
+ int increase = with.length() - replLength;
+ increase = (increase < 0 ? 0 : increase);
+ increase *= (max < 0 ? 16 : (max > 64 ? 64 : max));
+ StringBuffer buf = new StringBuffer(text.length() + increase);
+ while (end != -1) {
+ buf.append(text.substring(start, end)).append(with);
+ start = end + replLength;
+ if (--max == 0) {
+ break;
+ }
+ end = text.indexOf(repl, start);
+ }
+ buf.append(text.substring(start));
+ return buf.toString();
+ }
+
+}
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/DefineObjectsTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/DefineObjectsTag.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/DefineObjectsTag.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/DefineObjectsTag.java Mon Apr 30 01:52:57 2007
@@ -15,9 +15,7 @@
*/
package org.apache.pluto.tags;
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletRequest;
-import javax.portlet.RenderResponse;
+import javax.portlet.*;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagData;
@@ -26,46 +24,113 @@
import javax.servlet.jsp.tagext.VariableInfo;
/**
- * Supporting class for the <CODE>defineObjects</CODE> tag. Creates the
- * following variables to be used in the JSP: <UL> <LI><CODE>renderRequest</CODE>
- * <LI><CODE>renderResponse</CODE> <LI><CODE>portletConfig</CODE> </UL>
- * @see javax.portlet.PortletRequest
- * @see javax.portlet.RenderResponse
- * @see javax.portlet.PortletConfig
+ * A tag handler for the <CODE>defineObjects</CODE> tag. Creates the
+ * following variables to be used in the JSP:
+ * <UL>
+ * <LI><CODE>{@link RenderRequest} renderRequest</CODE>, when included from within the <CODE>render</CODE> method
+ * <LI><CODE>{@link ResourceRequest} resourceRequest</CODE>, when included from within the <CODE>serveResource</CODE> method
+ * <LI><CODE>{@link ActionRequest} actionRequest</CODE>, when included from within the <CODE>processAction</CODE> method
+ * <LI><CODE>{@link EventRequest} eventRequest</CODE>, when included from within the <CODE>processEvent</CODE> method
+ * <LI><CODE>{@link RenderResponse} renderResponse</CODE>, when included from within the <CODE>render</CODE> method
+ * <LI><CODE>{@link ResourceResponse} resourceResponse</CODE>, when included from within the <CODE>serveResource</CODE> method
+ * <LI><CODE>{@link ActionResponse} actionResponse</CODE>, when included from within the <CODE>processAction</CODE> method
+ * <LI><CODE>{@link EventResponse} eventResponse</CODE>, when included from within the <CODE>processEvent</CODE> method
+ * <LI><CODE>{@link PortletConfig} portletConfig</CODE>
+ * <LI><CODE>{@link PortletSession} portletSession</CODE>
+ * <LI><CODE>{@link PortletPreferences} portletPreferences</CODE>
+ * </UL>
+ *
+ * @author <a href="mailto:olisp_jena@yahoo.de">Oliver Spindler</a> (since Nov 01, 2006)
+ * @version 2.0
*/
public class DefineObjectsTag extends TagSupport {
- /**
- * Processes the <CODE>defineObjects</CODE> tag.
- * @return <CODE>SKIP_BODY</CODE>
+ /**
+ * Helper method.
+ * <p>
+ * Sets an pageContext attribute with <CODE>PAGE_SCOPE</CODE>.
+ *
+ * @param attribute - the attribute object to set
+ * @param attributeName - the name of the attribute object
+ *
+ * @return void
*/
- public int doStartTag() throws JspException {
- PortletRequest renderRequest = (PortletRequest) pageContext.getRequest()
- .getAttribute(Constants.PORTLET_REQUEST);
- RenderResponse renderResponse = (RenderResponse) pageContext.getRequest()
- .getAttribute(Constants.PORTLET_RESPONSE);
- PortletConfig portletConfig = (PortletConfig) pageContext.getRequest()
- .getAttribute(Constants.PORTLET_CONFIG);
-
- if (pageContext.getAttribute("renderRequest") == null) //Set attributes only once
+ private void setAttribute(Object attribute, String attributeName)
+ {
+ if (pageContext.getAttribute(attributeName) == null) //Set attributes only once
{
- pageContext.setAttribute("renderRequest",
- renderRequest,
- PageContext.PAGE_SCOPE);
- }
-
- if (pageContext.getAttribute("renderResponse") == null) {
- pageContext.setAttribute("renderResponse",
- renderResponse,
+ pageContext.setAttribute(attributeName,
+ attribute,
PageContext.PAGE_SCOPE);
}
-
- if (pageContext.getAttribute("portletConfig") == null) {
- pageContext.setAttribute("portletConfig",
- portletConfig,
- PageContext.PAGE_SCOPE);
- }
-
+ }
+
+ /**
+ * Helper method.
+ * <p>
+ * Sets render and request attribute with the names described in the
+ * JSR 286 - PLT 25.1 (defineObjects Tag).
+ * @param request PortletRequest
+ * @param response PortletResponse
+ * @return void
+ */
+ private void setReqRes(PortletRequest request,PortletResponse response )
+ {
+ //check where request and response where included from
+ if(request instanceof RenderRequest)
+ {
+ setAttribute(request,"renderRequest");
+ setAttribute(response,"renderResponse");
+ }
+
+ else if(request instanceof ResourceRequest)
+ {
+ setAttribute(request,"resourceRequest");
+ setAttribute(response,"resourceResponse");
+ }
+
+ else if(request instanceof ActionRequest)
+ {
+ setAttribute(request,"actionRequest");
+ setAttribute(response,"actionResponse");
+ }
+
+ else if(request instanceof EventRequest)
+ {
+ setAttribute(request,"eventRequest");
+ setAttribute(response,"eventResponse");
+ }
+ }
+
+
+ /**
+ * Processes the <CODE>defineObjects</CODE> tag.
+ * @return <CODE>SKIP_BODY</CODE>
+ */
+ public int doStartTag() throws JspException {
+ PortletRequest request = (PortletRequest) pageContext.getRequest()
+ .getAttribute(Constants.PORTLET_REQUEST);
+ PortletResponse response = (PortletResponse) pageContext.getRequest()
+ .getAttribute(Constants.PORTLET_RESPONSE);
+ PortletConfig portletConfig = (PortletConfig) pageContext.getRequest()
+ .getAttribute(Constants.PORTLET_CONFIG);
+
+ PortletSession portletSession=request.getPortletSession();
+
+ PortletPreferences portletPreferences = request.getPreferences();
+
+ // set attributes render and request
+ setReqRes(request,response);
+
+ // set attribute portletConfig
+ setAttribute(portletConfig,"portletConfig");
+
+ // set attribute portletSession
+ setAttribute(portletSession,"portletSession");
+
+ // set attribute portletPreferences
+ setAttribute(portletPreferences,"portletPreferences");
+
return SKIP_BODY;
}
@@ -73,21 +138,54 @@
public VariableInfo[] getVariableInfo(TagData tagData) {
VariableInfo[] info = new VariableInfo[]{
- new VariableInfo("renderRequest",
- "javax.portlet.PortletRequest",
+ new VariableInfo("renderRequest",
+ "javax.portlet.RenderRequest",
+ true,
+ VariableInfo.AT_BEGIN),
+ new VariableInfo("renderResponse",
+ "javax.portlet.RenderResponse",
+ true,
+ VariableInfo.AT_BEGIN),
+ new VariableInfo("resourceRequest",
+ "javax.portlet.ResourceRequest",
true,
VariableInfo.AT_BEGIN),
- new VariableInfo("renderResponse",
- "javax.portlet.RenderResponse",
+ new VariableInfo("resourceResponse",
+ "javax.portlet.ResourceResponse",
+ true,
+ VariableInfo.AT_BEGIN),
+ new VariableInfo("actionRequest",
+ "javax.portlet.ActionRequest",
true,
VariableInfo.AT_BEGIN),
+ new VariableInfo("actionResponse",
+ "javax.portlet.ActionResponse",
+ true,
+ VariableInfo.AT_BEGIN),
+ new VariableInfo("eventRequest",
+ "javax.portlet.EventRequest",
+ true,
+ VariableInfo.AT_BEGIN),
+ new VariableInfo("eventResponse",
+ "javax.portlet.EventResponse",
+ true,
+ VariableInfo.AT_BEGIN),
new VariableInfo("portletConfig",
"javax.portlet.PortletConfig",
true,
- VariableInfo.AT_BEGIN)
+ VariableInfo.AT_BEGIN),
+ new VariableInfo("portletPreferences",
+ "javax.portlet.PortletPreferences",
+ true,
+ VariableInfo.AT_BEGIN),
+ new VariableInfo("portletSession",
+ "javax.portlet.PortletSession",
+ true,
+ VariableInfo.AT_BEGIN)
};
return info;
}
}
}
+
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/NamespaceTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/NamespaceTag.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/NamespaceTag.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/NamespaceTag.java Mon Apr 30 01:52:57 2007
@@ -15,7 +15,7 @@
*/
package org.apache.pluto.tags;
-import javax.portlet.RenderResponse;
+import javax.portlet.PortletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
@@ -25,7 +25,7 @@
* This tag produces a unique value for the current portlet.
* <p/>
* <p/>
- * Supporting class for the <CODE>namespace</CODE> tag. writes a unique value
+ * A tag handler for the <CODE>namespace</CODE> tag. writes a unique value
* for the current portlet <BR>This tag has no attributes
*/
public class NamespaceTag extends TagSupport {
@@ -34,9 +34,9 @@
* @see javax.servlet.jsp.tagext.Tag#doStartTag()
*/
public int doStartTag() throws JspException {
- RenderResponse renderResponse = (RenderResponse) pageContext.getRequest()
- .getAttribute("javax.portlet.response");
- String namespace = renderResponse.getNamespace();
+ PortletResponse portletResponse = (PortletResponse) pageContext.getRequest()
+ .getAttribute(Constants.PORTLET_RESPONSE);
+ String namespace = portletResponse.getNamespace();
JspWriter writer = pageContext.getOut();
try {
writer.print(namespace);
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ParamTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ParamTag.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ParamTag.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ParamTag.java Mon Apr 30 01:52:57 2007
@@ -15,17 +15,21 @@
*/
package org.apache.pluto.tags;
-import javax.portlet.PortletURL;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
/**
- * Supporting class for the <CODE>param</CODE> tag. Defines a parameter that
- * can be added to a <CODE>actionURL</CODE> or a <CODE>renderURL</CODE>
+ * A tag handler for the <CODE>param</CODE> tag. Defines a parameter that
+ * can be added to a <CODE>actionURL</CODE>, a <CODE>resourceURL</CODE> or a <CODE>renderURL</CODE>
* <BR>The following attributes are mandatory:
- * <UL><LI><CODE>name</CODE>
- * <LI><CODE>value</CODE></UL>
+ * <UL>
+ * <LI><CODE>name</CODE>
+ * <LI><CODE>value</CODE>
+ * </UL>
+ *
+ * @author <a href="mailto:olisp_jena@yahoo.de">Oliver Spindler</a> (since Nov 01, 2006)
+ * @version 2.0
*/
public class ParamTag extends TagSupport {
@@ -37,19 +41,15 @@
* @return <CODE>SKIP_BODY</CODE>
*/
public int doStartTag() throws JspException {
- BasicURLTag urlTag = (BasicURLTag)
- findAncestorWithClass(this, BasicURLTag.class);
+ BaseURLTag urlTag = (BaseURLTag)
+ findAncestorWithClass(this, BaseURLTag.class);
if (urlTag == null) {
throw new JspException(
- "the 'param' Tag must have actionURL or renderURL as a parent");
+ "the 'param' Tag must have actionURL, renderURL or resourceURL as a parent");
}
- PortletURL url = urlTag.getUrl();
-
- if (getName() != null) {
- url.setParameter(getName(), getValue());
- }
+ urlTag.addParameter(getName(), getValue());
return SKIP_BODY;
}
Added: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/PortletURLTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/PortletURLTag.java?view=auto&rev=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/PortletURLTag.java (added)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/PortletURLTag.java Mon Apr 30 01:52:57 2007
@@ -0,0 +1,310 @@
+package org.apache.pluto.tags;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.Map;
+
+import javax.portlet.PortletModeException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.PortletURL;
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Abstract supporting class for actionURL tag and renderURL tag.
+ *
+ * @author <a href="mailto:olisp_jena@yahoo.de">Oliver Spindler</a> (since Nov 01, 2006)
+ * @version 2.0
+ */
+
+public abstract class PortletURLTag extends BaseURLTag {
+
+ /**
+ * TagExtraInfo class for PortletURLTag.
+ */
+ public static class TEI extends BaseURLTag.TEI {
+ public final static Hashtable definedWindowStates = getDefinedWindowStates();
+ public final static Hashtable portletModes = getDefinedPortletModes();
+
+ /**
+ * Provides a list of all static PortletMode available in the
+ * specifications by using introspection
+ * @return Hashtable
+ */
+ private static Hashtable getDefinedPortletModes() {
+ Hashtable<String,Object> portletModes = new Hashtable<String,Object>();
+ Field[] f = PortletMode.class.getDeclaredFields();
+
+ for (int i = 0; i < f.length; i++) {
+ if (f[i].getType().isAssignableFrom(
+ javax.portlet.PortletMode.class)) {
+ try {
+ portletModes.put(
+ f[i].get(f[i]).toString().toUpperCase(),
+ f[i].get(f[i]));
+ } catch (IllegalAccessException e) {
+ }
+ }
+ }
+
+ return portletModes;
+ }
+
+ /**
+ * Provides a list of all static WindowsStates available in the
+ * specifications by using introspection
+ * @return Hashtable
+ */
+ private static Hashtable getDefinedWindowStates() {
+ Hashtable<String,Object> definedWindowStates = new Hashtable<String,Object>();
+ Field[] f = WindowState.class.getDeclaredFields();
+
+ for (int i = 0; i < f.length; i++) {
+ if (f[i].getType().isAssignableFrom(
+ javax.portlet.WindowState.class)) {
+ try {
+ definedWindowStates.put(
+ f[i].get(f[i]).toString().toUpperCase(),
+ f[i].get(f[i]));
+ } catch (IllegalAccessException e) {
+
+ }
+ }
+ }
+ return definedWindowStates;
+ }
+
+ }
+
+ protected String portletMode;
+ protected String windowState;
+ protected Boolean copyCurrentRenderParameters=false;
+ protected PortletURL url;
+
+
+ /**
+ * Process the start tag for this instance.
+ * @throws JspException
+ * @return EVAL_BODY_INCLUDE
+ */
+ public int doStartTag() throws JspException {
+
+ //parameters= new HashMap<String,List<String>> ();
+
+ if(copyCurrentRenderParameters)
+ {
+ doCopyCurrentRenderParameters();
+ }
+
+ if (var != null) {
+ pageContext.removeAttribute(var, PageContext.PAGE_SCOPE);
+ }
+ PortletResponse portletResponse = (PortletResponse) pageContext.getRequest()
+ .getAttribute(Constants.PORTLET_RESPONSE);
+
+ if (portletResponse != null) {
+
+ setUrl(createPortletUrl(portletResponse));
+
+ if (portletMode != null) {
+ try {
+ PortletMode mode = (PortletMode)
+ TEI.portletModes.get(portletMode.toUpperCase());
+
+ if (mode == null) {
+ mode = new PortletMode(portletMode);// support for custom portlet modes PLUTO-258
+ }
+ url.setPortletMode(mode);
+ } catch (PortletModeException e) {
+ throw new JspException(e);
+ }
+ }
+
+ if (windowState != null) {
+ try {
+ WindowState state = (WindowState)
+ TEI.definedWindowStates.get(windowState.toUpperCase());
+ if (state == null) {
+ state = new WindowState(windowState);//support for custom window states PLUTO-258
+ }
+ url.setWindowState(state);
+ } catch (WindowStateException e) {
+ throw new JspException(e);
+ }
+ }
+
+ if (secure != null) {
+ try {
+ url.setSecure(getSecureBoolean());
+ } catch (PortletSecurityException e) {
+ throw new JspException(e);
+ }
+ }
+ }
+ return EVAL_BODY_INCLUDE;
+ }
+
+
+ /**
+ * Process the end tag for this instance.
+ * @throws JspException
+ * @return EVAL_PAGE
+ */
+ public int doEndTag() throws JspException{
+
+ setUrlParameters(url);
+
+
+ HttpServletResponse response=(HttpServletResponse) pageContext.getResponse();
+ // properly encoding urls to allow non-cookie enabled sessions - PLUTO-252
+ String urlString=response.encodeURL(url.toString());
+
+ if(escapeXml){
+ urlString=doEscapeXml(urlString);
+ }
+
+ if (var == null) {
+ try {
+ JspWriter writer = pageContext.getOut();
+ writer.print(urlString);
+ } catch (IOException ioe) {
+ throw new JspException(
+ "actionURL/renderURL Tag Exception: cannot write to the output writer.");
+ }
+ }
+ else {
+ pageContext.setAttribute(var, urlString,
+ PageContext.PAGE_SCOPE);
+ }
+
+ parameters.clear();//cleanup
+
+ return EVAL_PAGE;
+ }
+
+
+ /**
+ * Returns the url property.
+ * @return PortletURL
+ */
+ public PortletURL getUrl() {
+ return url;
+ }
+
+
+ /**
+ * Returns the portletMode property.
+ * @return String
+ */
+ public String getPortletMode() {
+ return portletMode;
+ }
+
+
+ /**
+ * Returns the windowState property.
+ * @return String
+ */
+ public String getWindowState() {
+ return windowState;
+ }
+
+
+ /**
+ * Returns the copyCurrentRenderParameters property.
+ * @return Boolean
+ */
+ public Boolean getCopyCurrentRenderParameters() {
+ return copyCurrentRenderParameters;
+ }
+
+
+ /**
+ * Sets the url property.
+ * @param url The url to set
+ * @return void
+ */
+ public void setUrl(PortletURL url) {
+ this.url = url;
+ }
+
+
+ /**
+ * Sets the portletMode property.
+ * @param portletMode - the portlet mode to set
+ * @return void
+ */
+ public void setPortletMode(String portletMode) {
+ this.portletMode = portletMode;
+ }
+
+
+ /**
+ * Sets the windowState property.
+ * @param windowState - the portlet window state to set
+ * @return void
+ */
+ public void setWindowState(String windowState) {
+ this.windowState = windowState;
+ }
+
+
+ /**
+ * Sets copyCurrentRenderParameters property.
+ * @param copyCurrentRenderParameters
+ * @return void
+ */
+ public void setCopyCurrentRenderParameters(Boolean copyCurrentRenderParameters) {
+ this.copyCurrentRenderParameters = copyCurrentRenderParameters;
+ }
+
+
+ /**
+ * Copies the current render parameters to the parameter map.
+ * @return void
+ */
+ protected void doCopyCurrentRenderParameters()
+ {
+ PortletRequest request = (PortletRequest) pageContext.getRequest()
+ .getAttribute(Constants.PORTLET_REQUEST);
+ if(request!=null)
+ {
+ Map<String,String[]> renderParamsMap=request.getParameterMap();
+ Set<String> keys=renderParamsMap.keySet();
+ Iterator i=keys.iterator();
+ while(i.hasNext())
+ {
+ String key=(String) i.next();
+ String[] values=renderParamsMap.get(key);
+ List<String> valuesList=new ArrayList<String>();
+ int index=0;
+ while(index<values.length){
+ valuesList.add(values[index]);
+ index++;
+ }
+ parameters.put(key,valuesList);
+ }
+ }
+ }
+
+
+ /**
+ * Creates an actionURL or a renderURL
+ * @param portletResponse PortletResponse
+ * @return PortletURL
+ */
+ protected abstract PortletURL createPortletUrl(PortletResponse portletResponse);
+
+}
Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/RenderURLTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/RenderURLTag.java?view=diff&rev=533627&r1=533626&r2=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/RenderURLTag.java (original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/RenderURLTag.java Mon Apr 30 01:52:57 2007
@@ -15,62 +15,31 @@
*/
package org.apache.pluto.tags;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletModeException;
-import javax.portlet.PortletSecurityException;
-import javax.portlet.RenderResponse;
-import javax.portlet.WindowState;
-import javax.portlet.WindowStateException;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
+
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletURL;
+
/**
- * Supporting class for the <CODE>renderURL</CODE> tag. Creates a url that
- * points to the current Portlet and triggers an render request * with the
- * supplied parameters. *
+ * A tag handler for the <CODE>renderURL</CODE> tag,which creates a url that
+ * points to the current Portlet and triggers a render request with the
+ * supplied parameters.
+ *
+ * @author <a href="mailto:olisp_jena@yahoo.de">Oliver Spindler</a> (since Nov 01, 2006)
+ * @version 2.0
*/
-public class RenderURLTag extends BasicURLTag {
-
+public class RenderURLTag extends PortletURLTag {
- /* (non-Javadoc)
- * @see javax.servlet.jsp.tagext.Tag#doStartTag()
- */
- public int doStartTag() throws JspException {
- if (var != null) {
- pageContext.removeAttribute(var, PageContext.PAGE_SCOPE);
- }
- RenderResponse renderResponse = (RenderResponse) pageContext.getRequest()
- .getAttribute("javax.portlet.response");
- if (renderResponse != null) {
- setUrl(renderResponse.createRenderURL());
- if (portletMode != null) {
- try {
- url.setPortletMode(
- (PortletMode) TEI.portletModes.get(
- portletMode.toUpperCase()));
- } catch (PortletModeException e) {
- throw new JspException(e);
- }
- }
- if (windowState != null) {
- try {
- url.setWindowState(
- (WindowState) TEI.definedWindowStates.get(
- windowState.toUpperCase()));
- } catch (WindowStateException e) {
- throw new JspException(e);
- }
- }
- if (secure != null) {
- try {
- url.setSecure(getSecureBoolean());
- } catch (PortletSecurityException e) {
- throw new JspException(e);
- }
- }
- }
- return EVAL_PAGE;
- }
+ /**
+ * Creates a renderURL
+ * @param portletResponse PortletResponse
+ * @return PortletURL
+ */
+ protected PortletURL createPortletUrl(PortletResponse portletResponse)
+ {
+ return portletResponse.createRenderURL();
+ }
+
}
Added: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ResourceURLTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ResourceURLTag.java?view=auto&rev=533627
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ResourceURLTag.java (added)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-taglib/src/main/java/org/apache/pluto/tags/ResourceURLTag.java Mon Apr 30 01:52:57 2007
@@ -0,0 +1,109 @@
+package org.apache.pluto.tags;
+
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.portlet.BaseURL;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletSecurityException;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+
+
+/**
+ * A tag handler for the <CODE>resourceURL</CODE> tag,which creates a url that
+ * points to the current Portlet and triggers a resource request with the
+ * supplied parameters.
+ *
+ * @author <a href="mailto:olisp_jena@yahoo.de">Oliver Spindler</a> (since Nov 01, 2006)
+ * @version 1.0
+ */
+
+public class ResourceURLTag extends BaseURLTag {
+
+ protected BaseURL url;
+
+ /**
+ * Process the start tag for this instance.
+ * @throws JspException
+ * @return EVAL_BODY_INCLUDE
+ */
+ public int doStartTag() throws JspException {
+ parameters= new HashMap<String,List<String>> ();
+ if (var != null) {
+ pageContext.removeAttribute(var, PageContext.PAGE_SCOPE);
+ }
+ PortletResponse portletResponse = (PortletResponse) pageContext.getRequest()
+ .getAttribute(Constants.PORTLET_RESPONSE);
+
+ if (portletResponse != null) {
+ setUrl(portletResponse.createResourceURL());
+ if (secure != null) {
+ try {
+ url.setSecure(getSecureBoolean());
+ } catch (PortletSecurityException e) {
+ throw new JspException(e);
+ }
+ }
+ }
+ return EVAL_BODY_INCLUDE;
+ }
+
+ /**
+ * Process the end tag for this instance.
+ * @throws JspException
+ * @return EVAL_PAGE
+ */
+ public int doEndTag() throws JspException{
+
+ setUrlParameters(url);
+
+ HttpServletResponse response=(HttpServletResponse) pageContext.getResponse();
+
+ String urlString=response.encodeURL(url.toString());
+
+ if(escapeXml)
+ {
+ urlString=doEscapeXml(urlString);
+ }
+
+ if (var == null) {
+ try {
+ JspWriter writer = pageContext.getOut();
+ writer.print(urlString);
+ } catch (IOException ioe) {
+ throw new JspException(
+ "resourceURL Tag Exception: cannot write to the output writer.");
+ }
+ } else {
+ pageContext.setAttribute(var, urlString,
+ PageContext.PAGE_SCOPE);
+ }
+
+ parameters.clear();//cleanup
+
+ return EVAL_PAGE;
+ }
+
+ /**
+ * Gets the url property.
+ * @return BaseURL
+ */
+ public BaseURL getUrl() {
+ return url;
+ }
+
+ /**
+ * Sets the url porperty.
+ * @param url BaseUrl - The url to set.
+ * @return void
+ */
+ public void setUrl(BaseURL url) {
+ this.url = url;
+ }
+}