Re: [Wicket-user] Wicket way of doing (inter-)component updates?
> The last remark is not clear to me, I have look into Wicket 2.0 sources. The difference between 1.x and 2.x is that in 2 you can apply generics to models and components. For example, you can now do this: public MyComponent(MarkupContainer p, IModel m) forcing on clients that a model is passed in that returns an object 'MyType'. In 1.x, you could only do public MyComponent(MarkupContainer p, IModel m) which neither forces proper use nor is very readable. So often, if you need component dependencies to be strong typed, what you would do in 1.x is: public MyComponent(MarkupContainer p, MyType o) Working with generics like we now support in 2 has all the flexibility of working with IModels, but with the additional advantage of strong typing. Eelco * btw, that first argument p is only needed for 2.0, but I kept in in the example so that it wouldn't distract. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Wicket way of doing (inter-)component updates?
Thanks Eelco for your time. I hope I get the intent even if I did not looked at Wicket 2.0. The first solution with CompoundPropertyModel is clear, I just hesitate to use the component id as the model accessor string. But my hesitation can be solved with BoundCompoundPropertyModel. The second solutions is interesting albeit more code is needed. The last remark is not clear to me, I have look into Wicket 2.0 sources. Thanks again, Jan "Eelco Hillenius" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Take a look at how NewUserWizard of wicket-examples/wizard works. It uses itself as the model object: public class NewUserWizard extends Wizard { ... private static final List allRoles = Arrays.asList(new String[] { "admin", "user", "moderator", "joker", "slacker" }); private boolean assignRoles = false; private User user; public NewUserWizard(MarkupContainer parent, String id) { super(parent, id); // create a blank user user = new User(); setModel(new CompoundPropertyModel(this)); ... Then, later on, that is used like: new RequiredTextField(this, "user.firstName"); new RequiredTextField(this, "user.lastName"); new TextField(this, "user.department"); new CheckBox(this, "assignRoles"); The point here is that NewUserWizard is used as the compound model object, nesting the user and assignRoles properties. Instead of NewUserWizard, we could have any other class to nest those properties, and instead of a CompoundPropertyModel, we could have just passed the model in the constructors of the panels that use them. And instead of relying on one top level model object, we could have used nested IModel instances: public class GimmeAll { private User user; private boolean assignRoles; ... } public class UserModel extends LoadableDetachableModel { private final IModel parentModel; public UserModel(IModel model) { this.parentModel = model; } protected User load() { GimmeAll o = parentModel.getObject(); return (o != null) ? o.getUser() : null; } protected void onDetach() { parentModel.detach(); } } and finally, in 2.0 you can 'force' using the proper model even if it is not the concrete object yet: public class SomePanel extends Panel { public SomePanel(MarkupContainer parent, IModel model) { super(parent, model); } } Does that help? Eelco On 8/22/06, jan_bar <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to see some sample too. In my opinion, the hierarchical model > sample should be part of the wicket samples. We can very easy partition our > pages into Panels, Borders and whatever, but what about models? They are not > so easy to use. I think that a set of possible solutions (model - best > practices) used by core Wicket developers may be of immense help. > > Thank you, Jan > > "Andre Matheus" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > Could you please explain better the option 2? > > If do you have an example it could be useful. > > Thanks. > ___ > André Matheus > > On 8/21/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote: > > Basically you have the choice between either: > > 1) using observers/ event listeners for notification much like you > > would probably do with swing; > > 2) use a hierarchal model that is shared between components so that > > any change in that model is automatically cascaded. > > > > 1) is probably more work and has the danger that it causes a domino > > effect letting you end up with a zillion listeners, but the advantage > > is that you don't need a foreign model and it is more loosely bound. > > > > My personal preference is usually 2). Not that this model hierarchy > > can be on the actual model objects as well as on the IModels > > themselves. > > > > Eelco > > > > - > > Using Tomcat but need to do more? Need to support web services, security? > > Get stuff done quickly with pre-integrated technology to make your job > easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > ___ > > Wicket-user mailing list > > Wicket-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > > -- > __ > André Matheus > > - > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > > > > > > - > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > D
Re: [Wicket-user] Wicket way of doing (inter-)component updates?
Take a look at how NewUserWizard of wicket-examples/wizard works. It uses itself as the model object: public class NewUserWizard extends Wizard { ... private static final List allRoles = Arrays.asList(new String[] { "admin", "user", "moderator", "joker", "slacker" }); private boolean assignRoles = false; private User user; public NewUserWizard(MarkupContainer parent, String id) { super(parent, id); // create a blank user user = new User(); setModel(new CompoundPropertyModel(this)); ... Then, later on, that is used like: new RequiredTextField(this, "user.firstName"); new RequiredTextField(this, "user.lastName"); new TextField(this, "user.department"); new CheckBox(this, "assignRoles"); The point here is that NewUserWizard is used as the compound model object, nesting the user and assignRoles properties. Instead of NewUserWizard, we could have any other class to nest those properties, and instead of a CompoundPropertyModel, we could have just passed the model in the constructors of the panels that use them. And instead of relying on one top level model object, we could have used nested IModel instances: public class GimmeAll { private User user; private boolean assignRoles; ... } public class UserModel extends LoadableDetachableModel { private final IModel parentModel; public UserModel(IModel model) { this.parentModel = model; } protected User load() { GimmeAll o = parentModel.getObject(); return (o != null) ? o.getUser() : null; } protected void onDetach() { parentModel.detach(); } } and finally, in 2.0 you can 'force' using the proper model even if it is not the concrete object yet: public class SomePanel extends Panel { public SomePanel(MarkupContainer parent, IModel model) { super(parent, model); } } Does that help? Eelco On 8/22/06, jan_bar <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to see some sample too. In my opinion, the hierarchical model > sample should be part of the wicket samples. We can very easy partition our > pages into Panels, Borders and whatever, but what about models? They are not > so easy to use. I think that a set of possible solutions (model - best > practices) used by core Wicket developers may be of immense help. > > Thank you, Jan > > "Andre Matheus" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > Could you please explain better the option 2? > > If do you have an example it could be useful. > > Thanks. > ___ > André Matheus > > On 8/21/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote: > > Basically you have the choice between either: > > 1) using observers/ event listeners for notification much like you > > would probably do with swing; > > 2) use a hierarchal model that is shared between components so that > > any change in that model is automatically cascaded. > > > > 1) is probably more work and has the danger that it causes a domino > > effect letting you end up with a zillion listeners, but the advantage > > is that you don't need a foreign model and it is more loosely bound. > > > > My personal preference is usually 2). Not that this model hierarchy > > can be on the actual model objects as well as on the IModels > > themselves. > > > > Eelco > > > > - > > Using Tomcat but need to do more? Need to support web services, security? > > Get stuff done quickly with pre-integrated technology to make your job > easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > ___ > > Wicket-user mailing list > > Wicket-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > > -- > __ > André Matheus > > - > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > > > > > > - > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > ___ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > ---
Re: [Wicket-user] Wicket way of doing (inter-)component updates?
Hi, I would like to see some sample too. In my opinion, the hierarchical model sample should be part of the wicket samples. We can very easy partition our pages into Panels, Borders and whatever, but what about models? They are not so easy to use. I think that a set of possible solutions (model - best practices) used by core Wicket developers may be of immense help. Thank you, Jan "Andre Matheus" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Could you please explain better the option 2? If do you have an example it could be useful. Thanks. ___ André Matheus On 8/21/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote: > Basically you have the choice between either: > 1) using observers/ event listeners for notification much like you > would probably do with swing; > 2) use a hierarchal model that is shared between components so that > any change in that model is automatically cascaded. > > 1) is probably more work and has the danger that it causes a domino > effect letting you end up with a zillion listeners, but the advantage > is that you don't need a foreign model and it is more loosely bound. > > My personal preference is usually 2). Not that this model hierarchy > can be on the actual model objects as well as on the IModels > themselves. > > Eelco > > - > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > ___ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > -- __ André Matheus - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Wicket way of doing (inter-)component updates?
Could you please explain better the option 2? If do you have an example it could be useful. Thanks. ___ André Matheus On 8/21/06, Eelco Hillenius <[EMAIL PROTECTED]> wrote: > Basically you have the choice between either: > 1) using observers/ event listeners for notification much like you > would probably do with swing; > 2) use a hierarchal model that is shared between components so that > any change in that model is automatically cascaded. > > 1) is probably more work and has the danger that it causes a domino > effect letting you end up with a zillion listeners, but the advantage > is that you don't need a foreign model and it is more loosely bound. > > My personal preference is usually 2). Not that this model hierarchy > can be on the actual model objects as well as on the IModels > themselves. > > Eelco > > - > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > ___ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > -- __ André Matheus - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Wicket way of doing (inter-)component updates?
Basically you have the choice between either: 1) using observers/ event listeners for notification much like you would probably do with swing; 2) use a hierarchal model that is shared between components so that any change in that model is automatically cascaded. 1) is probably more work and has the danger that it causes a domino effect letting you end up with a zillion listeners, but the advantage is that you don't need a foreign model and it is more loosely bound. My personal preference is usually 2). Not that this model hierarchy can be on the actual model objects as well as on the IModels themselves. Eelco - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] Wicket way of doing (inter-)component updates?
usually what i do is make listeners on the page level/panel level (whatever your encapsulaion unit is) that various components trigger.for examplePage.onUserSelected(User user) {}then whatever is in charge of selecting users raises this event. if it is encapsulated on the level of the panel i sometimes make these listeners abstract so i remember to implement them if they are required.sometimes the simplest solutions are the best :)-Igor On 8/21/06, Jan Willem Janssen <[EMAIL PROTECTED]> wrote: Hi,I'm, in general, wondering what the "Wicket way" of inter-componentcommunication would be. Or even, if there is such a way of doingthis.For example, I've got a Tree, which should update a List according to a clicked tree-node (viz. a simple webmail app). The click event ofthe tree node should fire an event to update the list, which might onits own another component, and so on.How are other users of Wicket dealing with this? Do they create custom controllers for this, which handle the events? Or, ...?TiA,--Jan Willem Janssen, M.Sc.software engineer, Development__Planon B.V.Wijchenseweg 8 6537 TL NijmegenP.O. Box 380746503 AB NijmegenThe NetherlandsT: +31 (0) 24 648 7662F: +31 (0) 24 642 2942E: [EMAIL PROTECTED]W: www.planon-fm.comDeze email en alle bijlagen zijn slechts voor gebruik door de beoogde ontvanger. De email kan intellectueel eigendom en/of vertrouwelijke informatie bevatten. Het mag niet worden gekopieerd, openbaar gemaakt, bewaard of gebruikt worden door anderen dan waarvoor deze bestemd is. Bent u niet de beoogde ontvanger,verwijdert u dan deze email met alle bijlagen en kopieën onmiddellijk en informeer de afzender. This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. -Using Tomcat but need to do more? Need to support web services, security?Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimohttp://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___Wicket-user mailing listWicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
[Wicket-user] Wicket way of doing (inter-)component updates?
Hi, I'm, in general, wondering what the "Wicket way" of inter-component communication would be. Or even, if there is such a way of doing this. For example, I've got a Tree, which should update a List according to a clicked tree-node (viz. a simple webmail app). The click event of the tree node should fire an event to update the list, which might on its own another component, and so on. How are other users of Wicket dealing with this? Do they create custom controllers for this, which handle the events? Or, ...? TiA, -- Jan Willem Janssen, M.Sc. software engineer, Development __ Planon B.V. Wijchenseweg 8 6537 TL Nijmegen P.O. Box 38074 6503 AB Nijmegen The Netherlands T: +31 (0) 24 648 7662 F: +31 (0) 24 642 2942 E: [EMAIL PROTECTED] W: www.planon-fm.com Deze email en alle bijlagen zijn slechts voor gebruik door de beoogde ontvanger. De email kan intellectueel eigendom en/of vertrouwelijke informatie bevatten. Het mag niet worden gekopieerd, openbaar gemaakt, bewaard of gebruikt worden door anderen dan waarvoor deze bestemd is. Bent u niet de beoogde ontvanger,verwijdert u dan deze email met alle bijlagen en kopieën onmiddellijk en informeer de afzender. This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user