logo

Make web development powerful & efficient

Each part of the user interface is composed of nested buildables, which state will persist through requests.

ILWidget is probably the most important class of Iliad, as widgets will compose most of your user interfaces.

Maintaining state

Maintaining state of widgets is easy. Because applications instances are saved in the session, all you have to do is to store widgets into instance variables of their parent.

ExampleApplication [
    | myWidget |

    initialize [
        
        super initialize.
        myWidget := MyWidget new.
    ]
    
    index [
        
        ^myWidget
    ]
]

Because Iliad automatically uses AJAX requests, the state of widgets must be maintained on the client side too.

To make this easier, Iliad uses a system called "dirty widgets". Whenever the state of a widget changes, #markDirty should be called to tell Iliad that the state of the widget has changed, so it will be rebuilt with an AJAX request.

Because the widget is going to be rebuilt, you don't have to mark child widgets as dirty. They will be automatically rebuilt too.

MyWidget [
    
    changeState [
        
        self markDirty
    ]

    contents [
        
        ^[:e |
            e a 
                action: [self changeState];
                text: 'change state']
    ]
]

Embedding widgets

Buildable objects can be added to an element through the #build: method.

MyWidget >> contents [
    
    ^[:e | 
        e build: self subWidget.
        e build: [:element | element div h1: 'hello world']]
]

#build: should always be used. For instance, you should never use ILWidget>>contents or ILElement>>add to build a widget on an element.