logo

abstract class

webapp::Widget

sys::Obj
  web::Weblet
    webapp::Widget

Widget is the base class for all web-based UI widgets.

See docLib::Widget

Slots

add

virtual This add(Widget child)

Add a child widget. If child is null, then do nothing. If child is already parented throw ArgErr. Return this.

Source

body

WebOutStream body()

Source

children

Widget[] children()

Get the children widgets.

Source

complete

virtual Void complete(Buf head, Buf body)

Complete the current request by flushing the head and body Bufs to the actual response OutStream. If the current request is a GET, this method is responsible for adding the appropriate markup to make the resulting HTML a valid page.

Source

each

Void each(|Widget, Int| f)

Iterate the children widgets.

Source

find

Widget find(Uri uri)

Return the Widget with the given Uri, or null if one cannot be found.

Source

flash

Str:Obj flash()

A short-term map that only exists for a single GET request, and is then automatically cleaned up. It is convenient for passing notifications following a POST.

Source

get

Widget get(Str name)

Return the child Widget with the given name, or null if one does not exist.

Source

WebOutStream head()

Source

invoke

virtual Void invoke(Str name)

Invoke the Func defined by name. The default implemenation will invoke the method on this Type with the given name.

Source

name

readonly Str name

The unique name for this widget within the parent, or null if this widget is not mounted.

Source

parent

readonly Widget parent

Get this widget's parent or null if not mounted.

Source

remove

virtual This remove(Widget child)

Remove a child widget. If child is null, then do nothing. If this widget is not the child's current parent throw ArgErr. Return this.

Source

removeAll

virtual This removeAll()

Remove all child widgets. Return this.

Source

service

override Void service()

Handle configuring the inital Widget pipeline. To allow Widgets to be nested, we use two thread local Bufs to capture the output for the <head> and <body> tags separately. After the request has been serviced, we flush the Bufs to the actual output stream via complete.

If this method is called again (on any instance) after the initial call, it short-circuits and simply calls the default web::Weblet.service implemenation.

Source

toInvoke

Uri toInvoke(Obj func)

Return the Uri used to invoke the given function. func must be a Str or a Method type:

toInvoke(&onPost)
toInvoke("onPost")

The Uri required to invoke functions follows the form:

req.uri.plusQuery(["invoke":"$uri/$name"])

Source

uri

Uri uri()

Return the uri to this Widget from the base widget, or null if this widget is not mounted.

Source