Can anyone please help me how to integrate OpenCMS with a Java Spring Web Application.Already googled and gone thru a lot of websites but no use.So, please help me.
I think there are two approaches in integrating SpringMVC with OpenCMS:
1) Two separate applications, a SpringMVC application and a standard OpenCMS installation. The SpringMVC application fetches content from OpenCMS via webservices implemented in OpenCMS. A bit more detail can be found here: http://lists.opencms.org/pipermail/opencms-dev/2012q3/037154.html. This approach is good if you are starting a new project or extending an existing SpringMVC site to add content management. It allows a clean separation between SpringMVC and the content management.
2) Integrating SpringMVC with a standard OpenCMS installation. This means that after the opencms.war is deployed the web.xml is modified to add the SpringMVC dispatcher servlet and a custom view resolver. Controllers are SpringMVC and views are OpenCMS resources. This approach is good if you already have an existing OpenCMS site and want to extend the site to have MVC functionality. For a detailed description of this approach please have a look at http://blog.shinetech.com/2013/04/09/integrating-springmvc-with-opencms/
Add a REST-API to your Spring-application and fetch data from OpenCms jsps directly through that API.
Here an example how to fetch data using Jackson to convert JSON to Objects:
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" session="true"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%# taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%# taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%# taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%# page import="org.codehaus.jackson.map.ObjectMapper" %>
<%# page import="org.codehaus.jackson.type.TypeReference" %>
<%# page import="java.util.*, java.net.*" %>
<%
ObjectMapper mapper = new ObjectMapper();
List<Map<String, Object>> result = mapper.readValue(new URL("https://server/api/rest/employeesOrderedByDepartment"), new TypeReference<List<Map<String, Object>>>() {} );
pageContext.setAttribute("result", result);
%>
<div class="span10">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Department</th>
<th>Function</th>
<th>Phone & Email</th>
</tr>
</thead>
<tbody id="staffbody">
<c:forEach items="${result}" var="person" varStatus="status">
<tr>
<td>${person.lastName} ${person.firstName}</td>
<td>${person.department.name}</td>
<td>${person.function}</td>
<td>${person.phone}<br /><a href='mailto:${person.email}'>${person.email}</a></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
Related
I have two applications:
X.Web - Asp.net core 1.1 web application
X.Api - ASP.NET WebApi2 application in .NET 4.6.1
Now they are both available as www.example.com/X.Web and www.example.com/X.Api respectively. My customer wants the web application to be available simply as www.example.com.
I tried a quick solution in my test environment - I just moved the content of X.Web folder to wwwroot and without any problems everything worked fine.
However, on my production server the web app works - htmls, scripts and styles are loaded correctly, but X.Api stops working - i get response
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> IIS 502.5 Error </title>
<style type="text/css"></style>
</head>
<body>
<div id = "content">
<div class = "content-container">
<h3> HTTP Error 502.5 - Process Failure </h3>
</div>
<div class = "content-container">
<fieldset>
<h4> Common causes of this issue: </h4>
<ul>
<li> The application process failed to start </li>
<li> The application process started but then stopped </li>
<li> The application process started but failed to listen on the configured port </li>
</ul>
</fieldset>
</div>
<div class = "content-container">
<fieldset>
<h4> Troubleshooting steps: </h4>
<ul>
<li> Check the system event log for error messages </li>
<li> Enable logging the application process’ stdout messages </li>
<li> Attach a debugger to the application process and inspect </li>
</ul>
</fieldset>
<fieldset>
<h4> For more information visit:
<a href="https://go.microsoft.com/fwlink/?linkid=808681">
<cite> https://go.microsoft.com/fwlink/?LinkID=808681 </cite>
</a>
</h4>
</fieldset>
</div>
</div>
</body>
</html>
for each and every request. In my Event log I can see:
Application 'MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE/X.API' with
physical root 'C:\inetpub\wwwroot\X.Api\' failed to start process
with commandline '"dotnet" .\X.Web.dll', ErrorCode =
'0x80004005 : 80008081.
The questions are:
1) what can be a problem
2) Why in the event log I can see ...failed to start process
with commandline '"dotnet" .**X.Web.dll**...
3) Is there any other way to achieve this simple requirement of my client
So, just to make sure I understand you properly, initially, you had: www.example.com/X.Web and www.example.com/X.Api, and X.Web was calling X.Api, right? Then you moved X.Web files from wwwroot/X.Web to wwwroot directly, and it worked on your env but not on the production env? Which version of IIS are you using?
1/ Maybe an idea: by moving X.Web maybe you have changed the user under which your X.Web application was running, making it unable to launch your ASP.NET Core application.
2/ My suggestion to 1 could explain, credentials issues.
3/ I would definitively avoid putting the file of X.Web directly under wwwroot and instead I would configure IIS to get a redirection from www.example.com to www.example.com/X.Wep. You could use URL Rewrite module (maybe an overkill in that case but it's a module that is very good to know in my opinion because it can help in various scenario) or simply configure IIS to redirect, this SO thread could be helping How to redirect a URL path in IIS?
I have two public pages, each having a portlet.
For the first portlet, on click of a button, I want to open up the other portlet.
Is there any simple way to do this in liferay 6.2?
So far, I tried -
Currently from the group/game/portal page ->
<script>
function manageGame() {
response.sendRedirect('group/games/manage');
}
</script>
<button onClick="manageGame()">Manage</button>
Either you can create URL in controller and pass it to JSP as below
PortletURL liferayURL = PortletURLFactoryUtil.create(renderRequest,<<portlet-name>>, <<Plid>>,PortletRequest.RENDER_PHASE);
renderRequest.setAttribute("anotherPortletUrl", liferayURL);
JSP
click here
OR
You can create Liferay Portlet Render URL in JSP as below
<%#page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%# taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<liferay-portlet:renderURL plid="10180" portletName="portlet-name" var="openForm" windowState="<%=LiferayWindowState.POP_UP.toString()%>"></liferay-portlet:renderURL>
With above two methods you can create a url on click of which portlet on other page will be opened.
If you portlet is instanciable add instance with portletname
When putting the liferay tag cloud portlet on a page, clicking the links in the tag cloud will just render the result in the same page if and only if I have an asset publisher portlet on the same page.
What I would want is that when I click a link in the tag cloud, it should take me to a different page showing the results, eg. a search result page.
Is there a way of doing this using the standard components? Or will I have to write my own tag cloud portlet to support this feature?
You dont have to create a new portlet. Please follow these steps
1) By using hooks, modify the links that are generated in the tag cloud portlet for the tags. Instead of current layout, redirect to the designated page (for eg. If you are on /web/guest/tag page, then all tags link will start from the /web/guest/tag?..... Make this to /web/guest/search?....)
2) on the search page, put the asset publisher
So now, when you click any tag link, it will go the search page, since this page has asset publisher, it reads all the parameters from the request url and from the session, and it will show results on the search page.
The code for this hook :
File liferay-hook.xml:
<hook>
<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
</hook>
File /docroot/META-INF/custom_jsps/html/taglib/ui/asset_tags_navigation/page.jsp:
<%# include file="/html/taglib/ui/asset_tags_navigation/init.jsp" %>
<%# taglib uri="<http://liferay.com/tld/util>"
prefix="liferay-util" %>
<%# page import="com.liferay.portal.kernel.util.StringUtil" %>
<%# page import="com.liferay.portal.service.LayoutLocalServiceUtil"%>
<liferay-util:buffer var="html">
<liferay-util:include page="/html/taglib/ui/asset_tags_navigation/page.portal.jsp"/>
</liferay-util:buffer>
<% Layout searchLayout =
LayoutLocalServiceUtil.getFriendlyURLLayout(scopeGroupId, false,
"/search");
html = StringUtil.replace(html,layout.getRegularURL(request),searchLayout.getRegularURL(request));
%>
<%= html %>
I am trying to create a simple JSF application...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%#taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%#taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%# page import="java.util.*"%>
<html>
<head>
<title>Login</title>
<f:loadBundle var="Message" basename="bundle.Messages" />
</head>
<body>
<f:view>
<h:form id="loginForm">
<h:message for="loginForm" />
<br />
<h:outputText value="#{Message.username_label}" ></h:outputText>
</h:form>
</f:view>
</body>
</html>
However, when I try to run the page in my browser, I get the value #{Message.username_label}. Could someone please help me to understand why the value was not substituted into the page?
So, EL doesn't get evaluated? This can happen when the web.xml is not properly declared conform at least Servlet 2.4 (for JSF 1.0/1.1) or 2.5 (for JSF 1.2) and/or your classpath is polluted with old versioned servletcontainer specific libraries.
Since you're using legacy JSP instead of its successor Facelets, I'll bet that you're using JSF 1.2 on a Servlet 2.5 container (such as Tomcat 6.0). In this case, you need to ensure that the web.xml is declared as follows:
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
version="2.5"
>
<!-- Your config here -->
</web-app>
In addition, you also need to ensure that you don't have any servletcontainer specific libraries like servlet-api.jar, j2ee.jar, javaee.jar, jsp-api.jar, etc.. in your webapp's /WEB-INF/lib folder or, worse, in the JRE/lib/ext folder. Get rid of them, they are supposed to be supplied by the servletcontainer itself, not your webapp. The /WEB-INF/lib folder should contain only the JSF libraries and other libraries specific to the webapp itself.
It is obvious to me. is not a complied staememnt in java therfore the foundation of core cant encrypt it. the id is not being compiled because you have it in these <> do you know java?
I am totally new to Sharepoint (2007) so please bear with me. I would like to automatically create aspx pages when a new site is created. These pages will be linked to through tabs which will be defined by a master page. I do not have a custom site definition and was planning to apply feature stapling to the out of the box blank site definition.
Through my research, I think you can create a web part page and turn this into a feature. I can then staple this to the blank site definition. The problem is I haven't found any information on how to do this. So the two questions I have are:
How do I create a feature that is just an aspx page?
How do I staple this feature to a blank site definition?
I found one person asking the same question here: How to add a web part page to a site definition?
I read the first response but it sort of goes over my head and I don't know if it really answers my question.
Thanks so much!
The answer to your first question depends on whether you mean application pages or content pages. They each have their advantages: application pages are good in that they can run custom server-side code, and content pages are nice because (for example) they can be customized by users, but by default are restricted in what kind of code can be run.
For a pretty good discussion on the differences between the two types in capabilities and restrictions, check out the Windows SharePoint Services SDK and look at the topics called "Application _layouts page type" and "Content page type."
As for stapling, it's pretty easy and more flexible than adding new features to a site definition's onet.xml file. This article seems a pretty good overview of the alternatives. You might want to make a copy of the blank site definition, rename it, and then use that one in your work, though.
Features with content pages
You'll need three types of things for this:
A feature.xml file -- just the boilerplate stuff that refers to the element manifest.
A page template -- this could be the entire aspx page itself, or it could be (for example) a shell of a web part page with WebPartZones defined but no actual web parts (yet).
The element manifest file which refers to your page templates and defines any web parts that should be provisioned as part of activation of your feature.
Your feature's folder structure would look something like this:
12
+-- TEMPLATES
+-- FEATURES
+-- YourFeature
+-- PageTemplates
| +-- Page.aspx (simple aspx page)
| +-- WebPartPage.aspx (still simple, but with WebPartZones)
+-- feature.xml
+-- elements.xml
Feature.xml:
<Feature
Id="CFF117BC-9685-4a7b-88D0-523D9DAD21F0"
Title="Custom Pages Feature"
Scope="Web"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml"/>
</ElementManifests>
</Feature>
Elements.xml
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Path="PageTemplates" Url="Pages" >
<File Url="Page.aspx" Type="Ghostable" />
<File Url="WebPartPage.aspx" Name="WebPartPage.aspx" Type="Ghostable" >
<AllUsersWebPart WebPartZoneID="Left" WebPartOrder="0">
<![CDATA[
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"
xmlns:cewp="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
<Title>Some content that you want to provision with the feature</Title>
<FrameType>TitleBarOnly</FrameType>
<cewp:Content>
Hello world.
</cewp:Content>
</WebPart>
]]>
</AllUsersWebPart>
</File>
</Module>
</Elements>
Page.aspx
<%# Page MasterPageFile="~masterurl/default.master"
meta:progid="SharePoint.WebPartPage.Document" %>
<asp:Content runat="server" ContentPlaceHolderID="PlaceHolderMain">
Hello World
</asp:Content>
WebPartPage.aspx
<%# Page Language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" %>
<%# Register Tagprefix="WebPartPages"
Namespace="Microsoft.SharePoint.WebPartPages"
Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ID="main" runat="server" ContentPlaceHolderID="PlaceHolderMain" >
<table width="100%">
<tr>
<td valign="top" style="width:50%">
<WebPartPages:WebPartZone ID="Left" runat="server"
FrameType="TitleBarOnly" Title="Left Web Part Zone" />
</td>
<td valign="top" style="width:50%">
<WebPartPages:WebPartZone ID="Right" runat="server"
FrameType="TitleBarOnly" Title="Right Web Part Zone" />
</td>
</tr>
</table>
</asp:Content>
If you configure your feature in that way, you should be able to deploy site content pages within that structure.
Also, I highly recommend Ted Pattison's Inside Windows SharePoint Services book. It covers this topic in much detail, including the important security aspects of site content pages. It's easily worth the purchase price.