• Shortcuts : 'n' next unread feed - 'p' previous unread feed • Styles : 1 2
Arrow New window 
aA :  -   + pdf Infos Unsubscribe

» Publishers, Monetize your RSS feeds with FeedShow:  More infos  (Show/Hide Ads)


Date: Wednesday, 07 Oct 2009 00:40
Page Page: Updated by John Lewis to revision 60 on Oct 06, 2009 19:40. Created by Dmitriy Kopylenko on Apr 14, 2004 08:35

Spring Portlet MVC

The Spring Portlet MVC framework provides a complete MVC layer for the JSR-168 Portlet API in the same way that Spring Web MVC does for the Servlet API. Wherever possible the APIs and capabilities are the same between the two frameworks. However, unlike most other portlet MVC frameworks, the unique workflow of the JSR-168 API is completely preserved, including the separation of the ActionRequest and the RenderRequest.

Downloads

Spring Portlet MVC has been part of the core Spring Framework since the 2.0 release.

Using Spring 2.0, the spring-portlet.jar file from the dist/extmodules directory needs to be included in your webapp libraries along with either dist/spring.jar or a number of libraries from dist/modules. Using Spring 2.5, the modules have been reorganized and the library has been renamed spring-webmvc-portlet.jar and also requires spring-webmvc.jar.

Documentation

The framework is fully documented as part of the Spring Framework Reference Manual – see "Chapter 16. Portlet MVC Framework". Full Javadocs are also included along with the Spring Framework API. Make sure that you are familiar with Spring Web MVC and the JSR 168 Specification before working with Spring Portlet MVC.

There are training slides available from the Spring Portlet MVC Seminar delivered at the Jasig 2009 Conference, as well as some slides on Securing Portlets with Spring Security from the same conference.

Samples

There is a small sample webapp for use with the current framework. It demonstrates a lot of the uniqueness of the Spring Portlet MVC framework and provides a good template for starting a new Spring Portlet project. The sample source code is available for download here. Be sure to review the included readme.txt file for information on installing the webapp into your environment.

There is also now a small sample application included with the Spring Framework distribution itself. See the samples/petportal directory in the distribution for more information.

Questions

If you have questions about using Spring Portlet MVC, please post them in the Spring Framework Support Forums, specifically in the "Web" forum.

There is also a Frequently Asked Questions area available here for Spring Portlet MVC – please review it before posting your questions.

Bugs & Enhancements

Please enter any bugs or enhancement requests into the Spring JIRA Issue Tracker. Use the Spring Framework (SPR) project and the "SpringWEB" component for your issues. Please be sure to mention that this is a Portlet issue.

Feedback

Please send any other feedback on Spring Portlet MVC or on this site directly to me: jlewis -|AT|- unicon -|DOT|- net

Thanks for trying out the Spring Portlet MVC Framework!

Recent News

Since I just answered this questions in the forums, I thought I would post the same information here. I expect that there will be JSR 286 support in Spring Portlet MVC as part of Spring 3.0. As for a likely release date, you'll have to bug Juergen for that.

We had been hoping to do the development and testing using the Pluto 2.0 portlet container, since that is slated to be the reference implementation for the spec. However,...

Posted at 18 Apr @ 11:40 AM by John Lewis | 0 comments

I can't believe it's been well over a year since I updated this page. While there has been a lot of great work going on in the background using and evolving Spring Portlet MVC, there hasn't been much to post here for a while – I guess that speaks to how stable the framework has become. Thanks to everyone for all their great questions in the forums – I am tremendously pleased at how widely adopted this framework has become in the niche community of Java Portlet developers....

Posted at 18 Jan @ 5:42 PM by John Lewis | 0 comments

The first complete draft of the chapter for Spring Framework Reference Manual is now available. It will be included with the RC1 release. Please send any feedback you have about the draft so we can continue to improve it before the final release of Spring 2.0.

