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 16:02:48 UTC
svn commit: r944266 - in
/portals/applications/sandbox/content/trunk/src/main:
java/org/apache/portals/applications/content/
java/org/apache/portals/applications/content/beans/ webapp/META-INF/
webapp/WEB-INF/view/
Author: woonsan
Date: Fri May 14 14:02:48 2010
New Revision: 944266
URL: http://svn.apache.org/viewvc?rev=944266&view=rev
Log:
Adding bean property example
Added:
portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java (with props)
Modified:
portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/NewsItem.java
portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/NewsPage.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/META-INF/context.xml
portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-view.jsp
portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/news-item-view.jsp
Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java?rev=944266&r1=944265&r2=944266&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java (original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java Fri May 14 14:02:48 2010
@@ -49,6 +49,8 @@ public class GenericContentPortlet exten
private String ocmProviderJndiName = "java:comp/env/jcr/ocmprovider";
+ private String contentBeanAttributeName = "contentBean";
+
@Override
public void init(PortletConfig config) throws PortletException {
super.init(config);
@@ -80,6 +82,13 @@ public class GenericContentPortlet exten
{
defaultRepositoryPassword = param;
}
+
+ param = StringUtils.trim(getInitParameterFromConfigOrContext(config, "contentBeanAttributeName", null));
+
+ if (!StringUtils.isBlank(param))
+ {
+ contentBeanAttributeName = param;
+ }
}
@Override
@@ -95,7 +104,10 @@ public class GenericContentPortlet exten
ocm = getObjectContentManagerProvider().getObjectContentManager(session);
String contentPath = getContentPath(request);
Object contentBean = ocm.getObject(contentPath);
- request.setAttribute("contentBean", contentBean);
+ request.setAttribute(contentBeanAttributeName, contentBean);
+
+ super.doView(request, response);
+
}
finally
{
@@ -120,8 +132,6 @@ public class GenericContentPortlet exten
}
}
}
-
- super.doView(request, response);
}
protected String getContentPath(final PortletRequest request) throws PortletException
Added: 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=944266&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java (added)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java Fri May 14 14:02:48 2010
@@ -0,0 +1,44 @@
+/*
+ * 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 org.apache.portals.applications.content.beans;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+/**
+ * HtmlBodyContent
+ *
+ * @version $Id$
+ */
+@Node(jcrType="hippostd:html", discriminator=false)
+public class HtmlBodyContent
+{
+
+ protected String content;
+
+ @Field(jcrName="hippostd:content")
+ public String getContent()
+ {
+ return this.content;
+ }
+
+ public void setContent(String content)
+ {
+ this.content = content;
+ }
+
+}
Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/HtmlBodyContent.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/NewsItem.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/NewsItem.java?rev=944266&r1=944265&r2=944266&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/NewsItem.java (original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/NewsItem.java Fri May 14 14:02:48 2010
@@ -16,6 +16,7 @@
*/
package org.apache.portals.applications.content.beans;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Bean;
import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
@@ -25,39 +26,55 @@ import org.apache.jackrabbit.ocm.mapper.
* @version $Id$
*/
@Node(jcrType="onehippo:newsitem", discriminator=false)
-public class NewsItem {
+public class NewsItem
+{
protected String title;
protected String summary;
protected String introduction;
- protected String body;
+ protected HtmlBodyContent bodyContent;
@Field(jcrName="onehippo:title")
- public String getTitle() {
+ public String getTitle()
+ {
return this.title;
}
- public void setTitle(String title) {
+ public void setTitle(String title)
+ {
this.title = title;
}
@Field(jcrName="onehippo:summary")
- public String getSummary() {
+ public String getSummary()
+ {
return this.summary;
}
- public void setSummary(String summary) {
+ public void setSummary(String summary)
+ {
this.summary = summary;
}
@Field(jcrName="onehippo:introduction")
- public String getIntroduction() {
+ public String getIntroduction()
+ {
return this.introduction;
}
- public void setIntroduction(String introduction) {
+ public void setIntroduction(String introduction)
+ {
this.introduction = introduction;
}
-
+ @Bean(jcrName="onehippo:body", proxy=true)
+ public HtmlBodyContent getBodyContent()
+ {
+ return bodyContent;
+ }
+
+ public void setBodyContent(HtmlBodyContent bodyContent)
+ {
+ this.bodyContent = bodyContent;
+ }
}
Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/NewsPage.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/NewsPage.java?rev=944266&r1=944265&r2=944266&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/NewsPage.java (original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/beans/NewsPage.java Fri May 14 14:02:48 2010
@@ -16,6 +16,7 @@
*/
package org.apache.portals.applications.content.beans;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Bean;
import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
@@ -25,26 +26,43 @@ import org.apache.jackrabbit.ocm.mapper.
* @version $Id$
*/
@Node(jcrType="demosite:textpage", discriminator=false)
-public class NewsPage {
+public class NewsPage
+{
protected String title;
- protected String summary;
+ protected String summary;
+ protected HtmlBodyContent bodyContent;
@Field(jcrName="demosite:title")
- public String getTitle() {
+ public String getTitle()
+ {
return this.title;
}
- public void setTitle(String title) {
+ public void setTitle(String title)
+ {
this.title = title;
}
@Field(jcrName="demosite:summary")
- public String getSummary() {
+ public String getSummary()
+ {
return this.title;
}
- public void setSummary(String summary) {
+ public void setSummary(String summary)
+ {
this.summary = summary;
}
+
+ @Bean(jcrName="demosite:body", proxy=true)
+ public HtmlBodyContent getBodyContent()
+ {
+ return bodyContent;
+ }
+
+ public void setBodyContent(HtmlBodyContent bodyContent)
+ {
+ this.bodyContent = bodyContent;
+ }
}
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=944266&r1=944265&r2=944266&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 14:02:48 2010
@@ -16,6 +16,7 @@
*/
package org.apache.portals.applications.content.beans;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Bean;
import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
@@ -25,26 +26,43 @@ import org.apache.jackrabbit.ocm.mapper.
* @version $Id$
*/
@Node(jcrType="demosite:textpage", discriminator=false)
-public class TextPage {
+public class TextPage
+{
protected String title;
protected String summary;
+ protected HtmlBodyContent bodyContent;
@Field(jcrName="demosite:title")
- public String getTitle() {
+ public String getTitle()
+ {
return this.title;
}
- public void setTitle(String title) {
+ public void setTitle(String title)
+ {
this.title = title;
}
@Field(jcrName="demosite:summary")
- public String getSummary() {
+ public String getSummary()
+ {
return this.title;
}
- public void setSummary(String summary) {
+ public void setSummary(String summary)
+ {
this.summary = summary;
}
+
+ @Bean(jcrName="demosite:body", proxy=true)
+ public HtmlBodyContent getBodyContent()
+ {
+ return bodyContent;
+ }
+
+ public void setBodyContent(HtmlBodyContent bodyContent)
+ {
+ this.bodyContent = bodyContent;
+ }
}
Modified: portals/applications/sandbox/content/trunk/src/main/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/META-INF/context.xml?rev=944266&r1=944265&r2=944266&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/META-INF/context.xml (original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/META-INF/context.xml Fri May 14 14:02:48 2010
@@ -25,7 +25,9 @@
type="javax.jcr.Repository"
factory="org.apache.portals.applications.content.jndi.ObjectContentManagerProviderObjectFactory"
annotatedClassNames="
+ org.apache.portals.applications.content.beans.HtmlBodyContent
org.apache.portals.applications.content.beans.TextPage
+ org.apache.portals.applications.content.beans.NewsPage
org.apache.portals.applications.content.beans.NewsItem
"
/>
Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-view.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-view.jsp?rev=944266&r1=944265&r2=944266&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-view.jsp (original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-view.jsp Fri May 14 14:02:48 2010
@@ -30,3 +30,7 @@ limitations under the License.
<td>${contentBean.summary}</td>
</tr>
</table>
+
+<hr/>
+
+${contentBean.bodyContent.content}
Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/news-item-view.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/news-item-view.jsp?rev=944266&r1=944265&r2=944266&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/news-item-view.jsp (original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/news-item-view.jsp Fri May 14 14:02:48 2010
@@ -30,3 +30,7 @@ limitations under the License.
<td>${contentBean.introduction}</td>
</tr>
</table>
+
+<hr/>
+
+${contentBean.bodyContent.content}