Recently we wanted to implement a few Ajax calls in our Hippo portal, a Jetspeed based portal product. Since you are quite restricted within the context of a portal application with respect to accessing or modifying the response object, it turns out that you need a special kind of strategy in order to receive the ajax calls from the client and pass back the results: resourceURLs.
Our version of Hippo is based on Jetspeed 2.1.3 which does not yet comply with JSR-286 for portal standards. This JSR specifies how to handle ajax calls within a portal. Luckily this part of the specification has already been implemented in Jetspeed 2.1.3. So how does it work?
First we have to create a resourceURL factory :
org.apache.portals.bridges.common.PortletResourceURLFactory resourceURLFactory = new org.apache.jetspeed.portlet.PortletResourceURLFactoryImpl();
I've put this code in the init(config) method of a portlet and store this factory in a private instance variable.
Now in your portlet render template you must use an URL generated by this factory. We prepare this URL in the portlet code and store it in the Freemarker model:
model.put("ajaxurl", resourceURLFactory.createResourceURL(getPortletConfig(),
request, response, null));
Refer to this url in your form:
<form id="aForm" method="post" action="${ajaxurl}">
..
</form>
Now, when this form gets submitted, you will receive a hit on your doView method and you can inspect the request to check whether it was a resource request or a normal request:
org.apache.jetspeed.request.RequestContext jrc =
(org.apache.jetspeed.request.RequestContext)
request.getAttribute(org.apache.jetspeed.PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
if
(jrc.getPortalURL().getNavigationalState().getPortletWindowOfResource()!=null)
{
// it was a resource request
} else {
// it was a normal render request
}
Now you have full control over the response and can set its content type and get the output stream to pass back whatever content you like without going through the portal aggregating cycle. Pretty simple and works like a charm.
dinsdag 23 september 2008
woensdag 23 juli 2008
Getting a Hippo Portal up and running
This week I started on a project where we'll be using Hippo Portal and repository for an online webshop application. I've never before worked with Hippo so it's a chance to get to know something new. The Hippo products in itself are open source and backed by a commercial company by the same name Hippo BV. Technically there are three products: a CMS, a repository and the portal. The Hippo Portal is based on Apache's JetSpeed.
So yesterday I started by trying to install Hippo Portal and encountered a few issues along the way... the Hippo portal homepage contains a setup document detailing how to install hippo repository, hippo portal as well as maven 1.0.2. All fine. Next we try to deploy a Hello World portal as detailed here. The first action (maven hp:create-portal-project) fails for two reasons:
Still an error message. Luckily after some browsing through the remainder of the documentation I found out that I needed a sitemap.xml document to be present in the hippo repository, specifying the basic structure of my portal. So I created a sitemap.xml identical to the one specified here and uploaded it to the hippo repository. This sitemap.xml contains a reference to the document /content/documents/home.xml which does not exist in the repository. I did find a document called /content/documents/test.xml so I changed the reference in sitemap.xml from home.xml to test.xml and uploaded sitemap.xml it for the second time to the repository.
This all seemed fine and logical but the portal still failed to display anything interesting. So I changed the debug level in /gettingstarted/WEB-INF/conf/Log4j.properties from ERROR to DEBUG and discovered in /gettingstarted/logs/jetspeed.log that something was wrong with a layout. The origin of the problem was that the
<table border="0" cellspacing="10" width="100%">
<tbody><tr>
<td valign="top">#includeFragment($myPage "home-HelloWorld")</td>
<td valign="top">#includeFragment($myPage "home-PickANumberPortlet")</td>
</tr>
</tbody></table>
Wow. So after all of this the portal did work and now I can proceed trying to understand what happened and how the various config files are related to each other and the repository. One final note: along the way I also changed one other config file although I'm not sure if this change was required to get the portal working. At the end of the
to make sure JetSpeed would look in the
So yesterday I started by trying to install Hippo Portal and encountered a few issues along the way... the Hippo portal homepage contains a setup document detailing how to install hippo repository, hippo portal as well as maven 1.0.2. All fine. Next we try to deploy a Hello World portal as detailed here. The first action (maven hp:create-portal-project) fails for two reasons:
- maven cannot find an XSLT transformer, solved by copying xalan-2.4.1.jar into
/lib/endorsed - on my Windows machine I had to tweak the default project.properties by replacing backslashes in the file project.properties by forward slashes like so:
nl.hippo.portal.server.home=c:/dev/apache-tomcat-5.5.23
and
nl.hippo.portal.jdbc.drivers.path=c:/dev/apache-tomcat-5.5.23/common/endorsed/mysql-connector-java-3.1.12.jar
(and also had to copy the mysql driver into the said directory)
127.0.0.1 preview.localhost
Still an error message. Luckily after some browsing through the remainder of the documentation I found out that I needed a sitemap.xml document to be present in the hippo repository, specifying the basic structure of my portal. So I created a sitemap.xml identical to the one specified here and uploaded it to the hippo repository. This sitemap.xml contains a reference to the document /content/documents/home.xml which does not exist in the repository. I did find a document called /content/documents/test.xml so I changed the reference in sitemap.xml from home.xml to test.xml and uploaded sitemap.xml it for the second time to the repository.
This all seemed fine and logical but the portal still failed to display anything interesting. So I changed the debug level in /gettingstarted/WEB-INF/conf/Log4j.properties from ERROR to DEBUG and discovered in /gettingstarted/logs/jetspeed.log that something was wrong with a layout. The origin of the problem was that the
/gettingstarted-portal/src/webapp/WEB-INF/pages/__site1/home.psml
contains a reference to a layoutType
called default
. Based on this 'default' value Jetspeeds looks in the directory /gettingstarted-portal/src/webapp/decorations/layout/default
for a file called default-layout.vm
and this file was empty. I added the following to default-layout.vm
:<table border="0" cellspacing="10" width="100%">
<tbody><tr>
<td valign="top">#includeFragment($myPage "home-HelloWorld")</td>
<td valign="top">#includeFragment($myPage "home-PickANumberPortlet")</td>
</tr>
</tbody></table>
Wow. So after all of this the portal did work and now I can proceed trying to understand what happened and how the various config files are related to each other and the repository. One final note: along the way I also changed one other config file although I'm not sure if this change was required to get the portal working. At the end of the
project.properties
file in /gettingstarted-portal
I uncommented the last two lines:nl.hippo.portal.jetspeed.psml.basedir=${nl.hippo.portal.home}/src/webapp/WEB-INF/pages
nl.hippo.portal.jetspeed.psml.context=site1
to make sure JetSpeed would look in the
../pages/__site1/
directory to find the psml files.
woensdag 16 juli 2008
How to integrate a blog into my website
While working on my company's website I decided I wanted to include a blog on the site to post any relevant findings, problems or experiences. So here's what I did.
- I created a free account on blogger.com
- I selected a so-called classic template and set the readability to Anybody. Only then did the option appear to publish to a custom domain, which is what I wanted, because I already have a domain name and a web hosting contract
- Selected Publishing via FTP and entered all the account details. I created a new directory /blog/ in the root of my web space
- Republished the site and...yep, it worked, I could see the first post at www.wwwilpower.nl/blog/
- Went to Template/Edit HTML and switched off the NavBar, which is only allowed to be switched off when you publish via FTP
Abonneren op:
Posts (Atom)