[opencms-dev] how to use opencms for my webproject

Harald Brabenetz brabenetz at gmx.net
Tue Jun 12 21:08:04 CEST 2012


Hi,

I would deploy the Struts2-application as separated Web-application(In the same Tomcat as OpenCms).

1. In your OpenCms template basically check the Request-Parameter "ContentPart":
-------------------------------------
<c:if test="${param.ContentPart is empty || param.ContentPart=='HEADER'}">
<html>
	<head>
		.....
	</head>
	<body class="content">
		<div id="inner">
</c:if>
-------------------------------------
and so on for "NAVIGATION" and "FOOTER"


2. In your webapp template (sitemesh or tiles) import the ContentPart you want:
------------------------------------------------
<%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<c:set var="openCmsContentPage" value="http://....../myApplicationPage.html" />

<c:import url="${openCmsContentPage}?ContentPart=HEADER" />
<c:import url="${openCmsContentPage}?ContentPart=NAVIGATION" />

<tiles:insert name="content" />

<c:import url="${openCmsContentPage}?ContentPart=FOOTER" />
------------------------------------------------


3. Of course You want link to your Web-application in your Navigation:
 - Create in OpenCms Page (The content is not relevant).
 - Select your OpenCms template
 - Set a Property (e.g.: "externalWebapp") the value to your Webapplikation
 - modify your OpenCms Navigation:
------------------------------------------------------
<c:forEach items="${nav.items}" var="elem">
	....
	<c:if test="${not empty elem.properties.externalWebapp}">
		<a href="${elem.properties.externalWebapp}"
	</c:if>
	<c:if test="${empty elem.properties.externalWebapp}">
		<a href="<cms:link>${elem.resourceName}</cms:link>"
	</c:if>
	....
------------------------------------------------------

I hope this helps,

regards,
Harald

-------- Original-Nachricht --------
> Datum: Tue, 12 Jun 2012 10:38:49 +0100
> Von: Roshan Wankhade <roshan.protocol at gmail.com>
> An: opencms-dev at opencms.org
> Betreff: [opencms-dev] how to use opencms for my webproject

> Hi,
> 
> I'm developing the web based project on the HRIS(Human Resource
> Information
> System) in which the client required the content management system.
> I have choose the OpenCms for the developement of Content management
> system.
> 
> I have to do this project in struts2 and hibernate (which provide multiple
> database support).
> i have made the opencms setup on my apache TOMCAT localhost. It's running
> fine.
> 
> *But i'm wondering how i will use this open cms in my HRIS project which i
> developing in eclipse Indigo.*
> *
> *
> Please anybody help me, i'm totally stuck.
> 
> Thanks,
> Roshan Wankhade.

-- 
Harald Brabenetz

Mauergasse 9
8020 Graz
AUSTRIA

Tel.. +43 664 1221025
Fax: +43 820 220262587

E-mail: brabenetz at gmx.net
Skype: brabenetz
Google-Talk: brabenetz
URL: http://www.brabenetz.net



-------------- next part --------------
<%@page buffer="none" session="false" taglibs="c,cms,fn" %>
<c:set var="navStartLevel" ><cms:property name="NavStartLevel" file="search" default="0" /></c:set>
<cms:navigation type="forFolder" startLevel="${navStartLevel}" var="nav"/>
<div id="nav_main" class="gradient">
<c:if test="${!empty nav.items}">
	<ul>
		<c:set var="oldLevel" value="" />
		<c:forEach items="${nav.items}" var="elem">
			<c:set var="currentLevel" value="${elem.navTreeLevel}" />
			
			<c:choose>
				<c:when test="${empty oldLevel}"></c:when>
				<c:when test="${currentLevel > oldLevel}"><ul></c:when>
				<c:when test="${currentLevel == oldLevel}"></li></c:when>
				<c:when test="${oldLevel > currentLevel}">
					<c:forEach begin="${currentLevel+1}" end="${oldLevel}"></li></ul></c:forEach>
				</c:when>
			</c:choose>
			
			<li>
			
			<c:if test="${not empty elem.properties.externalWebapp}">
				<a href="${elem.properties.externalWebapp}"
			</c:if>
			<c:if test="${empty elem.properties.externalWebapp}">
				<a href="<cms:link>${elem.resourceName}</cms:link>"
			</c:if>
			
			<c:choose><c:when test="${fn:startsWith(cms.requestContext.uri, elem.resourceName)}">class="gradient current"</c:when><c:otherwise>class="gradient"</c:otherwise></c:choose>>${elem.navText}</a>
			
			<c:set var="oldLevel" value="${currentLevel}" />
		</c:forEach>
		
		<c:forEach begin="${navStartLevel+1}" end="${oldLevel}"></li></ul></c:forEach>
	</ul>
</c:if>
</div>
-------------- next part --------------
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>

<c:if test="${param.ContentPart is empty || param.ContentPart=='HEADER'}">
<html>
	<head>
		.....
	</head>
	<body class="content">
		<div id="inner">
</c:if>


<c:if test="${param.ContentPart is empty || param.ContentPart=='NAVIGATION'}">
			<div id="content_navigation">
				<%-- OpenCms Menu1 --%>
			</div>
</c:if>


<div id="content">
<!-- CMS content TAG not realy relevant for your application -->
</div>


<c:if test="${param.ContentPart is empty || param.ContentPart=='FOOTER'}">

			<div id="content_footer">
			<%-- OpenCms footer --%>
			</div>
		</div>
	</body>
</html>
</c:if>
-------------- next part --------------
<%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<c:set var="openCmsContentPage" value="http://....../myApplicationPage.html" />

<c:catch var="exceptions">
	<c:import url="${openCmsContentPage}?ContentPart=HEADER" />
</c:catch>
<c:if test="${exceptions != null}">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		  
	</head>
	<body>
</c:if>

<c:catch var="exceptions">
   <c:import url="${openCmsContentPage}?ContentPart=NAVIGATION" />
</c:catch>

<div id="content">
	<tiles:insert name="content" />
</div>

<c:catch var="exceptions">
	<c:import url="${openCmsContentPage}?ContentPart=FOOTER" />
</c:catch>
<c:if test="${exceptions != null}">
	</body>
</html>
</c:if>


More information about the opencms-dev mailing list