>
> If addClickHandler is called at the time you switch from tab to tab, then
> you just found the culprit: refactor your code to make it so that it's only
> called once.
>
ok with this i find my error.. when i refresh the tab (with build_tab()) i
re-write the clickHandler.. however i need to clean the tab because i've
some global object (table1 for example) and if i didn't clean it would been
"re-added" to the tab twice..

However thanks for the answer and the patience


On Fri, Mar 7, 2014 at 12:23 PM, Thomas Broyer <[email protected]> wrote:

> That wasn't my question.
>
> How many times is addClickHandler called? (not the ClickHandler's onClick,
> the addClickHandler itself)
> And where is it called from? (not the exact call site obviously; but in
> response to which kind of events?)
>
> If addClickHandler is called at the time you switch from tab to tab, then
> you just found the culprit: refactor your code to make it so that it's only
> called once.
> (to be honest, that call to build_tab1 in response to tab switching looks
> suspicious; and I don't quite understand why you need to clean_tab2 at that
> time either; but you really didn't give much information on what you're
> trying to do and how you've organized your code and flow of events/actions)
>
>
> On Friday, March 7, 2014 12:13:07 PM UTC+1, Davide Micheletti wrote:
>
>> i'm sure, i run it step by step and at the end of onClick it runs 
>> SimpleEventBuss's
>> function and return to onclick.. the time depend to how many time i
>> switched tab..
>> 1 switch 1 repeat  ------> onload tab1 switch tab2 return to tab1
>> 2 switch 2 repeat  ------> onload tab1 switch tab2 return to tab1 switch
>> tab2 return to tab1
>> 3 switch 3 repeat  ------> onload tab1 switch tab2 return to tab1 switch
>> tab2 return to tab1 switch tab2 return to tab1
>> ......
>>
>>
>> On Fri, Mar 7, 2014 at 12:07 PM, Thomas Broyer <[email protected]> wrote:
>>
>>>
>>>
>>> On Friday, March 7, 2014 12:00:22 PM UTC+1, Davide Micheletti wrote:
>>>>
>>>> i did it.. it is called by himself..
>>>>
>>>
>>> Sure, but when? and how many times?
>>>
>>>
>>>>  i follow all the process step by step and at the end of the
>>>> clickHandler it goes in dispatchEvent(event, handler) of
>>>> SimpleEventBuss.class and it returns to the onClick of my project.. What
>>>> can i do?
>>>>
>>>
>>>
>>>>
>>>> On Fri, Mar 7, 2014 at 11:14 AM, Thomas Broyer <[email protected]>wrote:
>>>>
>>>>> I honestly have no idea, given the code snippets you showed. But put a
>>>>> breakpoint on your addClickHandler and see when it's being called, and
>>>>> where it's called from (look at the call stack in your IDE)
>>>>>
>>>>>
>>>>> On Friday, March 7, 2014 11:06:03 AM UTC+1, Davide Micheletti wrote:
>>>>>
>>>>>> i don't understand your answer.. how can i call an addClick handler
>>>>>> of a table in 2 different tab?
>>>>>>
>>>>>>
>>>>>> On Fri, Mar 7, 2014 at 11:01 AM, Thomas Broyer <[email protected]>wrote:
>>>>>>
>>>>>>> I suspect you're calling addClickHandler each time you switch tab.
>>>>>>> Just try to do it once only.
>>>>>>>
>>>>>>>
>>>>>>> On Friday, March 7, 2014 9:11:40 AM UTC+1, Davide Micheletti wrote:
>>>>>>>
>>>>>>>> its a long code, however in summary:
>>>>>>>> in tab1 i've a table (table1) with a clickHandler that depends from
>>>>>>>> another table (table2)
>>>>>>>> in tab2 i've only display some db data
>>>>>>>>
>>>>>>>> code when i switch tab
>>>>>>>>
>>>>>>>> if (tabLayoutPanel.getSelectedIndex() == 0) { // tab1
>>>>>>>>  build_tab1();
>>>>>>>>  clear_TAB2();
>>>>>>>> tabLayoutPanel.setSize("100%", "1245px");
>>>>>>>>
>>>>>>>> }else if (tabLayoutPanel.getSelectedIndex() == 1) { // tab2
>>>>>>>>  build_tab2();
>>>>>>>>  clear_TAB1();
>>>>>>>> tabLayoutPanel.setSize("100%", "1245px");
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> code tab1
>>>>>>>>
>>>>>>>> table1.addClickHandler(new ClickHandler() {
>>>>>>>>
>>>>>>>> public void onClick(ClickEvent event) {
>>>>>>>>
>>>>>>>>               bool t = Window.confirm("continue?")
>>>>>>>>
>>>>>>>>               if(t && is a radioButton in table2 checked??)
>>>>>>>>                         server call for db data
>>>>>>>>                         table1.settext(r,c,"something i need");
>>>>>>>>              else
>>>>>>>>                        Window.alert("select something in table2");
>>>>>>>>         }
>>>>>>>> });
>>>>>>>>
>>>>>>>>
>>>>>>>> now the problem is that if i change tab and i return in tab 1 the
>>>>>>>> code in onClick() is runned n time where n is the number of times that 
>>>>>>>> i
>>>>>>>> switched tab
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, Mar 6, 2014 at 6:46 PM, Thomas Broyer <[email protected]>wrote:
>>>>>>>>
>>>>>>>>>  Show your code?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thursday, March 6, 2014 6:22:01 PM UTC+1, Davide Micheletti
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Hi all, i've a tabLayoutPanel and in every tab there is a widget
>>>>>>>>>> with a click Handler.. If i switch tab and i click on the widget 
>>>>>>>>>> with click
>>>>>>>>>> Handler the code is runned 2 time for every switched tab.. Where i 
>>>>>>>>>> fail??
>>>>>>>>>> thanks..
>>>>>>>>>>
>>>>>>>>>> Davide
>>>>>>>>>>
>>>>>>>>>  --
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "Google Web Toolkit" group.
>>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>>> send an email to [email protected].
>>>>>>>>> To post to this group, send email to [email protected]
>>>>>>>>> .
>>>>>>>>>
>>>>>>>>> Visit this group at http://groups.google.com/group
>>>>>>>>> /google-web-toolkit.
>>>>>>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>>>>>>
>>>>>>>>
>>>>>>>>  --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Google Web Toolkit" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to [email protected].
>>>>>>> To post to this group, send email to [email protected].
>>>>>>> Visit this group at http://groups.google.com/group
>>>>>>> /google-web-toolkit.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Google Web Toolkit" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at http://groups.google.com/group/google-web-toolkit.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Google Web Toolkit" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/google-web-toolkit.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-web-toolkit.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to