Re: alternative solution for addOrReplace()?
> I think you might have over-complicated your design. Yes, I also think so, but unfortunately currently I'm not able to redesign it, and I try to find a quick solution. :-/ (please have a look at my reply to andreas mail. There is some code...) > should be simple to update the parent which in turn delegates that responsibility to the children. It is -somehow- the way you described. I think... hmm... but not very good implemented it seems. > Take a quick look over how Decebal implemented his Wicket-Dashboards Ok, thanx, I will do... > Otherwise I suggest you get rid of the addOrReplace() and move that logic > into your onBeforeRender() methods for those panels to update themself. Are markup modifications handled different by onBeforeRender() / add() compared to onConfigure() / addOrReplace()? Or do I also have to use addOrReplace() in onBeforeRender()? Patrick Am 07.10.2014 21:47, schrieb Paul Bors: > I think you might have over-complicated your design. > Your use-case is quite simple, you have user input that filters the > display. It might be that there are a lot of panels to be updated but then > again it should be simple to update the parent which in turn delegates that > responsibility to the children. > > Take a quick look over how Decebal implemented his Wicket-Dashboards as in > his project the entire dashboard is refreshed when adding a new panel which > in turn can be quite complicated. > > His code and examples are at: > https://github.com/decebals/wicket-dashboard > > Study his design and see how much of that you can apply to your page. > > Otherwise I suggest you get rid of the addOrReplace() and move that logic > into your onBeforeRender() methods for those panels to update themself. > > On Tue, Oct 7, 2014 at 12:43 PM, Patrick Davids < > patrick.dav...@nubologic.com> wrote: > >> Hi Paul, >> thanx for replying. >> >> Oh, I use Ajax very heavily in this case. Thats why I said: "the panel >> works quite good for ajax rendering and refreshing use-cases" >> >> Hmm... ok... I think I missed some details. I try to explain. >> >> My page contains two sections seperated from each other. >> A kind of data-entry and a kind of displaying the results. >> >> The section which displays the results is a quite complicated panel, >> having an RefreshingView for about 30 (I will name them) sub-panels. >> >> These sub-panels addOrReplace() an inner container while rendering itself. >> And the replacement depends on my model object type. >> >> So, my sub-panel class has a hugh knowledge about how to render the >> results. >> >> On entering some data on the data-entry section I refresh the whole >> panel in the display section with all its sub-panels using Ajax. And >> this works great. >> Some of the sub-panels also rerender/refresh own there own, by listening >> to events etc pepe. All this behaviours are working very well. >> >> The only disadvantage is, using addOrReplace(), I have a heavy >> detaching/attaching situation and a performance problem. >> >> So, the best solution for now would be, keeping my panel implementation >> as it is, but just having my models detached only once, not for iteration. >> >> And here I dont have any idea how to solve that... :-/ >> >> thanx and kind regards >> Patrick >> >> Am 07.10.2014 17:52, schrieb Paul Bors: >>> Why not use Ajax? >>> >>> addOrReplace() is really for when you need the full request cycle and >> have >>> the page rendered on the server side. With Ajax you get your target for >>> which you can add all the components you want to refresh on the page. >>> >>> Given the day and age we live in, I don't think there is a need to even >>> worry about browsers that do not support Ajax. Than again, that depends >> on >>> your product's requirements. >>> >>> Otherwise, you can keep on using addOrReplace() but stop using instaceof >>> and start using Generics. >>> If you need an example code-snippet of that let me know and I'll dig some >>> out for you. >>> >>> On Tue, Oct 7, 2014 at 9:51 AM, Patrick Davids < >> patrick.dav...@nubologic.com wrote: >>> Hi all, I have a panel, which renders a inner markupcontainer (different panels for different ways of displaying my model object) depending on its model objects type. I do this by addOrReplace() the inner panel in an onConfigure() having an "if instanceof"; and it also iterates over a list... I'm not sure, if it is a good solution (I dont like the instanceof approach), but the panel works quite good for ajax rendering and refreshing use-cases. But, the addOrReplace() has one big disadvantage. It forces to detach the model on each iteration, so on each iteration I get a database access to retrieve it again. Is there anyway to keep the model attached until the entire request cycle is finished? Or should I try to find complete other solution for this kind of "high dynamic iterating panel"? Is
Re: alternative solution for addOrReplace()?
Hi Andrea, this is the code (a bit pseudo-like...) I am quite sure it is not the way it should be and full of wicket anti-patterns. But still exists since my first wicket experiences 2 years ago. ;-) This panel gets rendered via RefreshingView about 30 times. public ElementPanel(String id, IModel elementState){ super(id, elementState); container = new WebMarkupContainer("innerElementContainer", elementState){ private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); ElementState s = (ElementState)getDefaultModelObject(); if(s instanceof DefaultState){ container.addOrReplace(new DefaultStatePanel(REPLACE_CONTAINER_ID, s)); }else if(s instanceof SpecialState){ container.addOrReplace(new SpecialStatePanel(REPLACE_CONTAINER_ID, s)); }else if(s instanceof AnotherSpecialState){ container.addOrReplace(new AnotherSpecialStatePanel(REPLACE_CONTAINER_ID, s)); ... }else{ String error = "No panel registered for class "+getDefaultModelObject().getClass().getSimpleName(); container.addOrReplace(new Label(REPLACE_CONTAINER_ID, error)); error(error); } } add(container); } Patrick Am 07.10.2014 19:42, schrieb Andrea Del Bene: > Hi, > > could you post the code you use inside onConfigure to addOrReplace inner > container? Maybe you could avoid detaching/attaching overriding method > detachModels in your inner containers. >> Hi Paul, >> thanx for replying. >> >> Oh, I use Ajax very heavily in this case. Thats why I said: "the panel >> works quite good for ajax rendering and refreshing use-cases" >> >> Hmm... ok... I think I missed some details. I try to explain. >> >> My page contains two sections seperated from each other. >> A kind of data-entry and a kind of displaying the results. >> >> The section which displays the results is a quite complicated panel, >> having an RefreshingView for about 30 (I will name them) sub-panels. >> >> These sub-panels addOrReplace() an inner container while rendering >> itself. >> And the replacement depends on my model object type. >> >> So, my sub-panel class has a hugh knowledge about how to render the >> results. >> >> On entering some data on the data-entry section I refresh the whole >> panel in the display section with all its sub-panels using Ajax. And >> this works great. >> Some of the sub-panels also rerender/refresh own there own, by listening >> to events etc pepe. All this behaviours are working very well. >> >> The only disadvantage is, using addOrReplace(), I have a heavy >> detaching/attaching situation and a performance problem. >> >> So, the best solution for now would be, keeping my panel implementation >> as it is, but just having my models detached only once, not for >> iteration. >> >> And here I dont have any idea how to solve that... :-/ >> >> thanx and kind regards >> Patrick >> >> > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org >
Re: alternative solution for addOrReplace()?
I think you might have over-complicated your design. Your use-case is quite simple, you have user input that filters the display. It might be that there are a lot of panels to be updated but then again it should be simple to update the parent which in turn delegates that responsibility to the children. Take a quick look over how Decebal implemented his Wicket-Dashboards as in his project the entire dashboard is refreshed when adding a new panel which in turn can be quite complicated. His code and examples are at: https://github.com/decebals/wicket-dashboard Study his design and see how much of that you can apply to your page. Otherwise I suggest you get rid of the addOrReplace() and move that logic into your onBeforeRender() methods for those panels to update themself. On Tue, Oct 7, 2014 at 12:43 PM, Patrick Davids < patrick.dav...@nubologic.com> wrote: > Hi Paul, > thanx for replying. > > Oh, I use Ajax very heavily in this case. Thats why I said: "the panel > works quite good for ajax rendering and refreshing use-cases" > > Hmm... ok... I think I missed some details. I try to explain. > > My page contains two sections seperated from each other. > A kind of data-entry and a kind of displaying the results. > > The section which displays the results is a quite complicated panel, > having an RefreshingView for about 30 (I will name them) sub-panels. > > These sub-panels addOrReplace() an inner container while rendering itself. > And the replacement depends on my model object type. > > So, my sub-panel class has a hugh knowledge about how to render the > results. > > On entering some data on the data-entry section I refresh the whole > panel in the display section with all its sub-panels using Ajax. And > this works great. > Some of the sub-panels also rerender/refresh own there own, by listening > to events etc pepe. All this behaviours are working very well. > > The only disadvantage is, using addOrReplace(), I have a heavy > detaching/attaching situation and a performance problem. > > So, the best solution for now would be, keeping my panel implementation > as it is, but just having my models detached only once, not for iteration. > > And here I dont have any idea how to solve that... :-/ > > thanx and kind regards > Patrick > > Am 07.10.2014 17:52, schrieb Paul Bors: > > Why not use Ajax? > > > > addOrReplace() is really for when you need the full request cycle and > have > > the page rendered on the server side. With Ajax you get your target for > > which you can add all the components you want to refresh on the page. > > > > Given the day and age we live in, I don't think there is a need to even > > worry about browsers that do not support Ajax. Than again, that depends > on > > your product's requirements. > > > > Otherwise, you can keep on using addOrReplace() but stop using instaceof > > and start using Generics. > > If you need an example code-snippet of that let me know and I'll dig some > > out for you. > > > > On Tue, Oct 7, 2014 at 9:51 AM, Patrick Davids < > patrick.dav...@nubologic.com > >> wrote: > > > >> Hi all, > >> I have a panel, which renders a inner markupcontainer (different panels > >> for different ways of displaying my model object) depending on its model > >> objects type. > >> > >> I do this by addOrReplace() the inner panel in an onConfigure() having > >> an "if instanceof"; and it also iterates over a list... > >> > >> I'm not sure, if it is a good solution (I dont like the instanceof > >> approach), but the panel works quite good for ajax rendering and > >> refreshing use-cases. > >> > >> But, the addOrReplace() has one big disadvantage. > >> It forces to detach the model on each iteration, so on each iteration I > >> get a database access to retrieve it again. > >> > >> Is there anyway to keep the model attached until the entire request > >> cycle is finished? > >> > >> > >> Or should I try to find complete other solution for this kind of "high > >> dynamic iterating panel"? > >> Is it better to use e.g. Fragments to display a model object in > >> different ways depending on its state? > >> > >> Please give some inspirations... I ran out of ideas. Help! > >> > >> kind regards :-) > >> Patrick > >> - > >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > >> For additional commands, e-mail: users-h...@wicket.apache.org > >> > >> > > >
Re: alternative solution for addOrReplace()?
Hi, could you post the code you use inside onConfigure to addOrReplace inner container? Maybe you could avoid detaching/attaching overriding method detachModels in your inner containers. Hi Paul, thanx for replying. Oh, I use Ajax very heavily in this case. Thats why I said: "the panel works quite good for ajax rendering and refreshing use-cases" Hmm... ok... I think I missed some details. I try to explain. My page contains two sections seperated from each other. A kind of data-entry and a kind of displaying the results. The section which displays the results is a quite complicated panel, having an RefreshingView for about 30 (I will name them) sub-panels. These sub-panels addOrReplace() an inner container while rendering itself. And the replacement depends on my model object type. So, my sub-panel class has a hugh knowledge about how to render the results. On entering some data on the data-entry section I refresh the whole panel in the display section with all its sub-panels using Ajax. And this works great. Some of the sub-panels also rerender/refresh own there own, by listening to events etc pepe. All this behaviours are working very well. The only disadvantage is, using addOrReplace(), I have a heavy detaching/attaching situation and a performance problem. So, the best solution for now would be, keeping my panel implementation as it is, but just having my models detached only once, not for iteration. And here I dont have any idea how to solve that... :-/ thanx and kind regards Patrick - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: alternative solution for addOrReplace()?
Hi Paul, thanx for replying. Oh, I use Ajax very heavily in this case. Thats why I said: "the panel works quite good for ajax rendering and refreshing use-cases" Hmm... ok... I think I missed some details. I try to explain. My page contains two sections seperated from each other. A kind of data-entry and a kind of displaying the results. The section which displays the results is a quite complicated panel, having an RefreshingView for about 30 (I will name them) sub-panels. These sub-panels addOrReplace() an inner container while rendering itself. And the replacement depends on my model object type. So, my sub-panel class has a hugh knowledge about how to render the results. On entering some data on the data-entry section I refresh the whole panel in the display section with all its sub-panels using Ajax. And this works great. Some of the sub-panels also rerender/refresh own there own, by listening to events etc pepe. All this behaviours are working very well. The only disadvantage is, using addOrReplace(), I have a heavy detaching/attaching situation and a performance problem. So, the best solution for now would be, keeping my panel implementation as it is, but just having my models detached only once, not for iteration. And here I dont have any idea how to solve that... :-/ thanx and kind regards Patrick Am 07.10.2014 17:52, schrieb Paul Bors: > Why not use Ajax? > > addOrReplace() is really for when you need the full request cycle and have > the page rendered on the server side. With Ajax you get your target for > which you can add all the components you want to refresh on the page. > > Given the day and age we live in, I don't think there is a need to even > worry about browsers that do not support Ajax. Than again, that depends on > your product's requirements. > > Otherwise, you can keep on using addOrReplace() but stop using instaceof > and start using Generics. > If you need an example code-snippet of that let me know and I'll dig some > out for you. > > On Tue, Oct 7, 2014 at 9:51 AM, Patrick Davids > wrote: > >> Hi all, >> I have a panel, which renders a inner markupcontainer (different panels >> for different ways of displaying my model object) depending on its model >> objects type. >> >> I do this by addOrReplace() the inner panel in an onConfigure() having >> an "if instanceof"; and it also iterates over a list... >> >> I'm not sure, if it is a good solution (I dont like the instanceof >> approach), but the panel works quite good for ajax rendering and >> refreshing use-cases. >> >> But, the addOrReplace() has one big disadvantage. >> It forces to detach the model on each iteration, so on each iteration I >> get a database access to retrieve it again. >> >> Is there anyway to keep the model attached until the entire request >> cycle is finished? >> >> >> Or should I try to find complete other solution for this kind of "high >> dynamic iterating panel"? >> Is it better to use e.g. Fragments to display a model object in >> different ways depending on its state? >> >> Please give some inspirations... I ran out of ideas. Help! >> >> kind regards :-) >> Patrick >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> >
Re: alternative solution for addOrReplace()?
Why not use Ajax? addOrReplace() is really for when you need the full request cycle and have the page rendered on the server side. With Ajax you get your target for which you can add all the components you want to refresh on the page. Given the day and age we live in, I don't think there is a need to even worry about browsers that do not support Ajax. Than again, that depends on your product's requirements. Otherwise, you can keep on using addOrReplace() but stop using instaceof and start using Generics. If you need an example code-snippet of that let me know and I'll dig some out for you. On Tue, Oct 7, 2014 at 9:51 AM, Patrick Davids wrote: > Hi all, > I have a panel, which renders a inner markupcontainer (different panels > for different ways of displaying my model object) depending on its model > objects type. > > I do this by addOrReplace() the inner panel in an onConfigure() having > an "if instanceof"; and it also iterates over a list... > > I'm not sure, if it is a good solution (I dont like the instanceof > approach), but the panel works quite good for ajax rendering and > refreshing use-cases. > > But, the addOrReplace() has one big disadvantage. > It forces to detach the model on each iteration, so on each iteration I > get a database access to retrieve it again. > > Is there anyway to keep the model attached until the entire request > cycle is finished? > > > Or should I try to find complete other solution for this kind of "high > dynamic iterating panel"? > Is it better to use e.g. Fragments to display a model object in > different ways depending on its state? > > Please give some inspirations... I ran out of ideas. Help! > > kind regards :-) > Patrick > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
alternative solution for addOrReplace()?
Hi all, I have a panel, which renders a inner markupcontainer (different panels for different ways of displaying my model object) depending on its model objects type. I do this by addOrReplace() the inner panel in an onConfigure() having an "if instanceof"; and it also iterates over a list... I'm not sure, if it is a good solution (I dont like the instanceof approach), but the panel works quite good for ajax rendering and refreshing use-cases. But, the addOrReplace() has one big disadvantage. It forces to detach the model on each iteration, so on each iteration I get a database access to retrieve it again. Is there anyway to keep the model attached until the entire request cycle is finished? Or should I try to find complete other solution for this kind of "high dynamic iterating panel"? Is it better to use e.g. Fragments to display a model object in different ways depending on its state? Please give some inspirations... I ran out of ideas. Help! kind regards :-) Patrick - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org