2009/5/24 Jim Driscoll <Jim.Driscoll@sun.com>
On 5/24/09 8:39 PM, David Geary wrote:
And that id is *exactly* what <f:ajax> says it cannot find. It's in the
page, but <f:ajax> cannot find it?!?

My guess is that <f:ajax> is evaluating the id before the page is
completely constructed, and therefore, it doesn't find it, but that's
just a WAG on my part.

So, if this is not correct:

<f:ajax render="#{cc.parent.clientId}:image"/>

Then how do I access the image in the parent (map) component?

It seems to me that I'm using <f:ajax> correctly, but I'd be happy to be
told otherwise.


It's late, but yes, that looks correct, and yes, your guess sounds correct.  Could you file this as an impl bug?

Okay. I'll send a WAR to Ryan, and see if we can get this fixed asap. I'd like to get this working for my J1 demo.


Now, we do need to fix that as a bug, but I must argue that your use case represents bad practice.  Your component is using ajax inside a component to modify the using page.  That's difficult to maintain, and I suspect it will lead to obfuscated code quite easily.  I'd instead argue that if you are going to have one component modify another, you should either group them into one composite, or, have the ID of the component you act upon passed in as an attribute (say "for="?)

Yup, I concur--too much coupling between parent and child components. Unfortunately, I can't seem to pass the component ID to the child component either. IOW, this doesn't work:

In parent component:

  <places:mapZoomControl componentToRender="#{cc.clientId}:image"/>

And in mapZoomControl.xhtml:

  <composite:attribute name="componentToRender"/>
  ...
  <f:ajax render="#{cc.attrs.componentToRender}"/>

I suppose it's not surprising that the preceeding doesn't work--it looks like a manifestation of the same bug. I'll give Ryan a buzz.

Thanks,


david



Of course, that second usage suggestion opens up another hole in the cc api - the lack of ability to do name resolution.  Though if/when we get method parameters, then cc.findComponent will work, I guess.    Though I've been saying that for a pretty long time now, I should check on when we're getting those method params...

Jim