0 and have problem where to put public files
I tried Where to place images/CSS in spring-mvc app? this soluion but its not working for me
I have tried to place my public folder every where in WEB-INF directory outside but still nothing
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<display-name>s-mvc</display-name>
<servlet>
<servlet-name>frontController</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>frontController</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<mvc:resources mapping="/css/**" location="/css/"/>
</web-app>
frontcontroller-servlet.xml
<mvc:annotation-driven/>
<context:component-scan base-package="pl.skowronline.controller" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
and that how I call css file
<link type="text/css" href="/css/bootstrap.css" rel="stylesheet" />
I think you are getting confused with the web.xml and the application-context.xml.
The web.xml should contain the webapp xsd declarations like this, and the mapping for the Dispatcher Servlet.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>s-mvc</display-name>
<servlet>
<servlet-name>frontController</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>frontController</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Where as the application-context.xml contains the spring-framework xsd declarations like below
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:annotation-driven />
<context:component-scan base-package="pl.skowronline.controller" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
the answer from JB Nizet is correct. However, it seems the problem of your application is more than just a place to put css/js file. For Spring MVC, you must put all configuration right, or it will not work.
For simplicity, just put the css folder right in the WEB-INF folder (/WEB-INF/css), so that you can access it like this in your page:
<a href="<c:url value='/css/bootstrap.css'/>"
That link should take you directly to the css file. If it works, you can change the <a> tag into the <link> tag for CSS styling.
If it doesn't work, there are a few things to check:
1) Spring Security constraints that forbid you to access the files
2) The affect of various filters/ interceptors that can hinder your file access
3) Servlet Configuration in web.xml. Make sure that no dispatcher intercept your access to the CSS file.
Often, <mvc:resources> will do all the above things for you. But just in case it failed, you may want to have a look.
For the <mvc:resources> error:
The matching wildcard is strict, but no declaration can be found for
element 'mvc:resources'.
It looks like you haven't declared the right schema yet. For example, you should add the following lines in the beginning of your file:
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
UPDATE:
As your response, the problem seems to be here:
<servlet-mapping>
<servlet-name>frontController</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
You should change it to:
<servlet-mapping>
<servlet-name>frontController</servlet-name>
<url-pattern>/*.html</url-pattern>
</servlet-mapping>
This will save the URL for the css/images files from conflicting with the URL mapping of controller (your servlet), and it let mvc:resources do it magic. Of course, you can use what ever extension you want for "html" part. For a beautiful URL, we may use a library like Turkey URL rewrite to solve the problem
This is described in the following section of the documentation. Follow the instructions given there, and then change your href: /css/bootstrap.css means: In the folder css right under the root of the server. So, unless your application is deployed as the root application, it won't work, because you need to prepend the context path of your app:
href="<c:url value='/css/bootstrap.css'/>"
And this will thus mean: in the css folder, right under the root of the webapp. If the context path of your webapp is /myFirstWebApp, the generated href will thus be
href="/myFirstWebApp/css/bootstrap.css"
You can try using context path to locate resource files.
<link type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.css" rel="stylesheet" />
Read this to know more.
I too had the same problem.Please perform below steps to get it work which worked well for me and my teammates as well.
Step1 :- Create a folder in Web-INF with name "resources"
Step2 :- Upload your bootstrap,css and js if you already do have or in case if you want to write it write inside this folder
Step3 :- Now Update your dispatcher servlet xml as below
Add Below code within beans tag
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />
Add below code to xsi:schemaLocation at top of this xml
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
step 4:- now you can use css,bootstrap resouces in your code as below
<header class="custem_header_bg"><img src="resources/img/product_banner.png" class="img-responsive"> </header>
You can only set base on JSP as following steps. Then you don't need to set mvc:resources in web.xml.
Just set base as following. Also we can use header file to set this value. Then we can include that header.jsp in to any page we are using in application. Then we dont need to set this value in every JSP.
You need to set <base/> as following...
<c:set var="req" value="${pageContext.request}" />
<c:set var="url"> ${req.requestURL} </c:set>
<c:set var="uri" value="${req.requestURI}" />
<head>
<title></title>
<base href="${fn:substring(url, 0, fn:length(url) - fn:length(uri))}${req.contextPath}/" />
Then You can Import any JS or CSS like below..
<script src="assets/js/angular/angular.js"></script>
Related
I want to create a workspace in Windchill calling Rest API from our web application. But no where to find such API end point in any of the Windchill Rest API documentation.
Is it possible to create workspace using rest API, if not is there any alternative way to achieve it.
On which Windchill version do you work?
When I don't find standard endpoints in the REST Services, I write them myself.
Since Windchill 11.1 I use Spring to create them.
For that you need an entry in codebase/WEB-INF/web.xml like:
<servlet>
<servlet-name>ConnectorName</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ConnectorName</servlet-name>
<url-pattern>/servlet/connector/*</url-pattern>
</servlet-mapping>
In the same folder you need a file named like the Servletname-servlet like ConnectorName-servlet.xml with following content:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop = "http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd ">
<context:component-scan base-package="packagename" />
<mvc:annotation-driven />
After this you can create a Spring RestController Class in the package defined above in component-scan.
I'm using Elastic Search for my project activities in which I communicated to the backend ES cluster through the spring utility
spring-data-elastic-search
Following are the spring-repository descriptions for the webapp.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
xsi:schemaLocation="http://www.springframework.org/schema/data/elasticsearch http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<elasticsearch:transport-client id="client" cluster-nodes="localhost:9300" />
<bean name="elasticsearchTemplate"
class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
<constructor-arg name="client" ref="client" />
</bean>
<elasticsearch:repositories
base-package="com.customer.repositories" />
</beans>
Here I've specified the cluster node configuration as cluster-nodes="localhost:9300" and it is working fine with my local testing.
In production server we've a full functional cluster setup with host IP say (192.xx.xx.xx). So my problem is that, we have specified the cluster host in a yml file in /etc/project/es.yml file in the production server. So I need to tweak my application to take the cluster configuration from this custom location.
Since the above spring-repository xml initialized by the spring container, we are unable to override the behaviour. Is there any way to achieve it with spring-data-elastic-search ?
Finally I resolved my issue and sharing it here, so that it may be useful to some one else.
Changed YML idea to property file (es.props)
spring repository descriptions should be as follows
<?xml version="1.0" encoding="UTF-8"?>co
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
xsi:schemaLocation="http://www.springframework.org/schema/data/elasticsearch
http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:property-placeholder location="file:/etc/project/es.props" />
<elasticsearch:transport-client id="client" cluster-nodes="${es-host}:9300""/>
<bean name="elasticsearchTemplate"
class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
<constructor-arg name="client" ref="client" />
</bean>
<elasticsearch:repositories
base-package="com.customer.repositories" />
</beans>
Which used Spring PropertySourcePlaceHolder modification mechanism in 3.1+.
So it will look up for es.host in /etc/project/es.props. Local testers can override this property by starting the server with -Des.host=custom-cluser-host
Actually Mohsin(Spring-data-elastic-search developer) gave hints to arrive at this solution. Thanks Mohsin.
I have a problem using spring mvc 3 and extjs 4 or more precisely a problem of path when exjs try to load my controllers or my images.
The structure of my webapp is like this :
src
-- webapp
-- app
-- extjs4.1.3
-- css
-- icons
-- WEB-INF
-- jsp
app.js
I have a controller annoted like this
#RequestMapping(value = "/path/init.do", method = RequestMethod.GET)
It return a view name that match a jsp in my WEB-INF/jsp folder. This jsp load extjs files.
ViewResolver :
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>tiana Web Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/spring/application-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Because my url pattern is "/", I had to make use of the mvc:resources magic tag available since spring 3.0.5 (approximatively) like this :
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/app/**" location="/app/" />
<mvc:resources mapping="/extjs-4.1.3/**" location="/extjs-4.1.3/" />
<mvc:resources mapping="/app.js" location="/app.js" />
I know it could be better if I place all those things in a resources folder. I would have to write only :
<mvc:resources mapping="/resources/**" location="/resources/" />
But I don't think it'll solve my problem
My jsp file is like this :
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>My jsp title</title>
<link rel="stylesheet" type="text/css" href='<c:url value="/extjs-4.1.3/resources/css/ext-all.css" />'>
<link rel="stylesheet" type="text/css" href='<c:url value="/css/myStyle.css" />'>
<script type="text/javascript" src='<c:url value="/extjs-4.1.3/ext-all-debug.js" />'></script>
<script type="text/javascript" src="<c:url value="/app.js" />"></script>
</head>
<body></body>
</html>
First of all I had to write the references to my resources files using jstl tags.
Without those tags, if I keep url like /myresource.xxx, the url will be
localhost:8080/myresource.xxx
And if I write myresource.xxx without the slash, it is
localhost:8080/mywebapp/path/myresource.xxx
But it works like this, any suggestion would be appreciated to skip the jstl dependency but it works.
My real problem is that my app.js will load extjs's controllers and for that it uses some kind of 'window.location' to construct the url. In my case, it will be
localhost:8080/mywebapp/path/app/controller/myController.js
but i'd like it to be
localhost:8080/mywebapp/app/controller/myController.js
I face the same kind of problem if I put an icon in my extjs files, the url will be
localhost:8080/mywebapp/path/icons/myIcon.png
and not
localhost:8080/mywebapp/icons/myIcon.png as expected.
I can solve this by adding
<mvc:resources mapping="/path/app/**" location="/app" />
<mvc:resources mapping="/path/icons/**" location="/icons" />
But I can believe that each time I define a new requestMapping in a Spring mvc controller, "path2" for example, I'll have to define a corresponding mvc:resources mapping.
I tried to define a global "baseUrl" javascript variable in my jsp file, prefixing the appFolder by this variable in the app.js file and prefixing all icons and things used in extjs code by this variable but it's not either acceptable.
What have I missed ? I googled a lot and I came to this "/" url-pattern and mvc:resources method (which seems very clean for spring mvc webapp) but I cannot solve my "uri" problem (I don't know how the path generated by the requestMapping is called in real english).
Thank you so much if you can help me and if not, thank you for your time
You can try to put all of your resources (i'm not sure which of your contents is a static resource) in:
-- webapp
--resources
-- app
-- extjs4.1.3
-- css
-- icons
-- WEB-INF
-- jsp
app.js
then you define a single mapping:
<mvc:resources mapping="/resources/**" location="/resources/" />
at this point you'll access the css folder for example using:
<c:url value="/resources/css/myStyle.css" />
and any other of your paths in the same way or you can try by using (but not tested):
<mvc:resources mapping="/**" location="/resources/" />
and i suppose you'll access your css folder:
<c:url value="/css/myStyle.css" />
I'm developing a software based upon Spring and ICEFaces.
I have a file at <project directory>/src/main/webapp/WEB-INF/views/<filename>.xhtml, that is correctly reached using the following URL: http://<hostname>/<projectname>/<filename>.xhtml
The file contains a <h:form id="formId"> which is rendered as a <form action="/<projectname>/WEB-INF/views/<filename>.xhtml" [.. some other stuff ..]>
It means that, when I click on the input submit contained in the form, the browser tries to open the URL http://<hostname>/<projectname>/WEB-INF/views/<filename>.xhtml and, as I said in the title, it shows an error 404 page.
I'd like that the file .xhtml could be reached using the "longer" URL, too. I'm pretty sure that I'm currently unable to achieve that due to a configuration error.
This is my web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<web-app>
<display-name>SIGLO</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>DispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
This is the applicationContext.xml referenced in the previous file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd" >
<context:component-scan base-package="com.infoone.siglo" />
<!--
map all requests to /resources/** to the container default servlet
(ie, don't let Spring handle them)
-->
<bean id="defaultServletHttpRequestHandler" class="org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler" />
<bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >
<property name="urlMap" >
<map>
<entry key="/resources/**" value-ref="defaultServletHttpRequestHandler" />
</map>
</property>
</bean>
<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter" />
<mvc:annotation-driven />
<!-- JSF for representation layer. All JSF files under /WEB-INF/views directory -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver" >
<property name="cache" value="false" />
<property name="viewClass" value="org.springframework.faces.mvc.JsfView" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<bean name="icefacesResourceHandler" class="org.springframework.faces.webflow.JsfResourceRequestHandler" />
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="order" value="0" />
<property name="mappings">
<value>
/javax.faces.resource/**=icefacesResourceHandler
</value>
</property>
</bean>
</beans>
And, in the end, this is my faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
<locale-config></locale-config>
<resource-bundle>
<base-name>MessageResources</base-name>
<var>msg</var>
</resource-bundle>
</application>
</faces-config>
Let me point out that this configuration still does not allow me to open successfully the shorter URL. Indeed, I have to create a proper controller or, better, a proper #RequestMapping inside a #Controller:
#RequestMapping(value = "<filename>", method = RequestMethod.GET)
public String creaBlocco()
{
return "<filename>";
}
#RequestMapping(value = "<filename>", method = RequestMethod.POST)
public String creaBlocco([.. parameters ..]) {
[.. stuff ..]
return "<filename>";
}
Yes, the value of the #RequestMapping is "<filename>", without the .xhtml extension. I already made sure, by trial and error, that such mapping is necessary for the GET to be successful. On the other hand, I realize that such configuration is really fragile. What should I change in my config files, in order to make <filename>.xhtml reachable using also the longer URL?
Thanks in advance for your attention.
After some research, I came up with the conclusion that I wasn't using those technologies in the way they're meant to be used. If you're facing my same problem, within the same context, you are probably making my same error, therefore you have to slightly modify your application architecture to solve it. Indeed, it seems that using JSF/ICEFaces and Spring MVC in conjunction with Spring WebFlow is the most comfortable and straightforward approach.
I'll try to explain the rationale.
Your site/user home page is filled up with links to the use cases (or, better, flows) that can be activated with his/her privileges. Those links look like http://<page-url>?<flow-id>. A flow in Spring WebFlow is defined as a graph of states, within an xml file. The transitions between states are labeled by strings, named actions, or conditions. Some states are view-state s, meaning that there's something to show to the user when such a state is reached. Therefore, for each view-state named <state-id>, there shall be an .xhtml file named <state-id>.xhtml.
The buttons provided by JSF and ICEFaces will always be rendered as <input type="submit" [..]> and the action of the containing form will always point to the same URL as the containing page (i.e. http://<page-url>?<flow-id>). That's a fact.
The difference is that, in this case, such URL is not backed by a real file (like in my question) but, if the app is properly configured, a flow-handler will answer and manage all the states and the transitions defined in the xml file, choosing the proper view to show.
Beside that, the buttons provided by JSF and ICEFaces have an action attribute. As you can imagine, they correspond to the actions defined in the flow definition file: therefore, a click on a button with a certain value of the action attribute will trigger the transition from the current state labeled exactly with that string.
Speaking more concretely, if you click on the button, the browser sends a POST request to http://<page-url>?<flow-id> whose body contains all the necessary parameters. The flow handler receives that POST request and computes the next state, possibly choosing which view has to be shown to the user.
If you're still reading this answer, I guess you need a concrete example to refer to. I'll provide you with the one I used to learn all the things I wrote here: http://wiki.icesoft.org/display/ICE/Spring+Web+Flow+2.3.1 It's an awesome starting point, because it's easy but exhaustive.
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.
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">
</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.
Spring has a project for its integration with Flex,BlazeDS and Java.
This might help you. Spring n Flex integration