wood burning stoves 2.0*
The moose likes JSF and the fly likes f:ajax and client-side components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "f:ajax and client-side components" Watch "f:ajax and client-side components" New topic
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: 15960
    
  19

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: 15960
    
  19

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: 15960
    
  19

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: f:ajax and client-side components
 
Similar Threads
FacesException: f:ajax contains an unknown id - cannot locate it in the context of the component
ui:repeat, c:foreach in JSF 2.0
JSF View
Composite Components with ViewScoped bean
Form Being Rendered Outside of the Page