You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Clint Checketts <ch...@gmail.com> on 2012/05/14 01:52:33 UTC

Lessons from Wicket Cookbook

While clearing out my drafts folder I found this.  While reading through
the Wicket cookbook by Igor (
http://www.packtpub.com/apache-wicket-cookbook/book) I noticed that I was
learning a ton of new interesting stuff about the Wicket way of doing
things, so I kept notes.

This draft is from over a year ago (Mar 2011), but the information is still
accurate for the book.* I highly recommend this book.*

-Clint


   - Form override onValidate input.getConvetedInput() gets value before
   its been stored in the input's model pg 11
   - Single validator displaying multiple messages: pg 16
   - Better way to set custom variables for error messages: pg 17
   (error.setVariable("max", max);)
   - FormComponents automatically know how to convert to the model object
   because the implement IObjectClassAwareModel, otherwise
   formField.setType(Class) is required pg 31
   - DropDownChoice wantOnSelectionChange (pg 38) makes a select box
   autosubmitting
   - <wicket:container /> (pg 42)  is the same as adding a component to a
   div and calling setRenderBodyOnly(true)
   - getConvertedInput can return a new instance of an object, and in
   updateModel you would copy the values over into the existing object, if you
   wanted to update the existing object (pg 45), be sure not to call
   super.updateModel() though
   - We can use Wicket's metadata facility to store data in the Wicket
   session without forcing a specific sub-class of session (pg 52)
   - aTextField.clearInput() forces a value="" on a text field ensuring
   that it is blanked out even if the user had typed something before (pg 57)
   Validation failure would otherwise retain the value and keep displaying it.
   - The AttributeAppender behavior doesn't allow for the replace model to
   be set after the constructor, and getReplaceModel is final so the
   implementation as listed on pg 62 is the best way to update a
   FormComponent's class when checking isValid()
   - Page 64 - remember to add form.visitChildren calls after all children
   have been added to the form.  Making the call in onInitialize isn't wise
   since that call actually happens as part of the 'add()' call in it's parent!
   - Question: Would separate components in separate app sessions cause
   feedback messages in each other's pages? pg 71
   - IAjaxRegionMarkupIdProvider can be used with a behavior to clean up
   extra surrounding markup around components pg 74
   - Example using MicroMap (map that holds a single value and is populated
   in its constructor, and MiniMap) and the Model.ofMap() factory usage,
   finally using getString("keyInPropFile",mapmodel) for manually getting a
   property message and displaying it. pg82