Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Scripting HelloWorld Application(Cannot inject JavaScript file into a HelloWorld example application)
Scripting HelloWorld Application [message #1860060] Fri, 14 July 2023 15:16 Go to next message
Aleksandar  Iliskovic is currently offline Aleksandar IliskovicFriend
Messages: 1
Registered: July 2023
Junior Member
I am trying to perform a check on the client side (my browser), before processing the content of the input field on the server side using the RAP application.

I set up a HelloWorld example for the application using the RAP developes-guide documentation (cannot upload the link from the external sites) and then I removed all components and add a simple text field. For the next step, I created a javascript file and inject it using scripting documentation for RAP.

Now when I run RWT Application for BasicEntryPoint, the listener is added to a text field, with the comment in a javascript file ("//# sourceURL=test.js", also tried with @ instead of #), and when I open the developer tools on my browser, the script is not in sources and therefore I am unable to debug. The goal of the script is to check if the key pressed by the user is an 'a' character, if yes, skip that character.

In addition I will upload my BasicEntryPoint.java file and javascript file.

Any help would be appreciated!
Re: Scripting HelloWorld Application [message #1860106 is a reply to message #1860060] Tue, 18 July 2023 08:12 Go to previous message
Sebastian Habenicht is currently offline Sebastian HabenichtFriend
Messages: 42
Registered: January 2013
Member
Hi Aleksandar,

I think there must be no extra quotes around the sourceURL comment. I see "test.js" in the sources when I use the sourceURL comment without quotes. About the event handling: According to the js docs [1], there is no field event.key. You could check the field event.character instead and set the field event.doit accordingly. This worked for me:

        @Override
	protected void createContents(final Composite parent) {
		final Text text = new Text(parent, SWT.BORDER);
		GridDataFactory.fillDefaults().grab(true, false).applyTo(text);
		String scriptCode = "//# sourceURL=test.js\n";
		scriptCode += "const handleEvent = event => event.doit = event.character !== 'a';";
		text.addListener(SWT.KeyDown, new ClientListener(scriptCode));
	}


Regards,
Sebastian

[1] https://download.eclipse.org/rt/rap/doc/3.25/guide/reference/jsdoc/symbols/Event.html

[Updated on: Tue, 18 July 2023 08:21]

Report message to a moderator

Previous Topic:Modify Event
Next Topic:3.25
Goto Forum:
  


Current Time: Fri Jun 21 07:04:46 GMT 2024

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

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

Back to the top