Creating Views

There are four ways to send events to an ActionFlow controller.

  • By a link
  • By a form
  • By an AJAX link
  • By an AJAX form

Any ActionFlow controller views can easily use these helper methods to create views that interact with the ActionFlow framework. To have all the details, consult the BaseHelper API.

Using links to send events

Links sending events can be created as follows.

<%= flow_link_to :caption, :event_name %>

This would produce the following code.

<a href="/links?flow_exec_key=[key value]&amp;_submit__event_event_name=_event_event_name">caption</a>

See the API for more details and configuration options.

Using forms to send events

Forms sending events can be created as follows.

<%= flow_form_tag  %>
 
  <!-- My inputs... -->
 
  <%= flow_submit_tag 'caption 1', :first_event %>
  
  <%= flow_submit_tag 'caption 2', :second_event %>
<%= end_flow_form_tag %>

This would produce the following code.

<form action="/simple_form" method="post">
  
  <input name="flow_exec_key" type="hidden" value="[key value]" />

  <input name="_submit__event_first_event" type="submit" value="caption 1" />
  <input name="_submit__event_second_event" type="submit" value="caption 2" />
  
</form>

See the API for more details and configuration options.

Using AJAX links to send events

AJAX links sending events can be created as follows.

<%= flow_link_to_remote 'caption', 'event_name', :update => 'domElementId' %>

This would produce the following code.

<a href="#" onclick="new Ajax.Updater('link', '/ajax?flow_exec_key=[key value]&amp;_submit__event_event_name=_event_event_name', {asynchronous:true, evalScripts:true}); return false;">caption</a>

See the API for more details and configuration options.

RJS Integration

ActionFlow is fully compliant with Rails RJS functionnality. If you master RJS, you’ll understand.

Using AJAX forms to send events

AJAX forms sending events can be created as follows.

<%= flow_form_remote_tag :update => :form %>
 
  <!-- My inputs... -->
 
  <p><%= flow_submit_tag 'Update', :update %></p>
 
  <p><%= flow_submit_tag 'Quit', :quit %></p>
  
<%= end_flow_form_tag %>

This would produce the following code.


<form action="/ajax" method="post" onsubmit="new Ajax.Updater('form', '/ajax', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">

  <input name="flow_exec_key" type="hidden" value="[key value]" />

  <p><input name="_submit__event_update" type="submit" value="Update" /></p>

  <p><input name="_submit__event_quit" type="submit" value="Quit" /></p>
  
</form>

See the API for more details and configuration options.

~~DISCUSSION~~

 
creating_views.txt · Last modified: 2007/06/28 11:49 by lucboudreau
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.