[Wicket-user] Design questions: Use of controllers and wicket models

2007-03-08 Thread David Leangen
Hi! Two design questions for experienced wicket users... Mail is a bit long. I apologise for this, but I wanted to explain the situation well. We have been using wicket now for a while, and I think it's time to try to finally clean up our code a little. With that in mind, I have two questions fo

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-08 Thread Igor Vaynberg
here are my short answers :) ask more if you need something explained in detail On 3/8/07, David Leangen <[EMAIL PROTECTED]> wrote: First Question: Controller Logic The idea sounds good, but I'm wondering if this is even necessary. It was suggested to me that

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-08 Thread David Leangen
Great! Thanks for this. Very helpful! This does give a lot of ideas, indeed. If my understanding is correct, this would indeed provide a very elegant solution to what we're trying to do. One precision: > you have to decide what is clearly "business logic" vs "ui logic". the > business logic sh

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-08 Thread Igor Vaynberg
On 3/8/07, David Leangen <[EMAIL PROTECTED]> wrote: This is actually something I'm kinda struggling with. In our model, the "biz logic" is the query. So, for instance, if I have two radios and a group of checkboxes: ( ) Any colour ( ) Choose colours [ ] Blue [ ] Red ... I

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-09 Thread Thomas R. Corbin
On Thursday, 08 March 2007 07:58 pm, Igor Vaynberg escreveu: > see above. take a simple example where you have a list of checkboxes and > you want all selected objects to end up in a collection. how do you do it? > sounds like a complex mapping? the most elegant way is to write a custom > model.

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-09 Thread Igor Vaynberg
yes, but then you are married to the output it genereates. [] label [] label whats below you can use just for the checkbox, so you are free to generate your own label/panel/whatever. eg selecting rows in a table. -igor On 3/9/07, Thomas R. Corbin <[EMAIL PROTECTED]> wrote: On Thursday, 08 M

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-09 Thread Thomas R. Corbin
On Friday, 09 March 2007 11:57 am, Igor Vaynberg escreveu: > yes, but then you are married to the output it genereates. > > [] label > [] label > > whats below you can use just for the checkbox, so you are free to generate > your own label/panel/whatever. eg selecting rows in a table. Oooo

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread David Leangen
Still playing around with this, and I have a question. When does the IModel's setObject() method get called? I'm stepping through the code, but this method is never being called... Cheers, Dave On Fri, 2007-03-09 at 16:47 -0600, Thomas R. Corbin wrote: > On Friday, 09 March 2007 11:57 am,

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread David Leangen
Igor, Regarding your suggestions below: > > class mypage extends page { > > private Set selected=new HashSet(); > > > > private class PersonCheckboxModel implements IModel { > > private final IModel person; > > public final PersonCheckBoxModel(IModel person) { > > this.person=person; } > > > > p

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Igor Vaynberg
setobject is called when the component needs to update the model. eg when you submit a textfield it needs to push new input into the model and so it calls setobject(). sometimes components that work with collections do not do that - they simply clear the collection and add new values - this is so

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Eelco Hillenius
> > > now all you have to do is > > > > > > LoadableDetachableModel person=new LoadalbeDetachableModel(id); > > > new CheckBox(this, "cb", new PersonCheckBoxModel(person)); > > > > > > and everything magically works, hope it gives you some ideas. > > Yes, it does indeed give me many ideas. Right no

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Igor Vaynberg
actually we are inconsistent in some places and i have been trying to fix it. what we mostly do is whenever we work with a collection we clear it and repopulate it. but we never call setobject() on the model which imho is wrong. sometimes i have a model in between that depends on setobject() calle

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Eelco Hillenius
If you are not changing the object that is the subject of the model, I see no reason why setObject should be called. Eelco On 3/12/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote: > actually we are inconsistent in some places and i have been trying to fix > it. what we mostly do is whenever we work w

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Igor Vaynberg
ah, but if you modify a collection that is a model object are you infact "changing" the object? you are not changing the reference itself but you are doing something that has sideffects. eg lets say you have a dropdown choice, but what you want is a collection of ids not the objects. the easiest

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Eelco Hillenius
Maybe it is good to gather a couple of use cases and pros and cons and start a separate thread? Eelco On 3/12/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote: > ah, but if you modify a collection that is a model object are you infact > "changing" the object? you are not changing the reference itself

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread David Leangen
Sorry for pulling you guys back to my mail issue. ;-) Since setObject() is not being called, I don't see how to apply my complex model to its children. I thought I could pull this off with setModel()... but it just ain't being called. Ok, let's stick with the "person" object. The person has att

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread Igor Vaynberg
if you disable a formcomponent then neither a set or get will be called -igor On 3/12/07, David Leangen <[EMAIL PROTECTED]> wrote: Sorry for pulling you guys back to my mail issue. ;-) Since setObject() is not being called, I don't see how to apply my complex model to its children. I though

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-12 Thread David Leangen
:-) > if you disable a formcomponent then neither a set or get will be > called Yes. But it's not disabled, and get is being called. Just not set. I must be doing something wrong or missing something in the impl here... but I don't see what it is. :-( Cheers, Dave > Sorry for p

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-14 Thread David Leangen
Ok, thanks for your help, guys. I finally figured out what you meant by your last comments, and implemented one way to go about this. Not sure if it's the "best" way, but it's certainly much cleaner than before. Thanks!! Just one question remaining. What's the deal with getNestedModel( )? It

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-15 Thread David Leangen
Ok, thanks for the info. Sorry for not letting this thread die... but one more question (and hopefully last): Right now, the page I refactored looks like this: MyPage page = new MyPage( MyBean bean ) { SomeComponent component = new Component( "id", new MyModel( bean ) ); bla bla Hi, Mo

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-16 Thread Gwyn Evans
Hi, (If Igor says anything different, just ignore this! :-)) The change that I'd consider would the standard one of if it'd be worth passing in a custom IMyBean interface derived from IModel, to cover the case where I might want to use something like-but-not-a MyBean, but I can't see anything

Re: [Wicket-user] Design questions: Use of controllers and wicket models

2007-03-16 Thread David Leangen
That's not a bad idea at all. Thanks! On Fri, 2007-03-16 at 08:55 +, Gwyn Evans wrote: > Hi, > (If Igor says anything different, just ignore this! :-)) > > The change that I'd consider would the standard one of if it'd be > worth passing in a custom IMyBean interface derived from IMode