| Author |
f:ajax and client-side components
|
nimo frey
Ranch Hand
Joined: Jun 28, 2008
Posts: 580
|
|
why does jsf 2.0 ajax does not recognize client-side tags?
For example, this works:
Version 1:
while this is not working (because I use the tag html-tag <div> instead of a jsf-tag):
Version 2:
Why is Version 2 not working? Can I only use JSF-Tags in combination with f:ajax?
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
|
If you use the "Display page source" feature of your browser on both those pages, I think you'll see that the actual ID attributes of the JSF and div components are not quite the same.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
nimo frey
Ranch Hand
Joined: Jun 28, 2008
Posts: 580
|
|
I was looking at the html-source (via firebug) and cannot find a different ID:
ajax works with id h:panelGrid.
I replaced h:panelGrid with div (which has the same id):
and then I get this error:
Looking at the "Component Tree", it shows me my div:
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
|
That punctuation is part of the ID. In other words: ":grid" is a completely different ID from "grid".
|
 |
nimo frey
Ranch Hand
Joined: Jun 28, 2008
Posts: 580
|
|
Yes, I have tried it with "grid":
but I get the same failure:
The debug-page offers the "Component Tree", I looked in it and found my id "grid". So it still exists! Strange..
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14475
|
|
Not as strange as you think. Take a look at the HTML generated for a JSF control. You should see that the HTML ID for "grid" is actually something more like "formId:grid". That's because JSF supports something called "naming containers".
Which brings up a point. I hope you've got your commandButton in a JSF form! Otherwise it won't work right.
|
 |
nimo frey
Ranch Hand
Joined: Jun 28, 2008
Posts: 580
|
|
I found the problem.
The problem lies in the JSF 2.0 specification:
JSF 2.0 AJAX-Tag can only update JSF-Tags and not HTML-Tags.
So we have to enclose HTML-Tags (which should be updated) by a JSF-Tag (such as h:panelGrid).
|
 |
 |
|
|
subject: f:ajax and client-side components
|
|
|