You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by David Chang <da...@yahoo.com> on 2010/02/05 04:51:32 UTC

Fix super(new CompoundPropertyModel(this)) error in the WIA book

Hello, I am learning Wicket by reading <<Wicket in Action>>. I am using Wicket 1.4.5 and Java 6. 

On page 244, the sample code is as follows:

private int counter = 0;
public MyPage() {
  super(new CompoundPropertyModel(this));
  final Label counterLabel = new Label("counter");
  add(counterLabel);
  counterLabel.setOutputMarkupId(true);
  add(new AjaxLink("counterLabelLink")
    @Override
    public void onClick(AjaxRequestTarget target) {
    counter++;
target.addComponent(counterLabel);
}
});
}

The line has super(new CompoundPropertyModel(this)); gives a compiler error. I replaced it with the following:

super();
setDefaultModel(new CompoundPropertyModel(this));

and it works. 

My question is: 

1. Am I doing the right thing?
2. Any better or more elegant way?
3. How much of WIA remains true as far as Wicket 1.4.5 concerned?

Thanks!






      

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


Re: Fix super(new CompoundPropertyModel(this)) error in the WIA book

Posted by Andrew Lombardi <an...@mysticcoders.com>.
WiA covers 1.3, there's a wiki page that covers the differences here: http://cwiki.apache.org/WICKET/migrating-to-wicket-14.html

95% of WiA is going to work just fine though, aside from the changes mentioned in the migration link above

On Feb 4, 2010, at 7:51 PM, David Chang wrote:

> Hello, I am learning Wicket by reading <<Wicket in Action>>. I am using Wicket 1.4.5 and Java 6. 
> 
> On page 244, the sample code is as follows:
> 
> private int counter = 0;
> public MyPage() {
>  super(new CompoundPropertyModel(this));
>  final Label counterLabel = new Label("counter");
>  add(counterLabel);
>  counterLabel.setOutputMarkupId(true);
>  add(new AjaxLink("counterLabelLink")
>    @Override
>    public void onClick(AjaxRequestTarget target) {
>    counter++;
> target.addComponent(counterLabel);
> }
> });
> }
> 
> The line has super(new CompoundPropertyModel(this)); gives a compiler error. I replaced it with the following:
> 
> super();
> setDefaultModel(new CompoundPropertyModel(this));
> 
> and it works. 
> 
> My question is: 
> 
> 1. Am I doing the right thing?
> 2. Any better or more elegant way?
> 3. How much of WIA remains true as far as Wicket 1.4.5 concerned?
> 
> Thanks!
> 
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


To our success!

Mystic Coders, LLC | Code Magic | www.mysticcoders.com

ANDREW LOMBARDI | andrew@mysticcoders.com
2321 E 4th St. Ste C-128, Santa Ana CA 92705
ofc: 714-816-4488
fax: 714-782-6024
cell: 714-697-8046
linked-in: http://www.linkedin.com/in/andrewlombardi
twitter: http://www.twitter.com/kinabalu

Eco-Tip: Printing e-mails is usually a waste.

========================================================
This message is for the named person's use only. You must not, directly or indirectly, use,
 disclose, distribute, print, or copy any part of this message if you are not the intended recipient.
========================================================


Re: Fix super(new CompoundPropertyModel(this)) error in the WIA book

Posted by David Chang <da...@yahoo.com>.
Martijn,

It is so nice of you to reply to my questions. One question I have about your book:

The bottom of Page xxi says: .. from Terracotta for giving Wicket a vaiable scaling strategy.

What do you exactly mean by that? Do you mean Terracotta makes the stateful programming model less of a concern in terms of memory consumption?

Regards,
David


--- On Fri, 2/5/10, Martijn Dashorst <ma...@gmail.com> wrote:

