[Bese-devel] Follow up to "New tutorial typos"
burban at opopop.net
burban at opopop.net
Wed Mar 4 00:41:28 UTC 2009
szergling <senatorzergling at gmail.com> writes:
[...]
>
> Now, I am also confused about another thing. Suppose a component
> displays an action that does not 'answer', but has side-effects
> instead. I'm not sure why this action would repeatedly get called even
> when the component display is only refreshed and not clicked on.
>
> Here is a simple example to illustrate:
>
> (defcomponent refresh-demo ()
> ((value :initform 0
> :accessor component-value)))
Add slot option ":backtrack t" for value.
Works also for the <ucw:form variant below.
>
> (defmethod render ((c refresh-demo))
> (<:p "Current value is: "
> (<:as-html (component-value c)))
> (<ucw:a :action (incf (component-value c))
> "Increase value"))
>
> (defentry-point "refresh.ucw" (:application *example-application*)
> ()
> (<:p "Refresh test")
> (call 'refresh-demo))
>
>
> It is similar to the counter (increment/decrement) example. We have a
> value which can be increased by clicking on our incf action. After the
> first click on the hyperlink, I see a new incremented
> value. Subsequent clicks on the hyperlink also increment the value, as
> expected. However, clicking on "refresh" in my browser (after the
> first increment action) also results in the value being incremented. I
> expect to see the same value, since no action has been carried out,
> really.
>
> I can sort of see why this must be so I guess, since there's some "URL
> propagation-like" stuff, so even a refresh is a new "hit" causing an
> action. However, this also works with form actions, and seems wrong,
> since nothing has been posted...
>
> (defmethod render ((c refresh-demo))
> (<:p "Current value is: "
> (<:as-html (component-value c)))
> (<ucw:form
> :action (incf (component-value c))
> (<:input :type "submit" :value "Increase value")))
>
> Again, try to increment once (clicking on the form button), then just
> use refresh. So what have I done wrong here? Would appreciate any
> pointers.
Well, time for a new chapter of the tutorial "backtracking":)
--
B. Urban
More information about the bese-devel
mailing list