logo

abstract class

webapp::Widget

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

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. If uri 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. If uri is null, req.uri is used for the base Uri to submit the action to. The action func must map to a Method.

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 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.

doPost

override Void doPost()

The default implemenation of doPost attempts to route the request to a method on a Widget based on the action query parameter:

http://foo.com/some/weblet?action=pod::Type.method
  • If action is not in the uri, return 404 Not Found
  • If action does not map to a pod::Type.method, throw sys::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.
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.

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.