You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Doug Donohoe <do...@donohoe.info> on 2008/05/07 23:40:41 UTC

Wicket 1.4 and generics

I'm just now using 1.4.  What type of thing is expected for T in WebPage<T> ?

It looks like what your model object is.  But if your page doesn't use
models (perhaps just it's children do), is the correct thing to do this?

class MyPage extends WebPage

I have lots of 'unchecked' and 'raw use' warnings now, so I'd like to know
what the recommended approach is.

Thanks,

-Doug
-- 
View this message in context: http://www.nabble.com/Wicket-1.4-and-generics-tp17115357p17115357.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Ajax and Loop

Posted by Eelco Hillenius <ee...@gmail.com>.
>  I have a Loop on my page (creates Components from a List ot Objects).
>  Now I have an AjaxFallbackLink on my page. This link adds an Object to
>  my List and as a reaction to this action I want my Loop to be repainted
>  (showing the new object). What must I do? A simple
>  "target.addComponent(Loop.getParent())" has no effect.
>  The Components of the loop are created in the Constructor of the Loop's
>  parent. Do I have to overwrite some "beforeRender" methods? Of course, I
>  took a look at the Wicket In Action book and the Wiki and the List but I
>  did not find a hint. Can anybody help me?

Repainting the loop won't have an effect because it is still the same
instance. If you want to keep using Loop, you'll have to replace it
with a new instance so that it will populate it's child components
based on the model now. Or use RefreshingView (consider using
ReuseIfModelsEqualStrategy if in a form) or ListView with reuseItems
== false.

Eelco

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


Re: Ajax and Loop

Posted by Stefan Lindner <li...@visionet.de>.
Thank you! The ListView did the trick! 

-----Ursprüngliche Nachricht-----
Von: Eelco Hillenius [mailto:eelco.hillenius@gmail.com] 
Gesendet: Donnerstag, 8. Mai 2008 00:35
An: users@wicket.apache.org; jeremy@thomersonfamily.com
Betreff: Re: Ajax and Loop

> Have you tried using a ListView in combination with a model (rather than passing a List to the constructor of ListView)?

That won't trigger a re-population of the child components (ListItem and everything you add to it). For that, you need to call setReuseItems(false). Note that this can cause problems in forms (particularly with updating feedback), so when using forms, things like RefreshingView are often preferable.

Eelco

---------------------------------------------------------------------
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: Ajax and Loop

Posted by Eelco Hillenius <ee...@gmail.com>.
> Have you tried using a ListView in combination with a model (rather than passing a List to the constructor of ListView)?

That won't trigger a re-population of the child components (ListItem
and everything you add to it). For that, you need to call
setReuseItems(false). Note that this can cause problems in forms
(particularly with updating feedback), so when using forms, things
like RefreshingView are often preferable.

Eelco

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


Re: Ajax and Loop

Posted by Jeremy Thomerson <je...@thomersonfamily.com>.
Hrmm...  I suspect that somewhere one of your components is holding on to a
copy of the list, and isn't modified.  Have you tried using a model, shared
between the component you want to refresh and the link that will modify the
list?  If the link modifies the list, then the component that has the same
model is added to the ajax target, it should know that the underlying list
has changed.  I shy away from any constructor that takes a list directly for
this reason - I'd rather have a model, and then use it any place that needs
access to that list.

BTW - With ListView, it would be real easy to make table rows....

add(new ListView<Foo>("list", new PropertyModel(myObject, "myListOfStuff"))
{
populateItem(ListItem<Foo> item) ....
});

HTML:
<table class="foo">
 <tr wicket:id="list">
  <td><span wicket:id="someLabelYouAddedToListItem"></span></td>
  <td><a wicket:id="someLinkYouAddedToListItem">click me</a></td>
 </tr>
</table>

Jeremy Thomerson
http://www.wickettraining.com

On Wed, May 7, 2008 at 5:21 PM, Stefan Lindner <li...@visionet.de> wrote:

