Help-Site Computer Manuals
  Algorithms & Data Structures   Programming Languages   Revision Control
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Web framework for a Jifty application

Jifty::Web - Web framework for a Jifty application


Jifty::Web - Web framework for a Jifty application



Creates a new Jifty::Web object


Returns a the HTML::Mason::Request manpage object


Send a string to the browser. The default implementation uses Mason->out;


Returns the root url of this Jifty application. This is pulled from the configuration file. Takes an optional named path which will form the path part of the resulting URL.


Returns a unique identifier, guaranteed to be unique within the runtime of a particular process (ie, within the lifetime of There's no sort of global uniqueness guarantee, but it should be good enough for generating things like moniker names.



Sets up the current session object (a the Jifty::Web::Session manpage tied hash). Aborts if the session is already loaded.


Returns the current session's hash. In a regular user environment, it persists, but a request can stop that by handing it a regular hash to use.


current_user [USER]

Getter/setter for the current user; this gets or sets the 'user' key in the session. These are the Jifty::Record manpage objects.

If a temporary_current_user has been set, will return that instead.

If the current application has no loaded current user, we get an empty app-specific CurrentUser object. (This ApplicationClass::CurrentUser class, a subclass of the Jifty::CurrentUser manpage, is autogenerated if it doesn't exist).

temporary_current_user [USER]

Sets the current request's current_user to USER if set.

This value will _not_ be persisted to the session at the end of the request. To restore the original value, set temporary_current_user to undef.


handle_request [REQUEST]

This method sets up a current session, and then processes the given the Jifty::Request manpage object. If no request object is given, processes the request object in request.

Each action on the request is vetted in three ways -- first, it must be marked as active by the the Jifty::Request manpage (this is the default). Second, it must be in the set of allowed classes of actions (see is_allowed in the Jifty::API manpage). Finally, the action must validate. If it passes all of these criteria, the action is fit to be run.

Before they are run, however, the request has a chance to be interrupted and saved away into a continuation, to be resumed at some later point. This is handled by save_continuation in the Jifty::Request manpage.

If the continuation isn't being saved, then handle_request goes on to run all of the actions. If all of the actions are successful, it looks to see if the request wished to call any continuations, possibly jumping back and re-running a request that was interrupted in the past. This is handled by call_continuation in the Jifty::Request manpage.

For more details about continuations, see the Jifty::Continuation manpage.

response [VALUE]

Gets or sets the current the Jifty::Response manpage object.


Returns the current the Jifty::Web::Form manpage object, creating one if there isn't one already.

new_action class => CLASS, moniker => MONIKER, order => ORDER, arguments => PARAMHASH

Creates a new action (an instance of a subclass of the Jifty::Action manpage). The named arguments passed to this method are passed on to the new method of the action named in CLASS.


CLASS is qualified, and an instance of that class is created, passing the Jifty::Web object, the MONIKER, and any other arguments that new_action was supplied.

MONIKER is a unique designator of an action on a page. The moniker is content-free and non-fattening, and may be auto-generated. It is used to tie together arguments that relate to the same action.

ORDER defines the order in which the action is run, with lower numerical values running first.

ARGUMENTS are passed to the new in the Jifty::Action manpage method. In addition, if the current request ($self->request) contains an action with a matching moniker, any arguments that are in that requested action but not in the PARAMHASH list are set. This implements ``sticky fields''.

As a contrast to add_action in the Jifty::Web::Form manpage, this does not add the action to the current form -- instead, the first form field to be rendered will automatically register the action in the current form field at that time.

new_action_from_request REQUESTACTION

Given a the Jifty::Request::Action manpage, creates a new action using new_action.


Returns an array of the Jifty::Action manpage objects, one for each the Jifty::Request::Action manpage that is marked as failed in the current response.


As failed_actions, but for actions that completed successfully; less often used.


next_page [VALUE]

Gets or sets the next page for the framework to show. This is normally set during the take_action method or a the Jifty::Action manpage

force_redirect [VALUE]

Gets or sets whether we should force a redirect to next_page, even if it's already the current page. You might set this, e.g. to force a redirect after a POSTed action.


Returns true if we need to redirect, now that we've processed all the actions. We need a redirect if either next_page is different from the current page, or force_redirect has been set.

webservices_redirect [TO]

Handle redirection inside webservices call. This is meant to be hooked by plugin that knows what to do with it.

redirect [TO]

Redirect to the next page. If you pass this method a parameter, it redirects to that URL rather than next_page.

It creates a continuation of where you want to be, and then calls it. If you want to redirect to a page with parameters, pass in a the Jifty::Web::Form::Clickable manpage object.


Returns the the Jifty::Request manpage of our enclosing continuation, or an empty the Jifty::Request manpage if we are not in a continuation.



If called in non-void context, creates and renders a the Jifty::Web::Form::Clickable manpage with the given PARAMHASH, forcing a continuation save.

In void context, does a redirect to the URL that the the Jifty::Web::Form::Clickable manpage object generates.

Both of these versions preserve all state variables by default.


Does an instant redirect to the url generated by the the Jifty::Web::Form::Clickable manpage object generated by the PARAMHASH.


Generates and renders a the Jifty::Web::Form::Clickable manpage using the given PARAMHASH.


If called in non-void context, creates and renders a the Jifty::Web::Form::Clickable manpage using the given PARAMHASH, additionally defaults to calling the current continuation.

Takes an additional argument, to, which can specify a default path to return to if there is no current continuation.

In void context, does a redirect to the URL that the the Jifty::Web::Form::Clickable manpage object generates.

render_messages [MONIKER]

Outputs any messages that have been added, in <div id=``messages''> and <div id=``errors''> tags. Messages are added by calling message in the Jifty::Result manpage.

If a moniker is specified, only messages for that moniker are rendered.

render_success_messages [MONIKER]

Render success messages for the given moniker, or all of them if no moniker is given.

render_error_messages [MONIKER]

Render error messages for the given moniker, or all of them if no moniker is given.

_render_messages TYPE [MONIKER]

Output any messages of the given TYPE (either 'error' or 'message') in a <div id=``TYPEs''> tag. If a moniker is given, only renders messages for that action. Internal helper for render_success_messages and render_errors.

query_string KEY => VALUE [, KEY => VALUE [, ...]]

Returns an URL-encoded query string piece representing the arguments passed to it.

escape STRING

HTML-escapes the given string and returns it

escape_uri STRING

URI-escapes the given string and returns it


Returns the the Jifty::Web::Menu manpage for this web request; one is automatically created if it hasn't been already.


Returns the the Jifty::Web::Menu manpage for this web request; one is automatically created if it hasn't been already. This is useful for separating page-level navigation from app-level navigation.


Returns a <link> tag for the compressed CSS

add_css FILE1, FILE2, ...

Pushes files onto Jifty-web->css_files>


Returns a <script> tag for the compressed Javascript.

Your application specific javascript goes in share/web/static/js/app.js. This will be automagically included if it exists.

If you want to add javascript behaviour to your page using CSS selectors then put your behaviour rules in share/web/static/js/app_behaviour.js which will also be automagically included if it exists. The behaviour.js library is included by Jifty. For more information on behaviour.js see

However if you want to include other javascript libraries you need to add them to the javascript_libs array of your application. Do this in the start sub of your main application class. For example if your application is Foo then in lib/

 sub start {

     Jifty->web->add_javascript(qw( jslib1.js jslib2.js ) );


The add_javascript method will append the files to javascript_libs. If you need a different order, you'll have to massage javascript_libs directly.

Jifty will look for javascript libraries under share/web/static/js/ by default as well as any plugin static roots.

add_javascript FILE1, FILE2, ...

Pushes files onto Jifty-web->javascript_libs>

add_external_javascript URL1, URL2, ...

Pushes urls onto Jifty-web->external_javascript_libs>


get_variable NAME

Gets a page specific variable from the request object.

set_variable NAME VALUE

Takes a key-value pair for variables to serialize and hand off to the next page.

Behind the scenes, these variables get serialized into every link or form that is marked as 'state preserving'. See the Jifty::Web::Form::Clickable manpage.

Passing undef as a value will remove the variable


Returns all of the state variables that have been set for the next request, as a hash;

N.B. These are not prefixed with J:V-, as they were in earlier versions of Jifty


Remove all the state variables to be serialized for the next request.


get_region [QUALIFIED NAME]

Given a fully QUALIFIED NAME of a region, returns the the Jifty::Web::PageRegion manpage with that name, or undef if no such region exists.


The provided PARAMHASH is used to create and render a the Jifty::Web::PageRegion manpage; the PARAMHASH is passed directly to its new in the Jifty::Web::PageRegion manpage method, and then render in the Jifty::Web::PageRegion manpage is called.

replace_current_region PATH

Replaces the current region with a new region and renders it Returns undef if there's no current region


Returns the name of the current the Jifty::Web::PageRegion manpage, or undef if there is none.

qualified_region [REGION]

Returns the fully qualified name of the current the Jifty::Web::PageRegion manpage, or the empty string if there is none. If REGION is supplied, gives the qualified name of REGION were it placed in the current region.