You are viewing a plain text version of this content. The canonical link for it is here.
Posted to portalapps-dev@portals.apache.org by wo...@apache.org on 2010/05/14 19:29:22 UTC
svn commit: r944346 - in
/portals/applications/sandbox/content/trunk/src/main:
java/org/apache/portals/applications/content/
java/org/apache/portals/applications/content/beans/ webapp/WEB-INF/
webapp/WEB-INF/view/
Author: woonsan
Date: Fri May 14 17:29:21 2010
New Revision: 944346
URL: http://svn.apache.org/viewvc?rev=944346&view=rev
Log:
Improving generic query portlet
Modified:
portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java
portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java
portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/TextPage.java
portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml
portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-view.jsp
Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java?rev=944346&r1=944345&r2=944346&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java (original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java Fri May 14 17:29:21 2010
@@ -16,12 +16,15 @@
*/
package org.apache.portals.applications.content;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.portlet.PortletException;
import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
@@ -38,6 +41,18 @@ import org.apache.portals.applications.c
*/
public class GenericQueryContentPortlet extends GenericContentPortlet
{
+ @Override
+ public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
+ String contentUrlBase = request.getPreferences().getValue("contentUrlBase", null);
+
+ if (contentUrlBase != null)
+ {
+ request.setAttribute("contentUrlBase", contentUrlBase);
+ }
+
+ super.doView(request, response);
+ }
@Override
protected Object getContentBean(final PortletRequest request, final ObjectContentManager ocm, final String contentPath) throws PortletException
Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java?rev=944346&r1=944345&r2=944346&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java (original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java Fri May 14 17:29:21 2010
@@ -27,9 +27,20 @@ import org.apache.jackrabbit.ocm.mapper.
@Node(jcrType="hippostd:html", discriminator=false)
public class HtmlBodyContent
{
-
+ protected String path;
protected String content;
+ @Field(path=true)
+ public String getPath()
+ {
+ return path;
+ }
+
+ public void setPath(String path)
+ {
+ this.path = path;
+ }
+
@Field(jcrName="hippostd:content")
public String getContent()
{
Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/TextPage.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/TextPage.java?rev=944346&r1=944345&r2=944346&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/TextPage.java (original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/TextPage.java Fri May 14 17:29:21 2010
@@ -28,10 +28,22 @@ import org.apache.jackrabbit.ocm.mapper.
@Node(jcrType="onehippo:document", discriminator=false)
public class TextPage
{
+ protected String path;
protected String title;
protected String introduction;
protected HtmlBodyContent bodyContent;
-
+
+ @Field(path=true)
+ public String getPath()
+ {
+ return path;
+ }
+
+ public void setPath(String path)
+ {
+ this.path = path;
+ }
+
@Field(jcrName="onehippo:title")
public String getTitle()
{
Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml?rev=944346&r1=944345&r2=944346&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml (original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml Fri May 14 17:29:21 2010
@@ -93,6 +93,10 @@
<value>/content/documents/en//</value>
</preference>
<preference>
+ <name>contentUrlBase</name>
+ <value>/content/documents/en</value>
+ </preference>
+ <preference>
<name>queryClass</name>
<value>org.apache.portals.applications.content.beans.TextPage</value>
</preference>
@@ -185,6 +189,10 @@
<value>/content/documents/en/news//</value>
</preference>
<preference>
+ <name>contentUrlBase</name>
+ <value>/content/documents/en</value>
+ </preference>
+ <preference>
<name>queryClass</name>
<value>org.apache.portals.applications.content.beans.NewsItem</value>
</preference>
Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-view.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-view.jsp?rev=944346&r1=944345&r2=944346&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-view.jsp (original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-view.jsp Fri May 14 17:29:21 2010
@@ -14,15 +14,25 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY
See the License for the specific language governing permissions and
limitations under the License.
--%>
+<%@ page import="org.apache.jetspeed.request.RequestContext"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="c_rt" uri="http://java.sun.com/jstl/core_rt" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<portlet:defineObjects/>
+<c_rt:set var="requestContext" value="<%=request.getAttribute(RequestContext.REQUEST_PORTALENV)%>"/>
+<c:set var="portalContextPath" value="${requestContext.request.contextPath}" />
+<c:if test="${empty portalContextPath}">
+ <c:set var="portalContextPath" value="/"/>
+</c:if>
+<c:set var="portalServletPath" value="${requestContext.request.servletPath}" />
+
<h1>Content query result</h1>
<hr/>
<c:forEach var="contentItem" items="${contentBean}">
-<h3>${contentItem.title}</h3>
+<h3><a href="${portalContextPath}${portalServletPath}${fn:substringAfter(contentItem.path, contentUrlBase)}">${contentItem.title}</a></h3>
<div>${contentItem.introduction}</div>
<p> </p>
</c:forEach>