Dear Wiki user, You have subscribed to a wiki page or wiki category on "Jakarta-tapestry Wiki" for change notification.
The following page has been changed by DanielGredler: http://wiki.apache.org/jakarta-tapestry/BeanForm The comment on the change is: use listener: and bean: bindings ------------------------------------------------------------------------------ An [http://howardlewisship.com/blog/2006/03/from-fanciful-ideas-category.html often-requested feature] is an easier, more Trails-like way of editing domain objects that gets rid of a lot of the boilerplate typing required to create an edit form. [http://planesailing.blogspot.com/2006/03/tapestry-edit-component.html Some solutions] are breathtaking in their comprehensiveness but suffer from lack of documentation and over-architecting (imho). The BeanForm is a simpler solution to this common problem: {{{ - <span jwcid="@BeanForm" bean="ognl:pojo" save="ognl:listeners.save" delete="ognl:listeners.delete"/> + <span jwcid="@BeanForm" bean="ognl:pojo" save="listener:save" delete="listener:delete"/> }}} The above code gets you a form that will call save() when submitted for save, delete() when submitted for delete, displays !TextFields for the bean's string and numerical properties, Checkboxes for its boolean properties and !DatePickers for its date properties, and automatically disables fields for read-only properties. Properties are discovered via [http://java.sun.com/docs/books/tutorial/javabeans/index.html bean introspection]. You can use the BeanForm with a single line, as shown above, or you can include it inside one of your existing Forms, in which case the internal Form component will not be generated. It's your choice. @@ -11, +11 @@ You can also specify exactly which properties you want included in the BeanForm, as well as cancel and refresh listeners and any of the other parameters supported by the [http://jakarta.apache.org/tapestry/tapestry/ComponentReference/Form.html Form component]. When you explicitly specify the editable properties, those properties are shown on the page in the order you specify: {{{ - <span jwcid="@BeanForm" bean="ognl:pojo" properties="ognl:'name,email,comment'" save="ognl:listeners.save" cancel="ognl:listeners.cancel" refresh="ognl:listeners.refresh" /> + <span jwcid="@BeanForm" bean="ognl:pojo" properties="ognl:'name,email,comment'" save="listener:save" cancel="listener:cancel" refresh="listener:refresh" /> }}} The generated HTML is a form containing a two-column table (unless the BeanForm is already inside a Form, in which case another Form is not generated). The left column contains the field labels and the right column contains the data entry fields. The bottom row spans both columns and contains the save button (if the ''save'' parameter was specified), the cancel button (if the ''cancel'' parameter was specified), the refresh button (if the ''refresh'' parameter was specified) and the delete button (if the ''delete'' parameter was specified). The table can be styled using CSS: the table's CSS class is ''beanFormTable'', the left column's CSS class is ''beanFormLeftColumn'', the right column's CSS class is ''beanFormRightColumn'', and the bottom column that contains the buttons has the CSS class ''beanFormButtonColumn''. @@ -29, +29 @@ In order to use validation, specify the ''delegate'' parameter (unless you have already specified it in an external Form component that contains this component) and add standard Tapestry [http://jakarta.apache.org/tapestry/UsersGuide/validation.html validator lists] to the ''properties'' parameter, in between squiggly brackets (''{ }''). Fox example, if you want to make the ''name'' and ''email'' properties required, and want to check that ''email'' is actually an email address, you could do the following: {{{ - <span jwcid="@BeanForm" bean="ognl:pojo" properties="ognl:'name{required},email{required,email},comment'" save="ognl:listeners.save" delegate="ognl:beans.validationDelegate" clientValidationEnabled="ognl:true"/> + <span jwcid="@BeanForm" bean="ognl:pojo" properties="ognl:'name{required},email{required,email},comment'" save="listener:save" delegate="bean:validationDelegate" clientValidationEnabled="ognl:true"/> }}} Internationalization is supported out of the box: field labels are messages keyed on the property name. The save button (if displayed) is labeled with the message corresponding to the key ''save''. The cancel button (if displayed) is labeled with the message corresponding to the key ''cancel''. The refresh button (if displayed) is labeled with the message corresponding to the key ''refresh''. The delete button (if displayed) is labeled with the message corresponding to the key ''delete''. @@ -199, +199 @@ * <p>Usage examples:</p> * <ul> * <li>Minimal: <tt><span jwcid="@BeanForm" bean="ognl:pojo" - * save="ognl:listeners.save"/></tt></li> + * save="listener:save"/></tt></li> * <li>More: <tt><span jwcid="@BeanForm" bean="ognl:pojo" - * properties="ognl:'name,email,comment'" save="ognl:listeners.save" + * properties="ognl:'name,email,comment'" save="listener:save" + * cancel="listener:cancel" delete="listener:delete" - * cancel="ognl:listeners.cancel" - * delete="ognl:listeners.delete" - * refresh="ognl:listeners.refresh" /></tt></li> + * refresh="listener:refresh" /></tt></li> * <li>To edit the <tt>comment</tt> property in a text area you would add the * following to your page:<br> * <tt><div jwcid="[EMAIL PROTECTED]"></tt><br> @@ -217, +216 @@ * <tt>email</tt> is actually an email: * <tt><span jwcid="@BeanForm" bean="ognl:pojo" * properties="ognl:'name{required},email{required,email},comment'" - * save="ognl:listeners.save" clientValidationEnabled="ognl:true" + * save="listener:save" clientValidationEnabled="ognl:true" - * delegate="ognl:beans.validationDelegate"/></tt></li> + * delegate="bean:validationDelegate"/></tt></li> * </ul> * * @author Daniel Gredler --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