> The Loop fills the rows of a table. I have no idea how a ListView can
> generate the <tr><td>..</td></tr> structure of a table. The examlpe code
> would be a little bit complex because I use Scriptaculous (self compiled for
> wicket 1.4 enriched by generics)). After a drag operation into a table
> (generated gy a Loop) I want to redraw the table (now having one more
> Component).
> I tried to investigate in the code of a Refreshing View (DataGrid), that
> supports this functionalits (add a line to a table, add the table to the
> AjaxRequestTarget and see a new line in the table) but I did not find a
> hint.
>
> Stefan
>
> -----Ursprüngliche Nachricht-----
> Von: jeremythomerson@gmail.com [mailto:jeremythomerson@gmail.com] Im
> Auftrag von Jeremy Thomerson
> Gesendet: Donnerstag, 8. Mai 2008 00:07
> An: users@wicket.apache.org
> Betreff: Re: Ajax and Loop
>
> Can you paste some code?  Have you tried using a ListView in combination
> with a model (rather than passing a List to the constructor of ListView)?
>
> Jeremy Thomerson
> http://www.wickettraining.com
>
> On Wed, May 7, 2008 at 4:55 PM, Stefan Lindner <li...@visionet.de>
> wrote:
>
> > Dear wicket wizzards,
> >
> > I have a Loop on my page (creates Components from a List ot Objects).
> > Now I have an AjaxFallbackLink on my page. This link adds an Object to
> > my List and as a reaction to this action I want my Loop to be
> > repainted (showing the new object). What must I do? A simple
> > "target.addComponent(Loop.getParent())" has no effect.
> > The Components of the loop are created in the Constructor of the
> > Loop's parent. Do I have to overwrite some "beforeRender" methods? Of
> > course, I took a look at the Wicket In Action book and the Wiki and
> > the List but I did not find a hint. Can anybody help me?
> >
> > Stefan
> >
> > ---------------------------------------------------------------------
> > 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: Ajax and Loop

Posted by Stefan Lindner <li...@visionet.de>.
The Loop fills the rows of a table. I have no idea how a ListView can generate the <tr><td>..</td></tr> structure of a table. The examlpe code would be a little bit complex because I use Scriptaculous (self compiled for wicket 1.4 enriched by generics)). After a drag operation into a table (generated gy a Loop) I want to redraw the table (now having one more Component).
I tried to investigate in the code of a Refreshing View (DataGrid), that supports this functionalits (add a line to a table, add the table to the AjaxRequestTarget and see a new line in the table) but I did not find a hint.

Stefan

-----Ursprüngliche Nachricht-----
Von: jeremythomerson@gmail.com [mailto:jeremythomerson@gmail.com] Im Auftrag von Jeremy Thomerson
Gesendet: Donnerstag, 8. Mai 2008 00:07
An: users@wicket.apache.org
Betreff: Re: Ajax and Loop

Can you paste some code?  Have you tried using a ListView in combination with a model (rather than passing a List to the constructor of ListView)?

Jeremy Thomerson
http://www.wickettraining.com

On Wed, May 7, 2008 at 4:55 PM, Stefan Lindner <li...@visionet.de> wrote:

> Dear wicket wizzards,
>
> I have a Loop on my page (creates Components from a List ot Objects).
> Now I have an AjaxFallbackLink on my page. This link adds an Object to 
> my List and as a reaction to this action I want my Loop to be 
> repainted (showing the new object). What must I do? A simple 
> "target.addComponent(Loop.getParent())" has no effect.
> The Components of the loop are created in the Constructor of the 
> Loop's parent. Do I have to overwrite some "beforeRender" methods? Of 
> course, I took a look at the Wicket In Action book and the Wiki and 
> the List but I did not find a hint. Can anybody help me?
>
> Stefan
>
> ---------------------------------------------------------------------
> 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: Ajax and Loop

Posted by Jeremy Thomerson <je...@thomersonfamily.com>.
Can you paste some code?  Have you tried using a ListView in combination
with a model (rather than passing a List to the constructor of ListView)?

Jeremy Thomerson
http://www.wickettraining.com

On Wed, May 7, 2008 at 4:55 PM, Stefan Lindner <li...@visionet.de> wrote:

