webtier@glassfish.java.net

Re: [webtier] JSF2: using JavaScript to update a component

From: Jim Driscoll <Jim.Driscoll_at_Sun.COM>
Date: Wed, 19 Aug 2009 09:54:09 -0700

On 8/19/09 8:52 AM, webtier_at_javadesktop.org wrote:
> Sorry, I didn't mean to be obtuse.
>
> My component is a diagram, showing different data for different dates. The page has a h:selectOneRadio which lets you select between two dates. You can see the JSF1.2 incarnation of the page here:
>
> http://www.apprisantj.com/jsfdemos/camp/reserve.faces
>
> In the h:selectOneRadio I put the following:
>
> <f:ajax render="diagram" onevent="printData" />
>
> The spec tells me that execute defaults to @this, so I would expect the radio button to update its value expression, and the diagram to get re-rendered. In fact looking at the output, the diagram is the only thing it is trying to render.
> [Message sent by forum member 'judys' (judys)]
>
> http://forums.java.net/jive/thread.jspa?messageID=361194

OK, now we're getting somewhere.

Yes, by updating the diagram (which appears to be what, a PanelGrid?),
you're launching an render update of the entire section, including
everything underneath it, including the radio button. That kicks off a
large update, which will in turn wrap your component - meaning that you
can't do an eval in the middle of it.

If you want to use eval, you'll have to be more specific about what
you're rendering, and list each component one by one. (Space separated
list). Then, it should work.

Or, if you look at my blog (Google Jim Driscoll java), about three or
four entries back you'll see a pointer to a blog that explains how to
use the event system to execute a script returned inline from a component.

As for what is getting executed vs what is not, @this is supposed to be
executed by default, yes. Is that not what you're seeing? (A debug run
with a break on your set method should show it being executed.)

Jim

P.S. Your example is an excellent argument for allowing inline
execution of scripts without having to use eval - I'm going to take this
example to the Expert Group as part of the argument.