1 package Reaction::UI::ViewPort::DisplayField;
5 class DisplayField is 'Reaction::UI::ViewPort', which {
8 isa => 'Str', is => 'rw', required => 1
12 isa => 'Reaction::InterfaceModel::Object',
13 is => 'ro', required => 0, predicate => 'has_object',
17 isa => 'Reaction::Meta::InterfaceModel::Object::ParameterAttribute',
18 is => 'ro', predicate => 'has_attribute',
22 is => 'rw', lazy_build => 1, trigger_adopt('value'),
25 has label => (isa => 'Str', is => 'rw', lazy_build => 1);
27 implements BUILD => as {
29 if (!$self->has_attribute != !$self->has_object) {
30 confess "Should have both object and attribute or neither"; }
33 implements _build_label => as {
35 return join(' ', map { ucfirst } split('_', $self->name));
38 implements _build_value => as {
40 if ($self->has_attribute) {
41 my $reader = $self->attribute->get_read_method;
42 return $self->object->$reader;
47 implements 'value_string' => as { shift->value };
55 Reaction::UI::ViewPort::DisplayField
59 Base class for displaying non user-editable fields.
67 L<Reaction::InterfaceModel::Object>
71 L<Reaction::Meta::InterfaceModel::Object::ParameterAttribute>
77 User friendly label, by default is based on the name.
81 L<Reaction::UI::ViewPort>
85 See L<Reaction::Class> for authors.
89 See L<Reaction::Class> for the license.