here is a simple example

the user is on the BookDetails page. the book details has a tabbed view that lets user tab through general/about author/reviews/comments tabs.

the user logs in and views details about book 2 - so you get the singleton page, set book id to 2, and show it to the user

the user clicks on the reviews tab

then the user goes back to the list of books and clicks on book 3 - so you get the singleton page, set book id to 3, and show it to the user

but now the user will be on the reviews tab instead of starting off on book details tab because while they were viewing book 2 they switched the tabbed view to show the reviews tab - and that state is kept in the component hiearchy.

so in order for it to function you have to:
get the singleton
set the book id
restore the tabbed view to first tab
show the page

and as the page gets more and more complex you will have more and more of these restore things you have to do

much easier to create a new instance

-Igor


On 5/8/06, ali <[EMAIL PROTECTED] > wrote:
On Sun, 07 May 2006 10:38:53 +0430, Igor Vaynberg
< [EMAIL PROTECTED]> wrote:

i return to first post :

      2- if a user view/edit 4 book in its session , for him/her created 4
BookDetails and 4 EditBook page object.(why this needed)

i can not understand "why this needed ?"

in mailing list , see that one of core developers told wicket pages
'component tree suppose dynamically chnaged/replaced , do this feature is
response to above FAQ.

if i will NOT want in this use case use this feature , what I do ?

OR i am still new in wicket and am iimmediately for tell ideas bring to my
head , please guide me in this problem

