<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dev @ Work &#187; Java</title>
	<atom:link href="http://www.devatwork.nl/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devatwork.nl</link>
	<description>A day in the life of a developer</description>
	<lastBuildDate>Tue, 18 Oct 2011 16:32:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Securing your Liferay Service using PermissionChecker</title>
		<link>http://www.devatwork.nl/2010/05/securing-your-liferay-service-using-permissionchecker/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=securing-your-liferay-service-using-permissionchecker</link>
		<comments>http://www.devatwork.nl/2010/05/securing-your-liferay-service-using-permissionchecker/#comments</comments>
		<pubDate>Mon, 03 May 2010 06:42:08 +0000</pubDate>
		<dc:creator>Bert Willems</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Liferay]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.devatwork.nl/?p=798</guid>
		<description><![CDATA[Welcome to 3rd article in this series of articles showing you how you can develop custom Liferay services. In the previous article I showed you how you can implement a custom Liferay service and expose it as a web service. In this article I will show you how you can secure your service using Liferay&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-656" title="Liferay" src="http://www.devatwork.nl/wp-content/uploads/2010/01/liferay-logo-block.jpg" alt="" width="99" height="96" />Welcome to 3rd article in this series of articles showing you how you can develop custom Liferay services. In the previous article I showed you how you can <a title="Implementing a reusable Liferay Service Without Ext or Service Builder" href="http://www.devatwork.nl/2010/04/implementing-a-reusable-liferay-service-without-ext-or-service-builder/">implement a custom Liferay service</a> and <a title="Expose a Liferay Service as a Web Service" href="http://www.devatwork.nl/2010/04/expose-a-liferay-service-as-a-web-service/">expose it as a web service</a>. In this article I will show you how you can secure your service using Liferay&#8217;s build-in permission model.</p>
<p>The permission system in Liferay is pretty powerful: you configure permissions on roles or teams. Next you apply roles to either groups (communities, organizations) or individual users. In this article we will define a new permission: the permission to access our &#8220;very exiting business logic&#8221; sayHello. After all, we have invested countless hours in developing it; we don&#8217;t want everybody to use it without us knowing <img src='http://www.devatwork.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>I hope this article is useful to you. Please let me know if you have any questions or comments; just drop me a message and I will get back to you as soon as I can.<br />
<span id="more-798"></span></p>
<h3>0. Project Setup</h3>
<p>I have made some modifications to the code since my last article, so please <a href="http://www.devatwork.nl/wp-content/uploads/2010/04/hello-world-remote-security-start.zip">download and unzip</a> the starting point of our application. Please familiarize yourself with the project structure. I have refactored the view of the SayHelloPortlet to render using a JSP called sayHello.jsp, this will help us further along in this article.</p>
<p>Please note that I have modified the service contract specified in HelloWorldService.java. I have added the groupId parameter which we will use later in this article. Here is the new service contract:</p>
<pre class="brush: java; light: true; title: ; notranslate">String sayHello(long groupId, String name);</pre>
<p>I have updated all the service implementation files as well to reflect changes in the contract.</p>
<h3>1. Implement the permission check on the service</h3>
<p>The first step is to implement the actual check on permission in our service implementation. Replace the sayHello method in HelloWorldServiceImpl.java with the following code (note the marked lines are new lines):</p>
<pre class="brush: java; highlight: [2,3,4,5,6,7]; title: ; wrap-lines: false; notranslate">public String sayHello(long groupId, String name) {
    try {
        if (!getPermissionChecker().hasPermission(groupId, &quot;nl.devatwork.hello.world.service&quot;, groupId, &quot;SAY_HELLO&quot;))
            return &quot;Hah, I don't think you can use my service. You don't have permission&quot;;
    } catch (PrincipalException ex) {
        return &quot;security blew up&quot;;
    }

    return &quot;Hello, &quot; + name;
}</pre>
<p>Lets dissect this code: The first thing we do is to get the instance of the <strong><em>PermissionChecker </em></strong>from our base class <strong><em>PrincipalBean</em></strong>. The <strong><em>PermissionChecker </em></strong>will do the heavy lifting for us, that is convenient isn&#8217;t it?</p>
<p>The second step is the call to the method hasPermission. This method performs the actual check for us. The method has the following signature:</p>
<pre class="brush: java; light: true; title: ; notranslate">public boolean hasPermission(long groupId, String name, long primKey, String actionId);</pre>
<p>The first argument, groupId, determines the scope of the check. Remember I told you that you can apply roles to communities and organizations? Those things are groups with and ID. In the next step I will show you how we will get the value for groupId.</p>
<p>The second argument, name, is the name of our permission. The convention is we pass a String representation of our package in which the service lives.</p>
<p>The third argument, primKey, is the primary key of the resource we are protecting. Our service is a so-called top level resource which do not have a primary key that is why we will use the value of groupId. If we would have a model stored in the database we would specify the ID of the model here.</p>
<p>The final argument, actionId, is the identifier of the action. We will use a capitalized version of the method name here.</p>
<p>I think that is enough info about these few lines of code.</p>
<h3>2. Getting the scope</h3>
<p>Now that our service checks for permission we need to modify our portlet to provide the correct groupId in order for Liferay to scope the authorization properly. Please add the highlighted lines to SayHelloPortlet.java:</p>
<pre class="brush: java; highlight: [2,3]; title: ; wrap-lines: false; notranslate">public void doView(RenderRequest request, RenderResponse response) throws PortletException, java.io.IOException {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long groupId = themeDisplay.getScopeGroupId();

    String msg = HelloWorldServiceUtil.sayHello(groupId, &quot;Liferay Dev&quot;);
    request.setAttribute(&quot;msg&quot;, msg);
    request.setAttribute(&quot;groupId&quot;, groupId);

    getPortletContext().getRequestDispatcher(&quot;/WEB-INF/jsp/sayHello.jsp&quot;).include(request, response);
}</pre>
<p>As you can see Liferay provides a nice utility called ThemeDisplay from which we can get the scope groupId.</p>
<h3>3. Telling Liferay about our new permission</h3>
<p>So far we have implemented the necessary code to check for permission. Now we have to inform Liferay that there is a new permission, otherwise you won&#8217;t be able to configure it and that would be a waste of effort, wouldn&#8217;t it? Create a new file called portlet.properties in the resource folder of the portlet application and paste the following content into it:</p>
<pre class="brush: plain; light: true; title: ; notranslate">resource.actions.configs=resource-actions/default.xml</pre>
<p>This properties file tells Liferay to look for resource actions (permissions) in default.xml in the folder resource-actions. Lets create that file now and paste the following content into it:</p>
<pre class="brush: xml; highlight: [4,6,10]; title: ; wrap-lines: false; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;resource-action-mapping&gt;
    &lt;model-resource&gt;
        &lt;model-name&gt;nl.devatwork.hello.world.service&lt;/model-name&gt;
        &lt;portlet-ref&gt;
            &lt;portlet-name&gt;SayHelloPortlet&lt;/portlet-name&gt;
        &lt;/portlet-ref&gt;

        &lt;supports&gt;
            &lt;action-key&gt;SAY_HELLO&lt;/action-key&gt;
        &lt;/supports&gt;

        &lt;community-defaults/&gt;
        &lt;guest-defaults/&gt;
        &lt;guest-unsupported/&gt;

    &lt;/model-resource&gt;
&lt;/resource-action-mapping&gt;</pre>
<p>I have highlighted the important lines. Please take a look at the first highlighted line. Does it look familiar to you? Yes, it is the same as the value of the name argument of the <strong><em>hasPermission </em></strong>method.</p>
<p>The second highlighted line tells Liferay that the SayHelloPortlet can configure this permission, I will show you how in the next step.</p>
<p>The final highlighted line should also look familiar to you. It is the same as the value of the actionId argument of the <strong><em>hasPermission </em></strong>method.</p>
<h3>4. Create configure permissions link</h3>
<p>This is the final step, we implemented the check, we told Liferay about our new permission. Now we need a place to configure it. Modify sayHello.jsp:</p>
<pre class="brush: java; highlight: [3,4,5,6,7,11,12,13]; title: ; wrap-lines: false; notranslate">&lt;%@ page contentType=&quot;text/html&quot; isELIgnored=&quot;false&quot; %&gt;
&lt;%@ include file=&quot;/WEB-INF/jsp/include.jsp&quot; %&gt;
&lt;liferay-security:permissionsURL
        modelResource=&quot;nl.devatwork.hello.world.service&quot;
        modelResourceDescription=&quot;Hello Service Permissions&quot;
        resourcePrimKey=&quot;${groupId}&quot;
        var=&quot;permissionURL&quot;/&gt;

&lt;p&gt;the msg was: ${msg}&lt;/p&gt;

&lt;div&gt;
    &lt;p&gt;lets &lt;a href=&quot;${permissionURL}&quot;&gt;configure&lt;/a&gt; the permission for our service&lt;/p&gt;
&lt;/div&gt;</pre>
<p>We have added a link to configure permission to our service. Notice that modelResource is again the same as the value of the name argument of the <strong><em>hasPermission </em></strong>method.</p>
<p>Now that we have implemented all the necessary changes we can compile and deploy the new JAR&#8217;s and WAR&#8217;s and start our application. Go ahead and add permissions, remove them, login and logout under different accounts. Our permission is working like a charm. If you haven&#8217;t followed all the steps above you can <a href="http://www.devatwork.nl/wp-content/uploads/2010/04/hello-world-remote-security-result.zip">download the finished project</a>.</p>
<p>That is it for now,I hope you have learned something. Let me know if you have any questions or comments. Bye.</p>

	Tags: <a href="http://www.devatwork.nl/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://www.devatwork.nl/tag/liferay/" title="Liferay" rel="tag">Liferay</a>, <a href="http://www.devatwork.nl/tag/security/" title="Security" rel="tag">Security</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.devatwork.nl/2010/05/securing-your-liferay-service-using-permissionchecker/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Expose a Liferay Service as a Web Service</title>
		<link>http://www.devatwork.nl/2010/04/expose-a-liferay-service-as-a-web-service/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=expose-a-liferay-service-as-a-web-service</link>
		<comments>http://www.devatwork.nl/2010/04/expose-a-liferay-service-as-a-web-service/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 06:39:50 +0000</pubDate>
		<dc:creator>Bert Willems</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Liferay]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.devatwork.nl/?p=729</guid>
		<description><![CDATA[In my previous article I showed you how you can implement a reusable Liferay Service without using Ext or  the Service Builder utility. In this article we will take it one step further and expose the service we have created as web service again without using Ext or the Service Builder. Liferay exposes the services [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-656" title="Liferay" src="http://www.devatwork.nl/wp-content/uploads/2010/01/liferay-logo-block.jpg" alt="" width="99" height="96" />In my previous article I showed you how you can implement a reusable Liferay Service without using Ext or  the Service Builder utility. In this article we will take it one step further and expose the service we have created as web service again without using Ext or the Service Builder.</p>
<p>Liferay exposes the services based on Axis using a separate web application called tunnel-web. We will hook into tunnel-web so our service will be exposed in exactly the same way Liferay services are externalized. Let&#8217;s get started.<br />
<span id="more-729"></span></p>
<h3>0. Project Setup</h3>
<p>We will pick up from where we ended in the previous article. I have you haven&#8217;t followed the previous article you can <a href="http://www.devatwork.nl/wp-content/uploads/2010/04/hello-world-result.zip">download the initial project setup here</a>. Please take a minute to familiarize yourself with the project structure.</p>
<p>We need to add a new dependencies to the pom of the service contract library:</p>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">&lt;dependency&gt;
    &lt;groupId&gt;com.liferay.portal&lt;/groupId&gt;
    &lt;artifactId&gt;portal-service&lt;/artifactId&gt;
    &lt;version&gt;${liferay.version}&lt;/version&gt;
    &lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;com.liferay.portal&lt;/groupId&gt;
    &lt;artifactId&gt;portal-kernel&lt;/artifactId&gt;
    &lt;version&gt;${liferay.version}&lt;/version&gt;
    &lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;com.liferay.portal&lt;/groupId&gt;
    &lt;artifactId&gt;portal-impl&lt;/artifactId&gt;
    &lt;version&gt;${liferay.version}&lt;/version&gt;
    &lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;</pre>
<h3>1. Prepare the portal</h3>
<p>Make sure tunnel-web is installed in your application server. See the Liferay administration guide for details. The access to the web-service is restricted based on IP address. Open your portal-ext.properties and add the following lines to allow specified IP addresses to access to the web-services.</p>
<pre class="brush: plain; title: ; notranslate">axis.servlet.hosts.allowed=127.0.0.1,SERVER_IP
axis.servlet.https.required=false</pre>
<h3>2. Add the Service Classes</h3>
<p>Ok lets get down to business. The first step is to create the web service class in the service contract library. Create a new class called HelloWorldServiceSoap in the package nl.devatwork.hello.world.service.http and copy the following code into it:</p>
<pre class="brush: java; title: ; wrap-lines: false; notranslate">package nl.devatwork.hello.world.service.http;

import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import nl.devatwork.hello.world.service.HelloWorldServiceUtil;

import java.rmi.RemoteException;

public class HelloWorldServiceSoap {
    private static Log _log = LogFactoryUtil.getLog(HelloWorldServiceSoap.class);

    public static String sayHello(String name)
            throws RemoteException {
        String result;
        try {
            result = HelloWorldServiceUtil.sayHello(name);
        } catch (Exception e) {
            _log.error(e, e);

            throw new RemoteException(e.getMessage());
        }

        return result;
    }
}</pre>
<p>This class wraps SOAP calls and maps them to the appropriate service call.</p>
<p>You can now build the service contract library by executing the following command in the /hello-world-service/ folder:</p>
<pre class="brush: bash; light: true; title: ; notranslate">mvn clean package</pre>
<p>Copy the resulting JAR file (/hello-world-service/target/hello-world-service-1.0.0-SNAPSHOT.jar) to the /lib/ext folder of your application server.</p>
<h3>3. Apply Glue</h3>
<p>The final step is a bit of handwork. We need to manually register the new service to the tunnel-web application. Open the server-config.wsdd located in the deploy directory/tunnel-web/WEB-INF folder of your application server. Add the following code just above the end of the XML:</p>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">&lt;service name=&quot;Portlet_DevAtWork_HelloWorldService&quot; provider=&quot;java:RPC&quot; style=&quot;rpc&quot; use=&quot;encoded&quot;&gt;
	&lt;parameter name=&quot;wsdlTargetNamespace&quot; value=&quot;urn:http.service.world.hello.devatwork.nl&quot;/&gt;
	&lt;parameter name=&quot;wsdlServiceElement&quot; value=&quot;HelloWorldServiceSoapService&quot;/&gt;
	&lt;parameter name=&quot;wsdlServicePort&quot; value=&quot;Portlet_DevAtWork_HelloWorldService&quot;/&gt;
	&lt;parameter name=&quot;className&quot; value=&quot;nl.devatwork.hello.world.service.http.HelloWorldServiceSoap&quot;/&gt;
	&lt;parameter name=&quot;wsdlPortType&quot; value=&quot;HelloWorldServiceSoap&quot;/&gt;
	&lt;parameter name=&quot;typeMappingVersion&quot; value=&quot;1.2&quot;/&gt;
	&lt;operation xmlns:operNS=&quot;urn:http.service.world.hello.devatwork.nl&quot; name=&quot;sayHello&quot; qname=&quot;operNS:sayHello&quot; soapAction=&quot;&quot;&gt;
		&lt;parameter xmlns:tns=&quot;http://www.w3.org/2001/XMLSchema&quot; qname=&quot;name&quot; type=&quot;tns:string&quot;&gt;&lt;/parameter&gt;
	&lt;/operation&gt;
	&lt;parameter name=&quot;allowedMethods&quot; value=&quot;sayHello&quot;/&gt;
&lt;/service&gt;</pre>
<p>This will register our service within tunnel-web.</p>
<p>Start your application server and navigate to <a href="http://127.0.0.1:8080/tunnel-web/axis">http://127.0.0.1:8080/tunnel-web/axis</a>. Here you will find a list of all the services currently exposed by Liferay. In the list you will find our service (Portlet_DevAtWork_HelloWorldService). You can view the WSDL by clicking on the link behind the service.</p>
<p>That wasn&#8217;t to bad now was it? If you are to lazy to copy the code you can <a href="http://www.devatwork.nl/wp-content/uploads/2010/04/hello-world-remote-result.zip">download the complete project here</a>.</p>
<p>I hope you learned how you can expose services as web services in Liferay. In the upcoming article I will show you how you can add security to the web service.</p>
<p>That is it for now. Let me know if you have any comments or questions.</p>

	Tags: <a href="http://www.devatwork.nl/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://www.devatwork.nl/tag/liferay/" title="Liferay" rel="tag">Liferay</a>, <a href="http://www.devatwork.nl/tag/spring/" title="Spring" rel="tag">Spring</a>, <a href="http://www.devatwork.nl/tag/web-services/" title="Web Services" rel="tag">Web Services</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.devatwork.nl/2010/04/expose-a-liferay-service-as-a-web-service/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Implementing a reusable Liferay Service Without Ext or Service Builder</title>
		<link>http://www.devatwork.nl/2010/04/implementing-a-reusable-liferay-service-without-ext-or-service-builder/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=implementing-a-reusable-liferay-service-without-ext-or-service-builder</link>
		<comments>http://www.devatwork.nl/2010/04/implementing-a-reusable-liferay-service-without-ext-or-service-builder/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 10:38:01 +0000</pubDate>
		<dc:creator>Bert Willems</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Liferay]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.devatwork.nl/?p=728</guid>
		<description><![CDATA[In Liferay you can split your application logic vertically exposing each component as a separate independent service. This service can be consumed by your portlet applications and any other applications. Liferay itself exposes several services to you: GroupService (for managing communities) and UserService (for managing users) for example. In this article I will show you how you [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-656" title="Liferay" src="http://www.devatwork.nl/wp-content/uploads/2010/01/liferay-logo-block.jpg" alt="" width="99" height="96" />In Liferay you can split your application logic vertically exposing each component as a separate independent service. This service can be consumed by your portlet applications and any other applications. Liferay itself exposes several services to you: GroupService (for managing communities) and UserService (for managing users) for example. In this article I will show you how you can create a reusable service yourself and host it in Liferay.</p>
<p>In this article we will build a simple hello world service, nothing to fancy (I want to leave something for you to do yourself <img src='http://www.devatwork.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ). We will code the service from scratch without using tools like service builder.</p>
<p>The project will contain 3 modules:</p>
<ol>
<li>A library containing the service contract</li>
<li>A web application implementing the service contract</li>
<li>A web application consuming the service</li>
</ol>
<p>I hope you like this article, please let me know if you have any questions or comments. Lets get started. I assume you have read my <a title="Setting up Maven for Liferay Development" href="http://www.devatwork.nl/2010/04/setting-up-maven-for-liferay-development/">previous article about using Maven to build Liferay applications</a>. If not please read it first.<br />
<span id="more-728"></span></p>
<h3>0. Project Setup</h3>
<p>Please <a href="http://www.devatwork.nl/wp-content/uploads/2010/04/hello-world-start.zip">download and unzip</a> the empty project and load it into an IDE of choice or use the command shell if you want. The project contains empty files. Please familiarizes yourself with the project structure and notice the dependencies in the different pom.xml files. Nothing special going on though.</p>
<h3>1. Service Contract</h3>
<p>This library contains the code contract of our HelloWorld service and a utility class which will provide easy access for non Spring portlets. Lets first set up our service contract, copy he following code into HelloWorldService.java:</p>
<pre class="brush: java; title: ; wrap-lines: false; notranslate">package nl.devatwork.hello.world.service;

public interface HelloWorldService {
    String sayHello(String name);
}</pre>
<p>That wasn&#8217;t so bad now was it? I think you have written more complex service contracts <img src='http://www.devatwork.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Lets implement the access utility class. Copy the following code into HelloWorldServiceUtil.java:</p>
<pre class="brush: java; title: ; wrap-lines: false; notranslate">package nl.devatwork.hello.world.service;

public class HelloWorldServiceUtil {
    private static HelloWorldService _service;

    public static HelloWorldService getService() {
        if (_service == null) {
            throw new RuntimeException(&quot;HelloWorldService is not set&quot;);
        }

        return _service;
    }

    public void setService(HelloWorldService service) {
        _service = service;
    }

    public static String sayHello(String name) {
        return getService().sayHello(name);
    }
}</pre>
<p>Again a really simple class. It has a getter and a setter which will be used to inject our service instance into this utility class. The static sayHello method is a proxies the service method.</p>
<p>You can build the service contract library by executing the following command in the /hello-world-service/ folder:</p>
<pre class="brush: bash; light: true; title: ; notranslate">mvn clean package</pre>
<p>Copy the resulting JAR file (/hello-world-service/target/hello-world-service-1.0.0-SNAPSHOT.jar) to the /lib/ext folder of your application server. You have to do this in order to avoid class loader issues. We will use this library later.</p>
<h3>2. Service Implementation</h3>
<p>Now we will implement the service in a self contained web application.  This application can be deployed using the auto deploy mechanism of your application server.</p>
<p>Lets implement the base class for our service implementation which implements the required plumbing. Copy the following code into HelloWorldServiceBaseImpl.java:</p>
<pre class="brush: java; title: ; wrap-lines: false; notranslate">package nl.devatwork.hello.world.service.base;

import com.liferay.portal.SystemException;
import com.liferay.portal.kernel.annotation.BeanReference;
import com.liferay.portal.service.base.PrincipalBean;
import com.liferay.portal.util.PortalUtil;
import nl.devatwork.hello.world.service.HelloWorldService;

public abstract class HelloWorldServiceBaseImpl extends PrincipalBean implements HelloWorldService {
    @BeanReference(name = &quot;nl.devatwork.hello.world.service.HelloWorldService.impl&quot;)
    protected HelloWorldService helloWorldService;

    public HelloWorldService getHelloWorldService() {
        return helloWorldService;
    }

    public void setHelloWorldService(HelloWorldService helloWorldService) {
        this.helloWorldService = helloWorldService;
    }

    protected void runSQL(String sql) throws SystemException {
        try {
            PortalUtil.runSQL(sql);
        } catch (Exception e) {
            throw new SystemException(e);
        }
    }
}</pre>
<p>Now that we have the plumbing in place lets concentrate on our state of the art business logic. Copy the following code into HelloWorldServiceImpl.java:</p>
<pre class="brush: java; title: ; wrap-lines: false; notranslate">package nl.devatwork.hello.world.service.impl;

import nl.devatwork.hello.world.service.base.HelloWorldServiceBaseImpl;

public class HelloWorldServiceImpl extends HelloWorldServiceBaseImpl {
    public String sayHello(String name) {
        return &quot;Hello, &quot; + name;
    }
}</pre>
<p>Very exiting business logic isn&#8217;t it? <img src='http://www.devatwork.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Ok, now that we have our code in place lets apply some glue to make it all work. Copy the following content to service.properties:</p>
<pre class="brush: plain; highlight: [29,30]; title: ; wrap-lines: false; notranslate">##
## Properties Override
##

    #
    # Specify where to get the overridden properties. Updates should not be made
    # on this file but on the overridden version of this file.
    #
    include-and-override=service-ext.properties

##
## Build
##

    build.namespace=DevAtWork
    build.number=1
    build.date=1269952033689
    build.auto.upgrade=true

##
## Spring
##

    #
    # Input a list of comma delimited Spring configurations. These will be
    # loaded after the bean definitions specified in the
	# portalContextConfigLocation parameter in web.xml.
    #
    spring.configs=\
        WEB-INF/classes/META-INF/portlet-spring.xml</pre>
<p>Notice the last two lines. This tells Liferay to load our Spring configuration.</p>
<p>Lets create our Spring configuration now. Copy the following code to portlet-spring.xml:</p>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; default-init-method=&quot;afterPropertiesSet&quot; xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;&gt;
    &lt;bean id=&quot;nl.devatwork.hello.world.service.HelloWorldService.impl&quot; class=&quot;nl.devatwork.hello.world.service.impl.HelloWorldServiceImpl&quot;/&gt;
    &lt;bean id=&quot;nl.devatwork.hello.world.service.HelloWorldServiceUtil&quot; class=&quot;nl.devatwork.hello.world.service.HelloWorldServiceUtil&quot;&gt;
        &lt;property name=&quot;service&quot; ref=&quot;nl.devatwork.hello.world.service.HelloWorldService.impl&quot;/&gt;
    &lt;/bean&gt;
&lt;/beans&gt;</pre>
<p>We register two beans into the Spring container. One for our service implementation instance and one for our service util.</p>
<p>Lets add the following code to web.xml:</p>
<pre class="brush: xml; highlight: [4,5,6]; title: ; wrap-lines: false; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot; version=&quot;2.4&quot;&gt;

    &lt;listener&gt;
        &lt;listener-class&gt;com.liferay.portal.kernel.spring.context.PortletContextLoaderListener&lt;/listener-class&gt;
    &lt;/listener&gt;

&lt;/web-app&gt;</pre>
<p>This will load the Spring configuration for us.</p>
<p>Add the following code to liferay-plugin-package.properties:</p>
<pre class="brush: plain; highlight: [10]; title: ; wrap-lines: false; notranslate">name=Hello World Service Implementation
module-group-id=nl.devatwork.service.impl
module-incremental-version=1
short-description=
change-log=
page-url=http://www.devatwork.nl
author=Dev @ Work
licenses=Free

portal-dependency-jars=hello-world-service-1.0.0-SNAPSHOT.jar</pre>
<p>Notice that we declare a dependency on the library we deployed earlier. Liferay will load the library on our class path.</p>
<p>We are ready with the service implementation now. You can build the service implementation by executing the following command in the /hello-world-service-impl/ folder:</p>
<pre class="brush: bash; light: true; title: ; notranslate">mvn clean package</pre>
<p>Copy the resulting WAR file (/hello-world-service-impl/target/hello-world-service-impl-1.0.0-SNAPSHOT.war to the auto deploy folder of your application server. The service implementation will be installed now.</p>
<h3>3. Consumer Implementation</h3>
<p>Now that we have the service contract and implementation in place lets create a portlet which consumes the service.</p>
<p>Copy the following code into SayHelloPortlet.java:</p>
<pre class="brush: java; title: ; wrap-lines: false; notranslate">package nl.devatwork.hello.world.portlets;

import nl.devatwork.hello.world.service.HelloWorldServiceUtil;

import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

public class SayHelloPortlet extends GenericPortlet {
    public void doView(RenderRequest request, RenderResponse response) throws PortletException, java.io.IOException {
        String msg = HelloWorldServiceUtil.sayHello(&quot;Liferay Dev&quot;);
        response.setContentType(&quot;text/html&quot;);
        response.getWriter().print(msg);
    }
}</pre>
<p>Copy the following code to portlet.xml:</p>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;portlet-app xmlns=&quot;http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; version=&quot;2.0&quot;
             xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd&quot;&gt;

    &lt;portlet&gt;
        &lt;portlet-name&gt;SayHelloPortlet&lt;/portlet-name&gt;
        &lt;display-name&gt;Say Hello Portlet&lt;/display-name&gt;
        &lt;portlet-class&gt;nl.devatwork.hello.world.portlets.SayHelloPortlet&lt;/portlet-class&gt;
        &lt;expiration-cache&gt;0&lt;/expiration-cache&gt;
        &lt;supports&gt;
            &lt;mime-type&gt;text/html&lt;/mime-type&gt;
            &lt;portlet-mode&gt;view&lt;/portlet-mode&gt;
        &lt;/supports&gt;
        &lt;portlet-info&gt;
            &lt;title&gt;Say Hello Portlet&lt;/title&gt;
            &lt;short-title&gt;Say Hello Portlet&lt;/short-title&gt;
            &lt;keywords&gt;DevAtWork&lt;/keywords&gt;
        &lt;/portlet-info&gt;
    &lt;/portlet&gt;

&lt;/portlet-app&gt;</pre>
<p>Copy the following code to liferay-plugin-package.properties:</p>
<pre class="brush: plain; highlight: [10]; title: ; wrap-lines: false; notranslate">name=Hello World Portlets
module-group-id=nl.devatwork.portlets
module-incremental-version=1
short-description=
change-log=
page-url=http://www.devatwork.nl
author=Dev @ Work
licenses=Free

portal-dependency-jars=hello-world-service-1.0.0-SNAPSHOT.jar</pre>
<p>Copy the following code to web.xml:</p>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot; version=&quot;2.4&quot;&gt;
&lt;/web-app&gt;</pre>
<p>We are ready with the consumer implementation now. You can build the portlet by executing the following command in the /hello-world-portlets/ folder:</p>
<pre class="brush: bash; light: true; title: ; notranslate">mvn clean package</pre>
<p>Copy the resulting WAR file (/hello-world-portlets/target/hello-world-portlets-1.0.0-SNAPSHOT.war to the auto deploy folder of your application server. The portlet will be installed now. Add the new portlet to a page and if everything works well then it should display the message: &#8216;Hello, Liferay Dev&#8217;.</p>
<p>You can <a href="http://www.devatwork.nl/wp-content/uploads/2010/04/hello-world-result.zip">download the complete project here</a>.</p>
<p>That is it for this article, I hope you enjoyed reading it and that you learned something. If you have any questions or comments please post a comment and I will get back to you as soon as I can. In the next article I will show you how you can expose the HelloWorld service as a web service so it can be consumed by external applications.</p>

	Tags: <a href="http://www.devatwork.nl/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://www.devatwork.nl/tag/liferay/" title="Liferay" rel="tag">Liferay</a>, <a href="http://www.devatwork.nl/tag/spring/" title="Spring" rel="tag">Spring</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.devatwork.nl/2010/04/implementing-a-reusable-liferay-service-without-ext-or-service-builder/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Setting up Maven for Liferay Development</title>
		<link>http://www.devatwork.nl/2010/04/setting-up-maven-for-liferay-development/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-up-maven-for-liferay-development</link>
		<comments>http://www.devatwork.nl/2010/04/setting-up-maven-for-liferay-development/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 13:08:03 +0000</pubDate>
		<dc:creator>Bert Willems</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Liferay]]></category>
		<category><![CDATA[Maven]]></category>

		<guid isPermaLink="false">http://www.devatwork.nl/?p=635</guid>
		<description><![CDATA[Welcome to the third article in these series about Liferay usage, maintenance and development. In this post I will show you how to set up your Liferay development enviroment using Apaches Maven2 build tool. We will develop a really simple JSR-168 portlet which can be deployed into Liferay. I assume you have read my previous [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-656" title="Liferay" src="http://www.devatwork.nl/wp-content/uploads/2010/01/liferay-logo-block.jpg" alt="" width="99" height="96" />Welcome to the third article in these series about Liferay usage, maintenance and development. In this post I will show you how to set up your Liferay development enviroment using Apaches Maven2 build tool. We will develop a really simple JSR-168 portlet which can be deployed into Liferay. I assume you have read my <a title="Setting up Liferay 5.2.3 on JBoss 5.1" href="http://www.devatwork.nl/2010/01/setting-up-liferay-in-jboss-5-1/">previous</a> <a title="Setting up Liferay 5.2.3 on Liferay" href="http://www.devatwork.nl/2010/01/setting-up-liferay-with-mysql/">articles</a> and that you are using Liferay 5.2.3 on JBoss 5.1. I hope you like this post as much as the previous ones, if you have any feedback feel free to contact me or post a response.</p>
<p>The next version of Liferay, release date end Q1 begin Q2, will have complete support for maven including custom archetypes. Some of the steps described in this article will be obsolete then, but lets get started.<span id="more-635"></span></p>
<h3>Installing Maven</h3>
<p>The first step is to actually install Maven. You can find the download and installation instructions on the Maven website <a href="http://maven.apache.org/">http://maven.apache.org/</a>. Confirm that Maven is installed properly by executing the following command:</p>
<pre class="brush: bash; light: true; title: ; notranslate">mvn --version</pre>
<p>You should see the Maven version number.</p>
<h3>Installing the Liferay dependencies into your local Maven repository</h3>
<p>The next step is to install the Liferay portal-kernel and portal-service into your local repository. This manual step is required in order for Maven to resolve the Liferay portal dependencies. Navigate the ‘%JBOSS_HOME%/server/default/lib/ext&#8217; folder where the JARs are located. Execute the following commands:</p>
<pre class="brush: bash; light: true; title: ; notranslate">mvn install:install-file -Dfile=&quot;portal-kernel.jar&quot; -DgroupId=&quot;com.liferay.portal&quot; -DartifactId=&quot;portal-kernel&quot; -Dversion=&quot;5.2.3-RELEASE&quot; -Dpackaging=jar
mvn install:install-file -Dfile=&quot;portal-service.jar&quot; -DgroupId=&quot;com.liferay.portal&quot; -DartifactId=&quot;portal-service&quot; -Dversion=&quot;5.2.3-RELEASE&quot; -Dpackaging=jar</pre>
<p>Now that you have installed the required dependencies let set up a quick Hello World portlet using Maven.</p>
<h3>Setting up the Hello World Portlet</h3>
<p>Now that we have all the required dependencies installed in our local Maven repository we can start building an application. <a href="http://www.devatwork.nl/wp-content/uploads/2010/04/maven-hello-world-portlet.zip">Download the complete source here</a>. Create the following folder structure:</p>
<pre class="brush: plain; light: true; title: ; notranslate">/pom.xml
/src/main/java/nl/devatwork/HelloWorldPortlet.java
/src/main/webapp/WEB-INF/portlet.xml
/src/main/webapp/WEB-INF/web.xml</pre>
<p>First let set up the POM so our dependencies can be loaded. Notice that I have set the Liferay dependencies as being provided. Add the following code to the pom.xml file you have just created:</p>
<pre class="brush: xml; collapse: true; highlight: [15,22]; light: false; title: ; toolbar: true; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;devatwork&lt;/groupId&gt;
    &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
    &lt;artifactId&gt;maven-hello-world&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;name&gt;Maven Hello World Portlet&lt;/name&gt;
    &lt;dependencies&gt;
        &lt;!-- Java dependencies --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.portlet&lt;/groupId&gt;
            &lt;artifactId&gt;portlet-api&lt;/artifactId&gt;
            &lt;version&gt;2.0&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;!-- liferay dependencies --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.liferay.portal&lt;/groupId&gt;
            &lt;artifactId&gt;portal-service&lt;/artifactId&gt;
            &lt;version&gt;5.2.3-RELEASE&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;com.liferay.portal&lt;/groupId&gt;
            &lt;artifactId&gt;portal-kernel&lt;/artifactId&gt;
            &lt;version&gt;5.2.3-RELEASE&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;
&lt;/project&gt;</pre>
<p>The portlet will be a very simple portlet. It will  print a string and the name of the current theme. Add the following code to the HelloWorldPortlet.java file:</p>
<pre class="brush: java; collapse: true; light: false; title: ; toolbar: true; notranslate">package nl.devatwork;

import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.theme.ThemeDisplay;

import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

public class HelloWorldPortlet extends GenericPortlet {
    protected void doView(RenderRequest request, RenderResponse response) throws PortletException, java.io.IOException {
        ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
        response.setContentType(&quot;text/html&quot;);
        response.getWriter().print(&quot;Hello World, &quot; + themeDisplay.getTheme().getName());
    }
}</pre>
<p>The next step is to set up the web.xml file, just copy the following code into it:</p>
<pre class="brush: xml; collapse: true; light: false; title: ; toolbar: true; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot; version=&quot;2.4&quot;&gt;
&lt;/web-app&gt;</pre>
<p>The final step of this sample portlet is the portlet.xml, again really straight forward. Just copy in the following code:</p>
<pre class="brush: xml; collapse: true; light: false; title: ; toolbar: true; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;portlet-app xmlns=&quot;http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; version=&quot;2.0&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd&quot;&gt;
    &lt;portlet&gt;
        &lt;portlet-name&gt;HelloWorldPortlet&lt;/portlet-name&gt;
        &lt;display-name&gt;Maven Hello World Portlet&lt;/display-name&gt;
        &lt;portlet-class&gt;nl.devatwork.HelloWorldPortlet&lt;/portlet-class&gt;
        &lt;expiration-cache&gt;0&lt;/expiration-cache&gt;
        &lt;supports&gt;
            &lt;mime-type&gt;text/html&lt;/mime-type&gt;
            &lt;portlet-mode&gt;view&lt;/portlet-mode&gt;
        &lt;/supports&gt;
    &lt;/portlet&gt;
&lt;/portlet-app&gt;</pre>
<p>Now that the application is finished you can package it by executing the following command in the root of your application:</p>
<pre class="brush: bash; light: true; title: ; notranslate">mvn clean package</pre>
<p>Deploy the WAR to your application server and test it. <a href="http://www.devatwork.nl/wp-content/uploads/2010/04/maven-hello-world-portlet.zip">Download the complete source here</a>.</p>
<p>Now you are able to build Liferay plug-ins using Maven. I hope you liked this article. Please let me know if you have any questions or comments. Bye for now!</p>

	Tags: <a href="http://www.devatwork.nl/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://www.devatwork.nl/tag/liferay/" title="Liferay" rel="tag">Liferay</a>, <a href="http://www.devatwork.nl/tag/maven/" title="Maven" rel="tag">Maven</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.devatwork.nl/2010/04/setting-up-maven-for-liferay-development/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Setting up Liferay with MySQL</title>
		<link>http://www.devatwork.nl/2010/01/setting-up-liferay-with-mysql/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-up-liferay-with-mysql</link>
		<comments>http://www.devatwork.nl/2010/01/setting-up-liferay-with-mysql/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 19:59:37 +0000</pubDate>
		<dc:creator>Bert Willems</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Liferay]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.devatwork.nl/?p=661</guid>
		<description><![CDATA[Welcome to the second article in a series of articles on Liferay. In this series I will show you various aspects of Liferay, Liferay installation, Liferay maintenance and Liferay development so lets get started. These articles assume that you have basic Java development skills. In this post I will show you how to configure Liferay [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-656" title="Liferay" src="http://www.devatwork.nl/wp-content/uploads/2010/01/liferay-logo-block.jpg" alt="" width="99" height="96" />Welcome to the second article in a series of articles on Liferay. In this series I will show you various aspects of Liferay, Liferay installation, Liferay maintenance and Liferay development so lets get started. These articles assume that you have basic Java development skills.</p>
<p>In this post I will show you how to configure Liferay to use MySQL instead of Hypersonic. I assume you have followed all the steps in the <a title="Setting up Liferay 5.2.3 aon JBoss 5.1" href="http://www.devatwork.nl/2010/01/setting-up-liferay-in-jboss-5-1/">previous post</a> or that you are using a JNDI datasource. I also assume that you have installed MySQL on your system already. If not, please install it first. If the portal is still running stop it first before continuing with the next steps.</p>
<h2><span id="more-661"></span>Installing the MySQL Connector</h2>
<p>The first step is to install the MySQL Java connector so that JBoss and Liferay know how to connect to the database. You can <a href="http://dev.mysql.com/downloads/connector/j/">download the connector</a> from the official MySQL website.Copy the JAR file of the connector to the &#8216;%JBOSS_HOME%\server\default\lib\&#8217; folder.</p>
<h2>Create the Database</h2>
<p>Use the MySQL command line to create a new database. In this post we will use &#8216;lportal&#8217; as the name of the database. Use the following command to create the database:</p>
<pre class="brush: sql; light: true; title: ; notranslate">create database lportal default character set utf8</pre>
<p>Modify the configuration</p>
<p>Modify the ‘%JBOSS_HOME%\server\default\deploy\liferay-ds.xml’ file and set its content to:</p>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;datasources&gt;
	&lt;local-tx-datasource&gt;
		&lt;jndi-name&gt;jdbc/LiferayPool&lt;/jndi-name&gt;
		&lt;connection-url&gt;jdbc:mysql://localhost/lportal?useUnicode=true&amp;amp;characterEncoding=UTF-8&lt;/connection-url&gt;
		&lt;driver-class&gt;com.mysql.jdbc.Driver&lt;/driver-class&gt;
		&lt;user-name&gt;username&lt;/user-name&gt;
		&lt;password&gt;password&lt;/password&gt;
		&lt;min-pool-size&gt;0&lt;/min-pool-size&gt;
	&lt;/local-tx-datasource&gt;
&lt;/datasources&gt;</pre>
<p>Make sure you set the proper username and password.</p>
<p>Now fire up the portal and it will create the database schema for you. It fills the database with minimal data. You can use test@liferay.com and test to log in. That is it!</p>

	Tags: <a href="http://www.devatwork.nl/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://www.devatwork.nl/tag/liferay/" title="Liferay" rel="tag">Liferay</a>, <a href="http://www.devatwork.nl/tag/mysql/" title="MySQL" rel="tag">MySQL</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.devatwork.nl/2010/01/setting-up-liferay-with-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up Liferay in JBoss 5.1</title>
		<link>http://www.devatwork.nl/2010/01/setting-up-liferay-in-jboss-5-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-up-liferay-in-jboss-5-1</link>
		<comments>http://www.devatwork.nl/2010/01/setting-up-liferay-in-jboss-5-1/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 11:18:46 +0000</pubDate>
		<dc:creator>Bert Willems</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Hypersonic]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Liferay]]></category>

		<guid isPermaLink="false">http://www.devatwork.nl/?p=634</guid>
		<description><![CDATA[Welcome to the first article in a series of articles on Liferay. In this series I will show you various aspects of Liferay, Liferay installation, Liferay maintenance and Liferay development so lets get started. These articles assume that you have basic Java development skills. In this post I will show you how to install Liferay [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-656" title="Liferay" src="http://www.devatwork.nl/wp-content/uploads/2010/01/liferay-logo-block.jpg" alt="" width="99" height="96" />Welcome to the first article in a series of articles on Liferay. In this series I will show you various aspects of Liferay, Liferay installation, Liferay maintenance and Liferay development so lets get started. These articles assume that you have basic Java development skills.</p>
<p>In this post I will show you how to install Liferay 5.2.3, the latest communitie edition, on your local machine in the JBoss 5.1 application server, I assume you have a Windows machine. If you are running a different OS you can take the same steps but some paths will change depending on your OS. There are quite a few steps that need to be taken in order to set up Liferay, I will go through each and every step in detail.<span id="more-634"></span></p>
<h2>Install the Java Development Kit 1.5</h2>
<p>If you have installed the JDK already you can skip this section. In order to develop you need the Java SDK. The SDK contains things like the compiler and the base libraries. You can download the latest vesion from the <a href="http://java.sun.com">Sun Java website</a>. You need to download and install the JDK 5.0 Update 22 version. Once you have installed the SDK verify that the JAVA_HOME enviroment variable is set. Go to the enviroment variables settings of your computer and check if an entry JAVA_HOME exists in the system variables group, if not add it the value should point to the root directory of th SDK installation folder, for example: &#8216;C:\java\jdk1.5.0_21&#8242;. Next ensure that the PATH system variable includes the value &#8216;%JAVA_HOME%\bin&#8217;, if not add it. Save the settings if you made a modification.</p>
<p>You can verify if the SDK is installed and configured properly by executing the following command in a command window:</p>
<pre class="brush: bash; light: true; title: ; notranslate">java -version</pre>
<p>Is should print something like:</p>
<pre class="brush: bash; light: true; title: ; notranslate">java version &quot;1.6.0_17&quot;
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)</pre>
<p>Java is now properly installed.</p>
<h2>Installing JBoss 5.1</h2>
<p>Although Liferay can run in a host of application servers I chose the JBoss application server for these series. First step is to download JBoss application server 5.1GA from the <a href="http://www.jboss.org/jbossas/">JBoss website</a>. Unzip the JBoss application server in a location of choice. I use &#8216;C:\java\jboss&#8217;, I call this path JBOSS_HOME directory. That is basically it.</p>
<p>You can start JBoss by double clicking on &#8216;%JBOSS_HOME%\bin\run.bat&#8217;. The JBoss console windows will popup and JBoss starts, it might take a few minutes before it is ready. When JBoss is completely started (look for this line [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221053)] Started in 1m:12s:239ms) go to <a href="http://localhost:8080/">http://localhost:8080/</a>, you will see the default website here.</p>
<p>Shutdown the JBoss server by pressing CTRL+C in the JBoss console window.</p>
<h2>Configuring the Java Authentication and Authorization Service</h2>
<p>Open the file &#8216;%JBOSS_HOME%\server\default\conf\login-config.xml&#8217; in a text editor of choice. Comment out the policy named other (defined in lines 110 and 129). After that it should look like this:</p>
<pre class="brush: xml; first-line: 110; title: ; toolbar: false; wrap-lines: false; notranslate">&lt;!-- The default login configuration used by any security domain that
  does not have a application-policy entry with a matching name

  &lt;application-policy name=&quot;other&quot;&gt;--&gt;
    &lt;!-- A simple server login module, which can be used when the number
    of users is relatively small. It uses two properties files:
    users.properties, which holds users (key) and their password (value).
    roles.properties, which holds users (key) and a comma-separated list of
    their roles (value).
    The unauthenticatedIdentity property defines the name of the principal
    that will be used when a null username and password are presented as is
    the case for an unuathenticated web client or MDB. If you want to
    allow such users to be authenticated add the property, e.g.,
    unauthenticatedIdentity=&quot;nobody&quot;

    &lt;authentication&gt;
      &lt;login-module code=&quot;org.jboss.security.auth.spi.UsersRolesLoginModule&quot;
        flag=&quot;required&quot;/&gt;
    &lt;/authentication&gt;
  &lt;/application-policy&gt;--&gt;</pre>
<p>This allows Liferay to add it&#8217;s own implementation.</p>
<h2>Setting up a Datasource</h2>
<p>In this post we will set up Liferay to work with Hypersonic, in a later post I will show you how to set up MySQL. Create a new file &#8216;%JBOSS_HOME%\server\default\deploy\liferay-ds.xml&#8217; and set its content to:</p>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;datasources&gt;
   &lt;local-tx-datasource&gt;

      &lt;jndi-name&gt;jdbc/LiferayPool&lt;/jndi-name&gt;
      &lt;connection-url&gt;jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB&lt;/connection-url&gt;
      &lt;driver-class&gt;org.hsqldb.jdbcDriver&lt;/driver-class&gt;
      &lt;user-name&gt;sa&lt;/user-name&gt;
      &lt;password&gt;&lt;/password&gt;
      &lt;min-pool-size&gt;0&lt;/min-pool-size&gt;

   &lt;/local-tx-datasource&gt;

&lt;/datasources&gt;</pre>
<h2>Setting up a Mailsource</h2>
<p>I assume you have a mail server running on your local machine, if not configure the proper URLs forPOP and SMTP. Create a new file &#8216;%JBOSS_HOME%\server\default\deploy\mail-service.xml&#8217; and set its content to:</p>
<pre class="brush: xml; title: ; wrap-lines: false; notranslate">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;server&gt;
   &lt;mbean code=&quot;org.jboss.mail.MailService&quot; name=&quot;jboss:service=MailSession&quot;&gt;
      &lt;attribute name=&quot;JNDIName&quot;&gt;mail/MailSession&lt;/attribute&gt;
      &lt;attribute name=&quot;User&quot;&gt;nobody&lt;/attribute&gt;
      &lt;attribute name=&quot;Password&quot;&gt;password&lt;/attribute&gt;
      &lt;attribute name=&quot;Configuration&quot;&gt;
         &lt;configuration&gt;
            &lt;property name=&quot;mail.store.protocol&quot; value=&quot;imap&quot; /&gt;
            &lt;property name=&quot;mail.transport.protocol&quot; value=&quot;smtp&quot; /&gt;
            &lt;property name=&quot;mail.imap.host&quot; value=&quot;localhost&quot; /&gt;
            &lt;property name=&quot;mail.pop3.host&quot; value=&quot;localhost&quot; /&gt;
            &lt;property name=&quot;mail.smtp.host&quot; value=&quot;localhost&quot; /&gt;
         &lt;/configuration&gt;
      &lt;/attribute&gt;
   &lt;/mbean&gt;
&lt;/server&gt;</pre>
<h2>Installing Liferay Dependencies</h2>
<p>This is the last preperation before we can install Liferay. Liferay needs several dependencies in order to run correctly. You can <a href="http://www.liferay.com/downloads/liferay-portal/additional-files">download the dependencies</a> from the Liferay website. Download them and unzip them in the &#8216;%JBOSS_HOME%\server\default\lib&#8217;.</p>
<h2>Installing Liferay</h2>
<p>Finally we can start installing Liferay. First delete all the files and folders of the JBoss root application, you can find them at &#8216;%JBOSS_HOME%\server\default\deploy\ROOT.war&#8217;. The directory must be left empty.</p>
<p><a href="http://www.liferay.com/downloads/liferay-portal/additional-files">Download the Liferay portal WAR</a> from the Liferay website. Unzip it in the &#8216;%JBOSS_HOME%\server\default\deploy\ROOT.war&#8217; folder.</p>
<p>Delete jaxen.jar, jaxrpc.jar, stax.jar, xercesImpl.jar, xml-apis.jar from the &#8216;%JBOSS_HOME%\server\default\deploy\ROOT.war\WEB-INF\lib&#8217; folder.</p>
<p>Create a new file &#8216;%JBOSS_HOME%\server\default\deploy\ROOT.war\WEB-INF\classes\portal-ext.properties&#8217; and set its content to:</p>
<pre class="brush: bash; light: true; title: ; notranslate">jdbc.default.jndi.name=jdbc/LiferayPool
mail.session.jndi.name=mail/MailSession</pre>
<p>That is it, fire up JBoss and Liferay will be installed. Once JBoss and Liferay are started(look for this line: [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221053)] Started in 2m:31s:673ms) go to <a href="http://localhost:8080/">http://localhost:8080/</a>. You will see the Liferay portal now.</p>
<p>You can login using username &#8216;test@liferay.com&#8217; and password &#8216;test&#8217; (without the quotes ofcourse).</p>
<p>You have learned to setup Liferay with JBoss and Hypersonic. Take a moment to familiarize yourself with the Liferay portal: add some portlets, change layouts and themes. That is it for now! In the following posts I will show you how to change from Hypersonic to a different database engine and how to develop a Liferay portlet, layout and theme.</p>
<p>I hope you liked my article, if you have any question or feedback feel free to post a comment or contact me.</p>

	Tags: <a href="http://www.devatwork.nl/tag/hypersonic/" title="Hypersonic" rel="tag">Hypersonic</a>, <a href="http://www.devatwork.nl/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://www.devatwork.nl/tag/jboss/" title="JBoss" rel="tag">JBoss</a>, <a href="http://www.devatwork.nl/tag/liferay/" title="Liferay" rel="tag">Liferay</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.devatwork.nl/2010/01/setting-up-liferay-in-jboss-5-1/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Liferay: Good, Bad or Ugly?</title>
		<link>http://www.devatwork.nl/2009/11/liferay-good-bad-or-ugly/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=liferay-good-bad-or-ugly</link>
		<comments>http://www.devatwork.nl/2009/11/liferay-good-bad-or-ugly/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 21:08:53 +0000</pubDate>
		<dc:creator>Bert Willems</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Liferay]]></category>

		<guid isPermaLink="false">http://www.devatwork.nl/?p=594</guid>
		<description><![CDATA[Hello, I have been developing application for Liferay for about one month now and I thought it would be a nice idea to share my experience. This is no thorough review of the product, just my personal experience with Liferay. For those who don&#8217;t know what Liferay is: it is a portal server based on [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-thumbnail wp-image-610" title="liferay logo" src="http://www.devatwork.nl/wp-content/uploads/2009/11/liferay-logo.jpg" alt="liferay logo" width="236" height="55" />Hello, I have been developing application for Liferay for about one month now and I thought it would be a nice idea to share my experience. This  is no thorough review of the product, just my personal experience with Liferay.</p>
<p>For those who don&#8217;t know what Liferay is: it is a portal server based on Java technology. It allows you to create portal and community websites easily. It provides more than 60 out-of-the-box and ready-to-use application called &#8216;portlets&#8217;. Those &#8216;portlets&#8217; range from simple editorial blocks to blog engine and a chat portlet. It contains a full blown content management system and some powerful collaboration tools. See <a title="Liferay features" href="http://www.liferay.com/web/guest/products/portal/features">http://www.liferay.com/web/guest/products/portal/features</a> for a comprehensive list of features.</p>
<p>Anyway, I have been working with Liferay for about one month now, specifically for one project. I won&#8217;t elaborate on the project in details but it is a career portal with jobs, resumes and company presentations. I have developed a considerable part of the code myself and it has been an interesting experience because I never wrote one line of Java before: I have a c++/.NET background. Fortunately, I have a good, experienced Java team to back me up.</p>
<p>Okay, lets get back to the subject now. I will separate my experiences into three categories:</p>
<h2>The good</h2>
<p>In my opinion Liferay is a complete product, the out of the box portlets are useful and you can actually create a full portal just with those portlets: that is impressive.</p>
<p>I also like the fact that Liferay provides pre-packaged version of their portal software which you can download and run without any special configuration. You can get a Liferay portal up and running in 5 minutes.</p>
<p>The Liferay community is active. You can find a lot of information in the WIKI and on the forum. I also like the fact that Liferay provides seminars around the world, to me that is a sign of professionalism.</p>
<p>I also like the fact that Liferay offers custom JS and CSS includes per portlet, this allows me add style and JavaScript without having to code it into the portlet itself  or in a Liferay theme.</p>
<p>The API is pretty powerful and usable, although it is hard to find out how it works (seen second point of The Bad).</p>
<h2>The bad</h2>
<p>What I think is really bad on Liferay is that there are still some major bugs open in version 5.2.3. Those bugs should have been fixed a long time ago IMHO. I am not sure if those bugs are fixed in the enterprise version of Liferay, so I am judging on that. For example <a href="http://issues.liferay.com/browse/LPS-114">LPS-114</a>.</p>
<p>One other thing I think is bad on Liferay is the lack of API documentation. It is really hard to find how certain things are achieved or what methods do exactly. For example I have spend some hours finding out how I can retrieve a list of pages of the current community. I have searched the Liferay Wiki, the Liferay forums and used Google without success: I ended up reverse engineering Liferay itself. It is working beautifully now but it wasn&#8217;t a good experience figuring it out.</p>
<h2>The Ugly</h2>
<p>Even though Liferay is supposed to be fully compliant with JSR-168 and JSR-286, I can&#8217;t get the custom portlet mode to work properly. Although this seems to be an optional part of the JSR-286 I  assume that a enterprise product like Liferay would support this feature. I had to apply a work around which resulted in ugly code.</p>
<p>Considering all above points, I can say I am fairly impressed by the Liferay portal. I would choose it again for portal project.</p>
<p>Please let me know if you agree or disagree with me, lets get into a debate regardin Liferay! It deserves it!</p>

	Tags: <a href="http://www.devatwork.nl/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://www.devatwork.nl/tag/liferay/" title="Liferay" rel="tag">Liferay</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.devatwork.nl/2009/11/liferay-good-bad-or-ugly/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Building a JSF Portlet for Liferay</title>
		<link>http://www.devatwork.nl/articles/liferay-portal-articles/building-a-jsf-portlet-for-liferay/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-a-jsf-portlet-for-liferay</link>
		<comments>http://www.devatwork.nl/articles/liferay-portal-articles/building-a-jsf-portlet-for-liferay/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 18:23:48 +0000</pubDate>
		<dc:creator>Trilobyte</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Liferay]]></category>

		<guid isPermaLink="false">http://www.devatwork.nl/?page_id=554</guid>
		<description><![CDATA[In this article I will show you how to build a portlet for the Liferay Portal using JavaServer Faces (JSF). I am not going to explain in detail how to setup Liferay, there are a lot of articles on that subject. I assume you have Java, Tomcat, Liferay, Ant and the Portal plugin SDK up [...]]]></description>
			<content:encoded><![CDATA[<p>In this article I will show you how to build a portlet for the Liferay Portal using JavaServer Faces (JSF). I am not going to explain in detail how to setup Liferay, there are a lot of articles on that subject. I assume you have Java, Tomcat, Liferay, Ant and the Portal plugin SDK up and running.</p>
<p><span id="more-554"></span></p>
<h3>Setting up the build</h3>
<p>The first step is to create the directory and file structure. I will use the pluginsdk to do it for us. Execute the following command in the command line in the directory &#8216;{pluginsdk}/portlets&#8217;:</p>
<pre class="brush: bash; title: ; notranslate">create.bat sample-Jsf-Portlet &quot;Sample Jsf Portlet&quot;</pre>
<p>The first parameter is the name of the portlet, also the name of the directory that will be created for this portlet. The second parameter is the title or display name for the portlet: you will be see the portlet in Liferay with this display name.</p>
<p>After executing the above statement the portlet is created as a plain JSP portlet in a new sub directory. Navigate to the created sub directory and build the portlet using the following command:</p>
<pre class="brush: bash; title: ; notranslate">ant all</pre>
<p>After the build and deploy have been completed fire up your application server and verify if the portlet is up and running.</p>
<h3>Setting up JavaServer Faces</h3>
<p>The next step is to configure the portlet to run using JSF instead of JSP.</p>
<p>Delete all the files in the &#8216;docroot/WEB-INF/src&#8217; directory.</p>
<p>Next  set up the appropiate libraries, copy the following JARs to &#8216;docroot/WEB-INF/lib&#8217;:</p>
<ul>
<li>jsf-api.jar</li>
<li>jsf-impl.jar</li>
<li>jsf-portlet.jar</li>
</ul>
<p>Next modify the &#8216;docroot/WEB-INF/web.xml&#8217; to look exactly like this:</p>
<pre class="brush: xml; title: ; notranslate">&lt; ?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web -app xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot; version=&quot;2.4&quot;&gt;
&lt;context -param&gt;
&lt;param -name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param&gt;
&lt;param -value&gt;client&lt;/param&gt;
&lt;/context&gt;
&lt;context -param&gt;
&lt;param -name&gt;javax.faces.application.CONFIG_FILES&lt;/param&gt;
&lt;param -value&gt;/WEB-INF/faces-config.xml&lt;/param&gt;
&lt;/context&gt;
&lt;context -param&gt;
&lt;param -name&gt;com.sun.faces.validateXml&lt;/param&gt;
&lt;param -value&gt;false&lt;/param&gt;
&lt;/context&gt;
&lt;listener&gt;
&lt;/listener&gt;&lt;listener -class&gt;com.liferay.util.bridges.jsf.sun.LiferayConfigureListener&lt;/listener&gt;

&lt;servlet&gt;
&lt;/servlet&gt;&lt;servlet -name&gt;FacesServlet&lt;/servlet&gt;
&lt;servlet -class&gt;javax.faces.webapp.FacesServlet&lt;/servlet&gt;

&lt;servlet -mapping&gt;
&lt;/servlet&gt;&lt;servlet -name&gt;FacesServlet&lt;/servlet&gt;
&lt;url -pattern&gt;/faces/*&lt;/url&gt;

&lt;security -constraint&gt;
&lt;web -resource-collection&gt;
&lt;/web&gt;&lt;web -resource-name&gt;Page Sources&lt;/web&gt;
&lt;url -pattern&gt;*.jsp&lt;/url&gt;
&lt;url -pattern&gt;*.jspx&lt;/url&gt;
&lt;url -pattern&gt;*.xhtml&lt;/url&gt;
&lt;/security&gt;&lt;/web&gt;
&lt;auth -constraint&gt;
&lt;role -name&gt;nobody&lt;/role&gt;
&lt;/auth&gt;

&lt;security -role&gt;
&lt;role -name&gt;nobody&lt;/role&gt;
&lt;/security&gt;
</pre>
<p>Next modify the &#8216;docroot/WEB-INF/portlet.xml&#8217;, change the following lines:</p>
<pre class="brush: xml; title: ; notranslate">&lt;portlet -class&gt;com.sun.faces.portlet.FacesPortlet&lt;/portlet&gt;
&lt;init -param&gt;
&lt;name&gt;com.sun.faces.portlet.INIT_VIEW&lt;/name&gt;
&lt;value&gt;/view.jsp&lt;/value&gt;
&lt;/init&gt;</pre>
<p>Create a new file &#8216;docroot/WEB-INF/faces-config.xml&#8217; and add the following content:</p>
<pre class="brush: xml; title: ; notranslate">&lt; ?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt; !DOCTYPE faces-config PUBLIC &quot;-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN&quot; &quot;http://java.sun.com/dtd/web-facesconfig_1_1.dtd&quot;&gt;
&lt;faces -config xmlns=&quot;http://java.sun.com/JSF/Configuration&quot;&gt;
&lt;/faces&gt;</pre>
<p>Add the following line to the build properties file &#8216;docroot/WEB-INF/liferay-plugin-package.properties&#8217;:</p>
<pre class="brush: plain; title: ; notranslate">portal-dependency-jars=commons-beanutils.jar,commons-collections.jar,commons-digester.jar,jstl.jar,jstl-impl.jar</pre>
<p>This will setup the portlet to run in the JSF context.</p>
<h3>Modify the view</h3>
<p>Open the &#8216;docroot\view.jsp&#8217; and replace the content with:</p>
<pre class="brush: xml; title: ; notranslate">&lt; %@ taglib uri=&quot;http://java.sun.com/jsf/core&quot; prefix=&quot;f&quot; %&gt;
&lt; %@ taglib uri=&quot;http://java.sun.com/jsf/html&quot; prefix=&quot;h&quot; %&gt;

&lt;f :view&gt;
&lt;p&gt;Hello World, from a JSF portlet&lt;/p&gt;
&lt;/f&gt;</pre>
<h3>Compile, Deploy and Run</h3>
<p>Compile and deploy the code using the above Ant command. The portlet is being deployed to the application server. Add the portlet to a page and view the result.</p>
<p>I hope this helped you to get build JSF based portlets. <a href="http://www.devatwork.nl/wp-content/uploads/2009/08/sample-Jsf-Portlet-portlet.zip">Download the source</a>. Take care!</p>

	Tags: <a href="http://www.devatwork.nl/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://www.devatwork.nl/tag/liferay/" title="Liferay" rel="tag">Liferay</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.devatwork.nl/articles/liferay-portal-articles/building-a-jsf-portlet-for-liferay/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>My First Java Steps</title>
		<link>http://www.devatwork.nl/2009/08/my-first-java-steps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-first-java-steps</link>
		<comments>http://www.devatwork.nl/2009/08/my-first-java-steps/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 19:06:20 +0000</pubDate>
		<dc:creator>Bert Willems</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Liferay]]></category>
		<category><![CDATA[Liones]]></category>

		<guid isPermaLink="false">http://www.devatwork.nl/?p=547</guid>
		<description><![CDATA[Hello all, sorry for the radio silence lately, you might wonder what I have been doing lately. Well I have committed a terrible sin against the .NET framework (my previous home ): I started learning Java. Why Java? Because several clients of Liones demand that their applications must be build on the Java platform and [...]]]></description>
			<content:encoded><![CDATA[<p>Hello all, sorry for the radio silence lately, you might wonder what I have been doing lately. Well I have committed a terrible sin against the .NET framework (my previous home <img src='http://www.devatwork.nl/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ): I started learning Java.</p>
<p>Why Java? Because several clients of <a title="Liones" href="http://www.liones.nl/" target="_blank">Liones</a> demand that their applications must be build on the Java platform and I am deeply involved in the process. I am not going to bother you with the organizational side of the process, I will focus on sharing my experience.</p>
<p>Learning Java isn&#8217;t really the objective for me, it is just another programming language and C# is similar enough to not cause any problems for me to program in Java. The real objective is to be able to develop applications (called portlets) for the <a title="Liferay" href="http://www.liferay.com/" target="_blank">Liferay</a> portal framework. The hidden challenge, for me, turned out to be setting up the environment.</p>
<p>I got everything up and running today: Java, Ant, Tomcat, Liferay and I developed my first custom portlet (an application for Liferay) using above technologies and Java Server Faces. I will post an article on how I did it soon!</p>

	Tags: <a href="http://www.devatwork.nl/tag/java/" title="Java" rel="tag">Java</a>, <a href="http://www.devatwork.nl/tag/liferay/" title="Liferay" rel="tag">Liferay</a>, <a href="http://www.devatwork.nl/tag/liones/" title="Liones" rel="tag">Liones</a><br />
]]></content:encoded>
			<wfw:commentRss>http://www.devatwork.nl/2009/08/my-first-java-steps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

