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 ms...@apache.org on 2015/02/25 09:58:42 UTC
[5/9] portals-pluto git commit: Added additional test portlet for
fragment identifier. improved action URL test portlet
Added additional test portlet for fragment identifier. improved action URL test portlet
Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/7ae768d1
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/7ae768d1
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/7ae768d1
Branch: refs/heads/V3Prototype
Commit: 7ae768d1dc039f7b82862386adb85cd73886cd7f
Parents: 5c0e32d
Author: Scott Nicklous <ms...@apache.org>
Authored: Tue Feb 24 09:55:41 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Tue Feb 24 09:55:41 2015 +0100
----------------------------------------------------------------------
.../src/main/java/basic/portlet/Constants.java | 9 +-
.../main/java/basic/portlet/LongPortlet.java | 197 +++++++++++++++++++
.../java/basic/portlet/UrlAPTestPortlet.java | 134 +++++++++----
.../src/main/webapp/WEB-INF/jsp/view-long.jsp | 84 ++++++++
.../src/main/webapp/WEB-INF/jsp/view-uaptp.jsp | 26 ++-
.../src/main/webapp/WEB-INF/portlet.xml | 18 ++
6 files changed, 423 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/7ae768d1/PortletV3Demo/src/main/java/basic/portlet/Constants.java
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/java/basic/portlet/Constants.java b/PortletV3Demo/src/main/java/basic/portlet/Constants.java
index 263849b..e69d869 100644
--- a/PortletV3Demo/src/main/java/basic/portlet/Constants.java
+++ b/PortletV3Demo/src/main/java/basic/portlet/Constants.java
@@ -56,7 +56,7 @@ public class Constants {
public final static String ATTRIB_PMS = "portletModes";
public final static String ATTRIB_WS = "windowStates";
- // For parameter test portlet
+ // For parameter & URL test portlets
public final static String PARAM_NAME = "pName";
public final static String PARAM_VALUES = "pValues";
@@ -73,7 +73,14 @@ public class Constants {
public final static String ATTRIB_PARAMS = "params";
public final static String ATTRIB_RENURLS = "renurls";
public final static String ATTRIB_RESURLS = "resurls";
+ public final static String ATTRIB_ACTURLS = "acturls";
public final static String ATTRIB_ACTURL = "aurl";
public final static String ATTRIB_ACTPARAMS = "actParams";
+
+ // For Fragment ID test portlet (LongPortlet)
+
+ public final static String PARAM_FRAG = "frag";
+ public final static String PARAM_LINE = "line";
+ public final static String ATTRIB_LONGLINES = "longlines";
}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/7ae768d1/PortletV3Demo/src/main/java/basic/portlet/LongPortlet.java
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/java/basic/portlet/LongPortlet.java b/PortletV3Demo/src/main/java/basic/portlet/LongPortlet.java
new file mode 100644
index 0000000..529be1c
--- /dev/null
+++ b/PortletV3Demo/src/main/java/basic/portlet/LongPortlet.java
@@ -0,0 +1,197 @@
+/* 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 basic.portlet;
+
+import static basic.portlet.Constants.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.portlet.ActionParameters;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+
+import static javax.portlet.MimeResponse.ParameterCopyOption.*;
+
+import javax.portlet.ActionURL;
+import javax.portlet.MutableActionParameters;
+import javax.portlet.MutableRenderParameters;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderParameters;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+
+
+/**
+ * A portlet that allows render parameter names & values to be entered and set.
+ *
+ * @author Scott Nicklous
+ */
+public class LongPortlet extends GenericPortlet {
+
+ // Set up logging
+ private static final String LOG_CLASS = LongPortlet.class.getName();
+ private static final Logger logger = Logger.getLogger(LOG_CLASS);
+ private static final boolean isDebug = logger.isLoggable(Level.FINE);
+
+ private static final ArrayList<String> lines = new ArrayList<String>();
+ static {
+ lines.add("");
+ lines.add("");
+ lines.add("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus mi orci,");
+ lines.add("eleifend eu molestie id, tincidunt nec sem. Etiam volutpat justo id egestas");
+ lines.add("auctor. Morbi malesuada dictum ultricies. Mauris vestibulum diam ut eleifend");
+ lines.add("malesuada. Quisque ornare mi quis auctor dapibus. Praesent ut maximus nibh.");
+ lines.add("Donec aliquet consequat luctus.");
+ lines.add("");
+ lines.add("Vivamus et porttitor ipsum, non feugiat mi. Phasellus eu turpis iaculis,");
+ lines.add("scelerisque sem in, faucibus eros. Ut sed lectus id turpis egestas congue non");
+ lines.add("cursus lorem. Vestibulum viverra porttitor sem, eget imperdiet turpis dignissim");
+ lines.add("vel. Curabitur ultrices non erat a lobortis. Nam mollis laoreet diam, sit amet");
+ lines.add("dictum mauris bibendum in. Curabitur a risus nec purus varius consequat. Sed");
+ lines.add("mattis sit amet turpis in bibendum. Phasellus congue risus risus, at porta ex");
+ lines.add("mollis fermentum. Morbi tincidunt nulla tellus, vel eleifend ex maximus eget. In");
+ lines.add("eget porta sapien. Integer viverra mauris ac massa porta aliquet. Fusce nisl");
+ lines.add("purus, ultrices non metus non, dignissim viverra augue.");
+ lines.add("");
+ lines.add("Donec eget eros sollicitudin, semper quam vel, pulvinar nulla. Nam sed elit nec");
+ lines.add("lacus finibus consequat in sed tortor. Lorem ipsum dolor sit amet, consectetur");
+ lines.add("adipiscing elit. Suspendisse laoreet arcu a magna euismod, malesuada interdum");
+ lines.add("diam venenatis. Nulla bibendum viverra leo, nec aliquam mauris. In viverra");
+ lines.add("mauris in ipsum porta imperdiet. Morbi sapien mi, convallis sit amet tempus vel,");
+ lines.add("pretium ac mi. Praesent risus eros, interdum quis faucibus nec, scelerisque non");
+ lines.add("diam. Nam mi turpis, dignissim sed ligula a, fringilla consectetur elit.");
+ lines.add("");
+ lines.add("Integer semper eros ut lorem finibus placerat. Praesent id magna auctor, pretium");
+ lines.add("ex eu, suscipit diam. Nunc felis tortor, luctus a pharetra sit amet, placerat");
+ lines.add("nec ante. Interdum et malesuada fames ac ante ipsum primis in faucibus.");
+ lines.add("Curabitur urna risus, gravida in justo id, sollicitudin pulvinar felis. Lorem");
+ lines.add("ipsum dolor sit amet, consectetur adipiscing elit. Aenean nec arcu semper,");
+ lines.add("ullamcorper libero vel, consectetur nulla. Donec at tincidunt est. Donec a");
+ lines.add("tempor urna, ac molestie neque. Suspendisse malesuada lacus et ligula gravida,");
+ lines.add("ut ullamcorper orci malesuada.");
+ lines.add("");
+ lines.add("Praesent tincidunt malesuada lectus eu lobortis. Nunc sit amet est non nibh");
+ lines.add("malesuada feugiat quis venenatis odio. Donec consectetur arcu eget odio");
+ lines.add("bibendum, a semper sem finibus. Nam ac orci sit amet libero eleifend cursus.");
+ lines.add("Curabitur faucibus lorem ut velit dignissim, luctus tristique mauris");
+ lines.add("consectetur. Nunc nec pellentesque ex, in porta lorem. Nullam sit amet justo");
+ lines.add("hendrerit, congue arcu eget, fringilla elit. Nunc vehicula sagittis orci, ut");
+ lines.add("auctor neque accumsan ac.");
+ lines.add("");
+ lines.add("Morbi porttitor sem id vestibulum tempor. Sed auctor condimentum dolor vel");
+ lines.add("laoreet. Suspendisse viverra dignissim lorem at tristique. Integer vel erat quis");
+ lines.add("diam porta tempus et consequat lectus. Mauris sagittis mattis nulla quis");
+ lines.add("rhoncus. Sed vel iaculis justo. Vivamus fermentum lectus et nunc congue, non");
+ lines.add("efficitur nisl gravida. Suspendisse bibendum nisl vel augue feugiat, et dapibus");
+ lines.add("sapien mollis. Praesent eleifend blandit porta. Vestibulum pulvinar libero est,");
+ lines.add("id lacinia ipsum facilisis at. Donec volutpat, nisi sed efficitur rhoncus, mi");
+ lines.add("purus bibendum nisi, et elementum elit orci aliquam sapien. Suspendisse sit amet");
+ lines.add("viverra sem, sed consequat magna. Nulla eget purus sed massa mollis hendrerit.");
+ lines.add("");
+ lines.add("Quisque velit ipsum, consectetur vel laoreet non, efficitur vitae metus.");
+ lines.add("Pellentesque enim ipsum, sagittis et gravida quis, vehicula nec elit. Aliquam");
+ lines.add("erat volutpat. Nulla facilisi. Vestibulum eu sem nec neque efficitur lacinia nec");
+ lines.add("maximus turpis. Sed iaculis libero tristique volutpat lacinia. Duis tellus");
+ lines.add("mauris, luctus eget semper nec, luctus vitae sem. Proin vitae odio lectus.");
+ lines.add("Vestibulum non felis sit amet elit porttitor fermentum at in urna. Integer sed");
+ lines.add("scelerisque lacus. Etiam facilisis diam non mi tempor efficitur. Ut nunc nisi,");
+ lines.add("porta non volutpat sed, ullamcorper a urna. Quisque sagittis blandit lacinia.");
+ lines.add("Suspendisse aliquam, est molestie pharetra tempor, mi justo luctus odio, non");
+ lines.add("efficitur turpis risus id sem.");
+ lines.add("");
+ lines.add("Nulla fringilla egestas magna vel scelerisque. Nunc at lacinia nisi. In eget");
+ lines.add("aliquet orci. Donec maximus tristique dignissim. Proin eu porttitor risus. Etiam");
+ lines.add("placerat sem justo, at lacinia risus sagittis vel. Praesent a dapibus velit.");
+ lines.add("Donec viverra risus eget pulvinar hendrerit.");
+ lines.add("");
+ lines.add("Aliquam sagittis consequat mi eu tincidunt. Proin lacinia hendrerit purus at");
+ lines.add("fringilla. Suspendisse aliquet eu turpis nec vulputate. Nunc tempor enim ut");
+ lines.add("facilisis fringilla. Morbi pharetra vestibulum pulvinar. Duis quis ex quis");
+ lines.add("ligula elementum molestie non a odio. Aenean gravida neque eu tincidunt commodo.");
+ lines.add("Donec purus nisi, auctor et elit non, venenatis gravida ex. Praesent sodales");
+ lines.add("fermentum nunc. Mauris feugiat et tellus id tempor.");
+ lines.add("");
+ lines.add("Ut finibus nisl et vestibulum efficitur. Curabitur ultrices lorem tellus, sed");
+ lines.add("tristique nulla feugiat eget. Donec vulputate mollis ligula id commodo. Donec");
+ lines.add("tempor, nulla vitae pellentesque hendrerit, sapien dui imperdiet lacus, vel");
+ lines.add("blandit lorem erat ac urna. Pellentesque volutpat pulvinar commodo. Sed");
+ lines.add("malesuada consequat dolor, id feugiat elit consequat dictum. Aenean est massa,");
+ lines.add("blandit consectetur arcu a, placerat volutpat tortor. Quisque semper scelerisque");
+ lines.add("vestibulum. Proin mattis malesuada viverra.");
+ }
+
+ @Override
+ public void init() throws PortletException {
+ super.init();
+ }
+
+ protected void doView(RenderRequest req, RenderResponse resp)
+ throws PortletException, IOException {
+
+ resp.setContentType("text/html");
+
+ req.setAttribute(ATTRIB_LONGLINES, lines);
+
+ PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
+ "/WEB-INF/jsp/view-long.jsp");
+ rd.include(req, resp);
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.GenericPortlet#serveResource(javax.portlet.ResourceRequest, javax.portlet.ResourceResponse)
+ */
+ @Override
+ public void serveResource(ResourceRequest req, ResourceResponse resp)
+ throws PortletException, IOException {
+ }
+
+ public void processAction(ActionRequest req, ActionResponse resp)
+ throws PortletException, IOException {
+
+ ActionParameters ap = req.getActionParameters();
+ MutableRenderParameters mrp = resp.getRenderParameters();
+ mrp.set(ap);
+
+ if (isDebug) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("Long portlet action parameters:");
+ for (String k : ap.getNames()) {
+ sb.append("\nName: ").append(k);
+ sb.append(", Values: ").append(Arrays.toString(ap.getValues(k)));
+ }
+ logger.fine(sb.toString());
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/7ae768d1/PortletV3Demo/src/main/java/basic/portlet/UrlAPTestPortlet.java
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/java/basic/portlet/UrlAPTestPortlet.java b/PortletV3Demo/src/main/java/basic/portlet/UrlAPTestPortlet.java
index b40ede1..cca59be 100644
--- a/PortletV3Demo/src/main/java/basic/portlet/UrlAPTestPortlet.java
+++ b/PortletV3Demo/src/main/java/basic/portlet/UrlAPTestPortlet.java
@@ -21,7 +21,6 @@ package basic.portlet;
import static basic.portlet.Constants.*;
import java.io.IOException;
-import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
@@ -39,19 +38,15 @@ import javax.portlet.GenericPortlet;
import static javax.portlet.MimeResponse.ParameterCopyOption.*;
import javax.portlet.ActionURL;
+import javax.portlet.MutableActionParameters;
import javax.portlet.MutableRenderParameters;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderParameters;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
-import javax.portlet.RenderURL;
-import javax.portlet.ResourceParameters;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
-import javax.portlet.ResourceURL;
-
-import static javax.portlet.ResourceURL.*;
/**
@@ -147,8 +142,8 @@ public class UrlAPTestPortlet extends GenericPortlet {
String name3 = "UParm" + (++ctr);
String val3 = "" + ctr;
- // Generate some render URLs with differing copy parameter and
- // additional parameters. Use a TreeSet to have sorted output
+ // Generate some action URLs with differing render parameters.
+ // Use a TreeSet to have sorted output
TreeMap<String, String> urls = new TreeMap<String, String>();
MutableRenderParameters mrp = req.getRenderParameters().clone();
@@ -242,6 +237,58 @@ public class UrlAPTestPortlet extends GenericPortlet {
}
req.setAttribute(ATTRIB_RENURLS, urls);
+
+ // Generate some action URLs with differing render parameters.
+ // Use a TreeSet to have sorted output
+
+ urls = new TreeMap<String, String>();
+ mrp = req.getRenderParameters().clone();
+
+ aurl = resp.createActionURL(COPY_RENDER_PARAMETERS);
+ urls.put(" 1 No action parameters", aurl.toString());
+
+ aurl = resp.createActionURL(COPY_RENDER_PARAMETERS);
+ aurl.getActionParameters().setValue(name1, val1);
+ aurl.getActionParameters().setValues(name2, new String[]{val2});
+ aurl.getActionParameters().clear();
+ urls.put(" 2 set & clear action params", aurl.toString());
+
+ aurl = resp.createActionURL(COPY_RENDER_PARAMETERS);
+ MutableActionParameters map = aurl.getActionParameters().clone();
+ map.setValue(name3, val3);
+ map.setValues(name1, new String[]{val1, val2});
+ logger.fine("MAP from request # entries: " + map.getNames().size());
+
+ {
+ aurl = resp.createActionURL(COPY_RENDER_PARAMETERS);
+ MutableActionParameters map2 = map.clone();
+ map2.clear();
+ logger.fine("MAP2 afer clear # entries: " + map2.getNames().size());
+ aurl.getActionParameters().set(map2);
+ urls.put(" 3 AP Clear clone all", aurl.toString());
+ }
+
+ {
+ aurl = resp.createActionURL(COPY_RENDER_PARAMETERS);
+ MutableActionParameters map2 = map.clone();
+ logger.fine("MAP2 afer adding 2: # entries: " + map2.getNames().size());
+ aurl.getActionParameters().add(map2);
+ urls.put(" 4 AP Add thru clone 2", aurl.toString());
+ }
+
+ {
+ aurl = resp.createActionURL(COPY_RENDER_PARAMETERS);
+ MutableActionParameters map2 = map.clone();
+ map2.clear();
+ map2.setValue(name1, val1);
+ map2.setValue(name2, val2);
+ map2.setValue(name3, val3);
+ logger.fine("MAP2 after adding 3: # entries: " + map2.getNames().size());
+ aurl.getActionParameters().add(map2);
+ urls.put(" 5 AP Add thru clone 3", aurl.toString());
+ }
+
+ req.setAttribute(ATTRIB_ACTURLS, urls);
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
"/WEB-INF/jsp/view-uaptp.jsp");
@@ -282,13 +329,42 @@ public class UrlAPTestPortlet extends GenericPortlet {
txt.append("<h3>Render parameters for the last ActionRequest:</h3>\n");
txt.append("<p>\n");
- txt.append(" <table>");
-
- // don't display the control parameters
- for (String pn : mrp.getNames()) {
- if (!pn.equals(PARAM_AURLCOPY) && !pn.equals(PARAM_REMTYPE) && !pn.equals(PARAM_SETTYPE)) {
- String val = mrp.getValue(pn);
- String[] vals = mrp.getValues(pn);
+ if (mrp.isEmpty()) {
+ txt.append("Render parameters is empty.");
+ } else {
+ txt.append(" <table>");
+
+ // don't display the control parameters
+ for (String pn : mrp.getNames()) {
+ if (!pn.equals(PARAM_AURLCOPY) && !pn.equals(PARAM_REMTYPE) && !pn.equals(PARAM_SETTYPE)) {
+ String val = mrp.getValue(pn);
+ String[] vals = mrp.getValues(pn);
+ txt.append(" <tr><td " + style + ">Name: ")
+ .append(pn)
+ .append("</td><td " + style + ">Val: ")
+ .append(val)
+ .append("</td><td " + style + ">Len: ")
+ .append(vals.length)
+ .append("</td><td " + style + ">Values: ")
+ .append(Arrays.toString(vals))
+ .append("</td></tr>\n");
+ }
+ }
+
+ txt.append(" </table>");
+ }
+ txt.append("</p>\n");
+
+ txt.append("<h3>Action parameters for the last ActionRequest:</h3>\n");
+ txt.append("<p>\n");
+ if (ap.isEmpty()) {
+ txt.append("Action parameters is empty.");
+ } else {
+ txt.append(" <table>");
+
+ for (String pn : ap.getNames()) {
+ String val = ap.getValue(pn);
+ String[] vals = ap.getValues(pn);
txt.append(" <tr><td " + style + ">Name: ")
.append(pn)
.append("</td><td " + style + ">Val: ")
@@ -299,30 +375,9 @@ public class UrlAPTestPortlet extends GenericPortlet {
.append(Arrays.toString(vals))
.append("</td></tr>\n");
}
+
+ txt.append(" </table>");
}
-
- txt.append(" </table>");
- txt.append("</p>\n");
-
- txt.append("<h3>Action parameters for the last ActionRequest:</h3>\n");
- txt.append("<p>\n");
- txt.append(" <table>");
-
- for (String pn : ap.getNames()) {
- String val = ap.getValue(pn);
- String[] vals = ap.getValues(pn);
- txt.append(" <tr><td " + style + ">Name: ")
- .append(pn)
- .append("</td><td " + style + ">Val: ")
- .append(val)
- .append("</td><td " + style + ">Len: ")
- .append(vals.length)
- .append("</td><td " + style + ">Values: ")
- .append(Arrays.toString(vals))
- .append("</td></tr>\n");
- }
-
- txt.append(" </table>");
txt.append("</p>\n");
req.getPortletSession().setAttribute(ATTRIB_ACTPARAMS, txt.toString());
@@ -392,8 +447,7 @@ public class UrlAPTestPortlet extends GenericPortlet {
mrp.setValue("Error:", "<span style='color: red;'>" + err.toString() + "</span>");
}
} else if (rpNames.isEmpty()) {
- txt.append("the error message");
- mrp.setValue("Error:", "<span style='color: red;'>No parameters available!</span>");
+ txt.append("nothing.");
}
if (isDebug) {
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/7ae768d1/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-long.jsp
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-long.jsp b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-long.jsp
new file mode 100644
index 0000000..86fb42d
--- /dev/null
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-long.jsp
@@ -0,0 +1,84 @@
+<%--
+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.
+--%>
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ page import="java.io.*,java.util.*,javax.portlet.*" %>
+<%@ page import="javax.portlet.MimeResponse.ParameterCopyOption" %>
+<%@ page import="static javax.portlet.MimeResponse.ParameterCopyOption.*" %>
+<%@ page import="static basic.portlet.Constants.*" %>
+
+<portlet:defineObjects />
+
+
+<h3>Long portlet for testing the fragment identifier</h3>
+<p>V3 portlet that allows setting the fragment identifier.</p>
+<p>Use the form below to enter the fragment identifier text and line number.</p>
+<%
+ ActionURL aurl = renderResponse.createActionURL();
+%>
+<FORM METHOD='POST' ACTION='<%=aurl.toString() %>' enctype='application/x-www-form-urlencoded' accept-charset='UTF-8'>
+ <table><tr><td align='left'>
+ Fragment ID:
+ </td><td>
+ <input name='<%=PARAM_FRAG%>' type='text' value='' size='30' maxlength='100'>
+ </td><td>
+ Line:
+ </td><td>
+ <input name='<%=PARAM_LINE%>' type='text' value='' size='10' maxlength='10'>
+ </td></tr><tr><td>
+ <INPUT VALUE='send' TYPE='submit'>
+ </td></tr></table>
+</FORM>
+<%
+ String frag = renderRequest.getRenderParameters().getValue(PARAM_FRAG);
+ String ln = renderRequest.getRenderParameters().getValue(PARAM_LINE);
+ int lineNum = -1;
+ if (frag != null && ln != null && frag.length() > 0 && ln.matches("\\d+")) {
+ lineNum = Integer.parseInt(ln);
+ RenderURL rurl = renderResponse.createRenderURL(COPY_RENDER_PARAMETERS);
+ rurl.setFragmentIdentifier(frag);
+ out.print("<p><a href='");
+ out.print(rurl.toString());
+ out.println("'>Jump to line " + ln + "</a></p>");
+ }
+ String colStyle = "align='left' style='min-width: 25px; padding:0 10px 0 10px;'";
+ String markStyle = "align='left' style='color:#00D; min-width: 25px; padding:0 10px 0 10px;'";
+%>
+<p><hr/></p>
+<table><tr>
+<%
+ ArrayList<String> lines = (ArrayList<String>)renderRequest.getAttribute(ATTRIB_LONGLINES);
+ int i = 0;
+ for (String line : lines) {
+ String s1 = colStyle;
+ String s2 = colStyle;
+ if (++i == lineNum) {
+ s1 = "id='" + frag + "' " + markStyle;
+ s2 = markStyle;
+ }
+ StringBuilder txt = new StringBuilder();
+ txt.append("<td ").append(s1).append(">").append(i).append("</td>");
+ txt.append("<td ").append(s2).append(">").append(line).append("</td>");
+ txt.append("</tr><tr>");
+ out.println(txt.toString());
+ }
+%>
+</tr></table>
+<p><hr/></p>
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/7ae768d1/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-uaptp.jsp
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-uaptp.jsp b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-uaptp.jsp
index 59680f4..b5828f1 100644
--- a/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-uaptp.jsp
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/jsp/view-uaptp.jsp
@@ -47,11 +47,11 @@ limitations under the License.
ActionURL aurl = renderResponse.createActionURL(pco);
%>
-<h3>Render URL Parameter clone & set Tester</h3>
-<p>V3 portlet to verify render parameter handling on render URLs through the set(), clone(),
+<h3>Action URL Parameter clone & set Tester</h3>
+<p>V3 portlet to verify render & action parameter handling on action URLs through the set(), clone(),
clear(), and add() methods.</p>
<p><hr/></p>
-<p>Render URLs:</p>
+<p>Action URLs, render parameters:</p>
<table><tr>
<%
Map<String, String> rurls = (Map<String, String>)renderRequest.getAttribute(ATTRIB_RENURLS);
@@ -59,7 +59,25 @@ clear(), and add() methods.</p>
for (String name : rurls.keySet()) {
StringBuilder txt = new StringBuilder("<td align='left' style='padding: 0 5px 0 5px;'>");
txt.append("<form METHOD='POST' ACTION='").append(rurls.get(name)).append("'>")
- .append("<button type='submit' name='action' value='doIt'>").append(name).append("</button>")
+ .append("<button type='submit'>").append(name).append("</button>")
+ .append("</form>")
+ .append("</td>");
+ out.println(txt.toString());
+ if ((++ctr)%3 == 0) {
+ out.println("</tr><tr>");
+ }
+ }
+ %>
+ </tr></table>
+<p>Action URLs, action parameters:</p>
+ <table><tr>
+ <%
+ Map<String, String> aurls = (Map<String, String>)renderRequest.getAttribute(ATTRIB_ACTURLS);
+ ctr = 0;
+ for (String name : aurls.keySet()) {
+ StringBuilder txt = new StringBuilder("<td align='left' style='padding: 0 5px 0 5px;'>");
+ txt.append("<form METHOD='POST' ACTION='").append(aurls.get(name)).append("'>")
+ .append("<button type='submit'>").append(name).append("</button>")
.append("</form>")
.append("</td>");
out.println(txt.toString());
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/7ae768d1/PortletV3Demo/src/main/webapp/WEB-INF/portlet.xml
----------------------------------------------------------------------
diff --git a/PortletV3Demo/src/main/webapp/WEB-INF/portlet.xml b/PortletV3Demo/src/main/webapp/WEB-INF/portlet.xml
index bb2861f..2b246b1 100644
--- a/PortletV3Demo/src/main/webapp/WEB-INF/portlet.xml
+++ b/PortletV3Demo/src/main/webapp/WEB-INF/portlet.xml
@@ -233,6 +233,24 @@
<supported-public-render-parameter>Farbe</supported-public-render-parameter>
</portlet>
+ <portlet>
+ <portlet-name>LongPortlet</portlet-name>
+ <display-name>V3 Fragment Identifier Test Portlet</display-name>
+
+ <portlet-class>basic.portlet.LongPortlet</portlet-class>
+
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+
+ <supported-locale>en</supported-locale>
+
+ <portlet-info>
+ <title>V3 Fragment Identifier Test Portlet</title>
+ </portlet-info>
+ </portlet>
+
<custom-portlet-mode>
<description>Test mode #1</description>
<portlet-mode>MyMode_nonPortalManaged_1</portlet-mode>