Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » RAP client error when disposing controls very early(JS error thrown in RAP on early widget disposal and JavaScriptExecutor)
RAP client error when disposing controls very early [message #1856531] Wed, 14 December 2022 10:10 Go to next message
John Gymer is currently offline John GymerFriend
Messages: 279
Registered: November 2012
Location: UK
Senior Member
We have seen some examples where a UI is created using RAP, but something in the user's business logic results in the UI being disposed immediately (perhaps a security flag for example, where the application detects that the user should not be in that screen).

Where the dispose of the freshly-created UI happens very soon after creation, there is a potential timing issue where some UI elements have not yet been synchronised between JS on the browser and the RAP Java side on the appserver.

This can result in messages like this on the browser:

Client Error
Details
Error: Error: Operation "call" on target "rwt.client.JavaScriptExecutor" of type "[object Object]" failed:
Cannot read properties of undefined (reading '$input')
Properties: 
content = rap.getObject( 'w681' ).$input.attr( 'genname', 'PR_ERRMSG' );


  Script: {"head":{},"operations":[["set","w28",{"bounds":[0,0,0,0]}],["set","w31",{...
  Stack: Error: Operation "call" on target "rwt.client.JavaScriptExecutor" of type "[object Object]" failed:
Cannot read properties of undefined (reading '$input')
Properties: 
content = rap.getObject( 'w681' ).$input.attr( 'genname', 'PR_ERRMSG' );

    at Object._processError (http://127.0.0.1:9090/rwt-resources/3220/rap-client.js:226:3813)
    at Object.processOperationArray (http://127.0.0.1:9090/rwt-resources/3220/rap-client.js:226:924)
    at Object.processMessage (http://127.0.0.1:9090/rwt-resources/3220/rap-client.js:226:253)
    at Object._handleSuccess (http://127.0.0.1:9090/rwt-resources/3220/rap-client.js:230:3804)
    at rwt.remote.Request._success (http://127.0.0.1:9090/rwt-resources/3220/rap-client.js:98:784)
    at http://127.0.0.1:9090/rwt-resources/3220/rap-client.js:98:1875
  Debug: off
  Request: {"head":{"requestCounter":14},"operations":[["set","w27",{"activeControl":"w384"}],[...


This happens where widgets have JavaScriptExecutor performed on them for custom attributes, such as:

rap.getObject( 'w27' ).$input.attr( 'genname', 'PR_ERRMSG' );
rap.getObject( 'w27' ).$input.attr( 'spellcheck', 'true' );
rap.getObject( 'w26' ).$el.css( 'overflow', null );


...the above JS being run through this:

    JavaScriptExecutor executor = RWT.getClient().getService( JavaScriptExecutor.class );
    executor.execute( builder.toString() );


If we never use JavaScriptExecutor, then the client-side crash does not occur.

Is there a way to get the RAP client to recognise that the widget has already been destroyed and ignore the request instead of crashing?

To add, I've tried this with RAP 3.22, but looks like it applies to all versions.


---
Just because you can doesn't mean you should

[Updated on: Wed, 14 December 2022 10:12]

Report message to a moderator

Re: RAP client error when disposing controls very early [message #1856534 is a reply to message #1856531] Wed, 14 December 2022 10:42 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi John,

the crash didn't come from the RAP framework code, but from your custom JavaScript code that is executed with JavaScriptExecuter. The fix is simple. Just update you custom JavaScript code like:

var object = rap.getObject( 'w27' );
if( object ) {
  object.$input.attr( 'genname', 'PR_ERRMSG' );
  object.$input.attr( 'spellcheck', 'true' );
  ...
}


Best regards,
Ivan
Re: RAP client error when disposing controls very early [message #1856537 is a reply to message #1856534] Wed, 14 December 2022 10:59 Go to previous messageGo to next message
John Gymer is currently offline John GymerFriend
Messages: 279
Registered: November 2012
Location: UK
Senior Member
Ah, yes, I hadn't even considered that perspective!
Thanks Ivan... will give that a go!


---
Just because you can doesn't mean you should
Re: RAP client error when disposing controls very early [message #1856538 is a reply to message #1856537] Wed, 14 December 2022 11:23 Go to previous message
John Gymer is currently offline John GymerFriend
Messages: 279
Registered: November 2012
Location: UK
Senior Member
works a treat - of course!


---
Just because you can doesn't mean you should
Previous Topic:Combo and color for items?
Next Topic:Mouse up / down event not triggering on column header click or select
Goto Forum:
  


Current Time: Mon Jun 17 10:40:25 GMT 2024

Powered by FUDForum. Page generated in 0.03091 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top