You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by MG...@escholar.com on 2010/05/20 20:57:08 UTC

PageLink binding

Hi all,

        I have a 

@Bindable protected PageLink refreshImage = new PageLink("Refresh", 
ThisClass.class);

but when I reference $refreshImage in the velocity template.  It prints 
out "$refreshImage".  I have other stuff that is @Bindable protected in 
the same class and it renders fine on the same template.  Is there a bug 
with PageLinks?

Thanks.
-Mike

Re: PageLink binding

Posted by Bob Schellink <sa...@gmail.com>.
Hi Mike,

On 22/05/2010 00:22, MGargano@escholar.com wrote:
> 
> no, wait... sorry.  i just read that again.  i'm confused again.
>  doesn't the binding use reflection to find the ivar names and use that
> to do the binding?  why would PageLink bind on a name in an object it's
> pointing to?  when i create a new Table the binding happens to the ivar,
> not some name i give the Table.  what am i missing here?

Binding should happen on the name of the Table if it is defined.

Its worth pointing out that autobinding does not add any special feature but simply streamlines the
process of defining the control name (if no name is defined on the control) and adding the control
to the page control list.

Have a look at the doco here, especially the second example which shows what happens "behind the
scenes":

http://click.apache.org/docs/user-guide/html/ch04s02.html#application-autobinding

What is not clear from the docs is that if the control name is defined, autobinding won't change it,
but simply add it to the page control list eg:

  public PageLink link = new PageLink("blah", SomePage.class);

  addControl(link);

If the name was not defined autobinding will set the name to the ivar name:

  public PageLink link = new PageLink();

  link.setName("link");
  addControl(link);

Hope that helps.

Kind regards

Bob

Re: PageLink binding

Posted by MG...@escholar.com.
no, wait... sorry.  i just read that again.  i'm confused again.  doesn't 
the binding use reflection to find the ivar names and use that to do the 
binding?  why would PageLink bind on a name in an object it's pointing to? 
 when i create a new Table the binding happens to the ivar, not some name 
i give the Table.  what am i missing here?

thanks again and sorry for my earlier misinterpretation.
-mike



From:
MGargano@escholar.com
To:
user@click.apache.org
Date:
05/21/2010 10:00 AM
Subject:
Re: PageLink binding




oh, so this is a lifecycle thing.  gotcha.  thanks. 

-mike 


From: 
Bob Schellink <sa...@gmail.com> 
To: 
user@click.apache.org 
Date: 
05/20/2010 06:28 PM 
Subject: 
Re: PageLink binding




Hi Mike,

On 21/05/2010 04:57, MGargano@escholar.com wrote:
> 
> @Bindable protected PageLink refreshImage = new PageLink("Refresh",
> ThisClass.class);
> 
> but when I reference $refreshImage in the velocity template.  It prints
> out "$refreshImage".  I have other stuff that is @Bindable protected in
> the same class and it renders fine on the same template.  Is there a bug
> with PageLinks?


The Velocity reference should be the same as the name of the control, in 
this case $Refresh. Binding
will set the Control name only if the Control has no name defined. In 
other words you could have
used $refreshImage if you did the following:

 @Bindable protected PageLink refreshImage = new PageLink();

Binding will detect that the PageLink has no name defined and set it 
automatically to the name of
the field, which translates to:

 refreshImage.setName("refreshImage");

I'll add this to the doco which isn't very clear on this issue.

Kind regards

Bob




Re: PageLink binding

Posted by MG...@escholar.com.
oh, so this is a lifecycle thing.  gotcha.  thanks.

-mike



From:
Bob Schellink <sa...@gmail.com>
To:
user@click.apache.org
Date:
05/20/2010 06:28 PM
Subject:
Re: PageLink binding



Hi Mike,

On 21/05/2010 04:57, MGargano@escholar.com wrote:
> 
> @Bindable protected PageLink refreshImage = new PageLink("Refresh",
> ThisClass.class);
> 
> but when I reference $refreshImage in the velocity template.  It prints
> out "$refreshImage".  I have other stuff that is @Bindable protected in
> the same class and it renders fine on the same template.  Is there a bug
> with PageLinks?


The Velocity reference should be the same as the name of the control, in 
this case $Refresh. Binding
will set the Control name only if the Control has no name defined. In 
other words you could have
used $refreshImage if you did the following:

  @Bindable protected PageLink refreshImage = new PageLink();

Binding will detect that the PageLink has no name defined and set it 
automatically to the name of
the field, which translates to:

  refreshImage.setName("refreshImage");

I'll add this to the doco which isn't very clear on this issue.

Kind regards

Bob



Re: PageLink binding

Posted by Bob Schellink <sa...@gmail.com>.
Hi Mike,

On 21/05/2010 04:57, MGargano@escholar.com wrote:
> 
> @Bindable protected PageLink refreshImage = new PageLink("Refresh",
> ThisClass.class);
> 
> but when I reference $refreshImage in the velocity template.  It prints
> out "$refreshImage".  I have other stuff that is @Bindable protected in
> the same class and it renders fine on the same template.  Is there a bug
> with PageLinks?


The Velocity reference should be the same as the name of the control, in this case $Refresh. Binding
will set the Control name only if the Control has no name defined. In other words you could have
used $refreshImage if you did the following:

  @Bindable protected PageLink refreshImage = new PageLink();

Binding will detect that the PageLink has no name defined and set it automatically to the name of
the field, which translates to:

  refreshImage.setName("refreshImage");

I'll add this to the doco which isn't very clear on this issue.

Kind regards

Bob