Hello all,
I try to explain my question using sourcecode ;)
Imagine:
MyTemplate.java
public abstract class MyTemplate extends WebPage {
public MyTemplate() {
add(new MyPanel("myPanel"));
}
}
MyTemplate.html
<body>
<wicket:child/>
</body>
MyPage.java (html is trivial, using wicket:extend)
public class MyPage extends MyTemplate {
...
}
MyPanel.java
public class MyPanel extends Panel {
public MyPanel() {
// THIS PANEL IS RECONSTRUCTED ON EACH MyPage REQUEST
// BECAUSE MyPageTemplate DOES A new MyPanel...
}
}
What could I do to use the old panel again? Do I really have to care about
the panel object reference by myself, i.e. store is to the user session,
check if it is there, if yes then retrieve, if not the do a new, etc.? I
don't have to, do I? The Panel is in the wicket session anyway, and the user
session would grow too much, leasing to the StackOverflowError I already had
...
I hope you can help me, thanks in advance :)
Kind regards,
Bernd
Icy wrote:
>
>
>
> Al Maw-2 wrote:
>>
>> Icy wrote:
>>> *** What is the "best practise" to not instanciate "page aggregating
>>> panels"
>>> all the time? ***
>>
>> This isn't really a Wicket question.
>>
>> Your page is slow because doing database/remote operations is slow. It
>> has nothing to do with creating Panels, but everything to do with the
>> database access you're doing in the constructor of those Panels.
>>
>> You need to break those operations out into a service layer that can
>> cache the results, then use that service layer in your constructor.
>>
>> Regards,
>>
>> Al
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>
> Heyho again, Al, and all,
>
> as with Spring it's not that easy to do what I wanted, because singleton
> beans are instanciated only once for ALL users, and prototype beans are
> instanciated on every request, which is too often, the natural target for
> storing sinlgeton references to objects for a user is the SESSION again...
> so I tried this.
>
> First question: I just wanted to put a wicket stuff GMap2 instance into
> the session, and got a java.lang.StackOverflowError. Is it possible to
> increase the stack size?
>
> Second question: Even if this works to construct GMap, etc. only once when
> the session is created, and add these components to a Panel on request,
> then still I have a common problem understanding the following:
>
> The special cool thing about Wicket is that components keep their state.
> If I have to instanciate all Panels again each time a page is requested,
> they for sure always loose their state - they are new. If I put everything
> in the session, to keep the state manually, then it will probably work,
> but that's old fashioned Web programming ;) Doesn't Wicket offer me the
> possibility to e.g. let a user scroll around in the Google Map Panel, and
> the scrolling position always remains the same on each page request? What
> about the cool Wicket Model approach, the Desktop App programming
> experience? What do I have to do to maintain Panels state?
>
> Please, explain this to me, it's a very very basic question for me, to
> understand the "magic" of the Wicket approach.
>
> Kind regards,
> Icy
>
>
>
>
--
View this message in context:
http://www.nabble.com/How-to-instanciate-panels-best--tf4855189.html#a13900134
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]