dev@woodstock.java.net

Re: Cant get ajax event on woodstock button

From: Dan Labrecque <Dan.Labrecque_at_Sun.COM>
Date: Thu, 28 Feb 2008 14:08:48 -0500

One thing you have to keep in mind is that the button runs through the
entire JSF life cycle. The last phase of the JSF life cycle is always
the rendering phase -- even when values are found to be invalid.
Depending on the navigation rules defined in the faces-config.xml file,
the user is typically forwarded to another page or the current page is
refreshed.

In order to achieve the functionality you're looking for, you might
consider using a hidden field and a value change event. When the user
clicks the button, call the submit() function of the hidden field. The
value is submitted asynchronously and if the value has changed, an event
will be fired for your backing bean to listen to. The page will not
refresh because we have overridden the rendering phase here. Instead of
re-rendering the hidden field, we return some JSON data indicating
success or failure. You can actually subscribe to the "submit.endTopic"
event if you're interested in using that to kick off the progress bar.

Typically, this type of behavior can be applied to anything that holds
an HTML element value. It's difficult to support this for a button
because it does not actually submit anything. Although, I'll take a look
and see if there is something we can do here. We may be able to trick it
into submitting a special hidden field, for example.

Dan

stuartr wrote:
> Can someone point me in the right direction to allow me to NOT re-render a
> page when I click a button
> All I want to do is
> 1. Onclick, fire off an event to the backing bean to start something .
> 2. popup a div showing a progress bar widget.
> 3. let the popup div have a STOP button that will send a stop to the back
> end using ajax.
>
> I dont want an page re-rendering and I know I can do this simply in the non
> woodstock world.
> However, surely there must be a method of doing this within woodstock button
> widgets .
>
> I succesfully use the update() on other areas of my apps to dynamically
> change things on the display
> and guessed that woodstock must have a layer that I can access to invoke a
> method on the backing bean.
>
>