Oracle Portlet Development – Consuming RSS Feeds


Looking back at the tutorial I posted last September 22, 2011, it was a very neat  tutorial that really showcases the power of Oracle Portlet Development using JDeveloper and the flexibility of WebCenter for consuming remote portets.  With that I created my own version of the tutorial just for fun!

Although, this isn’t a video, its just a power point presentation and I never got the WebCenter installation part (I don’t have EM in my laptop and besides, I don’t have that powerful machine yet). Here it is!

Screenshot of the JSP page with RSS Feed Data.

Download the Project Here.

Enjoy!

Oracle WebCenter 11g – Twitter Feed Data


I’ve been trying to learn Oracle WebCenter and ADF using JDeveloper for quite some time now, and it seems that its becoming clear to me that this thing called  ”Data Controls” (which at first I never thought is important in any of these) is actually the key that holds the truth about the power of Oracle ADF 11g. :)

Heres a video on developing a portlet with Twitter Feed inside. :)

Key Notes:

  1. Add the WebCenter Porlet Web Service for any Fusion Project to add portlet integration capabilities.
  2. RSS feeds is an XML document and uses XSD (XML Schema Definition)
  3. Oracle JDeveloper has a way to pull the XSD from an existing XML document.
  4. Our XML document along with an XSD can be a source of Data Controls – remember, XML is a universal format that can be used in a universal way (it can contain schema Data or just plain text).
  5. ADF components uses Data Controls – thus, if we do have the Data Controls, we can use them to develop ADF applications.
  6. Go to the info page to get the WSDL (v1 or v2).
  7. We need these WSDL to register out portlet to our WebCenter Instance
  8. Once we register this portlet, users can see and add these portlet via Composer.
I’ll be posting some tutorials for these as soon as I can. :)

Oracle ADF – End to End Simple Application Tutorial


I find this video very nice and easy to catch up with. Very detailed and straight to the hands-on exercise.


http://download.oracle.com/otn_hosted_doc/jdeveloper/11gdemos/JDevExperience/JDevExperience112flv.html

The demonstrator uses Oracle JDeveloper to develop a simple Enterprise solution that uses Oracle ADF Framework.

Key notes:

  1. JDeveloper supports both Declarative and Narrative development.
  2. Developers can create EJB / JPA Business components and expose it through Data Controls.
  3. Data Controls are created to expose functionalities to Oracle ADF.
  4. Once Data Controls are created, this can be used to create ADF based form components like Manager Forms and Graphs

Review: The tutorial is more of a declarative way of developing ADF applications. It first creates a Database Connection, then create an EJB Diagram to create Session Beans and JPA Entities. This beans will be the back bone (model) of our application for database transactions. Next, create Data Controls to expose EJBs for Oracle ADF. Then after exposing these, we can now use the ADF framework to create pages and combine very useful ADF components (accordion, data grids, graphs etc.)

This tutorial really showcased the power of Oracle ADF + the use of JDeveloper. Its completely a new way of developing Java EE applications. JDeveloper brings another level of development scheme as showed on the tutorial, its a very flexible IDE that support both declarative and narrative development method.  The addition of full support on Oracle ADF sums up the whole package as it allows developers to drag and drop exposed ADF data controls and create components for it (graphs, forms, etc.).

Oracle ADF/JSF – Page Template Development


Templating is the commonly used approach when building the presentation layer of a Web Application. It is never wise for a developer to not consider templating in their design, especially when a lot of users will view your side on a daily basis and a lot of page will be develop for the solution.

Efficiency is the term in doing templates, its somehow eases the developer and designer of their workload by developing a constant body of page template that can be used globally. it is by far, the most accurate form of “re-usability”.

Though there are a lot of templating technology for Java EE. I find only two of them very flexible and easy to learn (of course, excluding Velocity since its more of a presentation generator api). Apache – Tiles and JSF Templating.

Example of Struts Tiles Templating.


http://www.vaannila.com/struts/struts-example/struts-tiles-example-1.html

Example of JSF Templating


http://www.mkyong.com/jsf2/jsf-2-templating-with-facelets-example/

For this post, I will try to create a ADF Template using Oracle JDeveloper 11g. ADF templating is different a bit different from JSF templating.

1st: Create the Page Template

Right Click on a Folder > New > JSP Page

The Page Template creation dialog is shown. Now Tick on the Use quick start layout to customize our Template.

Choose from a variaty of default layouts.

Ticked on “Apply Themes” to apply default skins. We will ticked this one for this tutorial.

Click OK to create the actual template.

The files where updated to comply with the template we just created: faces-config.xml – the new render kit (fusion render kit) was introduce to server as the overall render kit for any pages developed. The trinidad-config is where the skin family is indicated and web.xml to add new libraries, init paramters and external source files support for the new skin and page (swf – flash).

Lets tweak the template first before using it. Lets put something on the “top”,”first” and “center” facelets. Go to Source and define faclets on the component section of the template. This section is where all the facelets should be defined.

 
      <component xmlns="http://xmlns.oracle.com/adf/faces/rich/component">
        <display-name>sample_adf_template</display-name>
        <facet>
                <facet-name>centerDetail</facet-name>
                <description>This child draws out the detailed forecast</description>
         </facet>
          <facet>
                <facet-name>centerTop</facet-name>
                <description>This child draws out the detailed forecast</description>
         </facet>
         <facet>
                <facet-name>centerFirst</facet-name>
                <description>This child draws out the detailed forecast</description>
         </facet>
      </component>

