-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi everyone,
this may be an obvious newbie question, but I have found no answer that looks good to me. Anyway, here goes: What is the best place to initialize a property with a default value for a form? I am looking at a page that makes heavy use of AJAX to re-render the form, displaying or hiding stuff based on some property values in the form. I also want the page to be stateless on the server side. The form is so specialized that using BeanEditor & Co does not fit - I am aware that those components pretty much take care of this problem for simple forms. That's just for background, I have the form with its logic working. I currently initialize the property in pageAttached() because that gets called before the form does its data binding: public class MyPage { @Property String p; // lots of other properties for the form, plus //logic for partial re-rendering public void pageAttached() { this.p = "default value"; } } Now pageAttached() is deprecated, and I understand the reasons (abolition of the page pool). But what other place fits the bill? onPrepare() is called before data binding, but it is called again after data binding. So simple initialization code in onPrepare() would overwrite the form data with the default. onPrepareForSubmit() is not called when the page is first rendered. onPrepareForRender() is called when the page is first rendered, but on subsequent submits for partial re-rendering it is called after data binding. Using a getter method that checks for null more or less works but is fragile with regard to null values being bound from the form (not sure if that can actually happen, but it has a fragile and non-obvious feel to it): public String getP() { if (this.p == null) { this.p = "default value"; } return this.p; } This also distributes the initialization to many methods, and I would like it better to have it in a single method. So - am I overlooking something? All suggestions are much appreciated! - - Arno -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+jwN8ACgkQbmZsMyUPuXTlgACgmH301OT63HeTMxC0qziLS0Uu G2cAoO1bZOmiezPjaXN9B4lh8JBX24k6 =fC2k -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org