YOUR FEEDBACK
James Nelson wrote: Thanks for the posting, which we are hoping will solve our software issue with t...


2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Developing Rich Internet Applications Using Swing
A solution based on OpenSwing & Spring frameworks

Configuring an RIA with OpenSwing and Spring
When creating an RIA with an OpenSwing-based GUI, it's possible to use a classic DispatcherServlet servlet provided with Spring as the unique access point for all HTTP requests; these requests come from the "ClientUtils.getData()" utility method provided by OpenSwing that can be used in a client-side application to generate requests to the server-side application: all data retrieval classes located in the client-side application will use this utility method to remotely contact the server-side via the HTTP protocol.

In any J2EE Web application there must be a defined "WEB-INF/web.xml" file; with Spring this is the first file to configure too. When combining OpenSwing with Spring, a typical web.xml content is like the one described in Listing 1.

As shown in there, a DispatcherServlet servlet class is defined; moreover, other XML files must be defined: they are the other classical files required by Spring: applicationContext.xml and dataAccessContext-....xml

When defining the DispatcherServlet servlet, Spring requires another XML file be created: "xxx-servlet.xml" in which "xxx" is the name of the servlet defined in the web.xml (in our example: "controller"); Listing 2 shows the "controller-servlet.xml" file.

OpenSwing provides two main classes that must be defined in this XML file:
OpenSwingHandlerMapping - This job of this class is to get all the requests coming from the DispatcherServlet: these HTTP requests always contain a serializable object of the org.openswing.swing.message.send.java.Command type that contains a server-side bean name to invoke; this bean is a controller type object recognized by the Spring framework; all controller type beans in a "controller-servlet.xml" file must be defined as having as an "id" the "methodName" values stored in the command object and defined in the client-side layer.

At this point the Spring framework is the only actor: it's possible to define a facade, dao objects, transactions, and any other Spring component. Consequently, it's possible to include any technology that Spring allows to connect: ORM layers (such as Hibernate or iBatis or TopLink or JPA), EJB, etc.

The only constraint to respect is that the value to return to the client-side must be an object that extends org.openswing.swing.message.response.java.Response. If the client request is generated by a grid control or a lookup then the return value must be a VOListResponse; if the client request is generated by a form then the return value must be a VOResponse type as with any other application based on OpenSwing and not on Spring (independent of the number of tiers, two or three tiers).
OpenSwingViewResolver - This class returns a Response type object to the client side; this object has been generated in the server-side application and is given back through HTTP by serializing the object.

So OpenSwingViewResolver doesn't render a Web page. It serializes objects for the client-side application.

It's possible to include any kind of Interceptor object in a Spring configuration as in any application based on Spring. The OpenSwingHandlerMapping class provided by OpenSwing always extracts the command serialized object from the request and stores it as the request's attribute named OpenSwingHandlerMapping. COMMAND_ATTRIBUTE_NAME. In this way the command object is available to all interceptor objects added to the application.

Optionally OpenSwing provides an interceptor class named SessionCheckInterceptor that could be included in "controller-servlet.xml" file: this interceptor checks each HTTP request coming from the client side; SessionCheckInterceptor dispatches requests only if the command object contains a session identifier previously stored in the servlet context (when the client was authenticated); if a command object doesn't contain a session identifier or it contains a session identifier not stored in the servlet context then the request is rejected.

The choice of storing session identifiers in the servlet context instead of in the session context bound to the client derives from the nature of three-tier client/server applications based on the Swing front-end: these applications may be started without a browser (for example, by directly using Java Web Start), so that the traditional means of client session identification (cookies or URL rewriting) can't be applied outside the browser. Consequently, session info bindable to a client must be stored in the servlet context and fetched starting from a client session identifier that must be sent from client to server in each command object.

SessionCheckInterceptor class extracts the client session identifier from the request (through the Command.getSessionId method) and checks in the ServletContext if this identifier is stored. Session identifiers are stored in a HashSet whose attribute name is OpenSwingHandlerMapping. USERS_AUTHENTICATED; if the identifier is stored then the interceptor returns true, otherwise it returns false and gives an org.openswing.swing.message.response. java.ErrorResponse object back to the client.

