You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by V SANTOSH PAVAN RAJU BS <pa...@gmail.com> on 2012/01/06 08:59:22 UTC

Question regarding listeners

Hi,
Is there any listeners that can be used to execute some block of code at
initialization time.
For example, buttonPressListeners  execute a block of code when that
corresponding button was clicked.
But, i want to execute a block of code that should run at initialization
time only, without any event occurs.

I wrote some code to do this.

this.getComponentClassListeners().add(new ComponentClassListener() {
 @Override
public void focusedComponentChanged(Component component) {
 custIdTest = WindowContext.getCustomerId(AccountInformationPane.this);
System.out.println(custIdTest);
 }
});

Here i tried to get a value from other class which is WindowContext in to
AccountInformationPane class which extends BoxPane.
System.out.println(custIdTest); this statement was executed infinitely......

So is there any other way to do this?
-- 
Thanks & Regards
B.S.V.S.Pavan Raju.
Skype: skype_pavan1
Hyderabad.

Re: Question regarding listeners

Posted by Chris Bartlett <cb...@gmail.com>.
As Mark said, this is what the Bindable interface is for when
deserializing BXML using BXMLSerializer.
http://pivot.apache.org/tutorials/bxml-primer.htmlhttp://pivot.apache.org/2.0/docs/api/org/apache/pivot/beans/Bindable.html
http://pivot.apache.org/2.0/docs/api/org/apache/pivot/beans/BXMLSerializer.html
If you are not using BXMLSerializer, but perhaps building the
Component graph manually, you would just need to keep references to
any object which you wish to initialize, and then call that code at
the appropriate point in your application's lifecycle.
Chris

On 6 January 2012 09:16, Mark Dodgson <ma...@googlemail.com> wrote:
> Hi,
>
> I am very new to pivot/java (started yesterday) so might be totally wrong,
> but I came accross the example on the pivot website which sounds like what
> you are after.
>
> http://pivot.apache.org/tutorials/push-buttons.html
>
> Implementing bindable provides an initialize method that is called once on
> startup
>
> Regards,
>
> Doddi
>
>
> On 6 January 2012 07:59, V SANTOSH PAVAN RAJU BS <pa...@gmail.com>
> wrote:
>>
>> Hi,
>> Is there any listeners that can be used to execute some block of code at
>> initialization time.
>> For example, buttonPressListeners  execute a block of code when that
>> corresponding button was clicked.
>> But, i want to execute a block of code that should run at initialization
>> time only, without any event occurs.
>>
>> I wrote some code to do this.
>>
>> this.getComponentClassListeners().add(new ComponentClassListener() {
>> @Override
>> public void focusedComponentChanged(Component component) {
>> custIdTest = WindowContext.getCustomerId(AccountInformationPane.this);
>> System.out.println(custIdTest);
>> }
>> });
>>
>> Here i tried to get a value from other class which is WindowContext in to
>> AccountInformationPane class which extends BoxPane.
>> System.out.println(custIdTest); this statement was executed
>> infinitely......
>>
>> So is there any other way to do this?
>> --
>> Thanks & Regards
>> B.S.V.S.Pavan Raju.
>> Skype: skype_pavan1
>> Hyderabad.
>>
>

Re: Question regarding listeners

Posted by Chris Bartlett <cb...@gmail.com>.
On 6 January 2012 09:16, Mark Dodgson <ma...@googlemail.com> wrote:
> I am very new to pivot/java (started yesterday) so might be totally wrong,
> but I came accross the example on the pivot website which sounds like what
> you are after.


Mark,

Thanks for contributing to the list so early on, it is much
appreciated.  Feel free to ask any questions of your own on the
mailing lists.
FYI we hope to begin the 2.0.1 release process very soon. There are
lots of little bug fixes and enhancements, but no major differences
from 2.0.

If you are just starting, you might want to get the latest Pivot
source from the Subversion repository, build it and start working with
those JARs.  You shouldn't experience any big problems switching from
2.0 to 2.01 in any case, so it is your choice.
http://pivot.apache.org/svn.html
Chris

Re: Question regarding listeners

Posted by Mark Dodgson <ma...@googlemail.com>.
Hi,

I am very new to pivot/java (started yesterday) so might be totally wrong,
but I came accross the example on the pivot website which sounds like what
you are after.

http://pivot.apache.org/tutorials/push-buttons.html

Implementing bindable provides an initialize method that is called once on
startup

Regards,

Doddi

On 6 January 2012 07:59, V SANTOSH PAVAN RAJU BS <pa...@gmail.com>wrote:

> Hi,
> Is there any listeners that can be used to execute some block of code at
> initialization time.
> For example, buttonPressListeners  execute a block of code when that
> corresponding button was clicked.
> But, i want to execute a block of code that should run at initialization
> time only, without any event occurs.
>
> I wrote some code to do this.
>
> this.getComponentClassListeners().add(new ComponentClassListener() {
>  @Override
> public void focusedComponentChanged(Component component) {
>  custIdTest = WindowContext.getCustomerId(AccountInformationPane.this);
>  System.out.println(custIdTest);
>  }
>  });
>
> Here i tried to get a value from other class which is WindowContext in to
> AccountInformationPane class which extends BoxPane.
> System.out.println(custIdTest); this statement was executed
> infinitely......
>
> So is there any other way to do this?
> --
> Thanks & Regards
> B.S.V.S.Pavan Raju.
> Skype: skype_pavan1
> Hyderabad.
>
>