views:

1008

answers:

2

Hello dear Stackoverflow - community, my quastion is, which is the best way to integrate existent spring-MVC-Project with flex. I'am using Spring-2.5 lib with annotations.

e.g my list controller:

package xxx.xxx.controller;

@Controller
public class ListController {

 @Autowired
 private ColorHome colorHome;

@RequestMapping("/admin/colors.do")
public ModelMap colorsHandler() {
 Collection<Object> colors = this.colorHome
   .findColors();
 return new ModelMap(colors);
}

i have also a colors.jsp which displays the colors. Now i would like to integrate flex as an UI-Layer. I only need to integrate the Spring-View with shown RequestMappings above. I would appreciate the answers. Thank you. Alex :)

+1  A: 

Go get BlazeDS. Install it using the WAR file. You'll also need the flex jar from Spring.

In your web.xml file, add this:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/flexContext.xml
    </param-value>
</context-param>
<servlet>
    <servlet-name>flex</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>flex</servlet-name>
    <url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>

Create a flex-servlet.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:flex="http://www.springframework.org/schema/flex"
       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-2.0.xsd"&gt;
</beans>

Create a flexContext.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:flex="http://www.springframework.org/schema/flex"
    ...
">
    <flex:message-broker />

    <flex:remoting-destination destination-id="flexService" ref="beanFromApplicationContext" />

</beans>

This should be enough to get you the remoting endpoints.

In Flex, create a remoteObject and give it a destination of "flexService" or whatever you set the destination-id on the to.

I Never Finish Anythi
A: 

Spring has a project for its integration with Flex,BlazeDS and Java.

This might help you. Spring n Flex integration

Chinmay