lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Feb 8, 2011 at 11:56 AM, Steve Litt <slitt@troubleshooters.com> wrote:
> Tell us more about declarative GUI building. I'd LOVE to pound out an outline
> and then have it converted to a screen.

Here's one way to build easy dialogs (using LuaJava)

require 'java.form'

tbl = {
    name = 'Bonzo',
    alpha = 1.0,
    beta = 0.0,
    gamma = 2.0,
    occupied = true
}

if auto_dialog_show {
    main = true, object = tbl,
    title = "Auto Dialog Test",
    "Name","name",{"Bonzo","Doggo","Whitsun",edit=true},
    "Alpha","alpha",
    "Beta","beta",
    "Gamma","gamma",
    "Occupied","occupied",
} then
    for k,v in pairs(tbl) do
        print(k,v)
    end
end

The dialog is built from an object, some descriptions (the first
column) and the field names. (We know the types so some basic input
checking can take place. Additional constraint objects can be provided
for restricting parameters to some range, etc.)

Not necessarily a thing of beauty, but fully functional:

http://mysite.mweb.co.za/residents/sdonovan/form.png

(I've been experimenting with a similar style with Orbiter)

> Yeah, everyone but me just LOVES MVC. Me -- every time I see MVC I just keep
> asking myself "OK, where do I put this, where do I put that?"

It is overkill for the small jobs, but provides a good discipline for
non-trivial things. Where small becomes non-trivial is one of those
personal things ;)

BTW, Orbit is the place to start for actual web applications that need
to be on the actual web. You can still use the Orbiter HTML libraries
with Orbit.

steve d.