There have been a large number of general bug fixes made in Tapestry 4.1, as well as a lot of work in the area of "ajax" support in the core framework.
This guide will attempt to highlight some of the key changes that might affect people trying to upgrade from 4.0.X to the current 4.1.X version.
Many of the previously marked as deprecated for removal in Tapestry 4.1 API sections have now been removed. There is also some new functionality that many may not be aware of.
getRequestContext()
method has now been removed from
IRequestCycle. The proper way to get the equivalent
functionality is to have the HttpServletRequest object injected in to your page/component:
@InjectObject("service:tapestry.globals.HttpServletRequest") public abstract HttpServletRequest getRequest();
This should greatly cut down on a lot of pain of having to look up service ids in the hivedoc documentation. The injection of the HttpServletRequest outlined in the first point could be re-written as:
public abstract HttpServletRequest getRequest();
IRequestCycle.getListenerParameters()
.
One of the largest changes to come about has been the general strategy in dealing with javascript inclusions as well as bundling of the Dojo javascript toolkit directly in Tapestry. More about these packaging changes can be found in the javascript guide.
<form>
element by attaching a form.events
property
to the object. This is no longer the case. Tapestry doesn't modify any of the DOM elements or client side events on your page anymore. While
this change has resulted in much easier form handling abilities on the client side it has come with a price of breaking anyone previously
relying on this functionality.
<script> <input-symbol key="component" required="yes"/> <let key="formObject"> document.${component.form.name} </let> <let key="componentObject"> ${formObject}.${component.name} </let> <body> function setFocus() { var inputField = ${componentObject}; if (inputField.type != "hidden") { if (inputField.disabled != true) { inputField.focus(); } } else { window.alert('InputFocus.script cannot set focus on a hidden field'); } } </body> <initialization> setFocus(); </initialization> </script>
<html> <head><title>Sample</title></head> <body> <script type="text/javascript"> function setFocus() { var inputField = document.form.field; if (inputField.type != "hidden") { if (inputField.disabled != true) { inputField.focus(); } } else { window.alert('InputFocus.script cannot set focus on a hidden field'); } } </script> <p>Hello! This is my sample page.</p> <script type="text/javascript"> setFocus(); </script> </body> </html>
New Tapestry 4.1.X generated output:
<html> <head><title>Sample</title></head> <body> <script type="text/javascript"> function setFocus() { var inputField = document.form.field; if (inputField.type != "hidden") { if (inputField.disabled != true) { inputField.focus(); } } else { window.alert('InputFocus.script cannot set focus on a hidden field'); } } </script> <p>Hello! This is my sample page.</p> <script type="text/javascript"> dojo.addOnLoad(function(){ setFocus(); }); </script> </body> </html>
id="foo"
attributes to support the new method as well.
The logic of what value is actually used for the id attribute varies widely depending on many different things (such as finding informal id parameters) , but all of changes are things to make it more intuitive for you / ie tries to do what you expect most of the time.