Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EGL Development Tools » Extending the RUI widget set
Extending the RUI widget set [message #923421] Tue, 25 September 2012 22:41 Go to next message
Richard Moulton is currently offline Richard MoultonFriend
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 #923428 is a reply to message #923421] Tue, 25 September 2012 22:50 Go to previous messageGo to next message
Dan Darnell is currently offline Dan DarnellFriend
Messages: 145
Registered: November 2011
Location: Arkansas
Senior Member
Two small changes and you are there:

egl.defineWidget(
				'utils', 'ShowAlert',		// this class
				'eglx.ui.rui', 'Widget',  	// the super class
				'div',						// dom element type name
{
	"constructor" : function() {
	},

	"showAlert" : function( alertText ) {
		alert( alertText );
	}
	
});


In EDT the super class is in the eglx.ui.rui package and since "alert" is a JS function your parm needs to be called something else (like "alertText").

--Dan

Re: Extending the RUI widget set [message #923432 is a reply to message #923421] Tue, 25 September 2012 22:54 Go to previous messageGo to next message
Dan Darnell is currently offline Dan DarnellFriend
Messages: 145
Registered: November 2011
Location: Arkansas
Senior Member

The only other thing I would add is that I try to match my folder structure to my package structure. So if my external type is in "client.utils" I put my JavaScript in client/utils under WebContent. That's just personal preference though. What you did works.

--Dan
Re: Extending the RUI widget set [message #923433 is a reply to message #923421] Tue, 25 September 2012 22:58 Go to previous messageGo to next message
Dan Darnell is currently offline Dan DarnellFriend
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 #923457 is a reply to message #923433] Tue, 25 September 2012 23:29 Go to previous messageGo to next message
Richard Moulton is currently offline Richard MoultonFriend
Messages: 92
Registered: August 2011
Location: Devon, UK
Member
Dan,

You're a saviour, many thanks; that 'x' on the end of 'egl' did the trick.

Yes, I too have been caught out with changes I've made to my externaltype javascript seemingly having no effect. I found that if I change, un-change and then save the externaltype egl source then that seems to do the trick.

Again, many thanks.

Richard

Re: Extending the RUI widget set [message #923865 is a reply to message #923457] Wed, 26 September 2012 09:01 Go to previous messageGo to next message
Nathan Reed is currently offline Nathan ReedFriend
Messages: 74
Registered: June 2012
Member
Richard/Dan:

Thx on the external type issue. I just finished working through my first and I was forever trying to figure out why it was not working and then after changes that should have no impact it would start working.

Nathan Reed
Re: Extending the RUI widget set [message #929454 is a reply to message #923865] Mon, 01 October 2012 13:20 Go to previous messageGo to next message
Richard Moulton is currently offline Richard MoultonFriend
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 Go to previous message
Dan Darnell is currently offline Dan DarnellFriend
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

Previous Topic:Amaze Me game update
Next Topic:HTTP Request
Goto Forum:
  


Current Time: Mon Dec 30 17:17:35 GMT 2024

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

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

Back to the top