Resources
• JMatter - http://jmatter.org/
• JGoodies - www.jgoodies.com/
• JDNC - Java Desktop Network Components: https://jdnc.dev.java.net/
• JSR 296 - Swing Application Framework: http://jcp.org/en/jsr/detail?id=296
• JavaDesktop: http://community.java.net/javadesktop/
• OpenSwing Framework: http://oswing.sourceforge.net
• Spring Application Framework: www.springframework.org
• Hibernate Framework: www.hibernate.org/
• iBatis: http://ibatis.apache.org

About Mauro Carniel
Mauro Carniel is an architect at Tecnoinformatica Group. He has more than 7 years of enterprise software development experience utilizing J2EE-based technologies, including JSP, JSF, Swing, EJB. He started focusing more on GUI-based client/server Java applications since 1998. He has a MSc in Information Technology from University of Udine, Italy.

YOUR FEEDBACK
James Nelson wrote: Thanks for the posting, which we are hoping will solve our software issue with two Turkish clients. This may be four years out of date, but please correct the code example, which has many nonsensical errors (two identical operations on anotherUserVisibleString, use of String tag without later reuse, introduction of variables s1 and sq without any context, misnaming of function to have "...twoEqualsStrings"...!) Locale turkishLocale = new Locale("tr","",""); String tag = anotherUserVisibleString.toUppercase(turkishLocale)); String s2 = anotherUserVisibleString.toUppercase(turkishLocale)); If(s1.equals(s2)){ doSomethingFunWithTwoEqualsStrings(); } However, even better would be: If(sq.equalsIgnoreCase(s2)){ doSomethingFunWithTwoEqualsStrings(); }
Gorkem Ercan wrote: I have been using java for more than 5 years in Turkish language environments. What you had described is a known issue java developers come across from time to time. From a technical perspective this is an interesting issue, but I do not think this issue has anything to do with "java being held back" in Turkey. If you wish to see the real reasons behind why java is held back in Turkey, compare the number of events by java big players, such as IBM, Sun, BEA to promote java with Microsoft' s .NET events.
LATEST JAVA STORIES & POSTS
Three-letter acronyms (TLAs) are hardly new in Information Technology: EAI, ESB, SOA, BPM, BAM, ETL, MDM; the list goes on and on. This article is about yet another three-letter acronym, EDA, which stands for Event-Driven Architecture. EDA is not a brand new technology, but rathe...
Furthering its dedication to providing Java developers productivity with choice, Oracle announced the Oracle Enterprise Pack for Eclipse, a new component of Oracle Fusion Middleware. This release marks the first free Eclipse 3.4 environment to support Oracle WebLogic Server 10g R...
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted...
Red Hat CTO Brian Stevens, Citrix CTO Simon Crosby, Egenera CTO Pete Manca, Allen Stewart, Group Manager, Windows Virtualization at Microsoft, and Brian Duckering, Sr. Director of Products and Alliances at Symantec were the top industry executives who joined Jeremy Geelan in the ...
Government intervention and direction has long been critical to the development of the computer industry. The Internet, after all, was derived from the ARPANET, developed in the early 1970s from a U.S. government-sponsored research project by the Advanced Research Projects Agency...
Commercial systems are developed with a huge range of performance requirements and we are concerned in this article with the small number of systems where absolute maximum performance is demanded either in terms of execution speed or available memory. We'll discuss the role of be...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

SPONSORED BY INFRAGISTICS
There are many forces that influence technological evolution. After a decade of building enterprise ...
2008 is going to be an important year for Rich Internet Applications. Most organizations are deliver...
The OpenAjax Alliance is developing an Ajax industry wishlist for future browsers, using a dedicated...
In every field of design one of the first things students do is learn from the work of others. They ...
Infragistics announced the availability of two Community Technology Preview (CTP) User Interface (UI...
The YUI development team has released version 2.5.2; you can download the new release from SourceFor...
ADS BY GOOGLE
BREAKING JAVA NEWS

SpringSource, a leading provider of infrastructure software and the company behind ...