Switching out your Weblogic Page Flow Controllers in favor of Spring Controllers is easier than you might think. Here are just a few steps to help the integration.

Dependencies

The latest production release version of Spring is version 3.0.2. In this version they have broken the release into about 20 different jar files. The libraries listed below are those that you will need to include in the WEB-INF/lib your project:

  • org.springframework.asm-3.0.2.RELEASE.jar
  • org.springframework.beans-3.0.2.RELEASE.jar
  • org.springframework.context-3.0.2.RELEASE.jar
  • org.springframework.context.support-3.0.2.RELEASE.jar
  • org.springframework.core-3.0.2.RELEASE.jar
  • org.springframework.expression-3.0.2.RELEASE.jar
  • org.springframework.web-3.0.2.RELEASE.jar
  • org.springframework.web.portlet-3.0.2.RELEASE.jar
  • org.springframework.web.servlet-3.0.2.RELEASE.jar

You'll also want to add the spring.tld and spring-form.tld in your WEB-INF/tlds directory. That way you can switch out your netui tags for the equivalent spring tags in your jsps.

Configuration

To integrate Spring into your portal application there are a few required configuration items that are needed.

  • web.xml - The listener and application context-param below basically just tell the Spring container where to find your applicationContext configuration file. This servlet is what converts the PortletRequest/PortletResponse to HttpServletRequest/HttpServletResponse for the DispatcherPortlet

  • applicationContext.xml - The applicationContext.xml is where you define beans and configuration items that will be shared by all the portlet within your web application. Here you can specify packages to scan for resources (clients/services) that will be called from your controllers. Here you also define a viewResolver bean so that Spring can resolve the views. Other application-wide beans can also be defined here, such as, a message codes resolver for displaying messages and labels and an exception resolver for error handling.

Portlet

Once your Spring Controller has been created the next step is to create the .portlet file.

  • Within Weblogic Workshop right click in the Package Explorer/Navigation panel and select New -> Portlet and give your .portlet file a name and location and click Next.

  • Then the Portlet Wizard will appear and prompt you to select a portlet type. Click the Java Portlet radio button to create a JSR 168 compliant portlet and click Next.

  • Next you will need to give a a title, label, portlet name, and a Class name and click Next.
    (The Definition Label and Portlet Name will generally always be the same, which will be the same as your [portlet-name]-portlet.xml configuration file. The Class Name will always beorg.springframework.web.portlet.DispatcherPortlet. The information entered here is automatically added to the web application's portlet.xml file.)

  • Finally, click Create to create the portlet.

  • Upon creation of your .portlet file an entry similar to the one below will be automatically added to your portlet.xml file.

  • Once your .portlet file is created you can open your .portal file within Weblogic Workshop and your new Portlet should display in the Design Palette panel. You can then easily drag your portlet onto any Book or Page you wish.


That's it. Now just redeploy your web app.