Jifty::Web::Form::Clickable - Some item that can be clicked on -- either a button or a link.
Clickable adds url, escape_label, continuation, call, returns, submit, and preserve_state to the list of accessors and mutators, in addition to those offered by "accessors" in Jifty::Web::Form::Element.
url
escape_label
continuation
call
returns
submit
preserve_state
Creates a new Jifty::Web::Form::Clickable object. Depending on the requirements, it may render as a link or as a button. Possible parameters in the PARAMHASH are:
Sets the page that the user will end up on after they click the button. Defaults to the current page.
The text on the clickable object.
Additional information about the link target.
If set to true, HTML escapes the content of the label and tooltip before displaying them. This is only relevant for objects that are rendered as HTML links. The default is true.
The current continuation for the link. Defaults to the current continuation now, if there is one. This may be either a Jifty::Continuation object, or the id of such.
id
The continuation to call when the link is clicked. This will happen after actions have run, if any. Like continuation, this may be a Jifty::Continuation object or the id of such.
Passing this parameter implies the creation of a continuation when the link is clicked. It takes an anonymous hash of return location to where the return value is pulled from -- that is, the same structure the parameters method takes.
parameters
See "query_parameters" in Jifty::Request::Mapper for details.
A list of actions to run when the object is clicked. This may be an array reference or a single element; each element may either be a moniker or, a Jifty::Action or a hashref with the keys 'action' and 'arguments'. An undefined value submits all actions in the form, an empty list reference (the default) submits none.
In the most complex case, you have something like this:
submit => [ { action => $my_action, arguments => { name => 'Default McName', age => '23' }, }, $my_other_action, 'some-other-action-moniker' ]
If you specify arguments in the submit block for a button, they will override any values from form fields submitted by the user.
A boolean; whether state variables are preserved across the link. Defaults to true if there are any AJAX actions on the link, false otherwise.
A hash reference of query parameters that go on the link or button. These will end up being submitted exactly like normal query parameters.
By default, Jifty will attempt to make the clickable into a link rather than a button, if there are no actions to run on submit. Providing a true value for as_button forces generate to produce a Jifty::Web::Form::Clickable::InlineButton instead of a Jifty::Web::Form::Link.
as_button
Attempt to rework a button into displaying as a link -- note that this only works in javascript browsers. Supplying both as_button and as_link will work, and not as perverse as it might sound at first -- it allows you to make any simple GET request into a POST request, while still appearing as a link (a GET request).
as_link
For things that start off as links, give them an html target attribute.
target
Note that this includes the onclick parameter, which allows you to attach javascript to your Clickable object, but be careful that your Javascript looks like return someFunction();, or you may get an unexpected error from your browser.
onclick
return someFunction();
Gets or sets the page that the user will end up on after they click the button. Defaults to the current page.
Gets or sets the text on the clickable object.
Gets or sets if the label is escaped. This is only relevant for objects that are rendered as HTML links. The default is true.
Gets or sets the current continuation for the link. Defaults to the current continuation now, if there is one. This may be either a Jifty::Continuation object, or the id of such.
Gets or sets the continuation to call when the link is clicked. This will happen after actions have run, if any. Like continuation, this may be a Jifty::Continuation object or the id of such.
Gets or sets the return value mapping from the continuation. See Jifty::Request::Mapper for details.
Gets or sets the list of actions to run when the object is clicked. This may be an array reference or a single element; each element may either be a moniker or a Jifty::Action. An undefined value submits all actions in the form, an empty list reference (the default) submits none.
Gets or sets whether state variables are preserved across the link. Defaults to true if there are any AJAX actions on the link, false otherwise.
Sets the given HTTP parameter named KEY to the given VALUE.
KEY
VALUE
Sets the state variable named KEY to VALUE.
Sets the path of the fragment named NAME to be PATH.
NAME
PATH
Sets the value of the ARG argument on the fragment named NAME to VALUE.
ARG
Returns the generic list of HTTP form parameters attached to the link as a hash. Use of this is discouraged in favor or "post_parameters" and "get_parameters".
Returns the hash of parameters as they would be needed on a POST request.
Returns the hash of parameters as they would be needed on a GET request.
Returns the complete GET URL, as it would appear on a link.
Returns the clickable as a Jifty::Web::Form::Link, if possible. Use of this method is discouraged in favor of "generate", which can better determine if a link or a button is more appropriate.
Returns the clickable as a Jifty::Web::Form::Field::InlineButton, if possible. Use of this method is discouraged in favor of "generate", which can better determine if a link or a button is more appropriate.
Returns a Jifty::Web::Form::Field::InlineButton or Jifty::Web::Form::Link, whichever is more appropriate given the parameters.
Registers the action if it isn't registered already, but only on the link. That is, the registration will not be seen by any other buttons in the form.
To install Jifty, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Jifty
CPAN shell
perl -MCPAN -e shell install Jifty
For more information on module installation, please visit the detailed CPAN module installation guide.