ate 2005/01/21 08:28:13
Modified: portals-bridges/struts/src/java/META-INF/tlds
struts-portlet-el.tld struts-1.2.4-portlet-html.tld
struts-1.2.4-portlet-html-el.tld struts-portlet.tld
portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib
LinkTag.java RewriteTag.java ELLinkTag.java
TagsSupport.java ELRewriteTag.java
portals-bridges/struts/src/java/org/apache/portals/bridges/struts/config
PortletURLTypes.java
Removed:
portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib
ELLinkTagBeanInfo.java ELImgTagBeanInfo.java
ELFormTagBeanInfo.java ELImageTagBeanInfo.java
ELScriptTagBeanInfo.java ELScriptTag.java
ELRewriteTagBeanInfo.java
Log:
Several fixes and a few enhancements:
- support anchor tag in link and rewrite tags
- improved and corrected struts-el handling and dropped all BeanInfo classes
(no longer needed)
- added PortletURLType.RESOURCE which allows link and rewrite tags to also
render resource urls
- allow resource url paths to be specified in struts-portlet-config.xml
- DROPPED all Script Tags as it functionality can now be realized by the
rewrite tag (rendering a resource url)
- a few corrections to the tld definitions
Revision Changes Path
1.2 +12 -16
jakarta-jetspeed-2/portals-bridges/struts/src/java/META-INF/tlds/struts-portlet-el.tld
Index: struts-portlet-el.tld
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/META-INF/tlds/struts-portlet-el.tld,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- struts-portlet-el.tld 20 Jan 2005 01:41:14 -0000 1.1
+++ struts-portlet-el.tld 21 Jan 2005 16:28:13 -0000 1.2
@@ -94,7 +94,7 @@
</tag>
<tag>
<name>image</name>
-<tagclass>org.apache.bridges.struts.taglib.ELImageTag</tagclass>
+<tagclass>org.apache.portals.bridges.struts.taglib.ELImageTag</tagclass>
<attribute>
<name>accesskey</name>
<required>false</required>
@@ -503,6 +503,11 @@
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
+<attribute>
+<name>resourceURL</name>
+<required>false</required>
+<rtexprvalue>true</rtexprvalue>
+</attribute>
</attribute>
<attribute>
<name>accesskey</name>
@@ -710,6 +715,11 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
+<name>resourceURL</name>
+<required>false</required>
+<rtexprvalue>true</rtexprvalue>
+</attribute>
+<attribute>
<name>action</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -782,20 +792,6 @@
<attribute>
<name>useLocalEncoding</name>
<required>false</required>
-<rtexprvalue>true</rtexprvalue>
-</attribute>
-</tag>
-<tag>
-<name>script</name>
-<tagclass>org.apache.portals.bridges.struts.taglib.ELScriptTag</tagclass>
-<attribute>
-<name>language</name>
-<required>false</required>
-<rtexprvalue>true</rtexprvalue>
-</attribute>
-<attribute>
-<name>src</name>
-<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
1.2 +11 -15
jakarta-jetspeed-2/portals-bridges/struts/src/java/META-INF/tlds/struts-1.2.4-portlet-html.tld
Index: struts-1.2.4-portlet-html.tld
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/META-INF/tlds/struts-1.2.4-portlet-html.tld,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- struts-1.2.4-portlet-html.tld 20 Jan 2005 01:41:14 -0000 1.1
+++ struts-1.2.4-portlet-html.tld 21 Jan 2005 16:28:13 -0000 1.2
@@ -1445,6 +1445,11 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
+<name>resourceURL</name>
+<required>false</required>
+<rtexprvalue>true</rtexprvalue>
+</attribute>
+<attribute>
<name>accesskey</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -2391,6 +2396,11 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
+<name>resourceURL</name>
+<required>false</required>
+<rtexprvalue>true</rtexprvalue>
+</attribute>
+<attribute>
<name>action</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -3057,20 +3067,6 @@
<name>xhtml</name>
<tagclass>org.apache.struts.taglib.html.XhtmlTag</tagclass>
<bodycontent>empty</bodycontent>
-</tag>
-<tag>
-<name>script</name>
-<tagclass>org.apache.portals.bridges.struts.taglib.ScriptTag</tagclass>
-<attribute>
-<name>language</name>
-<required>false</required>
-<rtexprvalue>true</rtexprvalue>
-</attribute>
-<attribute>
-<name>src</name>
-<required>true</required>
-<rtexprvalue>true</rtexprvalue>
-</attribute>
</tag>
</taglib>
1.2 +12 -16
jakarta-jetspeed-2/portals-bridges/struts/src/java/META-INF/tlds/struts-1.2.4-portlet-html-el.tld
Index: struts-1.2.4-portlet-html-el.tld
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/META-INF/tlds/struts-1.2.4-portlet-html-el.tld,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- struts-1.2.4-portlet-html-el.tld 20 Jan 2005 01:41:14 -0000 1.1
+++ struts-1.2.4-portlet-html-el.tld 21 Jan 2005 16:28:13 -0000 1.2
@@ -984,7 +984,7 @@
</tag>
<tag>
<name>image</name>
-<tagclass>org.apache.bridges.struts.taglib.ELImageTag</tagclass>
+<tagclass>org.apache.portals.bridges.struts.taglib.ELImageTag</tagclass>
<attribute>
<name>accesskey</name>
<required>false</required>
@@ -1445,6 +1445,11 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
+<name>resourceURL</name>
+<required>false</required>
+<rtexprvalue>true</rtexprvalue>
+</attribute>
+<attribute>
<name>accesskey</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -2391,6 +2396,11 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
+<name>resourceURL</name>
+<required>false</required>
+<rtexprvalue>true</rtexprvalue>
+</attribute>
+<attribute>
<name>action</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -3057,20 +3067,6 @@
<name>xhtml</name>
<tagclass>org.apache.struts.taglib.html.XhtmlTag</tagclass>
<bodycontent>empty</bodycontent>
-</tag>
-<tag>
-<name>script</name>
-<tagclass>org.apache.portals.bridges.struts.taglib.ELScriptTag</tagclass>
-<attribute>
-<name>language</name>
-<required>false</required>
-<rtexprvalue>true</rtexprvalue>
-</attribute>
-<attribute>
-<name>src</name>
-<required>true</required>
-<rtexprvalue>true</rtexprvalue>
-</attribute>
</tag>
</taglib>
1.5 +11 -15
jakarta-jetspeed-2/portals-bridges/struts/src/java/META-INF/tlds/struts-portlet.tld
Index: struts-portlet.tld
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/META-INF/tlds/struts-portlet.tld,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- struts-portlet.tld 20 Jan 2005 01:41:14 -0000 1.4
+++ struts-portlet.tld 21 Jan 2005 16:28:13 -0000 1.5
@@ -505,6 +505,11 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
+<name>resourceURL</name>
+<required>false</required>
+<rtexprvalue>true</rtexprvalue>
+</attribute>
+<attribute>
<name>accesskey</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -710,6 +715,11 @@
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
+<name>resourceURL</name>
+<required>false</required>
+<rtexprvalue>true</rtexprvalue>
+</attribute>
+<attribute>
<name>action</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -782,20 +792,6 @@
<attribute>
<name>useLocalEncoding</name>
<required>false</required>
-<rtexprvalue>true</rtexprvalue>
-</attribute>
-</tag>
-<tag>
-<name>script</name>
-<tagclass>org.apache.portals.bridges.struts.taglib.ScriptTag</tagclass>
-<attribute>
-<name>language</name>
-<required>false</required>
-<rtexprvalue>true</rtexprvalue>
-</attribute>
-<attribute>
-<name>src</name>
-<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
1.4 +52 -17
jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib/LinkTag.java
Index: LinkTag.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib/LinkTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LinkTag.java 20 Jan 2005 01:41:14 -0000 1.3
+++ LinkTag.java 21 Jan 2005 16:28:13 -0000 1.4
@@ -30,42 +30,59 @@
public class LinkTag extends org.apache.struts.taglib.html.LinkTag
{
/**
- * Indicates if a RenderURL or ActionURL must be generated.
+ * Indicates which type of a url must be generated: action, render or
resource.
* <p>If not specified, the type will be determined by
- * [EMAIL PROTECTED] PortletURLTypes#isActionURL(String)}</p>.
+ * [EMAIL PROTECTED] PortletURLTypes#getType(String)}</p>.
*/
- protected Boolean actionURL = null;
+ protected PortletURLTypes.URLType urlType = null;
+ /**
+ * @return "true" if an ActionURL must be rendered
+ */
public String getActionURL()
{
- return actionURL != null ? action.toString() : null;
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.ACTION) ? "true" : "false";
}
/**
- * Render an ActionURL when set to "true" otherwise render a RenderURL
- * @param actionURL "true" renders an ActionURL otherwise a RenderURL
+ * Render an ActionURL when set to "true"
+ * @param value "true" renders an ActionURL
*/
- public void setActionURL(String actionURL)
+ public void setActionURL(String value)
{
- this.actionURL = actionURL != null ?
actionURL.equalsIgnoreCase("true") ? Boolean.TRUE : Boolean.FALSE : null;
+ this.urlType = value != null && value.equalsIgnoreCase("true") ?
PortletURLTypes.URLType.ACTION : null;
}
public String getRenderURL()
{
- return actionURL != null ? actionURL.booleanValue() ? "false" :
"true" : null;
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.RENDER) ? "true" : "false";
}
/**
- * Render a RenderURL when set to "true" otherwise render an ActionURL
- * @param renderURL "true" renders a RenderURL otherwise an ActionURL
+ * Render a RenderURL when set to "true"
+ * @param value "true" renders a RenderURL
*/
- public void setRenderURL(String renderURL)
+ public void setRenderURL(String value)
{
- this.actionURL = renderURL != null ?
renderURL.equalsIgnoreCase("true") ? Boolean.FALSE : Boolean.TRUE : null;
+ this.urlType = value != null && value.equalsIgnoreCase("true") ?
PortletURLTypes.URLType.RENDER : null;
}
+ public String getResourceURL()
+ {
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.RESOURCE) ? "true" : "false";
+ }
+
/**
- * Generates a PortletURL for the link when in the context of a
+ * Render a ResourceURL when set to "true"
+ * @param value "true" renders a ResourceURL
+ */
+ public void setResourceURL(String value)
+ {
+ this.urlType = value != null && value.equalsIgnoreCase("true") ?
PortletURLTypes.URLType.RESOURCE : null;
+ }
+
+ /**
+ * Generates a PortletURL or a ResourceURL for the link when in the
context of a
* [EMAIL PROTECTED] PortletServlet#isPortletRequest(ServletRequest)
PortletRequest}, otherwise
* the default behaviour is maintained.
* @return the link url
@@ -75,7 +92,25 @@
{
if ( PortletServlet.isPortletRequest(pageContext.getRequest() ))
{
- return TagsSupport.getPortletURL(pageContext,
super.calculateURL(), actionURL);
+ String url = super.calculateURL();
+
+ // process embedded anchor
+ String anchor = null;
+ int hash = url.indexOf('#');
+ if ( hash > -1 )
+ {
+ // save embedded anchor to be appended later and strip it
from the url
+ anchor = url.substring(hash);
+ url = url.substring(0,hash);
+ }
+
+ url = TagsSupport.getURL(pageContext, url, urlType);
+
+ if ( anchor != null )
+ {
+ url = url + anchor;
+ }
+ return url;
}
else
{
@@ -86,6 +121,6 @@
public void release() {
super.release();
- actionURL = null;
+ urlType = null;
}
}
1.3 +60 -19
jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib/RewriteTag.java
Index: RewriteTag.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib/RewriteTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RewriteTag.java 20 Jan 2005 01:41:14 -0000 1.2
+++ RewriteTag.java 21 Jan 2005 16:28:13 -0000 1.3
@@ -32,42 +32,59 @@
public class RewriteTag extends org.apache.struts.taglib.html.RewriteTag
{
/**
- * Indicates if a RenderURL or ActionURL must be generated.
+ * Indicates which type of a url must be generated: action, render or
resource.
* <p>If not specified, the type will be determined by
- * [EMAIL PROTECTED] PortletURLTypes#isActionURL(String)}</p>.
+ * [EMAIL PROTECTED] PortletURLTypes#getType(String)}</p>.
*/
- protected Boolean actionURL = null;
+ protected PortletURLTypes.URLType urlType = null;
+ /**
+ * @return "true" if an ActionURL must be rendered
+ */
public String getActionURL()
{
- return actionURL != null ? action.toString() : null;
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.ACTION) ? "true" : "false";
}
/**
- * Render an ActionURL when set to "true" otherwise render a RenderURL
- * @param actionURL "true" renders an ActionURL otherwise a RenderURL
+ * Render an ActionURL when set to "true"
+ * @param value "true" renders an ActionURL
*/
- public void setActionURL(String actionURL)
+ public void setActionURL(String value)
{
- this.actionURL = actionURL != null ?
actionURL.equalsIgnoreCase("true") ? Boolean.TRUE : Boolean.FALSE : null;
+ this.urlType = value != null && value.equalsIgnoreCase("true") ?
PortletURLTypes.URLType.ACTION : null;
}
public String getRenderURL()
{
- return actionURL != null ? actionURL.booleanValue() ? "false" :
"true" : null;
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.RENDER) ? "true" : "false";
}
/**
- * Render a RenderURL when set to "true" otherwise render an ActionURL
- * @param renderURL "true" renders a RenderURL otherwise an ActionURL
+ * Render a RenderURL when set to "true"
+ * @param value "true" renders a RenderURL
*/
- public void setRenderURL(String renderURL)
+ public void setRenderURL(String value)
{
- this.actionURL = renderURL != null ?
renderURL.equalsIgnoreCase("true") ? Boolean.FALSE : Boolean.TRUE : null;
+ this.urlType = value != null && value.equalsIgnoreCase("true") ?
PortletURLTypes.URLType.RENDER : null;
}
+ public String getResourceURL()
+ {
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.RESOURCE) ? "true" : "false";
+ }
+
/**
- * Generates a PortletURL for the link when in the context of a
+ * Render a ResourceURL when set to "true"
+ * @param value "true" renders a ResourceURL
+ */
+ public void setResourceURL(String value)
+ {
+ this.urlType = value != null && value.equalsIgnoreCase("true") ?
PortletURLTypes.URLType.RESOURCE : null;
+ }
+
+ /**
+ * Generates a PortletURL or a ResourceURL for the link when in the
context of a
* [EMAIL PROTECTED] PortletServlet#isPortletRequest(ServletRequest)
PortletRequest}, otherwise
* the default behaviour is maintained.
* @return the link url
@@ -77,10 +94,34 @@
{
if ( PortletServlet.isPortletRequest(pageContext.getRequest()))
{
+ String url = null;
BodyContent bodyContent = pageContext.pushBody();
- super.doStartTag();
- String url =
TagsSupport.getPortletURL(pageContext,super.calculateURL(),actionURL);
- pageContext.popBody();
+ try
+ {
+ super.doStartTag();
+ url = bodyContent.getString();
+
+ // process embedded anchor
+ String anchor = null;
+ int hash = url.indexOf('#');
+ if ( hash > -1 )
+ {
+ // save embedded anchor to be appended later and strip
it from the url
+ anchor = url.substring(hash);
+ url = url.substring(0,hash);
+ }
+
+ url = TagsSupport.getURL(pageContext, url, urlType);
+
+ if ( anchor != null )
+ {
+ url = url + anchor;
+ }
+ }
+ finally
+ {
+ pageContext.popBody();
+ }
TagUtils.getInstance().write(pageContext, url);
return (SKIP_BODY);
}
@@ -93,6 +134,6 @@
public void release() {
super.release();
- actionURL = null;
+ urlType = null;
}
}
1.2 +83 -47
jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib/ELLinkTag.java
Index: ELLinkTag.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib/ELLinkTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ELLinkTag.java 20 Jan 2005 01:41:14 -0000 1.1
+++ ELLinkTag.java 21 Jan 2005 16:28:13 -0000 1.2
@@ -32,72 +32,75 @@
public class ELLinkTag extends org.apache.strutsel.taglib.html.ELLinkTag
{
/**
- * Indicates if a RenderURL or ActionURL must be generated.
+ * Indicates which type of a url must be generated: action, render or
resource.
* <p>If not specified, the type will be determined by
- * [EMAIL PROTECTED] PortletURLTypes#isActionURL(String)}</p>.
+ * [EMAIL PROTECTED] PortletURLTypes#getType(String)}</p>.
*/
- protected Boolean actionURL = null;
+ protected PortletURLTypes.URLType urlType = null;
+ /**
+ * @return "true" if an ActionURL must be rendered
+ */
public String getActionURL()
{
- return actionURL != null ? action.toString() : null;
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.ACTION) ? "true" : "false";
}
+ private String actionURL;
/**
- * Render an ActionURL when set to "true" otherwise render a RenderURL
- * @param actionURL "true" renders an ActionURL otherwise a RenderURL
+ * Render an ActionURL when set to "true"
+ * <p>
+ * Supports jstl expression language.
+ * </p>
+ * @param actionURL when (evaluated to) "true" renders an ActionURL
*/
public void setActionURL(String actionURL)
{
- this.actionURL = actionURL != null ?
actionURL.equalsIgnoreCase("true") ? Boolean.TRUE : Boolean.FALSE : null;
+ // delay evaluation of urlType to doStartTag
+ this.actionURL = actionURL;
}
public String getRenderURL()
{
- return actionURL != null ? actionURL.booleanValue() ? "false" :
"true" : null;
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.RENDER) ? "true" : "false";
}
+ private String renderURL;
/**
- * Render a RenderURL when set to "true" otherwise render an ActionURL
- * @param renderURL "true" renders a RenderURL otherwise an ActionURL
+ * Render a RenderURL when set to "true"
+ * <p>
+ * Supports jstl expression language.
+ * </p>
+ * @param renderURL when (evaluated to) "true" renders a RenderURL
*/
public void setRenderURL(String renderURL)
{
- this.actionURL = renderURL != null ?
renderURL.equalsIgnoreCase("true") ? Boolean.FALSE : Boolean.TRUE : null;
+ // delay evaluation of urlType to doStartTag
+ this.renderURL = renderURL;
}
- /**
- * struts-el support for [EMAIL PROTECTED] #setActionURL(String)}
- */
- protected String actionURLExpr = null;
-
- public String getActionURLExpr()
+ public String getResourceURL()
{
- return actionURLExpr;
- }
-
- public void setActionURLExpr(String actionURLExpr)
- {
- this.actionURLExpr = actionURLExpr;
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.RESOURCE) ? "true" : "false";
}
+
+ private String resourceURL;
/**
- * struts-el support for [EMAIL PROTECTED] #setRenderURL(String)}
+ * Render a ResourceURL when set to "true"
+ * <p>
+ * Supports jstl expression language.
+ * </p>
+ * @param resourceURL when (evaluated to) "true" renders a ResourceURL
*/
- protected String renderURLExpr = null;
-
- public String getRenderURLExpr()
+ public void setResourceURL(String resourceURL)
{
- return renderURLExpr;
+ // delay evaluation of urlType to doStartTag
+ this.resourceURL = resourceURL;
}
-
- public void setRenderURLExpr(String renderURLExpr)
- {
- this.renderURLExpr = renderURLExpr;
- }
-
+
/**
- * Generates a PortletURL for the link when in the context of a
+ * Generates a PortletURL or a ResourceURL for the link when in the
context of a
* [EMAIL PROTECTED] PortletServlet#isPortletRequest(ServletRequest)
PortletRequest}, otherwise
* the default behaviour is maintained.
* @return the link url
@@ -107,7 +110,25 @@
{
if ( PortletServlet.isPortletRequest(pageContext.getRequest() ))
{
- return TagsSupport.getPortletURL(pageContext,
super.calculateURL(), actionURL);
+ String url = super.calculateURL();
+
+ // process embedded anchor
+ String anchor = null;
+ int hash = url.indexOf('#');
+ if ( hash > -1 )
+ {
+ // save embedded anchor to be appended later and strip it
from the url
+ anchor = url.substring(hash);
+ url = url.substring(0,hash);
+ }
+
+ url = TagsSupport.getURL(pageContext, url, urlType);
+
+ if ( anchor != null )
+ {
+ url = url + anchor;
+ }
+ return url;
}
else
{
@@ -121,27 +142,42 @@
}
/**
- * Resolve the [EMAIL PROTECTED] #actionURLExpr} and [EMAIL PROTECTED]
#renderURLExpr} attributes using the JSTL expression
- * evaluation engine ([EMAIL PROTECTED] EvalHelper}).
+ * Resolve the [EMAIL PROTECTED] #actionURL}, [EMAIL PROTECTED]
#renderURL} and [EMAIL PROTECTED] #resourceURL} attributes
+ * using the Struts JSTL expression evaluation engine ([EMAIL PROTECTED]
EvalHelper}).
* @exception JspException if a JSP exception has occurred
*/
private void evaluateExpressions() throws JspException {
- String string = null;
+ Boolean value;
- if ((string = EvalHelper.evalString("actionURL",
getActionURLExpr(),this, pageContext)) != null)
+ value = EvalHelper.evalBoolean("actionURL", getActionURL(),this,
pageContext);
+ if ( value != null && value.booleanValue() )
+ {
+ urlType = PortletURLTypes.URLType.ACTION;
+ }
+ if ( urlType == null )
{
- setActionURL(string);
+ value = EvalHelper.evalBoolean("renderURL", getRenderURL(),this,
pageContext);
+ if ( value != null && value.booleanValue() )
+ {
+ urlType = PortletURLTypes.URLType.RENDER;
+ }
}
- if ((string = EvalHelper.evalString("renderURL",
getRenderURLExpr(),this, pageContext)) != null)
+ if ( urlType == null )
{
- setRenderURL(string);
+ value = EvalHelper.evalBoolean("resourceURL",
getResourceURL(),this, pageContext);
+ if ( value != null && value.booleanValue() )
+ {
+ urlType = PortletURLTypes.URLType.RESOURCE;
+ }
}
}
- public void release()
- {
+ public void release() {
+
super.release();
+ urlType = null;
actionURL = null;
- actionURLExpr = null;
+ renderURL = null;
+ resourceURL = null;
}
}
1.2 +16 -18
jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib/TagsSupport.java
Index: TagsSupport.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib/TagsSupport.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TagsSupport.java 20 Jan 2005 01:41:14 -0000 1.1
+++ TagsSupport.java 21 Jan 2005 16:28:13 -0000 1.2
@@ -90,22 +90,21 @@
}
/**
- * Creates an action or render PortletURL.
+ * Creates an action or render PortletURL, or a ResourceURL.
* <p>
* The url parameter is first [EMAIL PROTECTED]
#getContextRelativeURL(PageContext, String) resolved}
* to an context relative url.<br/>
* Then, a prefixed contextPath is removed from the resulting url.<br/>
- * If the actionURL parameter is specified (not null), a action or
render PortletURL
- * is created based on its value.<br/>
- * Otherwise, [EMAIL PROTECTED] PortletURLTypes#isActionURL(String)} is
used to determine which
- * type of PortletURL must be created.
+ * If the type parameter is specified (not null), the type of url
created is based on its value.<br/>
+ * Otherwise, [EMAIL PROTECTED] PortletURLTypes#getType(String)} is used
to determine which
+ * type of url must be created.
* </p>
* @param pageContext the JSP pageContext
* @param url the url to resolve
- * @param actionURL indicator if a ActionURL or RenderURL must be created
- * @return an action or render PortletURL
+ * @param type indicated which type of url must be created
+ * @return an action or render PortletURL, or a ResourceURL
*/
- public static String getPortletURL(PageContext pageContext, String url,
Boolean actionURL)
+ public static String getURL(PageContext pageContext, String url,
PortletURLTypes.URLType type)
{
url = getContextRelativeURL(pageContext,url,false);
String contextPath =
((HttpServletRequest)pageContext.getRequest()).getContextPath();
@@ -114,24 +113,23 @@
url = url.substring(contextPath.length());
}
- boolean action = false;
- if ( actionURL != null )
- {
- action = actionURL.booleanValue();
- }
- else if ( url != null )
+ if ( type == null )
{
StrutsPortletConfig strutsPortletConfig =
(StrutsPortletConfig)pageContext.getAttribute(StrutsPortlet.STRUTS_PORTLET_CONFIG,PageContext.APPLICATION_SCOPE);
- action =
strutsPortletConfig.getPortletURLTypes().isActionURL(url);
+ type = strutsPortletConfig.getPortletURLTypes().getType(url);
}
- if ( action )
+ if ( type.equals(PortletURLTypes.URLType.ACTION) )
{
return
StrutsPortletURL.createActionURL(pageContext.getRequest(),url).toString();
}
- else
+ else if ( type.equals(PortletURLTypes.URLType.RENDER) )
{
return
StrutsPortletURL.createRenderURL(pageContext.getRequest(),url).toString();
+ }
+ else // type.equals(PortletURLTypes.URLType.RESOURCE)
+ {
+ return contextPath + "/" + url;
}
}
1.2 +90 -49
jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib/ELRewriteTag.java
Index: ELRewriteTag.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/taglib/ELRewriteTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ELRewriteTag.java 20 Jan 2005 01:41:14 -0000 1.1
+++ ELRewriteTag.java 21 Jan 2005 16:28:13 -0000 1.2
@@ -33,72 +33,75 @@
public class ELRewriteTag extends
org.apache.strutsel.taglib.html.ELRewriteTag
{
/**
- * Indicates if a RenderURL or ActionURL must be generated.
+ * Indicates which type of a url must be generated: action, render or
resource.
* <p>If not specified, the type will be determined by
- * [EMAIL PROTECTED] PortletURLTypes#isActionURL(String)}</p>.
+ * [EMAIL PROTECTED] PortletURLTypes#getType(String)}</p>.
*/
- protected Boolean actionURL = null;
+ protected PortletURLTypes.URLType urlType = null;
+ /**
+ * @return "true" if an ActionURL must be rendered
+ */
public String getActionURL()
{
- return actionURL != null ? action.toString() : null;
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.ACTION) ? "true" : "false";
}
+ private String actionURL;
/**
- * Render an ActionURL when set to "true" otherwise render a RenderURL
- * @param actionURL "true" renders an ActionURL otherwise a RenderURL
+ * Render an ActionURL when set to "true"
+ * <p>
+ * Supports jstl expression language.
+ * </p>
+ * @param actionURL when (evaluated to) "true" renders an ActionURL
*/
public void setActionURL(String actionURL)
{
- this.actionURL = actionURL != null ?
actionURL.equalsIgnoreCase("true") ? Boolean.TRUE : Boolean.FALSE : null;
+ // delay evaluation of urlType to doStartTag
+ this.actionURL = actionURL;
}
public String getRenderURL()
{
- return actionURL != null ? actionURL.booleanValue() ? "false" :
"true" : null;
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.RENDER) ? "true" : "false";
}
+ private String renderURL;
/**
- * Render a RenderURL when set to "true" otherwise render an ActionURL
- * @param renderURL "true" renders a RenderURL otherwise an ActionURL
+ * Render a RenderURL when set to "true"
+ * <p>
+ * Supports jstl expression language.
+ * </p>
+ * @param renderURL when (evaluated to) "true" renders a RenderURL
*/
public void setRenderURL(String renderURL)
{
- this.actionURL = renderURL != null ?
renderURL.equalsIgnoreCase("true") ? Boolean.FALSE : Boolean.TRUE : null;
+ // delay evaluation of urlType to doStartTag
+ this.renderURL = renderURL;
}
- /**
- * struts-el support for [EMAIL PROTECTED] #setActionURL(String)}
- */
- protected String actionURLExpr = null;
-
- public String getActionURLExpr()
+ public String getResourceURL()
{
- return actionURLExpr;
- }
-
- public void setActionURLExpr(String actionURLExpr)
- {
- this.actionURLExpr = actionURLExpr;
+ return urlType != null &&
urlType.equals(PortletURLTypes.URLType.RESOURCE) ? "true" : "false";
}
+
+ private String resourceURL;
/**
- * struts-el support for [EMAIL PROTECTED] #setRenderURL(String)}
+ * Render a ResourceURL when set to "true"
+ * <p>
+ * Supports jstl expression language.
+ * </p>
+ * @param resourceURL when (evaluated to) "true" renders a ResourceURL
*/
- protected String renderURLExpr = null;
-
- public String getRenderURLExpr()
+ public void setResourceURL(String resourceURL)
{
- return renderURLExpr;
+ // delay evaluation of urlType to doStartTag
+ this.resourceURL = resourceURL;
}
-
- public void setRenderURLExpr(String renderURLExpr)
- {
- this.renderURLExpr = renderURLExpr;
- }
-
+
/**
- * Generates a PortletURL for the link when in the context of a
+ * Generates a PortletURL or a ResourceURL for the link when in the
context of a
* [EMAIL PROTECTED] PortletServlet#isPortletRequest(ServletRequest)
PortletRequest}, otherwise
* the default behaviour is maintained.
* @return the link url
@@ -110,10 +113,34 @@
if ( PortletServlet.isPortletRequest(pageContext.getRequest()))
{
+ String url = null;
BodyContent bodyContent = pageContext.pushBody();
- super.doStartTag();
- String url =
TagsSupport.getPortletURL(pageContext,super.calculateURL(),actionURL);
- pageContext.popBody();
+ try
+ {
+ super.doStartTag();
+ url = bodyContent.getString();
+
+ // process embedded anchor
+ String anchor = null;
+ int hash = url.indexOf('#');
+ if ( hash > -1 )
+ {
+ // save embedded anchor to be appended later and strip
it from the url
+ anchor = url.substring(hash);
+ url = url.substring(0,hash);
+ }
+
+ url = TagsSupport.getURL(pageContext, url, urlType);
+
+ if ( anchor != null )
+ {
+ url = url + anchor;
+ }
+ }
+ finally
+ {
+ pageContext.popBody();
+ }
TagUtils.getInstance().write(pageContext, url);
return (SKIP_BODY);
}
@@ -122,30 +149,44 @@
return super.doStartTag();
}
}
-
+
/**
- * Resolve the [EMAIL PROTECTED] #actionURLExpr} and [EMAIL PROTECTED]
#renderURLExpr} attributes using the JSTL expression
- * evaluation engine ([EMAIL PROTECTED] EvalHelper}).
+ * Resolve the [EMAIL PROTECTED] #actionURL}, [EMAIL PROTECTED]
#renderURL} and [EMAIL PROTECTED] #resourceURL} attributes
+ * using the Struts JSTL expression evaluation engine ([EMAIL PROTECTED]
EvalHelper}).
* @exception JspException if a JSP exception has occurred
*/
private void evaluateExpressions() throws JspException {
- String string = null;
+ Boolean value;
- if ((string = EvalHelper.evalString("actionURL",
getActionURLExpr(),this, pageContext)) != null)
+ value = EvalHelper.evalBoolean("actionURL", actionURL,this,
pageContext);
+ if ( value != null && value.booleanValue() )
+ {
+ urlType = PortletURLTypes.URLType.ACTION;
+ }
+ if ( urlType == null )
{
- setActionURL(string);
+ value = EvalHelper.evalBoolean("renderURL", renderURL,this,
pageContext);
+ if ( value != null && value.booleanValue() )
+ {
+ urlType = PortletURLTypes.URLType.RENDER;
+ }
}
- if ((string = EvalHelper.evalString("renderURL",
getRenderURLExpr(),this, pageContext)) != null)
+ if ( urlType == null )
{
- setRenderURL(string);
+ value = EvalHelper.evalBoolean("resourceURL", resourceURL,this,
pageContext);
+ if ( value != null && value.booleanValue() )
+ {
+ urlType = PortletURLTypes.URLType.RESOURCE;
+ }
}
}
public void release() {
super.release();
+ urlType = null;
actionURL = null;
- actionURLExpr = null;
- renderURLExpr = null;
+ renderURL = null;
+ resourceURL = null;
}
}
1.2 +51 -15
jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/config/PortletURLTypes.java
Index: PortletURLTypes.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/config/PortletURLTypes.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PortletURLTypes.java 20 Jan 2005 01:41:14 -0000 1.1
+++ PortletURLTypes.java 21 Jan 2005 16:28:13 -0000 1.2
@@ -31,10 +31,36 @@
}
};
+ public static class URLType
+ {
+ public static final URLType ACTION = new URLType(0,"action");
+ public static final URLType RENDER = new URLType(1,"render");
+ public static final URLType RESOURCE = new URLType(2,"resource");
+
+ private int id;
+ private String name;
+
+ private URLType(int id, String name)
+ {
+ this.id = id;
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean equals(URLType type)
+ {
+ return type != null ? type.id == id : false;
+ }
+ }
+
public static class PortletURLType
{
- private String path;
- private boolean action;
+ private String path;
+ private URLType type;
public PortletURLType(){}
public String getPath()
@@ -47,23 +73,23 @@
this.path = path;
}
- public void setAction(boolean action)
+ public void setType(URLType type)
{
- this.action = action;
+ this.type = type;
}
- public boolean isAction()
+ public URLType getType()
{
- return action;
+ return type;
}
public String toString()
{
- return "PortletURLType: path="+path+", action="+action;
+ return "PortletURLType: path="+path+", type="+type;
}
}
- private boolean defaultAction;
+ private URLType defaultPortletURLType = URLType.RENDER;
private PortletURLType[] portletURLTypes = new PortletURLType[0];
private ArrayList portletURLTypeList;
@@ -72,21 +98,28 @@
public void addActionType(PortletURLType portletURLType)
{
checkLoaded();
- portletURLType.setAction(true);
+ portletURLType.setType(URLType.ACTION);
portletURLTypeList.add(portletURLType);
}
public void addRenderType(PortletURLType portletURLType)
{
checkLoaded();
- portletURLType.setAction(false);
+ portletURLType.setType(URLType.RENDER);
+ portletURLTypeList.add(portletURLType);
+ }
+
+ public void addResourceType(PortletURLType portletURLType)
+ {
+ checkLoaded();
+ portletURLType.setType(URLType.RESOURCE);
portletURLTypeList.add(portletURLType);
}
public void setDefault(String value)
{
checkLoaded();
- this.defaultAction = "action".equals(value.toLowerCase());
+ this.defaultPortletURLType = "action".equals(value.toLowerCase()) ?
URLType.ACTION : URLType.RENDER;
}
public void configure(Digester digester)
@@ -100,6 +133,9 @@
digester.addObjectCreate("config/portlet-url-type/render",
PortletURLType.class);
digester.addSetProperties("config/portlet-url-type/render");
digester.addSetNext("config/portlet-url-type/render",
"addRenderType");
+ digester.addObjectCreate("config/portlet-url-type/resource",
PortletURLType.class);
+ digester.addSetProperties("config/portlet-url-type/resource");
+ digester.addSetNext("config/portlet-url-type/resource",
"addResourceType");
digester.addCallMethod("config/portlet-url-type", "afterLoad");
}
@@ -123,17 +159,17 @@
portletURLTypeList = null;
}
- public boolean isActionURL(String path)
+ public URLType getType(String path)
{
- boolean action = defaultAction;
+ URLType type = defaultPortletURLType;
for (int i = 0; i < portletURLTypes.length; i++ )
{
if (path.startsWith(portletURLTypes[i].path))
{
- action = portletURLTypes[i].action;
+ type = portletURLTypes[i].getType();
break;
}
}
- return action;
+ return type;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]