Skip to content
moellep edited this page Nov 17, 2014 · 7 revisions

UI.WidgetValue

  • Widgets request data from array_refs called "Widget Values"

  • A value is like an XPath or /proc in that it is a series of names interpreted within the context of the previous name.

  • The values are not blessed so they are simple to specify, e.g. [qw(auth_user display_name)] and ['Model.GroupUserList', 'role'].

  • Values are interpreted in a context, called a WidgetValueSource. As each name is interpreted, the source changes so for ['auth_realm', 'owner', 'display_name']

    $req is initial source, and the values are interpreted in order: The AgentHTTP.Request attribute "auth_realm" is the current realm, the "owner" is a reference to the Model.RealmOwner for the realm, the "display_name" is a property on the Model.RealmOwner

    # ['auth_realm', 'owner', 'display_name']
    $req->get('auth_realm')->get('owner')->get('display_name');
  • Simple widgets take their $source in render() and simple use that unmodified

  • Complex widgets (Table, List, With) use a dynamic value to interpret the rest of their attributes in the context of that WidgetValueSource (typically a ListModel).

Syntax

  • Always starts with an array_ref

  • If an element begins with '->', it calls the named method with the rest of the widget value elements as the arguments to the method. The object ($self) is the current source.

  • They nest, so you can say: [['->req', 'Type.UserAgent'], '->is_browser']

    1. The nested elements are evaluated in the context of the first source so ->req is called on that source.

    2. Type.UserAgent is passed to ->req, and returns the current user agent instance.

    3. ->is_browser is called on the result of $source->req('Type.UserAgent'), which asks the object if the current user agent is a browser (as opposed to a program, like lwp-get or b-sendmail-http).

  • if the first element is '!', the rest of the widget value is interpreted and the result is inverted (not).

  • If the first element is a sub {}, the rest of the arguments are evaluated and passed to the code_ref as arguments (the first argument is always $source).

  • As always, widget values are interpreted in a fast fail context.

Examples

[['Model.MotionForm', '->get_motion_document'], 'path']

would be equivalent to $req->get('Model.MotionForm')->get_motion_document->get('path')

['Model.MotionForm', '->get_motion_document', 'path']

would be equivalent to $req->get('Model.MotionForm')->get_motion_document('path')

Implementation

Clone this wiki locally