Author: chris.laprun(a)jboss.com
Date: 2010-08-18 13:06:41 -0400 (Wed, 18 Aug 2010)
New Revision: 3854
Modified:
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/remotecontroller/RemoteControllerPortlet.java
Log:
- Make RemoteControllerPortlet check if we have an existing resource id and fail if we
do.
Modified:
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/remotecontroller/RemoteControllerPortlet.java
===================================================================
---
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/remotecontroller/RemoteControllerPortlet.java 2010-08-18
13:19:02 UTC (rev 3853)
+++
components/pc/trunk/samples/src/main/java/org/gatein/pc/samples/remotecontroller/RemoteControllerPortlet.java 2010-08-18
17:06:41 UTC (rev 3854)
@@ -82,31 +82,39 @@
@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse
resourceResponse) throws PortletException, IOException
{
- resourceResponse.setContentType("text/html");
- PrintWriter writer = resourceResponse.getWriter();
- String namespace = "n_" + resourceResponse.getNamespace();
- writer.print("<html><head><script
type='text/javascript'>function
openLinkInParent(url){window.open(url,'"
- + namespace + "_parent');}</script>\n<link
rel=\"stylesheet\" href='" + resourceRequest.getContextPath() +
"/css/master.css'
type=\"text/css\"/></head><body>");
- PortletURL url = resourceResponse.createRenderURL();
- url.setWindowState(WindowState.MINIMIZED);
- writer.print("<div
class=\"remote-container\"><ul><li><a href='#'
onclick=\"" + createParentURL(url) + "\"><img\n" +
- " src=\"" +
resourceRequest.getContextPath() + "/images/icon-minimize.gif\"
alt=\"\"/> minimize parent portlet</a></li>");
- url.setWindowState(WindowState.MAXIMIZED);
- writer.print("<li><a href='#' onclick=\"" +
createParentURL(url) + "\"><img\n" +
- " src=\"" +
resourceRequest.getContextPath() + "/images/icon-maximize.gif\"
alt=\"\"/> maximize parent portlet</a></li>");
- url.setWindowState(WindowState.NORMAL);
- writer.print("<li><a href='#' onclick=\"" +
createParentURL(url) + "\"><img\n" +
- " src=\"" +
resourceRequest.getContextPath() + "/images/icon-normal.gif\"
alt=\"\"/> make parent portlet
normal</a></li></ul>");
- writer.print("<br/><ul><li>");
- url = resourceResponse.createRenderURL();
- writer.print("Set value of <b>'zipcode'</b> public render
parameter to:</li>");
- url.setParameter(ZIPCODE, "80201");
- writer.print("<li><a href='#' onclick=\"" +
createParentURL(url) + "\">Denver, CO</a>");
- url.setParameter(ZIPCODE, "94102");
- writer.print("<li><a href='#' onclick=\"" +
createParentURL(url) + "\">San Francisco, CA</a>");
- url.setParameter(ZIPCODE, "20001");
- writer.print("<li><a href='#' onclick=\"" +
createParentURL(url) + "\">Washington, DC</a>");
- writer.print("</ul></div></body></html>");
+ String id = resourceRequest.getResourceID();
+ if (id == null)
+ {
+ resourceResponse.setContentType("text/html");
+ PrintWriter writer = resourceResponse.getWriter();
+ String namespace = "n_" + resourceResponse.getNamespace();
+ writer.print("<html><head><script
type='text/javascript'>function
openLinkInParent(url){window.open(url,'"
+ + namespace + "_parent');}</script>\n<link
rel=\"stylesheet\" href='" + resourceRequest.getContextPath() +
"/css/master.css'
type=\"text/css\"/></head><body>");
+ PortletURL url = resourceResponse.createRenderURL();
+ url.setWindowState(WindowState.MINIMIZED);
+ writer.print("<div
class=\"remote-container\"><ul><li><a href='#'
onclick=\"" + createParentURL(url) + "\"><img\n" +
+ " src=\"" +
resourceRequest.getContextPath() + "/images/icon-minimize.gif\"
alt=\"\"/> minimize parent portlet</a></li>");
+ url.setWindowState(WindowState.MAXIMIZED);
+ writer.print("<li><a href='#' onclick=\"" +
createParentURL(url) + "\"><img\n" +
+ " src=\"" +
resourceRequest.getContextPath() + "/images/icon-maximize.gif\"
alt=\"\"/> maximize parent portlet</a></li>");
+ url.setWindowState(WindowState.NORMAL);
+ writer.print("<li><a href='#' onclick=\"" +
createParentURL(url) + "\"><img\n" +
+ " src=\"" +
resourceRequest.getContextPath() + "/images/icon-normal.gif\"
alt=\"\"/> make parent portlet
normal</a></li></ul>");
+ writer.print("<br/><ul><li>");
+ url = resourceResponse.createRenderURL();
+ writer.print("Set value of <b>'zipcode'</b> public
render parameter to:</li>");
+ url.setParameter(ZIPCODE, "80201");
+ writer.print("<li><a href='#' onclick=\"" +
createParentURL(url) + "\">Denver, CO</a>");
+ url.setParameter(ZIPCODE, "94102");
+ writer.print("<li><a href='#' onclick=\"" +
createParentURL(url) + "\">San Francisco, CA</a>");
+ url.setParameter(ZIPCODE, "20001");
+ writer.print("<li><a href='#' onclick=\"" +
createParentURL(url) + "\">Washington, DC</a>");
+ writer.print("</ul></div></body></html>");
+ }
+ else
+ {
+ throw new IllegalArgumentException("Don't know how to handle resource:
" + id);
+ }
}
private String createParentURL(PortletURL url)
Show replies by date