[Bese-devel] Processing form input
Marco Baringer
mb at bese.it
Wed Feb 23 17:58:43 UTC 2005
ocorrain at yahoo.com (Tiarnán Ó Corráin) writes:
> Now I want to call a method to process what's entered, and dispatch
> accordingly. I have tried defining a "submit" action:
>
> (defaction submit ((f text-form))
> (<:h1 "Yo"))
>
> And I expect to get a page with a large "Yo!" when I hit the submit
> button, but I just get the form again (still filled out). I've tried
> defining "submit" as a plain method, and an ":after" method, but still
> no dice.
>
> What am I missing?
actions are, basically, the "controller" part of the app (if we want
to use MVC terminiology). They descibe how the various components are
tied together. actions do _not_ do the actual rendering, that's left
upto the components.
here's what you're missing:
(defaction submit ((f text-form))
(if (validate-form-elements f)
(call 'show-form-output f)
(call 'form-error)))
the action can decide to pass control over to another component, in
which case the current component (text-form in this example) will
disappear and be replaced by the called component. your submit action
doesn't call anyone, it simply returns the string "<h1>Yo</h1>", so
the component tree remains as it is and you see the text-form
component again.
to sum it up: every diffirent kind of page in the application will
have a component (probably more than one if nested components are
used). every time the user clicks, or submits, or changes a select box
with an :on-change attribute, an action is called. actions can either
call another component, answer to the calling component (both of these
result in the current page (from the user's point of view) changing)
or do neither of these things. if they chose to not call nor answer
the page will remain the same (to be precise: the components in the
tree starting at context.window-component will remain the same).
hth.
--
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
-Leonard Cohen
More information about the bese-devel
mailing list