> From: Martijn Dashorst <ma...@gmail.com>
> Subject: Re: Fix super(new CompoundPropertyModel(this)) error in the WIA book
> To: users@wicket.apache.org
> Date: Friday, February 5, 2010, 7:09 AM
> On Fri, Feb 5, 2010 at 10:16 AM,
> Wilhelmsen Tor Iver <To...@arrive.no>
> wrote:
> >>   super(new CompoundPropertyModel(this));
> >
> > This seems wrong: A call to super() cannot reference
> "this" directly or indirectly:
> >
> > JLS §8.8.7 says:
> > "It is a compile-time error for a constructor to
> directly or indirectly invoke itself through a series of one
> or more explicit constructor invocations involving this."
> 
> Yup, this is a bug in the book's example code. Has nothing
> to do with
> 1.3 or 1.4.
> 
> And yes, the book is still valid apart from the model
> changes. My
> guess is that 1.5 will invalidate a bit more, but not too
> much. Mostly
> the part about page mounting and nice URLs will change. The
> internal
> request processing implementation is completely rewritten,
> but that
> should be transparent to the most of us (and was not
> covered in the
> book). The same goes for Wicket Ajax: completely
> rewritten,
> transparent for most users.
> 
> Martijn
> 
> ---------------------------------------------------------------------
> 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: Fix super(new CompoundPropertyModel(this)) error in the WIA book

Posted by Riyad Kalla <rk...@gmail.com>.
As someone working his way through WIA as well, will there be another wiki
entry showing differences between book and 1.5? (I'm fairly interested in
page mounting and nice URLs as well).

-- also I realize the cost to constantly maintain book diffs by the authors
is high, but just wanted to ask incase there were plans for it.

-R

On Fri, Feb 5, 2010 at 5:09 AM, Martijn Dashorst <martijn.dashorst@gmail.com
> wrote:

> On Fri, Feb 5, 2010 at 10:16 AM, Wilhelmsen Tor Iver <To...@arrive.no>
> wrote:
> >>   super(new CompoundPropertyModel(this));
> >
> > This seems wrong: A call to super() cannot reference "this" directly or
> indirectly:
> >
> > JLS §8.8.7 says:
> > "It is a compile-time error for a constructor to directly or indirectly
> invoke itself through a series of one or more explicit constructor
> invocations involving this."
>
> Yup, this is a bug in the book's example code. Has nothing to do with
> 1.3 or 1.4.
>
> And yes, the book is still valid apart from the model changes. My
> guess is that 1.5 will invalidate a bit more, but not too much. Mostly
> the part about page mounting and nice URLs will change. The internal
> request processing implementation is completely rewritten, but that
> should be transparent to the most of us (and was not covered in the
> book). The same goes for Wicket Ajax: completely rewritten,
> transparent for most users.
>
> Martijn
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Fix super(new CompoundPropertyModel(this)) error in the WIA book

Posted by Martijn Dashorst <ma...@gmail.com>.
On Fri, Feb 5, 2010 at 10:16 AM, Wilhelmsen Tor Iver <To...@arrive.no> wrote:
>>   super(new CompoundPropertyModel(this));
>
> This seems wrong: A call to super() cannot reference "this" directly or indirectly:
>
> JLS §8.8.7 says:
> "It is a compile-time error for a constructor to directly or indirectly invoke itself through a series of one or more explicit constructor invocations involving this."

Yup, this is a bug in the book's example code. Has nothing to do with
1.3 or 1.4.

And yes, the book is still valid apart from the model changes. My
guess is that 1.5 will invalidate a bit more, but not too much. Mostly
the part about page mounting and nice URLs will change. The internal
request processing implementation is completely rewritten, but that
should be transparent to the most of us (and was not covered in the
book). The same goes for Wicket Ajax: completely rewritten,
transparent for most users.

Martijn

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


SV: Fix super(new CompoundPropertyModel(this)) error in the WIA book

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
>   super(new CompoundPropertyModel(this));

This seems wrong: A call to super() cannot reference "this" directly or indirectly:

JLS §8.8.7 says:
"It is a compile-time error for a constructor to directly or indirectly invoke itself through a series of one or more explicit constructor invocations involving this."

- Tor Iver

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