i wonder if we should have something like BeanEditForm that does just this...


<property-name> <form-component>
<property-name> <form-component>
   ...

let's make this an RFE for 1.1

Eelco Hillenius wrote:

One thing I can imagine is a form with a panel attached, that you feed a java bean. Based on the properties of that java bean (using introspection), you could add form fields to the form.

This is quite easy to accomplish for simple introspection, though if you really want to do a good job, it's more work because you should then do the whole java beans trick with property descriptors etc.

Is that more like what you need?

Eelco

Ari Suutari wrote:

- On a large form, which has many fields it would be nice
to be able to auto-wire fields to model properties automatically.
(ie. I have a text field called "userName" in html form and
I have property called "userName" in my model). This would
speed up development a lot.



You can use (Bound)CompoundPropertyModel for this. See Jonathan's article on Wicket Models , which you can find here:
http://wicket.sourceforge.net/wiki/doku.php?id=models
The actual code needed to wire your form to your java is really small in this case. Just declare the fields using the field wicket-ID's, and make sure they match the property in your POJO.



I already use CompoundPropertyModel, so I have code like:

  add(new TextField("code"));
  add(new TextField("descr"));
  add(new TextField("shortName"));

  I was hoping to avoid this code also for trivial cases.


I don't know if this would work
 for everyone, but we have most of business-level validation logic
 in models so simple validation in wicket layer (like just checking
 that field is a number) is enough.



You can use your business validation logic in your own implementations of IValidator
and use those in your presentation layer, giving your user more direct feedback.



I'll have to check this. Sounds useful.


- Empty TextFields seem to be stored into model as Strings with
  zero lengths. Our previous UI system maps empty strings to nulls.
  Is there a way to tweak this anywhere in wicket ?



I don't know. Perhaps someone else on the list can answer this.



Maybe it would be possible to derive my own class from TextField and override updateModel ?


- Is it OK to create instances of page objects myself, ie. doing something like this:
getPage().setResponsePage(new PersonListPage(coll));
or should pages be instantiated by some factory class ?



If you wish to do so. Factories are useful if you need more configuration or want to change the behaviour in a subclass, but it is not a requirement of Wicket. Your example works and is by no means an anti-pattern.



Ok, and thanks for your response.

       Ari S.



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user





------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to