Re: Textarea KeyUpHandler not working

2012-11-29 Thread marco
Hi Thomas,

thanks for your explanation. I had that setElement(rootPanel.getElement()) 
thing in my mind, but I didn't really got what it does until your 
explanation. Now it makes much sense to me what happened.

Cheers,
Marco

Am Mittwoch, 28. November 2012 14:45:51 UTC+1 schrieb Thomas Broyer:
>
>
>
> On Wednesday, November 28, 2012 1:40:18 PM UTC+1, marco wrote:
>>
>> Ok I fixed it, with the following changes
>>
>> -public class ValidatableTextarea extends ComplexPanel
>> +public class ValidatableTextarea extends FlowPanel
>> -   private FlowPanel rootPanel;
>> protected TextArea input;
>> private Label errorLabel;
>>
>> @UiConstructor 
>> public ValidatableTextarea() { 
>> input = new TextArea(); 
>> -   rootPanel = new FlowPanel(); 
>> -   rootPanel.add(input); 
>> +   add(input)
>>
>> -   setElement(rootPanel.getElement()); 
>> }
>> ...
>> public void setText(String text) { 
>> input.setText(String Text); 
>> }
>> ...
>> public void addKeyUpHandler(KeyUpHandler keyUpHandler) { 
>> input.addKeyUpHandler(keyUpHandler); 
>> }
>>
>> Don't know why but it's working now.
>>
>
> I know why: setElement() is only meant to be used when you create your own 
> Widget, not when you extend an existing one. The root of your problem was 
> actually using rootPanel;getElement() as the element for another widget, 
> yet adding widgets to rootPanel (which is never *attached* to the DOM: 
> its element is "physically" attached, by way of the ValidatableTextArea, 
> but the FlowPanel itself is not "logically" attached.
>
> Now, instead of *extending* FlowPanel, you should extend Composite 
> instead, and use a FlowPanel with setWidget (more or less reverting to your 
> previous code, fixing it: ComplexPanel→Composite, setElement→setWidget)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/vlSS2xPuS5AJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Textarea KeyUpHandler not working

2012-11-28 Thread Thomas Broyer


On Wednesday, November 28, 2012 1:40:18 PM UTC+1, marco wrote:
>
> Ok I fixed it, with the following changes
>
> -public class ValidatableTextarea extends ComplexPanel
> +public class ValidatableTextarea extends FlowPanel
> -   private FlowPanel rootPanel;
> protected TextArea input;
> private Label errorLabel;
>
> @UiConstructor 
> public ValidatableTextarea() { 
> input = new TextArea(); 
> -   rootPanel = new FlowPanel(); 
> -   rootPanel.add(input); 
> +   add(input)
>
> -   setElement(rootPanel.getElement()); 
> }
> ...
> public void setText(String text) { 
> input.setText(String Text); 
> }
> ...
> public void addKeyUpHandler(KeyUpHandler keyUpHandler) { 
> input.addKeyUpHandler(keyUpHandler); 
> }
>
> Don't know why but it's working now.
>

I know why: setElement() is only meant to be used when you create your own 
Widget, not when you extend an existing one. The root of your problem was 
actually using rootPanel;getElement() as the element for another widget, 
yet adding widgets to rootPanel (which is never *attached* to the DOM: its 
element is "physically" attached, by way of the ValidatableTextArea, but 
the FlowPanel itself is not "logically" attached.

Now, instead of *extending* FlowPanel, you should extend Composite instead, 
and use a FlowPanel with setWidget (more or less reverting to your previous 
code, fixing it: ComplexPanel→Composite, setElement→setWidget)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/Nh8uJGPtOKsJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: Textarea KeyUpHandler not working

2012-11-28 Thread marco
Ok I fixed it, with the following changes

-public class ValidatableTextarea extends ComplexPanel
+public class ValidatableTextarea extends FlowPanel
-   private FlowPanel rootPanel;
protected TextArea input;
private Label errorLabel;

@UiConstructor 
public ValidatableTextarea() { 
input = new TextArea(); 
-   rootPanel = new FlowPanel(); 
-   rootPanel.add(input); 
+   add(input)

-   setElement(rootPanel.getElement()); 
}
...
public void setText(String text) { 
input.setText(String Text); 
}
...
public void addKeyUpHandler(KeyUpHandler keyUpHandler) { 
input.addKeyUpHandler(keyUpHandler); 
}

Don't know why but it's working now.

Cheers

Am Mittwoch, 28. November 2012 08:34:43 UTC+1 schrieb marco:
>
> Hi there,
>
> I'm trying to implement a counter for a textarea. Something like this is 
> working for me
>
> final TextArea textArea = new TextArea();final Label counter = new 
> Label("Number of characters: 0");...private void addlistener() {
> textArea.addKeyUpHandler(new KeyUpHandler() {
> public void onKeyUp(KeyUpEvent keyUpEvent) {
>   counter.setText(" Number of 
> characters:"+textArea.getText().length());
> }
> });
>
>
> In my project the TextArea is enhanced e.g. for displaying validation errors.
>
>
> public class ValidatableTextarea extends ComplexPanel
> private FlowPanel rootPanel;
> protected TextArea input;
> private Label errorLabel;
>
> @UiConstructor 
> public ValidatableTextarea() { 
> input = new TextArea(); 
> rootPanel = new FlowPanel(); 
> rootPanel.add(input); 
> setElement(rootPanel.getElement()); 
> }
> ...
> public void setText(String text) { 
> input.setText(String Text); 
> }
> ...
> public void addKeyUpHandler(KeyUpHandler keyUpHandler) { 
> input.addKeyUpHandler(keyUpHandler); 
> }
>
> My Presenter is calling ValidatableTextarea.addKeyUpHandler onBind but 
> the keyhandler seems not to be added. The same thing happens when I call 
> ValidatableTextarea.setText
> My Presenter is a dialog, so when I call those functions in Presenter.openat 
> least 
> ValidatableTextarea.setText is working and the given text is displayed, 
> but there is still no keyUpHandler working.
>
> So is there any magic working I don't see? Any event I can listen to be 
> sure that my ValidatableTextarea is ready to accept my keyUpHandler? Or 
> is my given Handler somehow overwritten?
>
> Thanks in advance,
> Marco
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/e2xreRpjzXQJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Textarea KeyUpHandler not working

2012-11-28 Thread marco
Hi there,

I'm trying to implement a counter for a textarea. Something like this is 
working for me

final TextArea textArea = new TextArea();final Label counter = new 
Label("Number of characters: 0");...private void addlistener() {
textArea.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent keyUpEvent) {
  counter.setText(" Number of 
characters:"+textArea.getText().length());
}
});


In my project the TextArea is enhanced e.g. for displaying validation errors.


public class ValidatableTextarea extends ComplexPanel
private FlowPanel rootPanel;
protected TextArea input;
private Label errorLabel;

@UiConstructor 
public ValidatableTextarea() { 
input = new TextArea(); 
rootPanel = new FlowPanel(); 
rootPanel.add(input); 
setElement(rootPanel.getElement()); 
}
...
public void setText(String text) { 
input.setText(String Text); 
}
...
public void addKeyUpHandler(KeyUpHandler keyUpHandler) { 
input.addKeyUpHandler(keyUpHandler); 
}

My Presenter is calling ValidatableTextarea.addKeyUpHandler onBind but the 
keyhandler seems not to be added. The same thing happens when I call 
ValidatableTextarea.setText
My Presenter is a dialog, so when I call those functions in Presenter.openat 
least 
ValidatableTextarea.setText is working and the given text is displayed, but 
there is still no keyUpHandler working.

So is there any magic working I don't see? Any event I can listen to be 
sure that my ValidatableTextarea is ready to accept my keyUpHandler? Or is 
my given Handler somehow overwritten?

Thanks in advance,
Marco

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/kBaHPnWDL5oJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.