[Bedework-commit] webapps r375 - in trunk: webclient/war/docs
webcommon/src/org/bedework/webcommon/taglib/portlet
svnadmin at bedework.org
svnadmin at bedework.org
Wed May 30 11:37:08 EDT 2007
Author: douglm
Date: 2007-05-30 11:37:07 -0400 (Wed, 30 May 2007)
New Revision: 375
Modified:
trunk/webclient/war/docs/header.jsp
trunk/webcommon/src/org/bedework/webcommon/taglib/portlet/CalRewriteTag.java
trunk/webcommon/src/org/bedework/webcommon/taglib/portlet/TagsSupport.java
Log:
Changes to try to get resource urls looking correct in portal environment.
Modified: trunk/webclient/war/docs/header.jsp
===================================================================
--- trunk/webclient/war/docs/header.jsp 2007-05-29 13:52:50 UTC (rev 374)
+++ trunk/webclient/war/docs/header.jsp 2007-05-30 15:37:07 UTC (rev 375)
@@ -146,7 +146,7 @@
</search>
<misc>
- <export><genurl:rewrite action="/misc/export.gdo?b=de"/></export>
+ <export><bw:rewrite resourceURL="true" action="/misc/export.gdo?b=de"/></export>
</misc>
<mail>
@@ -154,7 +154,7 @@
</mail>
<stats>
- <stats><genurl:rewrite action="/stats/stats.do?be=d"/></stats>
+ <stats><genurl:rewrite action="/stats/stats.do?b=de"/></stats>
</stats>
<%-- The following URLs are used only in the personal client --%>
Modified: trunk/webcommon/src/org/bedework/webcommon/taglib/portlet/CalRewriteTag.java
===================================================================
--- trunk/webcommon/src/org/bedework/webcommon/taglib/portlet/CalRewriteTag.java 2007-05-29 13:52:50 UTC (rev 374)
+++ trunk/webcommon/src/org/bedework/webcommon/taglib/portlet/CalRewriteTag.java 2007-05-30 15:37:07 UTC (rev 375)
@@ -37,6 +37,10 @@
public class CalRewriteTag extends RewriteTag {
private transient Logger log;
+ /** Specifically flagged as resource url
+ */
+ protected boolean resourceURL = false;
+
/** Indicates which type of a url must be generated: action, render or resource.
* <p>If not specified, the type will be determined by
* {@link PortletURLTypes#getType(String)}</p>.
@@ -53,77 +57,114 @@
public int doStartTag() throws JspException {
boolean debug = getLogger().isDebugEnabled();
- if (!PortletServlet.isPortletRequest(pageContext.getRequest())) {
+ if (!TagsSupport.isPortletRequest(pageContext.getRequest())) {
return super.doStartTag();
}
- String urlStr = null;
BodyContent bodyContent = pageContext.pushBody();
+ super.doStartTag();
+ String urlStr = bodyContent.getString();
+ if (debug) {
+ trace(bodyContent.getString());
+ }
- super.doStartTag();
- if (debug) {
- trace(bodyContent.getString());
+ if (resourceURL) {
+ urlType = PortletURLTypes.URLType.RESOURCE;
+ } else {
+ urlType = TagsSupport.calculateURLType(urlStr);
+ }
+
+ if (debug) {
+ String type = "unknown";
+ if (urlType == null) {
+ type = "null";
+ } else if (urlType.equals(PortletURLTypes.URLType.ACTION)) {
+ type = "ACTION";
+ } else if (urlType.equals(PortletURLTypes.URLType.RENDER)) {
+ type = "RENDER";
+ } else if (urlType.equals(PortletURLTypes.URLType.RESOURCE)) {
+ type = "RESOURCE";
}
+ trace("urlType = " + type + " UrlStr = " + urlStr);
+ }
- urlStr = bodyContent.getString();
-// URL url = new URL(bodyContent.getString());
+ urlStr = commonStartTag(urlStr);
- urlType = TagsSupport.calculateURLType(urlStr);
+ pageContext.popBody();
- if (debug) {
- String type = "unknown";
- if (urlType.equals(PortletURLTypes.URLType.ACTION)) {
- type = "ACTION";
- } else if (urlType.equals(PortletURLTypes.URLType.RENDER)) {
- type = "RENDER";
- } else if (urlType.equals(PortletURLTypes.URLType.RESOURCE)) {
- type = "RESOURCE";
- }
- trace("urlType = " + type + " UrlStr = " + urlStr);
- }
+ TagUtils.getInstance().write(pageContext, urlStr);
- /* Drop the context
- */
- int pos = urlStr.indexOf('/');
- if (pos > 0) {
- urlStr = urlStr.substring(pos);
- }
+ return (SKIP_BODY);
+ }
- if (debug) {
- trace("UrlStr = " + urlStr);
- }
+ /** Sets the resourceURL value.
+ *
+ * @param val
+ */
+ public void setResourceURL(boolean val) {
+ resourceURL = val;
+ }
- urlStr = TagsSupport.getURL(pageContext, urlStr, urlType);
+ /** Returns the resourceURL value.
+ *
+ * @return boolean
+ */
+ public boolean getResourceURL() {
+ return resourceURL;
+ }
- if (debug) {
- trace("UrlStr = " + urlStr);
- }
+ /* Generates a URL for the link once urlType is set when in the context of a
+ * {@link PortletServlet#isPortletRequest(ServletRequest) PortletRequest}, otherwise
+ * the default behaviour is maintained.
+ *
+ * @return the link url
+ * @exception JspException if a JSP exception has occurred
+ */
+ protected String commonStartTag(String urlStr) throws JspException {
+ boolean debug = getLogger().isDebugEnabled();
- /* remove embedded anchor because calendar xsl stylesheet
- * adds extra parameters later during transformation
- */
- pos = urlStr.indexOf('#');
- if (pos > -1) {
- urlStr = urlStr.substring(0, pos);
- }
+ if (debug) {
+ trace("UrlStr = " + urlStr);
+ }
- /* Remove bedework dummy request parameter -
- * it's an encoded form of ?b=de */
- urlStr = urlStr.replaceAll(TagsSupport.bedeworkDummyPar, "");
+ /* Drop the context
+ */
+ int pos = urlStr.indexOf('/');
+ if (pos > 0) {
+ urlStr = urlStr.substring(pos);
+ }
- //Generate valid xml markup for transformation
- urlStr = urlStr.replaceAll("&", "&");
+ if (debug) {
+ trace("UrlStr = " + urlStr);
+ }
- if (debug) {
- trace("UrlStr = " + urlStr);
- }
+ urlStr = TagsSupport.getURL(pageContext, urlStr, urlType);
- pageContext.popBody();
+ if (debug) {
+ trace("UrlStr = " + urlStr);
+ }
- TagUtils.getInstance().write(pageContext, urlStr);
+ /* remove embedded anchor because calendar xsl stylesheet
+ * adds extra parameters later during transformation
+ */
+ pos = urlStr.indexOf('#');
+ if (pos > -1) {
+ urlStr = urlStr.substring(0, pos);
+ }
- return (SKIP_BODY);
+ /* Remove bedework dummy request parameter -
+ * it's an encoded form of ?b=de */
+ urlStr = urlStr.replaceAll(TagsSupport.bedeworkDummyPar, "");
+
+ //Generate valid xml markup for transformation
+ urlStr = urlStr.replaceAll("&", "&");
+
+ if (debug) {
+ trace("UrlStr = " + urlStr);
+ }
+
+ return urlStr;
}
public void release() {
@@ -131,11 +172,11 @@
urlType = null;
}
- private void trace(String msg) {
+ protected void trace(String msg) {
getLogger().debug(msg);
}
- private Logger getLogger() {
+ protected Logger getLogger() {
if (log == null) {
log = Logger.getLogger(this.getClass());
}
Modified: trunk/webcommon/src/org/bedework/webcommon/taglib/portlet/TagsSupport.java
===================================================================
--- trunk/webcommon/src/org/bedework/webcommon/taglib/portlet/TagsSupport.java 2007-05-29 13:52:50 UTC (rev 374)
+++ trunk/webcommon/src/org/bedework/webcommon/taglib/portlet/TagsSupport.java 2007-05-30 15:37:07 UTC (rev 375)
@@ -15,6 +15,7 @@
*/
package org.bedework.webcommon.taglib.portlet;
+import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.PageContext;
@@ -59,6 +60,16 @@
return null;
}
+
+ /** Return true if this is a portlet request
+ *
+ * @param request
+ * @return boolean true for portlet
+ */
+ public static boolean isPortletRequest(ServletRequest request) {
+ return request.getAttribute("javax.portlet.request") != null;
+ }
+
/** Resolves a, possibly relative, url to a context relative one for use
* within a Portlet context.
*
More information about the Bedework-commit
mailing list