Friday, August 12, 2011

Create JSR 286 Portlet with Oracle WebCenter and JDeveloper

What I really like in JDeveloper is the easiness to create JSR 286 Portlets. Since I want to write several articles about creating and using JSR 286 Portlets in Oracle WebCenter Portal let me give you the here the first step about creating such a portlets.

Step 1: Open JDeveloper and click on New Application. To be able to start developing a portlet you do need first to create Portlet Producer Application. Type the name of the application and select Portlet Producer Application from the list with application templates.

image

On the next screen give the project a name. JDeveloper already selected the minimum needed project technologies and libraries needed to be included into the project.

image

On the next screen you can type the default package name and click Finish to finish this project creation.

image

Now as you can see the JDeveloper create empty producer application for you. You can use now this to create your JSR 286 into.

image

To do so go and click with the right mouse button on the application and click on New.

image

In the newly opened window select Portlets and then Standard-based Java Portlet (JSR 286) to create new portlet.

image

This will open a new window, where now you can set up you portlet. Since this is just a example I will leave everything by default.

image

Just click always Next until the last step and then on finish to complete the creation. All setting you see into the wizard are changeable later, so you do not have to worry about this now. I will try to show you how to do this in another article.

Now when you finish the creation you will see something like this:

image

You create your fist portlet, which is ready to run. To run the portlet click with the right mouse button into your portlet and then on Run. This will deploy your portlet and then start it automatically into your default browser.

image

So that you will something like this in your browser:

image

If you want to open the view.jsp page you can go for the link: http://127.0.0.1:7101/Portlets-PortletsOtn-context-root/portlet1/html/view.jsp

or you can just click on the view.jsp with the right mouse button and select Run again. This will open the view page directly into your browser:

Step 3: Adding more portlets to the current project.

If you want to add more portlets to this project you do the following:

Right mouse click on the portlet.xml file and from the menu click on Add Portlet.

image

This opens the already familiar window with the portlet settings but now for the new portlet you want to add into the current application. I will leave the setting again by default and click on next and then finish until I create the project.

image

After you finish with the wizard your JDeveloper project will look now like this:

image

The wizard added now one more portlet into the current project. If you run the project again you will into your browser now the following:

image

The JDeveloper exported the two portlets WSDL and there are ready to be consumed from portal supporting WSRP. Having this we now register our portlets into the WebCenter Portal.

Step 4: Registering the portlets into the WebCenter Portal

There are two ways to register the portlets into the WebCenter Portal:

  • In Design Mode – this step is done in JDeveloper when you create and design your portal.
  • In Running Mode – when your portal is packed and deployed on separated environment.

I would like to show you how to register the newly created portlets in Running Mode. Open your portal and login in as administrator.

image

Click on Administration to go into the admin section and then click on Services->Portlet Producer as shown bellow:

image

Now click on Register and you will see the registration form:

image

Where you can choose the producer name, the producer type which in our case is WSRP-Producer and then the WSDL URL. To get the URL you have to go to your portlet info page and click on WSRL v2 WSDL link,

image

which will open the URL into the browser like this:

image

this is the URL which you have to use as WSDL URL when you register the portlet. On the end click on OK to finish the registration. You portlets now should be accessible and you can add them to a page from the portlet catalog shown bellow:

image

and then here

image

Now those were very simple steps but initial and important to start your portlet development. In the next article I would try to go more in details about how to use the different JSR 286 functions together with JDeveloper.

4 comments:

  1. Great post Lyudmil! Thanks for putting this together, it's a good way to start understanding and coding portlets to WebCenter!
    Thanks!

    ReplyDelete
  2. Thanks you !!

    ReplyDelete
  3. hi , i need the tutorial for creating user management task in webcenter portal using jdeveloper please help me .

    ReplyDelete