You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Will Jaynes <ja...@mail.umms.med.umich.edu> on 2007/07/27 20:20:05 UTC

general question on dynamic pages

I'm new to Wicket and struggling a bit. I feel I may be stuck in old 
thinking of action frameworks like Struts or Spring MVC.

All of the examples I have looked at so far do all the work of creating 
and adding components for a page (or panel) in the constructor of the 
page. Are there other places where this work can be done? In a dynamic 
page, I can imagine that between the time a page class is constructed 
and when the page is displayed, there might be changes that have to be 
made. Where could this code be placed?

For example, the Pro Wicket book (around page 32) has an example of a 
Login and a Welcome page. The Welcome page constructor takes a reference 
to Login.this, so that a link back to the Login page takes you back to 
the same instance of the Login page. In this scenario, when the link is 
clicked and the response page is set to the existing Login page, where 
is the opportunity to change the Login page, if required? In Struts I 
would have the Struts action. Here, I'm not so sure.

Thanks for any info.

Will


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: general question on dynamic pages

Posted by Igor Vaynberg <ig...@gmail.com>.
how about a concrete example

-igor


On 7/30/07, Will Jaynes <ja...@mail.umms.med.umich.edu> wrote:
>
> Thanks for the reply. I appreciate the desirability of thinking more OO
> and less request/response. Even so, the Wicket Page class is still
> modeling an html page. Where is the "onBeforeLoad" functionality of a
> web page? Is "onBeforeRender" the equivalent?
>
> With regard to the Login/Welcome example, I have a problem with the
> Login's page's mutator methods being called in the onClick() in the
> Welcome page. Your scenario requires that Welcome know too much about
> Login.  If Welcome and Login depend on the same model, and Welcome
> changes the model, then when control is passed back to Login it should
> be able to act on that change without the need for Welcome to know about
> it. I don't see yet where Login has the opportunity to act on the model
> change before the page is displayed. Again, is this where
> onBeforeRender() comes in? Or some other method?
>
> Thanks, again, Will
>
> Ryan Holmes wrote:
> > I think one of the keys to getting comfortable with Wicket is to think
> > in terms of plain objects rather than requests, pages, etc. For
> > example, if you were working with a Person object rather than a Login
> > page and you wanted to provide some way of modifying that Person
> > object, you would just add a mutator method to the Person class,
> > right? Well, it's the same thing in Wicket. Just add a method to the
> > Login page class that performs whatever modifications you want. This
> > method might update the models for components on that page, change the
> > visibility of components, replace components with other components,
> > just to name a few possibilities.
> >
> > In the example you gave, this method (the Login page's mutator method)
> > would be called from the onClick() method in the Welcome page's Link,
> > just before calling setResponsePage().
> >
> > hth,
> > -Ryan
> >
> >
> > On Jul 27, 2007, at 11:20 AM, Will Jaynes wrote:
> >
> >> I'm new to Wicket and struggling a bit. I feel I may be stuck in old
> >> thinking of action frameworks like Struts or Spring MVC.
> >>
> >> All of the examples I have looked at so far do all the work of
> >> creating and adding components for a page (or panel) in the
> >> constructor of the page. Are there other places where this work can
> >> be done? In a dynamic page, I can imagine that between the time a
> >> page class is constructed and when the page is displayed, there might
> >> be changes that have to be made. Where could this code be placed?
> >>
> >> For example, the Pro Wicket book (around page 32) has an example of a
> >> Login and a Welcome page. The Welcome page constructor takes a
> >> reference to Login.this, so that a link back to the Login page takes
> >> you back to the same instance of the Login page. In this scenario,
> >> when the link is clicked and the response page is set to the existing
> >> Login page, where is the opportunity to change the Login page, if
> >> required? In Struts I would have the Struts action. Here, I'm not so
> >> sure.
> >>
> >> Thanks for any info.
> >>
> >> Will
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: general question on dynamic pages

Posted by Eelco Hillenius <ee...@gmail.com>.
> With regard to the Login/Welcome example, I have a problem with the
> Login's page's mutator methods being called in the onClick() in the
> Welcome page. Your scenario requires that Welcome know too much about
> Login.  If Welcome and Login depend on the same model, and Welcome
> changes the model, then when control is passed back to Login it should
> be able to act on that change without the need for Welcome to know about
> it. I don't see yet where Login has the opportunity to act on the model
> change before the page is displayed. Again, is this where
> onBeforeRender() comes in? Or some other method?

I don't really get what you're after tbh. You can make your components
to be completely independent. In the end, they need to function in a
page/ component hierarchy, but this doesn't have to be related to how
components work with their models.

The onAttach/ onBeforeRender methods can be used if you need to do
special preparation before the rendering starts, but if I understand
you correctly, this wouldn't be the best way to go. What you do when
constructing the page is set the initial component hierarchy, and that
hierarchy can change later on, typically through callbacks like link
clicks and form posts.

Take a good look at the wicket-examples project for inspriration, and
if you have concrete cases you struggle with, please explain in more
detail.

Eelco

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: general question on dynamic pages

Posted by Will Jaynes <ja...@mail.umms.med.umich.edu>.
Thanks for the reply. I appreciate the desirability of thinking more OO 
and less request/response. Even so, the Wicket Page class is still 
modeling an html page. Where is the "onBeforeLoad" functionality of a 
web page? Is "onBeforeRender" the equivalent?

With regard to the Login/Welcome example, I have a problem with the 
Login's page's mutator methods being called in the onClick() in the 
Welcome page. Your scenario requires that Welcome know too much about 
Login.  If Welcome and Login depend on the same model, and Welcome 
changes the model, then when control is passed back to Login it should 
be able to act on that change without the need for Welcome to know about 
it. I don't see yet where Login has the opportunity to act on the model 
change before the page is displayed. Again, is this where 
onBeforeRender() comes in? Or some other method?

Thanks, again, Will

Ryan Holmes wrote:
> I think one of the keys to getting comfortable with Wicket is to think 
> in terms of plain objects rather than requests, pages, etc. For 
> example, if you were working with a Person object rather than a Login 
> page and you wanted to provide some way of modifying that Person 
> object, you would just add a mutator method to the Person class, 
> right? Well, it's the same thing in Wicket. Just add a method to the 
> Login page class that performs whatever modifications you want. This 
> method might update the models for components on that page, change the 
> visibility of components, replace components with other components, 
> just to name a few possibilities.
>
> In the example you gave, this method (the Login page's mutator method) 
> would be called from the onClick() method in the Welcome page's Link, 
> just before calling setResponsePage().
>
> hth,
> -Ryan
>
>
> On Jul 27, 2007, at 11:20 AM, Will Jaynes wrote:
>
>> I'm new to Wicket and struggling a bit. I feel I may be stuck in old 
>> thinking of action frameworks like Struts or Spring MVC.
>>
>> All of the examples I have looked at so far do all the work of 
>> creating and adding components for a page (or panel) in the 
>> constructor of the page. Are there other places where this work can 
>> be done? In a dynamic page, I can imagine that between the time a 
>> page class is constructed and when the page is displayed, there might 
>> be changes that have to be made. Where could this code be placed?
>>
>> For example, the Pro Wicket book (around page 32) has an example of a 
>> Login and a Welcome page. The Welcome page constructor takes a 
>> reference to Login.this, so that a link back to the Login page takes 
>> you back to the same instance of the Login page. In this scenario, 
>> when the link is clicked and the response page is set to the existing 
>> Login page, where is the opportunity to change the Login page, if 
>> required? In Struts I would have the Struts action. Here, I'm not so 
>> sure.
>>
>> Thanks for any info.
>>
>> Will
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: general question on dynamic pages

Posted by Ryan Holmes <ry...@hyperstep.com>.
I think one of the keys to getting comfortable with Wicket is to  
think in terms of plain objects rather than requests, pages, etc. For  
example, if you were working with a Person object rather than a Login  
page and you wanted to provide some way of modifying that Person  
object, you would just add a mutator method to the Person class,  
right? Well, it's the same thing in Wicket. Just add a method to the  
Login page class that performs whatever modifications you want. This  
method might update the models for components on that page, change  
the visibility of components, replace components with other  
components, just to name a few possibilities.

In the example you gave, this method (the Login page's mutator  
method) would be called from the onClick() method in the Welcome  
page's Link, just before calling setResponsePage().

hth,
-Ryan


On Jul 27, 2007, at 11:20 AM, Will Jaynes wrote:

> I'm new to Wicket and struggling a bit. I feel I may be stuck in  
> old thinking of action frameworks like Struts or Spring MVC.
>
> All of the examples I have looked at so far do all the work of  
> creating and adding components for a page (or panel) in the  
> constructor of the page. Are there other places where this work can  
> be done? In a dynamic page, I can imagine that between the time a  
> page class is constructed and when the page is displayed, there  
> might be changes that have to be made. Where could this code be  
> placed?
>
> For example, the Pro Wicket book (around page 32) has an example of  
> a Login and a Welcome page. The Welcome page constructor takes a  
> reference to Login.this, so that a link back to the Login page  
> takes you back to the same instance of the Login page. In this  
> scenario, when the link is clicked and the response page is set to  
> the existing Login page, where is the opportunity to change the  
> Login page, if required? In Struts I would have the Struts action.  
> Here, I'm not so sure.
>
> Thanks for any info.
>
> Will
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org