> you still havent explained exactly what the point is? and what you want
> to
> do is easily achieved.
>
> create your own page factory that keeps a map:class->instance in the
> session
> object, that way wicket will always use that singleton instance whenever
> you
> do things like setResponsePage(Blah.class)
>
> also never create a page using the new operator, always do it through the
> pagefactory.
>
> and there you go.
>
> i still dont see any advantages, only disadvantages, but the usecase can
> be
> easily implemented nontheless.
>
> -Igor
>
>
> On 5/6/06, ali <[EMAIL PROTECTED]> wrote:
>>
>> sorry for come late.
>> but i talk about singleton page in level of session/user and not in
>> level
>> application
>>
>> user1 has one and only one instance of page A
>> user2 has one and only one instance of page A (not equals with page of
>> user1)
>> ==========
>> On Tue, 21 Mar 2006 12:11:45 +0430, Martijn Dashorst
>> <[EMAIL PROTECTED]> wrote:
>>
>> > You probably can manage to make the page a singleton, but I strongly
>> > discourage you from trying.
>> >
>> > You are in a multithreaded environment. Wicket pages are stateful,
>> which
>> > means you can't safely share them across threads. As a consequence a
>> page
>> > can not be shared between sessions, and that is what you do when you
>> > build a
>> > singleton.
>> > When you let Wicket 'manage' your pages, i.e. you just create pages on
>> > the
>> > fly, you won't run into multithreading problems. Wicket will
>> synchronize
>> > for
>> > each session on the session with an incoming request. So per user you
>> > won't
>> > have threading issues.
>> >
>> > I can't think of any web framework that supports this way of working,
>> > perhaps the action oriented frameworks (webwork, struts). Wicket is
>> not
>> > like
>> > that. Wicket creates statefull pages and components, which means they
>> > cannot
>> > be shared between threads at the same time. Even Tapestry doesn't
>> support
>> > singletons, but uses page pooling. And because of that, they had to
>> > create
>> > some magic to make the pages loose their state when the page is put
>> back
>> > into the pool.
>> >
>> > If you are /that/ concerned with memory, then you probably shouldn't
>> use
>> > Wicket. Not because we don't think Wicket is up for the task, but I
>> think
>> > you'd have more fun with Tapestry or another framework that let's you
>> > work
>> > the way you want.
>> >
>> > Martijn
>> >
>> >
>> > On 3/21/06, ali <[EMAIL PROTECTED]> wrote:
>> >>
>> >> On Tue, 21 Mar 2006 04:47:13 +0530, Martijn Dashorst
>> >> <[EMAIL PROTECTED]> wrote:
>> >>
>> >> i want suppose can EditBook be is singleton .
>> >>
>> >> > new Link("editLink") {
>> >> >     protected void onClick() {
>> >> >         Book book = (Book)getParent().getModelObject();
>> >> >         setResponsePage(new EditBook(book));
>> >> >     }
>> >> > }
>> >> >
>> >> > Should work.
>> >> >
>> >> > Martijn
>> >> >
>> >> > On 3/20/06, ali < [EMAIL PROTECTED]> wrote:
>> >> >>
>> >> >> On Mon, 20 Mar 2006 14:18:48 +0530, Johan Compagner
>> >> >> < [EMAIL PROTECTED]>
>> >> >> wrote:
>> >> >> can i do like :
>> >> >>
>> >> >> class BookList extends WebPage {
>> >> >>
>> >> >>         public BookList() {
>> >> >>
>> >> >>                 add(new ListView("booksList", booksList){
>> >> >>
>> >> >>                         public void populateItem(ListItem item) {
>> >> >>
>> >> >>                                 add(new Link("editLink") {
>> >> >>                                         EditBook page =
>> >> >> EditBook.getInstance();
>> >> >>                                         page.setModel (new
>> >> >> CompoundPropertyModel(item.getModelObject ())); //or
>> >> >> line also move to page
>> >> >>                                         setResponsePage(page);
>> >> >>                         }
>> >> >>                 });
>> >> >>         }
>> >> >> }
>> >> >>
>> >> >> if i can do this then what effects do it put in on end-user of
>> app?
>> >> >>
>> >> >> > you can reuse pages just fine for one session ofcourse if you
>> want.
>> >> >> >
>> >> >> > So in youre BookList you hold on to an internal page BookDetails
>> or
>> >> >> > EditBook
>> >> >> > page
>> >> >> > And when you click on a view/edit link you just reuse that page.
>> >> >> >
>> >> >> > I wouldn't share pages across sessions.
>> >> >> >
>> >> >> > johan
>> >> >> >
>> >> >> >
>> >> >> > On 3/20/06, ali <[EMAIL PROTECTED]> wrote:
>> >> >> >>
>> >> >> >> i am new in wicket , it's correct that we tell
>> >> >> >>
>> >> >> >> 1- always use getPageFactory.newPage() instead "new".
>> >> >> >>
>> >> >> >> 2- if a user view/edit 4 book in its session , for him/her
>> >> created 4
>> >> >> >> BookDetails and 4 EditBook page object.(why this needed)
>> >> >> >>
>> >> >> >> do we can define page be singleton in level of handler thread
>> or
>> >> >> session
>> >> >> >> (i remember ThreadLocal)? so that like swing only once EditBook
>> or
>> >> >> >> BookDetails pages instanced and for next book only needed that
>> >> call
>> >> >> on
>> >> >> >> them setBook(booK);
>> >> >> >>
>> >> >> >> refrence to these pages can keep in session and also they can
>> >> >> >>
>> >> >> >> or maybe i must more read examples and docs
>> >> >> >>
>> >> >> >> --
>> >> >> >> Using Opera's revolutionary e-mail client:
>> >> http://www.opera.com/mail/
>> >> >> >>
>> >> >> >>
>> >> >> >> -------------------------------------------------------
>> >> >> >> This SF.Net email is sponsored by xPML, a groundbreaking
>> scripting
>> >> >> >> language
>> >> >> >> that extends applications into web and mobile media. Attend the
>> >> live
>> >> >> >> webcast
>> >> >> >> and join the prime developer group breaking into this new
>> coding
>> >> >> >> territory!
>> >> >> >>
>> >> >>
>> >>
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>> >>
>> >> >> >> _______________________________________________
>> >> >> >> Wicket-user mailing list
>> >> >> >> Wicket-user@lists.sourceforge.net
>> >> >> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> Using Opera's revolutionary e-mail client:
>> http://www.opera.com/mail/
>> >> >>
>> >> >>
>> >> >> -------------------------------------------------------
>> >> >> This SF.Net email is sponsored by xPML, a groundbreaking scripting
>> >> >> language
>> >> >> that extends applications into web and mobile media. Attend the
>> live
>> >> >> webcast
>> >> >> and join the prime developer group breaking into this new coding
>> >> >> territory!
>> >> >>
>> >>
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>> >> >> _______________________________________________
>> >> >> Wicket-user mailing list
>> >> >> Wicket-user@lists.sourceforge.net
>> >> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Cast your final vote for Wicket in the SourceForge.net 2006
>> Community
>> >> > Choice
>> >> > Awards!
>> >> > http://www.wilsonresearch.com/2006/ostgawards06/ostgawards4.php
>> >>
>> >>
>> >>
>> >> --
>> >> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
>> >>
>> >>
>> >> -------------------------------------------------------
>> >> This SF.Net email is sponsored by xPML, a groundbreaking scripting
>> >> language
>> >> that extends applications into web and mobile media. Attend the live
>> >> webcast
>> >> and join the prime developer group breaking into this new coding
>> >> territory!
>> >>
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
>> >> _______________________________________________
>> >> Wicket-user mailing list
>> >> Wicket-user@lists.sourceforge.net
>> >> https://lists.sourceforge.net/lists/listinfo/wicket-user
>> >>
>> >
>> >
>> >
>> > --
>> > Cast your final vote for Wicket in the SourceForge.net 2006 Community
>> > Choice
>> > Awards!
>> > http://www.wilsonresearch.com/2006/ostgawards06/ostgawards4.php
>>
>>
>>
>> --
>> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
>>
>>
>> -------------------------------------------------------
>> 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?cmdlnk&kid0709&bid&3057&dat1642
>> _______________________________________________
>> Wicket-user mailing list
>> Wicket-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wicket-user
>>



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


-------------------------------------------------------
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?cmdlnk&kid0709&bid&3057&dat1642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to