File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes ajax within a composite component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "ajax within a composite component " Watch "ajax within a composite component " New topic

ajax within a composite component

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
I have a component called "test":

and the "view.xhtml" which uses the component "test":

When rendering "view.xhtml", then I get the following error:

How can I solve that?

(Besides, when using <f:ajax render="@form" /> within the component-component all works, but I want to assign a ID to limit the rendering.)

Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218
Use render=":client-view", or possible ":form-id:client-view", to search from the root.
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
Unfortunately, ":client-view" does also not work:

<f:ajax> contains an unknown id ':client-view' - cannot locate it in the context of the component test-id.

When I look at the client-code, that the component has indeed the "client-view" as ID. (no ":my-form:client-view", as I wrapped the component with <h:form id="my-form" prependId="false">).

Why does my JSF-component not find the ID of its parent?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

nimo frey wrote:
Why does my JSF-component not find the ID of its parent?

Because parameters don't understand relative paths within naming containers. Just string values. That means that you're going to have to deal with it the same way JavaScript does.

I think that if you code the following, it should work better:

However, I'm uncertain on a few things, since you didn't declare a "parent" attribute in cc:attrs. Then again, I'm not familiar with that technique anyway. I'm pretty sure last time I did something like this, I just coded things in this form:

An IDE is no substitute for an Intelligent Developer.
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
I added the parent-property (the string-identifier of the parent component in which my component is put):

The use of my component:

now returns the following error:

java.lang.IllegalArgumentException: java.lang.ClassCastException@2b4193b3
at sun.reflect.GeneratedMethodAccessor213.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at javax.faces.component.UIComponentBase$AttributesMap.put(
at javax.faces.component.UIComponentBase$AttributesMap.put(
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler$CompositeComponentRule$LiteralAttributeMetadata.applyMetadata(
at com.sun.faces.facelets.tag.MetadataImpl.applyMetadata(
I agree. Here's the link:
subject: ajax within a composite component
It's not a secret anymore!