Put Facelets in the Template Page.

<af:facetReg facetName="centerTop"/>
<af:facetReg facetName="centerFirst"/>
<af:facetReg facetName="centerDetail"/>

2nd: Use the Page template

Lets create the page using the page template. Click on Pages folder (create one) > New > JSF Page. Choose the JSF Template we created.

Create the Page.

        <af:pageTemplate viewId="/pagetemplates/sample_adf_template.jspx" id="pt1">
            <f:facet name="centerDetail">
            <af:panelGroupLayout layout="vertical">
                <f:verbatim>THIS IS JUST A STRING</f:verbatim>
            </af:panelGroupLayout>
          </f:facet>
          <f:facet name="centerTop">
            <af:panelGroupLayout layout="vertical">
              <af:outputText value="HELLO WORLD"/>
            </af:panelGroupLayout>
          </f:facet>
          <f:facet name="centerFirst">
            <af:panelGroupLayout layout="vertical">
              <af:outputText value="HELLO WORLD"/>
            </af:panelGroupLayout>
          </f:facet>
        </af:pageTemplate>

3rd: Run the Page that uses the Page Template.

Result:

Download the source here.

Review: Oracle ADF really puts a lot to the table. Arrays of components and custom tools plus, a great IDE to build enterprise applications with it. Page Templating is not very far from JSF templating, it uses the same concept of inserting ui components (for ADF’s case, facelets) to get page fragments for consistency.

Oracle JDeveloper 11g – First Hand on EJB/JPA Development


I find EJB/JPA Development in Oracle JDeveloper too good to be true! :) Seriously. I tried developing a new Java EE Application using JDeveloper:

The wizard created 2 components in the project. A ViewController package and a Model Package.

ViewController Package – Is where all JSF/JSP and Servlets go, basically the view and controller sources. Model – Business Components such as EJBs and JPA entities are placed in this package.

Lets try creating an end to end Person Registration! :)

1st Step: Design the Model.

Go to New  > Offline Database

Start by creating a dummy database – developers can create an offline database (oracle database emulator) that will run with your application.

Then lets create a table on that offline database we just created.

Click on OK. After creating the table, new database components will be created on the project setup.

What we did with the first step is just to create a database and a table to store our Person Registration.

2nd Step: Create Model Diagram (EJB/JPA Diagram) and Components

After creating the database and table, we now need to create the components that will interact with the database from our application.

Create EJB/JPA Diagram: Developers usually skip the part of creating a diagram first – I would say that this process is one of the most under-rated process for any developer regardless of the platform  (I sometimes wonder how one can develop without even doing some drawing to visualize the flow of their application logic).

After hitting “OK”, a blank diagramming canvass will be displayed. Note: This canvass I believe is one of the most powerful feature of Oracle JDeveloper! – Keep reading.

Next, drag the PERSON table on the canvass. This will create a new Entity Bean (JPA entity bean), create a new Persistence unit and a persistence XML for its definition.

Note: I move the generated entity class to a new package (this is one of the features I actually don’t like about all this automation stuff).

Create a simple Stateless Session Bean. Drag a new Session Bean from the EJB Component Palette on the right side to the canvass.

This will open up a wizard to create the new Session Bean.

Methods will be automatically generated. These generated methods will perform basic querying, insertion, delete and update.

Put the Session Bean on the beans package.

Remote and Local Interface (Both interface will be placed on the beansiface package).

Session Beans are now created. :)

We just created our Model Layer. We can now use the Session Beans to do Database Transaction from our Controller.

3rd Step: Develop the Page and ManagedBean

Open the faces-config.xml – We will create 2 JSP that will handle user input and a success page.

After creating creating the Page Flow, we now create the actual page. Right click on the diagram page component to create page.

Pages can be created from a template or a blank page. I will discuss Page template development in another post. :)

Create a ManagedBean – this is the controller class where in we put form fields and actual call to the business logic. From the faces-config.xml, right click on the canvas to create the managedbean. This will create a new ManageBean entry on the xml file.

After the ManagedBean is created, put the fields First Name and Last Name (Generate or create Accessors) in it. Put also the logic to insert the new Person data.

Create a Registration Form. Open the registerperson page to create the form and map the fields to its corresponding ManagedBean mapping.

Success Page:

4th Step: Test the Person Registration

Right Click on the Register Person Page.

Test the Person Registration:

As I’m trying this stuff, it took me a while to get a hang of getting my source running. The first thing I did was not to rely on automation scripts to really experience how to assemble each piece of components together. Yet as I go along some roadblocks and issues, I would really say that if I’ll be using this IDE for J2EE Development, I would rather build it using the automation tools available.

The Diagram tool is amazing, drag and drop your components and your off and running.

Offline database is cool. You don’t have to mind how much memory would it consume your terminal just to try a EJB/JPA, you can just use the offline database (which is basically just a file) and your good to go.

JSF Flow Diagram is great. I’ve use the faces-config diagram and its like mapping the flow of your pages. All drag and drop components are available, page and beans generate are also available.

One thing I didn’t like at all is the package management, it seems that if you have a convention of creating sub-packages, you’ll likely to be irritated by that fact that it can’t create sub-package for itself. You’ll have to create one sub-package after the other.

Overall, I’m impress how Oracle manage to put a lot of automation in the IDE. The Diagramming canvass is perfect for modelling (EJB and JPA generated), the offline database is too good to be true for development trials and the JSF Diagram canvass from faces-config and bean generators really did put the ease on developing view components.

Download the project here