You're not currently signed in.

Page continuations: Jumping between pages

Jifty has a very cool way of linking between pages. The links can be thought of as the GOSUB, GOTO and RETURN commands of some people's favorite programming language :-)

Technically, a stack (like a history) of pages viewed is stored in the _jifty_session table of your database with keys marked with key_type='continuation'. At time of this writing, Jifty version 0.607220 always adds entries to the database even in case of a return. This allows the user to go back in his history to any point he was before and reuse the state that was stored in the continuation that was recorded at this point.

At any point in your template you may use the following constructs to deal with continuations. All kinds do have in common, that a Jifty::Web::Form::Clickable object gets rendered that may get displayed either as a link or as a button.

  • Jifty->web->tangent(url=>'/url.html', label=>'link_name' [, ...]) allows the user to jump to a subroutine-like page from which he could return back. As soon as the jump is made by the browsing user, a continuation is created and stored in the user's session for a later return.
  • Jifty->web->goto(url=>'/url.html', label=>'link_name' [, ...]) forces an immediate jump to the given URL.
  • Jifty->web->link(url=>'/url.html', label=>'link_name' [, ...]) allows the user to jump to a page without creating a continuation. Thus, a return to the originating page is not possible except using another link.
  • Jifty->web->return(to=>'/url.html', label=>'link_name' [, ...]) allows the user to return to the last created continuation point that was created by tangent. The page containing the return can also be a page that was reached using several link or goto jumps from the original tangent target page. If there is no open continuation, this jump will point the user to the same page or an alternate url (if the to parameter is given).

CAUTION: The form field values are only kept during tanget and return calls, when assigning a moniker to the action, that is created by Jifty->web->new_action() in the <%init> section of a template.

Kinds of jumps

Every page jump could be of one of the following kinds:

  • a text-link. As usual, a <A href=""> tag is used for rendering the link. This means, that all form elements' values on the current page are lost if this link is followed. However, using a text-link to return to a continuation point will restore every piece of information that is stored in the continuation structure.
  • a button. Without ugly javascript tricks, a button per se cannot act as a link to another URL. However, if used inside an open form a button could help. Using a button instead of a text link, the form will get posted (including all form fields' values) and save the form content entered so far in the continuation. At the later return the form will magically be filled as it was left. A genius feature!

Additional parameters

All link-creating methods above may get the same parameters (except return to be precise, that also accepts the to parameter):

  • label sets the label of the link or button.
  • url sets the page that will be the target of this jump. Defaults to the current page.
  • tooltip adds a tooltip text banner to this element (in case your browser supports this feature). The tooltip will be visible on a text-link only.
  • continuation !!write more!!
  • returns an internally used parameter to force the creation of a continuation, do not use that directly.
  • submit using this parameter, a (possibly empty) list of actions to run after clicking this object may be specified. Using this parameter will automatically render the object as a button.
  • preserve_state accepts a boolean value. By default, state is only preserved, if any AJAX actions are on the link. If some variables have been set with Jifty->web->set_variable and this link is rendered as a text link, this switch has to manually get set in order to transport these variables to the next request.
  • parameters helps to transport extra parameters given in a hash reference to the called page.
  • as_button forces the rendering of this element as a button instead of as a text-link.
  • as_link forces to create a text-link.
  • class allows to set the CSS class for that element.
  • key_binding sets the key binding for the element.