Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EGL Development Tools » Widget Instantiability Confusion (Widget Instantiability Confusion )
Widget Instantiability Confusion [message #1006616] Fri, 01 February 2013 08:05 Go to next message
Wilfried Reinoehl is currently offline Wilfried ReinoehlFriend
Messages: 9
Registered: July 2012
Junior Member
I ported the sample code of Joe Pluta's book "Developing WEB 2.0 Applications with EGL for IBM i" to the EDT 0.8.2. environment. The code below compiles, but shows nothing in the browser or in the designer. If the promptBox instance is created without the new operator (using the prompBox Box{...}; notation), everything works.


// The UI consists of the prompt and the display
ui Box { columns = 1, children = [ promptBox, new Box ] };

// Prompt box - prompt for order number
promptBox Box = new Box { children = [
new TextLabel {
text = "Order Number: ",
paddingRight = 10 },
new Button { text = "Read", onClick ::= readOrder }
orderField TextField {};

I always thought, that
promptBox Box {...}; is the same as promptBox Box = new Box {...};
Is this an EDT bug? Or an EDT feature that I do not understand?


-- Wilfried Reinoehl
Re: Widget Instantiability Confusion [message #1006773 is a reply to message #1006616] Fri, 01 February 2013 18:36 Go to previous message
Paul Harmon is currently offline Paul HarmonFriend
Messages: 11
Registered: July 2009
Junior Member

What is happening here is that when the children of the "ui" box is created, the default value for promptBox is added to the children array. Since promptBox is not defined as nullable, the default value of this variable is just "new Box()". Then when the initialer code is run, the code:

promptBox = new Box{....}

will create a new instance of a Box. At this point, the children of "ui" will be holding onto a different instance than the variable "promptBox".

The correct way to do this in EDT is to use the notation:

promptBox Box {...}

This specification will not create a new object, but will simply modify the default value.

In RBD, we tried to simplify things for the user by treating both of these specifications the same way. However, to keep the language more pure and ultimately easier to understand in EDT, we chose not to carry over this special code.


Previous Topic:Insert Record with Identity (auto-generate)
Next Topic:Array sort
Goto Forum:

Current Time: Tue Oct 20 09:59:23 GMT 2020

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

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

Back to the top