Skip to main content



      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 05:10 Go to next message
Eclipse UserFriend
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.

[Updated on: Wed, 14 December 2022 05:12] by Moderator

Re: RAP client error when disposing controls very early [message #1856534 is a reply to message #1856531] Wed, 14 December 2022 05:42 Go to previous messageGo to next message
Eclipse UserFriend
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 05:59 Go to previous messageGo to next message
Eclipse UserFriend
Ah, yes, I hadn't even considered that perspective!
Thanks Ivan... will give that a go!
Re: RAP client error when disposing controls very early [message #1856538 is a reply to message #1856537] Wed, 14 December 2022 06:23 Go to previous message
Eclipse UserFriend
works a treat - of course!
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: Wed May 14 18:09:33 EDT 2025

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

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

Back to the top