# Reaction
{{toc 2-}}
Reaction is a set of modules on top of Catalyst that provides a full component UI system.
Reaction is similar to [Apache Wicket](http://wicket.apache.org/). Albeit not as mature, it aspires to be, and to do so with the elegance of Perl.
## Get excited
[FormFu](http://dev.catalyst.perl.org/wiki/FormFu_FAQ) and [Rose::HTML::Objects](http://search.cpan.org/dist/Rose-HTML-Objects/) are "local maxima" of particular solutions to the form-based data input and Object-Relational-Mapper problems. They are very good implementations, but of limited ideas. Reaction aims to be a very good implementation of MVC vs. the Component model and bare Catalyst vs. Wicket:
## Testimonials
> I actually prefer the event/component way of dealing with things over MVC. For simple REST based applications I would go with Catalyst. For large and complex applications I would pick Wicket. `add(new Link("foo") { onClick() { ... do stuff... });` instead of forwarding to a controller action. Event based. Then components are self aware, they know how to handle them selves, so I can drop an "invite a friend" component any where on the site and it just works. I don't need to know anything about the implementation/flow of it. Catalyst is a lot easier to work with. Wicket/hibernate/spring requires a lot of up front investment. Wicket and hibernate are both really complex abstractions. -- [Oleg](http://olegkorneitchouk.com)
## Concepts
From the data to the rendered page, these are the concepts used by Reaction:
* DM = Data (or Domain) Model. DBIC::Schema is an example
* IM = Interface Model - the facade which lies above the DM, which would contain business logic
* VP = ViewPort - an abstract UI state and interface that talks to the Interface Model. For example, a "virtual" grid with many rows, and a state which says which page we're currently viewing, would contain user interface logic
* Widget - uses the ViewPort data to define fragments which are rendered into a web page
* Layout
* Catalyst controller
* Catalyst action
* Rendered Page
See also the [Reaction tutorial](https://satya.huntana.com:8888//hunter/reaction/reaction_tutorial_step_through) by [[/mateus]].
## FAQ
### Do I need this many layers for a simple Hello World app?
A: Reaction does not aim at trivial applications; instead, it enforces structured programming practices to build complex and flexible real-world web applications. There is an upfront cost paid to build this structure, but gains will become apparent as the application grows.
## Get started
* `cpan Module::Install` # make sure you use v0.76 or later
* `svn co http://code2.0beta.co.uk/reaction/svn/Reaction`
* `perl Makefile.PL; make installdeps; make install` # tests may fail at the moment
Look through the source code
## With what Modules should I be familiar?
* [Catalyst](http://search.cpan.org/perldoc?Catalyst) - most importantly, controller action chains: [Catalyst::DispatchType::Chained](http://search.cpan.org/perldoc?Catalyst::DispatchType::Chained)
* [Moose](http://search.cpan.org/perldoc?Moose) - Attributes and method modifiers
* [DBIx::Class](http://search.cpan.org/perldoc?DBIx::Class) - the more the better
* [Template::Toolkit](http://search.cpan.org/perldoc?Template::Toolkit) - only how variables are interpolated into templates ([% foo %], [% bar %], etc...)
## Examples
* [[Hook into a login action]] to update a timestamp and increment login count
## Resources
* [Reaction on CPAN](http://search.cpan.org/dist/Reaction/)
* [Castaway's preliminary docs on Reaction](http://desert-island.me.uk:8888/reaction/); [channel log](http://desert-island.me.uk:8888/~castaway/reaction_log_2008_04_23.txt)
* [YAPC::NA talk](http://shadow.cat/catalyst/-talks/yapc-na-2008/) -- This Resource references a XUL document. Remote XUL is no longer supported by Firefox. The directory contents has been left here for reference.
* [Reaction at OSS community site OpenHub](http://www.ohloh.net/projects/Reaction)