Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Text's keyReleased listener doesn't deliver complete Text.getText().
Text's keyReleased listener doesn't deliver complete Text.getText(). [message #1062571] Sun, 09 June 2013 04:57 Go to next message
somporn pongpan is currently offline somporn pongpan
Messages: 7
Registered: April 2013
Junior Member
I found a likely bug with RAP 2.1 RC2-RC3 regarding Text's keyReleased listener and this doesn't happen on RAP 2.0 RC3. This problem happens on IE10, Chrom 27.0.1453.110 m and Firefox 21.0 -- all in their latest versions.

On the server side, I add keyRelease KeyListner to Text component shown below.

Text filterText = new Text(composite, SWT.BORDER);
filterText.addKeyListener(new KeyAdapter() {
	@Override
	public void keyReleased(KeyEvent e) {
		System.out.println(filterText.getText());
	}
});


On my page every time that I type a character on filterText textfield, RAP will deliver that character and called keyReleased method. However, when I print filterText.getText() to the console, a delivered character isn't included in Text.getText().

For example:

First time I type '1', Text.getText() printed nothing.

Sencond time I type '2', Text.getText() printed '1'.

Third time I type '3', Text.getText() printed '12'.

Fourth time I type '4', Text.getText() printed '123'.

If I look at sending json string on the Firefox Firebug console, it is clear to me that the javascript side engine doens't deliver all its complete value so I think there is something wrong on the Javascript side.

Note again that this problem doesn't happen on RAP 2.0 RC3.
Re: Text's keyReleased listener doesn't deliver complete Text.getText(). [message #1062573 is a reply to message #1062571] Sun, 09 June 2013 05:21 Go to previous messageGo to next message
somporn pongpan is currently offline somporn pongpan
Messages: 7
Registered: April 2013
Junior Member
After spent some time digging into RAP Javascript code, I found the likely wrong in bundles\org.eclipse.rap.rwt\js\rwt\widgets\base\BasicText.js:643 (RAP 2.1 RC3):

633:
634:    _oninput : function() {
635:      try {
636:        var newValue = this.getComputedValue().toString();
        var doit = true;
        if( this.hasEventListeners( "input" ) ) {
          doit = this.dispatchEvent( new rwt.event.DataEvent( "input", this._typed ), true );
        }
641:        if( doit ) {
642:          // at least webkit does sometiems fire "input" before the selection is updated
643:          rwt.client.Timer.once( this._updateValueProperty, this, 0 );
644:        } else if( rwt.client.Client.isWebkit() || rwt.client.Client.isMshtml() ){
645:          // some browser set new selection after input event, ignoring all changes before that
          rwt.client.Timer.once( this._renderSelection, this, 0 );
          this._selectionNeedsUpdate = true;
        }
      } catch( ex ) {
        rwt.runtime.ErrorHandler.processJavaScriptError( ex );
      }
    },

654:    _updateValueProperty : function() {
655:      this.setValue( this.getComputedValue().toString() );
656:    },
657:


It looks like rwt.client.Timer.once() on line 643 cannot set the complete value to Json string on the time that Ajax request has been called.

Compare to BasicText.js on RAP 2.0 RC3 below which on the line 642:

634:    _oninput : function() {
      try {
        var newValue = this.getComputedValue().toString();
        var doit = true;
        if( this.hasEventListeners( "input" ) ) {
          doit = this.dispatchEvent( new rwt.event.DataEvent( "input", this._typed ), true );
        }
        if( doit ) {
642:          this.setValue( newValue ); // if doit is false, the listener has to do this
        } else if( rwt.client.Client.isWebkit() || rwt.client.Client.isMshtml() ){
          // some browser set new selection after input event, ignoring all changes before that
          rwt.client.Timer.once( this._renderSelection, this, 0 );
          this._selectionNeedsUpdate = true;
        }
      } catch( ex ) {
        rwt.runtime.ErrorHandler.processJavaScriptError( ex );
      }
651:    },


The code on RAP 2.0 RC3 didn't call a Timer class and it didn't has this problem.

[Updated on: Sun, 09 June 2013 05:22]

Report message to a moderator

Re: Text's keyReleased listener doesn't deliver complete Text.getText(). [message #1062575 is a reply to message #1062573] Sun, 09 June 2013 05:37 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1794
Registered: July 2009
Senior Member
Hi,
please open a bugzilla about this regression and put your findings there.
Thanks,
Ivan

On 6/9/2013 12:21 PM, somporn pongpan wrote:
> After spent some time digging into RAP Javascript code, I found the
> likely wrong in
> bundles\org.eclipse.rap.rwt\js\rwt\widgets\base\BasicText.js:643 (RAP
> 2.1 RC3):
>
>
> 633:
> 634: _oninput : function() {
> 635: try {
> 636: var newValue = this.getComputedValue().toString();
> var doit = true;
> if( this.hasEventListeners( "input" ) ) {
> doit = this.dispatchEvent( new rwt.event.DataEvent( "input",
> this._typed ), true );
> }
> 641: if( doit ) {
> 642: // at least webkit does sometiems fire "input" before
> the selection is updated
> 643: rwt.client.Timer.once( this._updateValueProperty, this,
> 0 );
> 644: } else if( rwt.client.Client.isWebkit() ||
> rwt.client.Client.isMshtml() ){
> 645: // some browser set new selection after input event,
> ignoring all changes before that
> rwt.client.Timer.once( this._renderSelection, this, 0 );
> this._selectionNeedsUpdate = true;
> }
> } catch( ex ) {
> rwt.runtime.ErrorHandler.processJavaScriptError( ex );
> }
> },
>
> 654: _updateValueProperty : function() {
> 655: this.setValue( this.getComputedValue().toString() );
> 656: },
> 657:
>
>
> It looks like rwt.client.Timer.once() on line 643 cannot set the
> complete value to Json string on the time that Ajax request has been
> called.
>
> Compare to BasicText.js on RAP 2.0 RC3 below which on the line 642:
>
>
> 643: _oninput : function() {
> try {
> var newValue = this.getComputedValue().toString();
> var doit = true;
> if( this.hasEventListeners( "input" ) ) {
> doit = this.dispatchEvent( new rwt.event.DataEvent( "input",
> this._typed ), true );
> }
> if( doit ) {
> 642: this.setValue( newValue ); // if doit is false, the
> listener has to do this
> } else if( rwt.client.Client.isWebkit() ||
> rwt.client.Client.isMshtml() ){
> // some browser set new selection after input event, ignoring
> all changes before that
> rwt.client.Timer.once( this._renderSelection, this, 0 );
> this._selectionNeedsUpdate = true;
> }
> } catch( ex ) {
> rwt.runtime.ErrorHandler.processJavaScriptError( ex );
> }
> 651: },
>
>
> The code on RAP 2.0 RC3 didn't call a Timer class and it didn't has
> this problem.

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Text's keyReleased listener doesn't deliver complete Text.getText(). [message #1062614 is a reply to message #1062575] Mon, 10 June 2013 00:59 Go to previous message
somporn pongpan is currently offline somporn pongpan
Messages: 7
Registered: April 2013
Junior Member
Hi,

I have create #410294 for this problem.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=410294
Previous Topic:[ANN] RAP 2.1 RC3 is available
Next Topic:E4/RAP Integration
Goto Forum:
  


Current Time: Fri Aug 29 20:37:00 EDT 2014

Powered by FUDForum. Page generated in 0.06813 seconds