Posted at 10 May @ 7:33 PM by John Lewis | 0 comments
.diffadded{background: #ddffdd;padding:1px 1px 1px 4px;border-left: 4px solid darkgreen;} .diffdeleted{color:#999;background: #ffdddd;padding: 1px 1px 1px 4px;border-left: 4px solid darkred;} .diffnochange{padding:1px 1px 1px 4px;border-left: 4px solid #d3d3d3;} .differror{background:brown;} .diff{font-family:lucida console, courier new, fixed-width;font-size: 12px;line-height: 14px;} .diffaddedchars{background-color:#99ff99;font-weight:bolder;} .diffremovedchars{background-color:#ff9999;text-decoration: line-through;font-weight:bolder;} .diffnav{display:none;}
 {section}
 {column:width=70%}
  
 h1. Spring Portlet MVC
  
 The Spring Portlet MVC framework provides a complete MVC layer for the JSR-168 Portlet API in the same way that Spring Web MVC does for the Servlet API. Wherever possible the APIs and capabilities are the same between the two frameworks. However, unlike most other portlet MVC frameworks, the unique workflow of the JSR-168 API is completely preserved, including the separation of the ActionRequest and the RenderRequest.
  
 h2. Downloads
  
 Spring Portlet MVC has been part of the core [Spring Framework|http://www.springframework.org/download] since the 2.0 release.
  
 Using Spring 2.0, the {{spring-portlet.jar}} file from the {{dist/extmodules}} directory needs to be included in your webapp libraries along with either {{dist/spring.jar}} or a number of libraries from {{dist/modules}}. Using Spring 2.5, the modules have been reorganized and the library has been renamed {{spring-webmvc-portlet.jar}} and also requires {{spring-webmvc.jar}}.
  
 h2. Documentation
  
  The framework is fully documented as part of the [Spring Framework Reference Manual|http://www.springframework.org/documentation] -- see "Chapter 16. Portlet MVC Framework". Full Javadocs are also included along with the Spring Framework API. Make sure that you are familiar with Spring Web MVC and the JSR-168 Specification before working with Spring Portlet MVC.
  The framework is fully documented as part of the [Spring Framework Reference Manual|http://www.springframework.org/documentation] -- see "Chapter 16. Portlet MVC Framework". Full Javadocs are also included along with the Spring Framework API. Make sure that you are familiar with Spring Web MVC and the JSR 168 Specification before working with Spring Portlet MVC.
  
 There are training slides available from the [Spring Portlet MVC Seminar|http://www.slideshare.net/johnalewis/sprint-portlet-mvc-seminar] delivered at the Jasig 2009 Conference, as well as some slides on [Securing Portlets with Spring Security|http://www.slideshare.net/johnalewis/securing-portlets-with-spring-security] from the same conference.
  
 h2. Samples
  
 There is a small sample webapp for use with the current framework. It demonstrates a lot of the uniqueness of the Spring Portlet MVC framework and provides a good template for starting a new Spring Portlet project. The sample source code is available for [download here|^spring-portlet-sample.zip]. Be sure to review the included {{readme.txt}} file for information on installing the webapp into your environment.
  
 There is also now a small sample application included with the Spring Framework distribution itself. See the {{samples/petportal}} directory in the distribution for more information.
  
 h2. Questions
  
 If you have questions about using Spring Portlet MVC, please post them in the [Spring Framework Support Forums|http://forum.springframework.org/], specifically in the ["Web"|http://forum.springframework.org/forumdisplay.php?f=25] forum.
  
 There is also a [Frequently Asked Questions] area available here for Spring Portlet MVC -- please review it before posting your questions.
  
 h2. Bugs & Enhancements
  
 Please enter any bugs or enhancement requests into the [Spring JIRA Issue Tracker|http://opensource.atlassian.com/projects/spring/]. Use the [Spring Framework (SPR)|http://jira.springframework.org/browse/SPR] project and the "SpringWEB" component for your issues. Please be sure to mention that this is a Portlet issue.
  
 h2. Feedback
  
 Please send any other feedback on Spring Portlet MVC or on this site directly to me: {color:blue}jlewis \-\|AT\|\- unicon \-\|DOT\|\- net{color}
  
 Thanks for trying out the Spring Portlet MVC Framework!
  
 {column}
 {column:width=30%}
  
 h1. Recent News
  
 {blog-posts:3|content=excerpts}
  
 {column}
 {section}
Author: "John Lewis"
Send by mail Print  Save  Delicious 
Date: Saturday, 19 Sep 2009 06:47
Page Page: Updated by Iwein Fuld to revision 5 on Sep 19, 2009 01:47. Created by Iwein Fuld on Jul 10, 2009 06:40
Comment: Added more details on configuring the DeFTPCF

FTP adapters

The FTP adapters have been evicted from the main Spring Integration project before the 1.0.0.RELEASE. The main reasoning behind this was to avoid having to support something that we were not too sure we got right. In retrospect this has been a good decision, it has allowed some changes that would not have been possible had we committed to backwards compatibility.

Since spring of 2009 the FTP adapters have been stable and are in use in production in several projects.

Overview

The FTP adapters are for you if you need to read files from a remote FTP directory, or write files to a similar drop box. They're aimed to cover all the simple ftp scenarios and be extensible for more complex cases. For inbound ftp use cases there is the the FtpFileSource. For outbound scenarios the FtpSendingMessageConsumer.

Inbound: FtpFileSource

The FtpFileSource is composed of an FtpInboundSynchronizer and a FileReadingMessageSource. The latter is documented in Spring Integration itself. The FtpInboundSynchronizer will pull files from the remote ftp directory and write them to the local directory (renaming them once the transfer is complete). The FtpInboundSynchronizer needs an FTPClientPool to do it's job.

So first configure the FtpFileSource:

<integration:inbound-channel-adapter
	channel="file-channel" ref="ftpFileSource" />

<beans:bean id="ftpFileSource"
	class="org.springframework.integration.ftp.FtpFileSource">
	<beans:property name="clientPool" ref="ftpClientPool" />
	<beans:property name="localWorkingDirectory"
	value="file:${java.io.tmpdir}/FtpConfigIntegrationTests" />
	<beans:property name="taskScheduler" ref="taskScheduler" />
	<beans:property name="trigger">
		<beans:bean
			class="org.springframework.integration.scheduling.IntervalTrigger">
			<beans:constructor-arg value="1500" />
		</beans:bean>
	</beans:property>
</beans:bean>

The trigger property is optional, by default an interval of 10 seconds is used.

Next we set up the FTPClientPool:

<bean id="ftpClientPool"
        class="org.springframework.integration.ftp.QueuedFTPClientPool">
      <constructor-arg>
          <bean class="org.springframework.integration.ftp.DefaultFTPClientFactory">
              <property name="host" value="${ftp.host}"/>
              <property name="username" value="${ftp.username}"/>
              <property name="password" value="${ftp.password}"/>
              <property name="port" value="${ftp.port}"/>
              <property name="remoteWorkingDirectory" value="${ftp.remotedir}"/>
          </bean>
      </constructor-arg>
</bean>

The client factory can be customized in the pool, but for more exotic ftp setups you can also extend or replace the QueuedFTPClientPool.

Outbound: FtpSendingMessageConsumer

For outbound scenarios you need to setup an FtpSendingMessageConsumer as an endpoint. The pooling is identical to the inbound setup.

<integration:outbound-channel-adapter
	ref="consumer" channel="file-channel" />

<beans:bean id="consumer"
	class="org.springframework.integration.ftp.FtpSendingMessageConsumer">
	<beans:property name="ftpClientPool" ref="outboundPool" />
</beans:bean>
.diffadded{background: #ddffdd;padding:1px 1px 1px 4px;border-left: 4px solid darkgreen;} .diffdeleted{color:#999;background: #ffdddd;padding: 1px 1px 1px 4px;border-left: 4px solid darkred;} .diffnochange{padding:1px 1px 1px 4px;border-left: 4px solid #d3d3d3;} .differror{background:brown;} .diff{font-family:lucida console, courier new, fixed-width;font-size: 12px;line-height: 14px;} .diffaddedchars{background-color:#99ff99;font-weight:bolder;} .diffremovedchars{background-color:#ff9999;text-decoration: line-through;font-weight:bolder;} .diffnav{display:none;}
 h2. FTP adapters
 The FTP adapters have been evicted from the main Spring Integration project before the 1.0.0.RELEASE. The main reasoning behind this was to avoid having to support something that we were not too sure we got right. In retrospect this has been a good decision, it has allowed some changes that would not have been possible had we committed to backwards compatibility.
  
 Since spring of 2009 the FTP adapters have been stable and are in use in production in several projects.
  
 h2. Overview
 The FTP adapters are for you if you need to read files from a remote FTP directory, or write files to a similar drop box. They're aimed to cover all the simple ftp scenarios and be extensible for more complex cases. For inbound ftp use cases there is the the FtpFileSource. For outbound scenarios the FtpSendingMessageConsumer.
  
 h3. Inbound: FtpFileSource
 The FtpFileSource is composed of an FtpInboundSynchronizer and a FileReadingMessageSource. The latter is documented in Spring Integration itself. The FtpInboundSynchronizer will pull files from the remote ftp directory and write them to the local directory (renaming them once the transfer is complete). The FtpInboundSynchronizer needs an FTPClientPool to do it's job.
  
 So first configure the FtpFileSource:
 {code}
 <integration:inbound-channel-adapter
  channel="file-channel" ref="ftpFileSource" />
  
 <beans:bean id="ftpFileSource"
  class="org.springframework.integration.ftp.FtpFileSource">
  <beans:property name="clientPool" ref="ftpClientPool" />
  <beans:property name="localWorkingDirectory"
  value="file:${java.io.tmpdir}/FtpConfigIntegrationTests" />
  <beans:property name="taskScheduler" ref="taskScheduler" />
  <beans:property name="trigger">
  <beans:bean
  class="org.springframework.integration.scheduling.IntervalTrigger">
  <beans:constructor-arg value="1500" />
  </beans:bean>
  </beans:property>
 </beans:bean>
 {code}
 The trigger property is optional, by default an interval of 10 seconds is used.
  
 Next we set up the FTPClientPool:
 {code}
  <beans:bean id="ftpClientPool"
  class="org.springframework.integration.ftp.QueuedFTPClientPool">
  <beans:constructor-arg>
  <beans:bean class="org.springframework.integration.ftp.DefaultFTPClientFactory"/>
  </beans:constructor-arg>
 </beans:bean>
  <bean id="ftpClientPool"
  class="org.springframework.integration.ftp.QueuedFTPClientPool">
  <constructor-arg>
  <bean class="org.springframework.integration.ftp.DefaultFTPClientFactory">
  <property name="host" value="${ftp.host}"/>
  <property name="username" value="${ftp.username}"/>
  <property name="password" value="${ftp.password}"/>
  <property name="port" value="${ftp.port}"/>
  <property name="remoteWorkingDirectory" value="${ftp.remotedir}"/>
  </bean>
  </constructor-arg>
 </bean>
 {code}
  
 The client factory can be customized in the pool, but for more exotic ftp setups you can also extend or replace the QueuedFTPClientPool.
  
 h3. Outbound: FtpSendingMessageConsumer
 For outbound scenarios you need to setup an FtpSendingMessageConsumer as an endpoint. The pooling is identical to the inbound setup.
  
 {code}
 <integration:outbound-channel-adapter
  ref="consumer" channel="file-channel" />
  
 <beans:bean id="consumer"
  class="org.springframework.integration.ftp.FtpSendingMessageConsumer">
  <beans:property name="ftpClientPool" ref="outboundPool" />
 </beans:bean>
 {code}
Author: "Iwein Fuld"
Send by mail Print  Save  Delicious 
Date: Friday, 10 Jul 2009 10:33
Page Page: Created by Iwein Fuld on Jul 10, 2009 05:33

Extensions for Spring Integration

Introduction

The number of protocols in active use is astonishing. However, integrating an adapter for one of these protocols with Spring Integration using the appropriate library is usually quite trivial. For example a twitter adapter using Twitter4J shouldn't take more that 10 lines of code. For that reason SESIA will never be a large project. It will also be under constant flux.

Once a code base is mature enough to be considered a candidate for addition to the Spring Integration project, it can first be ironed out and exposed through SESIA for early adopters. Adapters that are not interesting for the majority of SI users, but are interesting for many SI users can be kept in SESIA to keep the main project light. If you choose to use SESIA adapters, you will either pick a build number use that jar trusting the developer hasn't gone off track, or you will take the code from the repository and add it to your own code base. Typically you'll have a handful of classes to copy, so it might be easy to maintain them yourself. All Spring Extensions are made available under the Apache license, so you're free to do pretty much everything you'll ever need to to the code.

I'll include all adapters here.

FTP adapters

The FTP adapters have been evicted from the main Spring Integration project before the 1.0.0.RELEASE. The main reasoning behind this was to avoid having to support something that we were not too sure we got right. In retrospect this has been a good decision, it has allowed some changes that would not have been possible had we committed to backwards compatibility.

Since spring of 2009 the FTP adapters have been stable and are in use in production in several projects.

Overview

The FTP adapters are for you if you need to read files from a remote FTP directory, or write files to a similar drop box. They're aimed to cover all the simple ftp scenarios and be extensible for more complex cases. For inbound ftp use cases there is the the FtpFileSource. For outbound scenarios the FtpSendingMessageConsumer.

Inbound: FtpFileSource

The FtpFileSource is composed of an FtpInboundSynchronizer and a FileReadingMessageSource. The latter is documented in Spring Integration itself. The FtpInboundSynchronizer will pull files from the remote ftp directory and write them to the local directory (renaming them once the transfer is complete). The FtpInboundSynchronizer needs an FTPClientPool to do it's job.

So first configure the FtpFileSource:

<integration:inbound-channel-adapter
	channel="file-channel" ref="ftpFileSource" />

<beans:bean id="ftpFileSource"
	class="org.springframework.integration.ftp.FtpFileSource">
	<beans:property name="clientPool" ref="ftpClientPool" />
	<beans:property name="localWorkingDirectory"
	value="file:${java.io.tmpdir}/FtpConfigIntegrationTests" />
	<beans:property name="taskScheduler" ref="taskScheduler" />
	<beans:property name="trigger">
		<beans:bean
			class="org.springframework.integration.scheduling.IntervalTrigger">
			<beans:constructor-arg value="1500" />
		</beans:bean>
	</beans:property>
</beans:bean>

The trigger property is optional, by default an interval of 10 seconds is used.

Next we set up the FTPClientPool:

<beans:bean id="ftpClientPool"
	class="org.springframework.integration.ftp.QueuedFTPClientPool">
	<beans:constructor-arg>
		<beans:bean class="org.springframework.integration.ftp.DefaultFTPClientFactory"/>
	</beans:constructor-arg>
</beans:bean>

The client factory can be customized in the pool, but for more exotic ftp setups you can also extend or replace the QueuedFTPClientPool.

Outbound: FtpSendingMessageConsumer

For outbound scenarios you need to setup an FtpSendingMessageConsumer as an endpoint. The pooling is identical to the inbound setup.

<integration:outbound-channel-adapter
	ref="consumer" channel="file-channel" />

<beans:bean id="consumer"
	class="org.springframework.integration.ftp.FtpSendingMessageConsumer">
	<beans:property name="ftpClientPool" ref="outboundPool" />
</beans:bean>

That's all folks

If something is missing you're very welcome to contribute. If you want to submit your own adapter project:

  1. sign over your soul
  2. create an issue
  3. attach your patch, zipped project

The more you help me, the more likely it is that your code will be included in the build

Author: "Iwein Fuld"
Send by mail Print  Save  Delicious 
Date: Friday, 10 Jul 2009 08:39
Page Page: Updated by Iwein Fuld to revision 6 on Jul 10, 2009 03:39. Created by Rob Harrop on Apr 10, 2005 08:59
Comment: added explanation of Spring Integration and SESIA doco's link

h1 Spring Integration

The Spring Integration project

Somewhat confusingly there is a project called Spring Integration, if you're looking for ways to integrate a third party product with Spring, look at the bottom section. The Spring Integration project aims at providing a framework for implementing Enterprise Integration Patterns as described by Gregor Hohpe and Bobby Woolf. The project contains a handful of adapters for the most common integration need. However, there are an extreme amount of integration protocols thinkable.

To avoid the core framework growing into an unwieldy blob the committers have chosen to put less mainstream adapters into a Spring Extensions project code named SESIA. The documentation for SESIA is maintained on this wiki.

Integrate with Spring

This section contains code snippets, hints and tips for integrating Spring with 3rd party products that are not explicitly covered as part of the core framework. For components that are included are part of the Spring distribution check out the reference manual for information on how they work with Spring.

3rd Party Product List

Articles

.diffadded{background: #ddffdd;padding:1px 1px 1px 4px;border-left: 4px solid darkgreen;} .diffdeleted{color:#999;background: #ffdddd;padding: 1px 1px 1px 4px;border-left: 4px solid darkred;} .diffnochange{padding:1px 1px 1px 4px;border-left: 4px solid #d3d3d3;} .differror{background:brown;} .diff{font-family:lucida console, courier new, fixed-width;font-size: 12px;line-height: 14px;} .diffaddedchars{background-color:#99ff99;font-weight:bolder;} .diffremovedchars{background-color:#ff9999;text-decoration: line-through;font-weight:bolder;} .diffnav{display:none;}
 h1. Integrate with Spring
  h1 Spring Integration
  
This space contents code snippets, hints and tips for integrating Spring with 3rd party products that are not explicitly covered as part of the core framework. For components that are included are part of the Spring distribution check out the reference manual for information on how they work with Spring.
  h2. The Spring Integration project
 Somewhat confusingly there is a project called [Spring Integration|http://www.springsource.org/spring-integration], if you're looking for ways to integrate a third party product with Spring, look at the bottom section. The Spring Integration project aims at providing a framework for implementing Enterprise Integration Patterns as described by Gregor Hohpe and Bobby Woolf. The project contains a handful of adapters for the most common integration need. However, there are an extreme amount of integration protocols thinkable.
  
h2. 3rd Party Product List
  To avoid the core framework growing into an unwieldy blob the committers have chosen to put less mainstream adapters into a Spring Extensions project code named [SESIA]. The documentation for SESIA is maintained on this wiki.
  
h2. Integrate with Spring
  
 This section contains code snippets, hints and tips for integrating Spring with 3rd party products that are not explicitly covered as part of the core framework. For components that are included are part of the Spring distribution check out the reference manual for information on how they work with Spring.
  
 h3. 3rd Party Product List
  
 * [OSCache]
 * [XMLC]
  
 h2. Articles
  h3. Articles
  
 * [Using JSP taglibs with FreeMarkerView]
Author: "Iwein Fuld"
Send by mail Print  Save  Delicious 
Date: Wednesday, 03 Jun 2009 12:31
Comment:

<a href="http://woxiva.com">hovipi</a> | [url=http://nizene.com]virica[/url] | [link=http://kuroxu.com]tyxuza[/link] | http://cazezu.com | hosaxu | [http://kezize.com zineku]

Comment Posted by: Anonymous at Jun 03, 2009 07:31
Added to Page:

Space Index

0-9 ... 0 A ... 1 B ... 0 C ... 1 D ... 0 E ... 0
F ... 2 G ... 0 H ... 1 I ... 1 J ... 2 K ... 0
L ... 0 M ... 0 N ... 0 O ... 0 P ... 0 Q ... 0
R ... 0 S ... 1 T ... 0 U ... 1 V ... 0 W ... 0
X ... 1 Y ... 0 Z ... 0 !@#$ ... 0    

0-9

A

Ajax and DWR
modified version of the Petclinic sample is here showing a DWR front end. The Clinic object is exported and made available to the local JavaScript functions from the index.html page. It's not complete, only some of the functionality is implemented, but it should give you eneough of a head ...

B

C

Checkboxes - Dealing with single checkboxes
macro solution to single checkboxes.  The default macros files that come with spring for Freemarker http://www.freemarker.org and Velocity http://jakarta.apache.org/velocity/ are very good at providing a base infrastructure for creating web documents. However they are a base and adding further macros ...

D

E

F

FOP - Using XSL-FO and Apache FOP with Spring
Intro FOP http://xml.apache.org/fop/index.html is an XSLT driven print formatter capable of rendering to different output types such as PDF or SVG. It's pretty simple to extend the Spring view classes to implement a FOP view and so enable dynamic ...
Forms - Multiple forms on the same page
you've ever tried to put multiple forms on the same web page and bind to their form bean (command) properties, then hook various controllers to them you will have rapidly run into a variety of issues. most especially if you are dealing with controllers (such as the SimpleFormController ...

G

H

Home
Cookbook is a collection of short Spring examples. Some highlight how to get started with standard Spring technologies, some show how to use Spring with other technologies where no standard integration code is included in the Spring codebase. Feel free to add ...

I

Index

J

JTA JOTM usage
author of this page is actually JorisPZ from Spring Forums original thread here http://forum.springframework.org/viewtopic.php?p=30741#30741 This cookbook describes how to setup global transactions using Spring's JtaTransactionManager, JOTM, a RDBMS and the ActiveMQ JMS provider ...
JTA - Jencks TranQL-Connector OracleXA
following is what I pieced together from certain sources of how Jencks could be configured for JTA using the OracleXA driver to connect to Oracle. <! ###### Transaction manager ###### >

K

L

M

N

O

P

Q

R

S

Spring Aware Axis Services
anyone developing web services with Axis, it can be tricky to get a large number of different web services to share a common application context or make use of the web application context if Axis is bundled inside of a WAR in servlet form. Often, developers ...

T

U

using a custom view to change view resolver behaviour
standard way to resolve views in a Spring web application is to turn each view resolution request into the name of a web page. But sometimes we don't necessarily want to do this. This example explores a situation I encountered where I wanted to use ...

V

W

X

XMLC integration
Effectively, a custom View implementation that uses XMLC could look as follows without any XMLCspecific base class shipped in Spring: public abstract class MyXmlcView extends AbstractView { protected void renderMergedOutputModel( Map model, HttpServletRequest request, HttpServletResponse ...

Y

Z

!@#$

Author: "--"
Send by mail Print  Save  Delicious 
Date: Monday, 01 Jun 2009 14:52
Comment:

Thanks for the great article.

It is working excellently when I have just one command class (You call it form bean) which has some boolean property.

But I'm facing the issue when I have command class with list of objects when each of them has some boolean property.

For instance, I'm trying something similar to:

<#list command.getSegmentations() as segmentation>
 <tr>
 <td><@external.formCheckbox "segmentation.selected", ""/></td>
 </#list>

But the problem is while binding to "segmentation".

Will be very grateful for any suggestions.

Best,

Taras

Comment Posted by: Anonymous at Jun 01, 2009 09:52
Added to Page:

A macro solution to single checkboxes. 

The default macros files that come with spring for Freemarker and Velocity are very good at providing a base infrastructure for creating web documents. However they are a base and adding further macros is often required to create anythingmore than a basic web site. One aspect of this is that the formCheckboxes macro is designed to work with a collection of values in order to create multiple checkboxes. This can be useful but many people want to create just one checkbox and map it directly to a boolean property of the command class. In addition there can be problems if you try and map to a boolean property and want that property to be one by default.

There has been much discussion in the forums about dealing with checkboxes and most specifically handling them considering that the default browser behaviour is to not return any request parameter for a checkbox unless it is ticked (true). The default formCheckbox macro does not appear to handle this either.

Note: I find this notion of refering to the bean backing the form as a Command to be a bit missleading. I prefer to call it a Form Bean (ala struts). To me this is much closer to it's function and easer to understand.

This cook book page attempts to provide information and code on doing the following: 

  1. Provide a macro for dealing with a single checkbox and matching boolean value.
  2. Handle both default values (true and false) for a checkbox.

Lets start by looking at my custom macro which I have coded in a file called macros.ftl:

[ftl] <#--
 * formCheckbox
 *
 * Show a single checkbox and also include a hidden marker field so that an un-checked
 * checkbox still presents a false value back to the form.
 *
 * For details on the _Hidden field usange. Refer to
 * http://www.springframework.org/docs/api/org/springframework/web/bind/WebDataBinder.html#setFieldMarkerPrefix(java.lang.String)
 *
 * @param path the name of the field to bind to
 * @param attributes any additional attributes for the element (such as class or CSS styles or size
-->
[#macro formCheckbox path attributes=""]
    [@spring.bind path /]
    <input type="hidden" name="_${spring.status.expression}" value="false" />
    <input type="checkbox" id="${spring.status.expression}" name="${spring.status.expression}"
        [#if spring.status.value]checked="checked"[/#if]
        ${attributes}
    [@spring.closeTag/]
[/#macro]

 

 

I'll work through it's design in order of appearance:

  • [ftl] - I use Freemarker templates and this tag indicates to freemarker that I am using square brackets [] around freemarker tags. I prefer this method because it helps me to clearly see freemarker markup in the templates and doesn't confuse editors. If you are using the default brackets <> or Velocity then you won't need this tag.
  • [#macro formCheckbox path attributes=""] - Because we are only dealing with a single checkbox we don't need to be passed a collection or delimiter HTML. So the only parameters we need are the path the bind to to get the data and and extra formatting tags.
  • [@spring.bind path /] - Slightly different. Freemarker ensures that each macro file has it's own namespace in the model. So in order to access anything contained in the spring.ftl file of default macros,  I have to prefix it with spring. Note that the path will be bound inside the spring namespace, even though we are calling from a different namespace.
  • <input type="hidden" name="*_$
    Unknown macro: {spring.status.expression}" value="false" />_* _- This is a new addition over the default macro. According to the documentation for the____[WebDataBinder|http}

    package myapp.spring.formbeans;

public class MyFormBean {
private boolean checkboxValue = true;
public boolean isCheckboxValue() {
return this.checkboxValue;
}
public void setCheckboxValue(boolean checkboxValue)

Unknown macro: { this.checkboxValue = checkboxValue;}}{code}

 

 

You can see how simple this now is. Nothing else is required. I.e. no extra data bindings or property editors.

How does this work ?

Basically on submission of the form, spring creates a new instance of your form bean and populates it with values from the form. If the checkbox has been ticked then the bean is populated with true. If the checkbox has not been ticked therefore not sending a parameter back in the request, then spring automatically looks at the '_' prefixed hidden field and grabs the value from that. Because we have hard coded this in the macro to be false, the form bean gets set to false, thus being correct.

I have deliberately coded the above form bean with a default of true for the property because in this example I wanted the check box to initially be on. When looking at this problem, I initially did this without the hidden form field providing a default. When the form was submitted, spring created a new form bean (default true) and then did nothing because there was no matching parameter in the request. The visible effect of not having the hidden field is that when you submit, spring executes the code with a true value and when you come back to your form, the check box is turned on again.

Show me the template !

[#ftl]
[#import "spring.ftl" as spring /]
[#import "macros.ftl" as lp /]

<html>
<head>
</head>

<body>
<h2>[@spring.message "mypage.title"/]</h2>
<form action="${webroot}/accounts/dosomething.form" method="POST">
<table>
      <tr>
          <td></td>
               <td>[@lp.formCheckbox "formBeanName.checkboxValue", "" /] [@spring.message "myapp.checkbox.fieldname"/]</td>
    </tr>
</table>
<input type="submit" value="[@spring.message "myapp.submit.buttontext"/]" />
</form></body></html>

 

 

There's not much to it because our macro is doing the hard work. Remember I am using square brackets around my freemarker directives. Anything else in ${} is a reference to a data item sitting in the freemarker model. Note the two import statements at the top. These import the two macros files we need. Firstly the spring.ftl which defines the bind macro and secondly our macros.ftl. Remember freemarker ensures that each macros library lives in it's own namespace in the freemarker model, so in this case our custom check box macro is in the lp name space.

Author: "--" Tags: "freemarker, checkbox, macro"
Send by mail Print  Save  Delicious 
Date: Tuesday, 26 May 2009 11:12
Comment:

This cook book could be a great source of ideas and inspiration, but all this spam is a pain.

It looks unprofessional and doesn't fit in with the image I and most people I know have of SpringSource. Clean this mess up by forcing people to register.

Comment Posted by: Anonymous at May 26, 2009 06:12
Added to Page:

Cookbook is a collection of short Spring examples. Some highlight how to get started with standard Spring technologies, some show how to use Spring with other technologies where no standard integration code is included in the Spring codebase.

Feel free to add new pages to this space. The list below will automatically update to keep a current index of available recipes.

Space Index

0-9 ... 0 A ... 1 B ... 0 C ... 1 D ... 0 E ... 0
F ... 2 G ... 0 H ... 1 I ... 1 J ... 2 K ... 0
L ... 0 M ... 0 N ... 0 O ... 0 P ... 0 Q ... 0
R ... 0 S ... 1 T ... 0 U ... 1 V ... 0 W ... 0
X ... 1 Y ... 0 Z ... 0 !@#$ ... 0    

0-9

A

Ajax and DWR
modified version of the Petclinic sample is here showing a DWR front end. The Clinic object is exported and made available to the local JavaScript functions from the index.html page. It's not complete, only some of the functionality is implemented, but it should give you eneough of a head ...

B

C

Checkboxes - Dealing with single checkboxes
macro solution to single checkboxes.  The default macros files that come with spring for Freemarker http://www.freemarker.org and Velocity http://jakarta.apache.org/velocity/ are very good at providing a base infrastructure for creating web documents. However they are a base and adding further macros ...

D

E

F

FOP - Using XSL-FO and Apache FOP with Spring
Intro FOP http://xml.apache.org/fop/index.html is an XSLT driven print formatter capable of rendering to different output types such as PDF or SVG. It's pretty simple to extend the Spring view classes to implement a FOP view and so enable dynamic ...
Forms - Multiple forms on the same page
you've ever tried to put multiple forms on the same web page and bind to their form bean (command) properties, then hook various controllers to them you will have rapidly run into a variety of issues. most especially if you are dealing with controllers (such as the SimpleFormController ...

G

H

Home
Cookbook is a collection of short Spring examples. Some highlight how to get started with standard Spring technologies, some show how to use Spring with other technologies where no standard integration code is included in the Spring codebase. Feel free to add ...

I

Index

J

JTA JOTM usage
author of this page is actually JorisPZ from Spring Forums original thread here http://forum.springframework.org/viewtopic.php?p=30741#30741 This cookbook describes how to setup global transactions using Spring's JtaTransactionManager, JOTM, a RDBMS and the ActiveMQ JMS provider ...
JTA - Jencks TranQL-Connector OracleXA
following is what I pieced together from certain sources of how Jencks could be configured for JTA using the OracleXA driver to connect to Oracle. <! ###### Transaction manager ###### >

K

L

M

N

O

P

Q

R

S

Spring Aware Axis Services
anyone developing web services with Axis, it can be tricky to get a large number of different web services to share a common application context or make use of the web application context if Axis is bundled inside of a WAR in servlet form. Often, developers ...

T

U

using a custom view to change view resolver behaviour
standard way to resolve views in a Spring web application is to turn each view resolution request into the name of a web page. But sometimes we don't necessarily want to do this. This example explores a situation I encountered where I wanted to use ...

V

W

X

XMLC integration
Effectively, a custom View implementation that uses XMLC could look as follows without any XMLCspecific base class shipped in Spring: public abstract class MyXmlcView extends AbstractView { protected void renderMergedOutputModel( Map model, HttpServletRequest request, HttpServletResponse ...

Y

Z

!@#$

Author: "--"
Send by mail Print  Save  Delicious 
Date: Friday, 08 May 2009 16:19
Comment:

Below is my configuration using ibm mq that is throwing the exception as given after the config....ppl plz throw some light... i m doing this to test whether i can put a commit count in place when using a platform transaction manager that is used when placing a transaction manager within the dmlc container as given below...com.MessageListener is nothing but DMLC with the abstractpollingcontainer receiveAndExecute method overriden where i place the condition to do commit....

   <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:txn.properties" />
    </bean>

    <!- For JMS based listener ->
    <bean id="msgListener" class="com.MyMessageListener"></bean>

    <!- JMS Container listening on source queue org.springframework.jms.listener.DefaultMessageListenerContainer->
    <bean id="jmsContainer" class="com.MyContainer" lazy-init="false">
        <property name="connectionFactory" ref="sourceQCFCredential" />
        <property name="destination" ref="sourceQueue" />
        <property name="messageListener" ref="msgListener" />
        <property name="concurrentConsumers" value="1" />
        <property name="sessionAcknowledgeModeName"
            value="CLIENT_ACKNOWLEDGE" />
        <!- <property name="sessionTransacted" value="true"/> ->
        <property name="transactionManager" ref="transactionManager" />
    </bean>

    <!- MQ Connection factory setup ->
    <bean id="sourceQCF"
        class="com.ibm.mq.jms.MQXAQueueConnectionFactory">
        <property name="transportType" value="1" />
        <property name="queueManager" value="$

Unknown macro: {jms.mq.queuemanager}

" />
        <property name="hostName" value="$

Unknown macro: {jms.mq.hostname}
" />
        <property name="port" value="$
Unknown macro: {jms.mq.port}
" />
        <property name="channel" value="$
Unknown macro: {jms.mq.channel}
" />
    </bean>

    <!- MQ queue setup ->
    <bean id="sourceQueue" class="com.ibm.mq.jms.MQQueue">
        <property name="baseQueueManagerName"
            value="$

" />
        <property name="baseQueueName" value="$
Unknown macro: {jms.mq.queuename}
" />
    </bean>

    <!- User credential for source queue connection  ->
    <bean id="sourceQCFCredential"
        class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
        <property name="targetConnectionFactory" ref="connectionFactory" />
        <property name="username" value="$

Unknown macro: {jms.mq.username}
" />
        <property name="password" value="$
Unknown macro: {jms.mq.password}
" />
    </bean>
    
    <!- JmsTemplate for queue  ->
    <bean id="qjmsTemplate"
        class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="sourceQCFCredential" />
        <property name="sessionAcknowledgeModeName"
            value="CLIENT_ACKNOWLEDGE" />
        <property name="sessionTransacted" value="true" />
        <property name="defaultDestination" ref="sourceQueue" />
    </bean>

    <bean id="transactionManager"
        class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="userTransaction">
            <ref local="jotm" />
        </property>
    </bean>

    <bean id="connectionFactory"
        class="org.jencks.pool.PooledSpringXAConnectionFactory">
        <property name="connectionFactory" ref="sourceQCF"/>
        <property name="transactionManager" ref="jotm" />
    </bean>

    <bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean" />

Exception in thread "main" org.springframework.jms.UncategorizedJmsException: Uncategorized exception occured during JMS processing; nested exception is javax.jms.JMSException: MQJMS1068: failed to obtain XAResource; nested exception is javax.transaction.xa.XAException: client connection not XA enabled
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:292)
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474)
    at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:539)
    at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:646)
    at org.springframework.jms.core.JmsTemplate.convertAndSend(JmsTemplate.java:635)
    at com.TransactionDriver.main(TransactionDriver.java:17)
Caused by: javax.jms.JMSException: MQJMS1068: failed to obtain XAResource
    at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:567)
    at com.ibm.mq.jms.MQXAQueueConnection.createXAQueueSession(MQXAQueueConnection.java:108)
    at com.ibm.mq.jms.MQXAQueueConnection.createXASession(MQXAQueueConnection.java:143)
    at org.jencks.pool.XASessionPool.createSession(XASessionPool.java:108)
    at org.jencks.pool.XASessionPool.makeObject(XASessionPool.java:72)
    at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:974)
    at org.jencks.pool.XASessionPool.borrowSession(XASessionPool.java:51)
    at org.jencks.pool.PooledSpringXAConnection.createXASession(PooledSpringXAConnection.java:248)
    at org.jencks.pool.PooledSpringXAConnection.createSession(PooledSpringXAConnection.java:277)
    at org.springframework.jms.support.JmsAccessor.createSession(JmsAccessor.java:196)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:462)
    ... 4 more

Comment Posted by: Anonymous at May 08, 2009 11:19
Added to Page:
the author of this page is actually JorisPZ from Spring Forums - original thread here

This cookbook describes how to setup global transactions using Spring's JtaTransactionManager, JOTM, a RDBMS and the ActiveMQ JMS provider. Since all configuration takes place in Spring context files (so no need for JNDI), and JOTM is a standalone global transaction manager, this setup does not require a full blown J2EE container. The setup described below has been tested using Tomcat and MySQL.

The solution described below is a result of a few hours of trial-and-error, so better solutions might very well exist. If so, please update this page!

First, set up a JOTM instance, which is easily achieved using the Spring JotmFactoryBean:

<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean"/>

The resulting bean should then be injected into the UserTransaction property of a JtaTransactionManager:

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
   <property name="userTransaction"><ref local="jotm"/></property>
</bean>

Now, we will set up two transactional resources, a RDBMS and a JMS provider. For this example we will use ActiveMQ.

We will use Enhydra's XAPool for providing XA connection pooling:

<bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
   <property name="dataSource">
      <bean class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
         <property name="transactionManager" ref="jotm" />
         <property name="driverName" value="$\{jdbc.driverClassName}" />
         <property name="url" value="$\{jdbc.url}" />
      </bean>
   </property>
   <property name="user" value="$\{jdbc.username}"/>
   <property name="password" value="$\{jdbc.password}"/>
</bean>

Note that a reference to the JOTM bean is injected into the transactionManager property of the StandardXADataSource.

Next, we will setup a JMS connection factory. ActiveMQ comes with a connection factory (org.activemq.ActiveMQXAConnectionFactory) which provides XA capabale JMS connections. However, these connections do not automatically take part in Spring managed JTA transactions.

The solution to this problem is to wrap the ActiveMQXAConnectionFactory with a PooledSpringXAConnectionFactory. The code for the latter was kindly provided by Andy DePue, and can be downloaded here.

<bean id="connectionFactory" class="com.marathon.jms.PooledSpringXAConnectionFactory">
   <property name="connectionFactory">
      <bean class="org.activemq.ActiveMQXAConnectionFactory">
         <property name="brokerURL" value="$\{brokerURL}" />
      </bean>
   </property>
   <property name="transactionManager" ref="jotm"/>
</bean>

Note that again, a reference to the JOTM bean is injected into the transactionManager property of the PooledSpringXAConnectionFactory. (BTW, if you need to set a Client ID on the JMS connections, you should do this through the clientID property of the ActiveMQXAConnectionFactory.)

As an example of defining a JMS destination purely in Spring, the following fragment sets up an ActiveMQTopic:

<bean id="destination" class="org.activemq.message.ActiveMQTopic" autowire="constructor">
   <constructor-arg>
      <value>myTopicName</value>
   </constructor-arg>
</bean>

Finally, to use the convenient Spring JmsTemplate class, we set it up as follows:

<bean id="myJmsTemplate" class=" org.springframework.jms.core.JmsTemplate">
   <property name="connectionFactory" ref="connectionFactory" />
</bean>

And that's it! Messages send or received through the JmsTemplate will now automatically take part in Spring managed JTA transactions.

Author: "--"
Send by mail Print  Save  Delicious 
» You can also retrieve older items : Read
» © All content and copyrights belong to their respective authors.«
» © FeedShow - Online RSS Feeds Reader