Hello, I've been working during my free time on a wicket port of the struts-nested sample example. (For those who don't know what struts nested is, it is, for the struts community, the jsp library that allows developers to do complex nesting levels of form models, with many levels editable at the same time. This is a very powerfull library for struts users.)
1/ Availibility ------------------ I've called it wicket-strutsnested, and you can find the mavenized think in attachment. I've tried to minimize at most the size of the archive (only 13ko) - Hide quoted text - in order to not overload the sf.net mail servers. I have done my best to make it as simple as possible to launch : it respects the de-facto standard of the wicket-phonebook application, with a Jetty starter class in src/launcher directory. It is built against the upcoming 1.2 version of wicket. Don't know if it still works with the 1.1 release. This demo page was a good test of dealing with a complex business model : team of monkeys, each monkey holding a bunch of bananas, and being able to modify, at the same time, monkey properties, all the property of all the bananas of all the monkeys, adding bananas to bunches, deleting bananas from bunches, to any monkey of the team. This lead me to try & help Johan to do the form preserve state stuff in core, because I didn't want to loose my user inputs when adding / deleting bananas to/from the form. Please feel free to play with & test the demo, and let me know if you find a bug. If you have not the time to install the demo, but want to see at once what is the original stuff that the demo mimics, simply go to : http://www.keyboardmonkey.com/StrutMonkey/monkey-action.do 2/ Question ----------------- My intent was to only have one concrete model for all the form : some kind of CompoundPropertyModel. Much more reassuring than many models to me (much simpler to do in a single place the job of choosing a persistence policy for the model of the form). In a first attempt, I then wrote what I called a RecursiveCompoundPropertyModel, that was able to reattach at will ListItemModels to the Model of the RecursiveCompoundPropertyModel. That was good, because I was then able to deal with (almost) any kind of models (except those using Map or Set properties, ...). But it appeared that the ListView I was using was not good for Component reuse, and I was constantly loosing my user inputs everytime a roundtrip with the server was made. Then I used the DataView of wicket-extensions. I only had to write a custom ReuseIfModelObjectsEqualStrategy in order to make it work ( I think I could also have written a custom Model and reimplement the equals() method to answer true if the model objects were equal). BUT : (and there is -finally- !) the question: Is there a way with the current stage of wicket that could have helped me not doing concrete invocations of models ? Because I'm not so happy with the fact that the models of my Items' DataView embark the instances of childs of the parent MonkeyTeam object. What I wanted to do was just to use the index in the bean, but the problem is that this does not work well with adding / deleting bananas, because the Component is lost between the old and new index (because Item components load their models from the list, whose list has already changed when the Strategy is called ... and the models are lazy initialized!) For the few that had the courage (and time!) to read this whole long e-mail, please let me know if you have some ideas that could help me improve the design of this demo. If you guys are interested to place it in the wicket-stuff project as an example of form nesting, I would be happy to join the team (already having a user in sourceforge : lpetit). This could also be a demonstration of how to do the same thing as done with struts libraries and be referenced somewhere in the wiki .... ... but first of all, I hope this will be of some interest for somebody! see you, -- Laurent
wicket-strutsnested-0.5.tar.gz
Description: GNU Zip compressed data
