
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.
- body
-
WebOutStream body()
- children
-
Widget[] children()
Get the children widgets.
- complete
-
virtual Void complete(Buf head, Buf body)
Complete the current request by flushing the
head
andbody
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. - each
-
Iterate the children widgets.
- find
-
Return the Widget with the given Uri, or null if one cannot be found.
- 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.
- get
-
Return the child Widget with the given name, or null if one does not exist.
- head
-
WebOutStream head()
- invoke
-
Invoke the Func defined by
name
. The default implemenation will invoke the method on this Type with the given name. -
private Widget[] kids := Widget[,]
- name
-
readonly Str name
The unique name for this widget within the parent, or null if this widget is not mounted.
-
private Int nextId := 0
- parent
-
readonly Widget parent
Get this widget's parent or null if not mounted.
- 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.
- removeAll
-
virtual This removeAll()
Remove all child widgets. Return this.
- 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. - toInvoke
-
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"])
- uri
-
Uri uri()
Return the uri to this Widget from the base widget, or null if this widget is not mounted.