
Widget extends Weblet to provide functionality to aid in creating reusable UI components.
See docLib::Widget
Slots
- actionForm
-
Void actionForm(Func action, Str attrs := null, Uri uri := null)
Write out an opening
<form>
tag to submit to the given action. Ifuri
is null,req.uri
is used for the base Uri to submit the form to.<form method='post' action='${uri}?action=$action.qname'>
- actionUri
-
Uri actionUri(Func action, Uri uri := null)
Return the
uri
used to invoke the given action on the given uri. Ifuri
is null,req.uri
is used for the base Uri to submit the action to. Theaction
func must map to aMethod
. - body
-
WebOutStream body()
The buffered WebOutStream for the <body> element.
- 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. - doPost
-
override Void doPost()
The default implemenation of
doPost
attempts to route the request to a method on a Widget based on theaction
query parameter:http://foo.com/some/weblet?action=pod::Type.method
- If
action
is not in the uri, return404 Not Found
- If
action
does not map to apod::Type.method
, throwsys::UnknownSlotErr
- If
action
maps to a valid type and method, then a new instance of that type is created, and the method is invoked on it.
- If
- flash
-
Str:Obj flash()
A short-term storage that only exists for a single GET request, and is then automatically cleaned up. It is convenient for passing notifications following a POST.
- head
-
WebOutStream head()
The buffered WebOutStream for the <head> element.
- 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.