webtier@glassfish.java.net

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

From: <webtier_at_javadesktop.org>
Date: Wed, 19 Aug 2009 11:12:27 PDT

> On 8/19/09 8:52 AM, webtier_at_javadesktop.org wrote:
> >
> 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
> arge update, which will in turn wrap your component -
> meaning that you
> can't do an eval in the middle of it.

Jim,
Thanks for your efforts looking at this.

My diagram component is written in Java (not a composite component), and doesn't contain any other facets, children, or HTML. It renders as a div containing lots of HTML with scripts around it. The radio button is not inside it, it is another component in the form. I don't want the form updated, just the diagram, and when I print the response I see updates for the diagram and the view state, that's all.

(Having said that, I have no control over what my users might want to do, but lets stay with this scenario for now.)

>
> 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.

But, isn't that what I'm doing? Is there something else I need to do? Here's the outline of my page:

<f:view><h:form id="ff">
...
<h:selectOneRadio ... >...
<f:ajax render="diagram" onevent="printData" />
</h:selectOneRadio>
...
<ah:selectDiagram id="diagram" ... />
...
</h:form></f:view>

>
> 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.
>
I did see that, I was hoping to use the eval solution, not the script execution solution. I'll try it if there's no way with eval.

> 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.)

I'm assuming it works for now.
>
> 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.
>

Thanks for your consideration, but I would really prefer the eval solution so it doesn't replace my component's DOM subtree. Besides being less efficient I worry that it will be visually disruptive, especially in IE, which was the whole point of doing Ajax.
[Message sent by forum member 'judys' (judys)]

http://forums.java.net/jive/thread.jspa?messageID=361217