Fan

 

abstract class

webapp::Widget

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

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

See docLib::WebWidget

Slots

addSource

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.

bodySource

WebOutStream body()

childrenSource

Widget[] children()

Get the children widgets.

completeSource

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.

eachSource

Void each(|Widget, Int| f)

Iterate the children widgets.

findSource

Widget? find(Uri uri)

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

flashSource

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.

getSource

Widget? get(Str name)

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

WebOutStream head()

invokeSource

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.

nameSource

readonly Str? name

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

parentSource

readonly Widget? parent

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

removeSource

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.

removeAllSource

virtual This removeAll()

Remove all child widgets. Return this.

serviceSource

override Void service()

Overrides web::Weblet.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.

toInvokeSource

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"])
uriSource

Uri? uri()

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