DWR 1.1 - New and Noteworthy
DWR 1.1 is a significant update to version 1.0. The themes of this release are stability and solving the simple problems that we didn't solve in version 1.0. You can download it now.
Better DHTML Manipulation
DWR 1.0 could manipulate most html page elements including select lists, ul and ol lists, tables, form fields and so on. DWR 1.1 adds the following options:
- addRows() will allow you to specify an options object that contains rowCreator or cellCreator functions for creating zebra tables, filtering rows or creating merged cells.
- setValue() and getValue() will now manipulate grouped radio buttons and select items in a <select> list. They will also handle input text as well as HTML for manipulating divs and spans.
- getValues() will will create objects from forms - pass it a form and it will generate an object containing the form fields and values
- useLoadingMessage() will allow you to specify the loading message.
Integration with other projects
DWR 1.0 featured integration with Spring, and many scripting languages through BSF, BeanShell was the most commonly used. From DWR 1.1 we also have some experimental integration with:
- Struts: Thanks to Ariel O. Falduto
- JSF: Thanks to Pierpaolo Follia
- PageFlow (BeeHive or Weblogic): Thanks to Kevin Conaway
Bram Smeets has enhanced the integration with the Spring Framework, and also done lots of excellent work improving the test suites.
Dennis Muhlestein has updated the scripting support to be able to read and reload scripts from the filesystem.
DWR is also becoming a part of many other frameworks including WebWork 2.2 and Rife 1.4.
Transparently convert more data between Java and Javascript
In DWR 1.0 we could convert native types, Strings, Dates, Arrays, JavaBeans (including those from Hibernate), Collections (Lists, Sets, Iterators, Maps) and DOM Objects (DOM, XOM, JDOM, DOM4J). From 1.1 we can also convert:
- Enums. JDK5 users can convert between Java Enums and their string forms in Javascript.
- Objects. If your objects don't have getters and setters, we can still convert them. The object converter has 'include' and 'exclude' parameters for added security - they restrict which members are converted. It also has a 'force' parameter to allow DWR to read from private fields.
- Exceptions. If you have data in an exception that you wish to travel into Javascript you only have to add that exception to your 'allow' section. The 'exception' object will be passed as the second parameter to your JavaScript error handler.
In addition we can now select which properties of a JavaBean are converted using 'include' and 'exclude' parameters. So if you have properties that you wish to restrict to the server you can do just that.
More Remoting Options
At 1.0 you could batch calls together, and hook into the calling process to pop-up loading messages along with other options. With 1.1 you have the following new features:
- Synchronous calling, either globally using
DWREngine.setAsynch(false), or locally using meta-data{ async:false }. See the synchronous calling documentation for more. - Much improved error handing and call timeouts.
- The ability to set almost all options at any level; globally, at an individual call level, or as part of a batch of calls.
Other Enhancements
ExecutionContext has been deprecated. The replacement is WebContext, which is similar but has a factory. You use it like this:
WebContextFactory.get().getSession();
DWR is now being used in orders of magnitude more projects including big projects like Jira and Confluence, so many bugs have been found and fixed.
It has Maven2 build files thanks to Julien Dubois.
We've done some internal refactoring so DWR now has a small replaceable IoC container and a more pluggable architecture. It's planned to continue this work with the next release of DWR
It is envisaged that the next release of DWR will change the Converter interface slightly. If you are writing a custom converter then it's a good idea to inherit from BaseV10Converter so your code can be more easily forwards compatible.
DWR now has support for being configured in places where the pathinfo is null.
What's Next?
DWR 1.1 was slowed down considerably by a nasty Safari bug, so DWR 2.0 (or whatever we call it) is well underway. It has a far broader scope; the major new features are accessibility enhancements, and what now appears to be called 'Comet'.