> Dear wicket wizzards,
>
> I have a Loop on my page (creates Components from a List ot Objects).
> Now I have an AjaxFallbackLink on my page. This link adds an Object to
> my List and as a reaction to this action I want my Loop to be repainted
> (showing the new object). What must I do? A simple
> "target.addComponent(Loop.getParent())" has no effect.
> The Components of the loop are created in the Constructor of the Loop's
> parent. Do I have to overwrite some "beforeRender" methods? Of course, I
> took a look at the Wicket In Action book and the Wiki and the List but I
> did not find a hint. Can anybody help me?
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Ajax and Loop

Posted by Stefan Lindner <li...@visionet.de>.
Dear wicket wizzards,

I have a Loop on my page (creates Components from a List ot Objects).
Now I have an AjaxFallbackLink on my page. This link adds an Object to
my List and as a reaction to this action I want my Loop to be repainted
(showing the new object). What must I do? A simple
"target.addComponent(Loop.getParent())" has no effect.
The Components of the loop are created in the Constructor of the Loop's
parent. Do I have to overwrite some "beforeRender" methods? Of course, I
took a look at the Wicket In Action book and the Wiki and the List but I
did not find a hint. Can anybody help me?

Stefan

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


Re: Wicket 1.4 and generics

Posted by Jeremy Thomerson <je...@thomersonfamily.com>.
You are correct, WebPage<T> is for the model type of your page.  This allows
you to do MyObject getObject(), etc.  I, too, am trying to deal with all of
the generics warnings right now and figure out what my strategy will be for
pages without a model.

One suggestion that has been made on the list is for a page that does not
use a model is to use Void, like this:

class MyPage extends WebPage<Void>

Jeremy Thomerson
http://www.wickettraining.com

On Wed, May 7, 2008 at 4:40 PM, Doug Donohoe <do...@donohoe.info> wrote:

>
> I'm just now using 1.4.  What type of thing is expected for T in
> WebPage<T> ?
>
> It looks like what your model object is.  But if your page doesn't use
> models (perhaps just it's children do), is the correct thing to do this?
>
> class MyPage extends WebPage
>
> I have lots of 'unchecked' and 'raw use' warnings now, so I'd like to know
> what the recommended approach is.
>
> Thanks,
>
> -Doug
> --
> View this message in context:
> http://www.nabble.com/Wicket-1.4-and-generics-tp17115357p17115357.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wicket 1.4 and generics

Posted by Doug Donohoe <do...@donohoe.info>.
HTML gobbled my &lt;Object> in that last message ... my proposed example was:

class MyPage extends WebPage&lt;Object>



Doug Donohoe wrote:
> 
> I'm just now using 1.4.  What type of thing is expected for T in
> WebPage<T> ?
> 
> It looks like what your model object is.  But if your page doesn't use
> models (perhaps just it's children do), is the correct thing to do this?
> 
> class MyPage extends WebPage
> 
> I have lots of 'unchecked' and 'raw use' warnings now, so I'd like to know
> what the recommended approach is.
> 
> Thanks,
> 
> -Doug
> 

-- 
View this message in context: http://www.nabble.com/Wicket-1.4-and-generics-tp17115357p17115478.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Wicket 1.4 and generics

Posted by Matej Knopp <ma...@gmail.com>.
I usually just use <Object> in such case.

-Matej

On Wed, May 7, 2008 at 11:40 PM, Doug Donohoe <do...@donohoe.info> wrote:
>
>  I'm just now using 1.4.  What type of thing is expected for T in WebPage<T> ?
>
>  It looks like what your model object is.  But if your page doesn't use
>  models (perhaps just it's children do), is the correct thing to do this?
>
>  class MyPage extends WebPage
>
>  I have lots of 'unchecked' and 'raw use' warnings now, so I'd like to know
>  what the recommended approach is.
>
>  Thanks,
>
>  -Doug
>  --
>  View this message in context: http://www.nabble.com/Wicket-1.4-and-generics-tp17115357p17115357.html
>  Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Resizable and reorderable grid components.
http://www.inmethod.com

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