Announcement Announcement Module
Collapse
No announcement yet.
Help: Upconverting from Portlets to Servlets Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help: Upconverting from Portlets to Servlets

    Hi,
    I am having a horrible time trying to upconvert my project from a portlet to a servlet. I'm trying to minimize the code change as this project is complete (for the most part) just certain IBM components that were supposed to work with the portal server don't.

    As a background I am very new to webflow and have been learning it as I go on. We didn't use annotations in the initial release of this and at this point I'd rather avoid putting them in. We also use FormAction for our controllers to use, each portlet had it's own controller and then the main portlet would subflow the other portlets. Example:

    (Rather large but their is a benefit of showing it all)

    I have 5 of those named <appname>-portlet.xml each one invokes there own webflow, invokes there own form action, and holds it's own values.

    The hierarchy looks like this: View Controller subflows Enroll Controller which subflows 3 other controllers.

    How do I do this?
    Last edited by rasperin; Apr 13th, 2009, 01:14 PM.

  • #2
    I hate to bump, but I'm really in need of help, if anyone knows anything. A link to point me in the right direction.

    Mostly what I need is to see how a Servlet handles multiple Webflows that can run stand alone without using annotations. I've seen it for SWF 1.

    Thanks!

    Comment


    • #3
      I don't know how useful this will be, I tend to have a coherency issue when it comes to anything else then coding and casual conversation.

      I thought I'd reply to myself as I've finally up-converted from a Servlet to a Portlet. Basically the information you would have had in a *-portlet.xml is going to be switched to a *-servlet.xml. Oddly I had to also create a webflow-config.xml and import both of those from my application-config.xml (bean directory defined in your contextLoader), so anything I need to do I actually have to do in the webflow-config.xml but it doesnít work without the *-servlet.xml. If you have multiple portlet with multiple flows sub-flowing each other you are going to have to make multiple entries into your web.xml for each portlet. I switched from ViewRenderServlet to:

      Code:
      <servlet>
              <servlet-name>SSO</servlet-name>
              <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      		<init-param>
      			<param-name>contextConfigLocation</param-name>
      			<param-value></param-value>
      		</init-param>
      		<load-on-startup>2</load-on-startup>
          </servlet>
      
      	<servlet-mapping>
              <servlet-name>SSO</servlet-name>
              <url-pattern>*.html</url-pattern>
          </servlet-mapping>
      The rest stayed the same.

      The only real tricky part about the conversion is the webmvc-config.xml

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
                              http://www.springframework.org/schema/beans/spring-beans.xsd">
      	
      		<!-- Enables annotated methods on POJO @Controllers  -->
      	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
      	
      	<!-- Enables plain Controllers (e.g. FlowController) -->
      	<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
      
          <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
              <property name="interceptors" ref="localeChangeInterceptor"/>
          </bean>
      	
      	<!-- Enables plain Controllers -->
          <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
      
      	<!-- URL to flow mapping rules -->
      	<bean id="flowMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
      		<property name="mappings">
      			<value>
                     /asdf.html=ViewFlowHandler
      			</value>
      		</property>
      		<property name="order" value="0" />
      	</bean>
      	
      	<bean name="/asdf.html" class="org.springframework.webflow.mvc.servlet.FlowController">
      	    <property name="flowExecutor" ref="flowExecutor" />
      	</bean>
      	
      	<bean id="ViewFlowHandler" class="com.ViewFlowHandler"/>
      	
      	<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
      		<property name="basenames">
      			<list>
      				<value>com.Resources</value>
      			</list>
      		</property>
      	</bean>
          
          <!-- Declare the Interceptor -->
          <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
              <property name="paramName" value="locale"/>
          </bean>
          
          <!-- Declare the Resolver -->
          <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />    
      </beans>
      This is a huge addition and change up, take a good look through it most things are commented where they need to be.

      When you go to deploy this, you are going to run http://serverName/deployedLocation/asdf.html and it should load your Controller if you built your beans correctly. Thatís about the gist of it, the rest I was able to easily port over. Iím now trying to figure out this whole attribute mapping in subflow thing.

      Comment

      Working...
      X