Extending the RUI widget set [message #923421] |
Tue, 25 September 2012 22:41 |
Richard Moulton Messages: 92 Registered: August 2011 Location: Devon, UK |
Member |
|
|
EDT 0.8.1
I'm in the process of creating a HTML5 audio file player and have been pretty successful at creating this as externaltype javascript class but when I try converting the class to a widget I'm running in to problems. I've read all of the documentation and forum posts I can find on the subject and still I can't see the problem.
To illustrate the problem I've created a very simple externaltype javascript widget and I'm hoping someone can show me the error of my ways.
The javascript file ShowAlert.js in my webcontent/utils folder:
egl.defineWidget(
'utils', 'ShowAlert', // this class
'egl.ui.rui', 'Widget', // the super class
'div', // dom element type name
{
"constructor" : function() {
},
"showAlert" : function( alert ) {
alert( alert );
}
});
The egl widget ShowAlert in my client.utils package:
package client.utils;
externalType ShowAlert extends Widget type JavaScriptObject {
relativePath = "utils",
externalName = "ShowAlert" }
function showAlert( alert string in );
end
And finally my test rig, TestShowAlert, in my client package:
package client;
import org.eclipse.edt.rui.widgets.*;
import client.utils.ShowAlert;
import eglx.ui.rui.Event;
handler TestShowAlert type RUIhandler{initialUI =[ui], onConstructionFunction = start, title = "Test Show Alert"}
ui box{ columns=3, children =[lbl, fld, but] };
lbl html{ text = "Alert message:" };
fld textfield{ text = "Why aren't you working?" };
but button{ text="Show Alert", onClick::=but_onClick };
function start()
end
function but_onClick(e Event in)
alert ShowAlert{};
alert.showAlert(fld.text);
end
end
The error I'm getting when I switch to the preview tab, and before I interact with the RUI page.
[CRRUI2085E] Internal Error: While defining widget utils.ShowAlert as a subclass of egl.ui.rui.Widget
'undefined' is not a constructor
[CRRUI2095E] Could not find the EGL function calls leading to this error
Any help or pointers would be most appreciated.
Richard
[Updated on: Mon, 01 October 2012 12:34] Report message to a moderator
|
|
|
|
|
Re: Extending the RUI widget set [message #923433 is a reply to message #923421] |
Tue, 25 September 2012 22:58 |
Dan Darnell Messages: 145 Registered: November 2011 Location: Arkansas |
Senior Member |
|
|
Oh...and a word to the wise...working with external types in EDT can be interesting in that generated code doesn't always seem to pick up changes to external type code. I find that I usually have to do a Project->Clean after changing external type code. I've spent more time that I care to admit chasing problems that didn't exist because changes to external types didn't make the trip without a "clean". Your mileage may vary.
--Dan
[Updated on: Tue, 25 September 2012 22:58] Report message to a moderator
|
|
|
|
|
Re: Extending the RUI widget set [message #929454 is a reply to message #923865] |
Mon, 01 October 2012 13:20 |
Richard Moulton Messages: 92 Registered: August 2011 Location: Devon, UK |
Member |
|
|
A word of warning, this gotcha took me hours to finally work out what the problem was, so be careful.
After the excellent support I received in this post I was able to get my external javascript working and wrapped it up with a new RUI widget. Pleased with the results I decided I'd move this new widget, and associated files, to a new project for easier use with future projects.
This was fairly easy using the EDT tooling simply moving the source files to a new project, so far so good. I then referenced my new widget project and updated references to the widget as approriate, so far so good. Having moved the widget to a new project I changed it slightly to introduce a new property, giving it greater flexibility.
When I then tried the application, that referenced the widget, I received the following message (in the preview tab).
[CRRUI1083E] An error occurred while the click browser event was being handled.
[CRRUI2002E] but_onClick
An error occurred inside TestAlert: Object doesn't support this property or method
[CRRUI2094E] Here are the EGL function calls leading to this error:
org/eclipse/edt/rui/widgets/TextField.egl() at line 114
client/TestAlert.egl() at line 24
At this point my assumption was that there was something wrong with the new property I added and I tried all sorts of tweaks to the code, I read all sorts of previous forum postings, I trawled through help pages, blog posts, etc and all to no avail. I eventually created a brand new project and referenced my new widget project, this worked!
The problem is that when I moved the source files from my original project to the widget project there was some residual files left behind in my original project, relating to my widget, and still being used.
I deleted files (using the navigator view) from the <original project>/generatedJavaScript/utils and <original project>/javaScriptDev/utils folders that related to the moved widget. This sorted the problem.
Hopefully this will save someone else from a similar fate.
Richard
|
|
|
Re: Extending the RUI widget set [message #929674 is a reply to message #929454] |
Mon, 01 October 2012 16:56 |
Dan Darnell Messages: 145 Registered: November 2011 Location: Arkansas |
Senior Member |
|
|
I've encountered this too. Just sorry I didn't mention it earlier which might have saved you a lot of time. I guess that I wasn't sure whether the problem was me (it often is) or the tooling. It's unfortunate that a "clean" leaves so much residue behind. Maybe eventually things will get to a point where this isn't the case.
--Dan
[Updated on: Mon, 01 October 2012 16:56] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04139 seconds