2009/5/24 Jim Driscoll <span dir="ltr">&lt;<a href="mailto:Jim.Driscoll@sun.com">Jim.Driscoll@sun.com</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The only bizzare bit is where the absolute id didn&#39;t work - but that&#39;s explainable in a few ways.<br>
<br>
The basic technique - using #{cc.clientId}:subcomponentid to reference the rendered id in the ajax calls,  does not seem excessively hard to me.</blockquote><div><br>Agreed.<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If you&#39;re doing ajax stuff in page, you need to know what the rendered id&#39;s are going to be.  The minute you start doing anything past hello world, you will anyway.<br>
<br>
If you disagree with this, having seen the basic demo, then obviously I&#39;m wrong, since I&#39;d say you&#39;re both more sophisticated than the target audience.  So please check that out (jsf-demo/ajax-switchlist), and let me know.</blockquote>
<div><br>Okay, I&#39;ve done that, and I understand how to use component ids with ajax (at least I think so), but something&#39;s not working for me. Check this out. Sorry for the long listings, but I want to show everything. You can pretty much just look at the bold text.<br>
<br>I have a composite component, map.xhtml<br><br>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;<br>        &quot;<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>&quot;&gt;<br>
<br>&lt;html xmlns=&quot;<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>&quot;<br>    xmlns:f=&quot;<a href="http://java.sun.com/jsf/core">http://java.sun.com/jsf/core</a>&quot;<br>    xmlns:h=&quot;<a href="http://java.sun.com/jsf/html">http://java.sun.com/jsf/html</a>&quot;<br>
    xmlns:ui=&quot;<a href="http://java.sun.com/jsf/facelets">http://java.sun.com/jsf/facelets</a>&quot;<br>    xmlns:composite=&quot;<a href="http://java.sun.com/jsf/composite">http://java.sun.com/jsf/composite</a>&quot;<br>
    xmlns:places=&quot;<a href="http://java.sun.com/jsf/composite/components/places">http://java.sun.com/jsf/composite/components/places</a>&quot;&gt;<br>    <br>   &lt;!-- INTERFACE --&gt;<br>   &lt;composite:interface&gt;<br>
   &lt;/composite:interface&gt;<br>        <br>   &lt;!-- IMPLEMENTATION --&gt; <br>   &lt;composite:implementation&gt;<br>     &lt;h:outputScript library=&quot;javascript/prototype&quot; name=&quot;prototype-1.6.0.2.js&quot;/&gt;<br>
     &lt;h:outputScript library=&quot;components/places&quot; name=&quot;util.js&quot;/&gt;<br>     <br>     &lt;div class=&quot;map&quot; id=&quot;mapDiv&quot;&gt;<br>         &lt;div style=&quot;padding-bottom: 10px;&quot;&gt;<br>
           &lt;h:outputText value=&quot;#{cc.attrs.title}&quot;<br>             style=&quot;color: blue&quot;/&gt;<br>         &lt;/div&gt;<br>            <br>         &lt;h:panelGrid id=&quot;grid&quot; columns=&quot;1&quot;&gt;<br>
           &lt;h:panelGroup id=&quot;group&quot;&gt;<br>             &lt;div style=&quot;padding-left: 5px;&quot;&gt;<br>               &lt;i&gt;<br>                 &lt;h:outputText value=&quot;#{cc.parent.attrs.location.streetAddress},&quot;/&gt;<br>
               &lt;/i&gt;<br>                <br>                &lt;h:outputText value=&quot; #{cc.parent.attrs.location.city}, &quot; /&gt;<br>               &lt;h:outputText value=&quot;#{cc.parent.attrs.location.state}&quot;/&gt;<br>
               &lt;hr/&gt;<br>             &lt;/div&gt;<br>           &lt;/h:panelGroup&gt;<br><br><b>        &lt;places:mapZoomControl/&gt;<br></b>              <br>          &lt;h:graphicImage id=&quot;<b>image</b>&quot; url=&quot;#{cc.parent.attrs.location.mapUrl}&quot; <br>
            style=&quot;border: thin solid gray&quot;/&gt;<br>     <br>         &lt;/h:panelGrid&gt;<br>     &lt;/div&gt;<br>   &lt;/composite:implementation&gt;    <br>&lt;/html&gt;<br><br>The pertinent thing is that I&#39;m using &lt;places:mapZoomControl/&gt;. In that component, I have an &lt;f:ajax&gt; tag in a menu that should render the image beneath &lt;places:mapZoomControl&gt;. That mapZoomControl component looks like this:<br>
<br>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;<br>        &quot;<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>&quot;&gt;<br>
<br>&lt;html xmlns=&quot;<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>&quot;<br>    xmlns:f=&quot;<a href="http://java.sun.com/jsf/core">http://java.sun.com/jsf/core</a>&quot;<br>    xmlns:h=&quot;<a href="http://java.sun.com/jsf/html">http://java.sun.com/jsf/html</a>&quot;<br>
    xmlns:ui=&quot;<a href="http://java.sun.com/jsf/facelets">http://java.sun.com/jsf/facelets</a>&quot;<br>    xmlns:composite=&quot;<a href="http://java.sun.com/jsf/composite">http://java.sun.com/jsf/composite</a>&quot;&gt;<br>
    <br>  &lt;!-- INTERFACE --&gt;<br>  &lt;composite:interface&gt;<br>    &lt;composite:attribute name=&quot;ccId&quot;/&gt;<br>  &lt;/composite:interface&gt;<br>        <br> &lt;!-- IMPLEMENTATION --&gt; <br> &lt;composite:implementation&gt;<br>
   &lt;h:outputScript library=&quot;javascript/prototype&quot; name=&quot;prototype-1.6.0.2.js&quot;/&gt;<br>   &lt;h:outputScript library=&quot;components/places&quot; name=&quot;util.js&quot;/&gt;<br>     &lt;div id=&quot;#{cc.clientId}&quot;&gt;<br>
<br>   &lt;h:panelGrid columns=&quot;2&quot;&gt;<br>     &lt;div class=&quot;zoomPrompt&quot;&gt;<br>       #{msgs.zoomPrompt}<br>     &lt;/div&gt;<br><br>     &lt;h:selectOneMenu id=&quot;menu&quot;<br>          value=&quot;#{cc.parent.attrs.location.zoomIndex}&quot;<br>
          style=&quot;font-size:13px;font-family:Palatino&quot;&gt;<br><br><b>       &lt;f:ajax render=&quot;#{cc.parent.clientId}:image&quot;/&gt;<br></b>       &lt;f:selectItems value=&quot;#{places.zoomLevelItems}&quot;/&gt;<br>
       <br>       &lt;h:graphicImage id=&quot;progressbar&quot; style=&quot;display: none&quot; <br>         library=&quot;images&quot; name=&quot;orange-barber-pole.gif&quot;/&gt;<br>       <br>     &lt;/h:selectOneMenu&gt;<br>
   &lt;/h:panelGrid&gt;<br>     &lt;/div&gt;<br> &lt;/composite:implementation&gt;    <br>&lt;/html&gt;<br><br>Notice the &lt;f:ajax&gt; tag. I think I&#39;m accessing the image from the parent component (map.xhtml) correctly. However, when I load the page I get this:<br>
<br>    &lt;f:ajax&gt; contains an unknown id <br>    &#39;form:j_id1186681689_16ef8569:0:j_id1186681689_16ef8513:j_id-1105909415_41ead6fe:image&#39;<br><br>If I remove the f:ajax tag, load the page, and check the source, I see an &lt;img&gt; tag:<br>
<br>&lt;img id=&quot;form:j_id1186681689_16ef8569:0:j_id1186681689_16ef8513:j_id-1105909415_41ead6fe:image&quot; src=&quot;...&quot;/&gt;<br><br>And that id is *exactly* what &lt;f:ajax&gt; says it cannot find. It&#39;s in the page, but &lt;f:ajax&gt; cannot find it?!?<br>
<br>My guess is that &lt;f:ajax&gt; is evaluating the id before the page is completely constructed, and therefore, it doesn&#39;t find it, but that&#39;s just a WAG on my part.<br><br>So, if this is not correct:<br><br>  &lt;f:ajax render=&quot;#{cc.parent.clientId}:image&quot;/&gt;<br>
<br>Then how do I access the image in the parent (map) component?<br><br>It seems to me that I&#39;m using &lt;f:ajax&gt; correctly, but I&#39;d be happy to be told otherwise.<br><br>Thanks,<br><br><br>david<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><font color="#888888">
<br>
Jim</font><div><div></div><div class="h5"><br>
<br>
On 5/24/09 7:09 PM, Dan Allen wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hmmm, that seems really bizarre. Perhaps this is a bug in Mojarra but<br>
some chance. Could you distill this down to a basic use case and see if<br>
Ryan et al can make it a test in Mojarra. If there is a problem with the<br>
API, then it will be more clearly revealed.<br>
<br>
<br>
        Frankly, for JSF 2.1, I would like to see us go to an XPath-like<br>
        syntax (or jQuery) to find components because component IDs in<br>
        JSF just plain suck.<br>
<br>
<br>
    Yup, I agree wholeheartedly, but we need to make it easy to do Ajax<br>
    rendering across composite components for JSF 2.0. IMO, composite<br>
    components are by far the single most kickass feature of JSF 2, and<br>
    if they&#39;re crippled, we&#39;re gonna get some bad press.<br>
<br>
<br>
No doubt. We definitely can&#39;t overlook the foreground problem here.<br>
<br>
-Dan<br>
<br>
--<br>
Dan Allen<br>
Senior Software Engineer, Red Hat | Author of Seam in Action<br>
<br>
<a href="http://mojavelinux.com" target="_blank">http://mojavelinux.com</a><br>
<a href="http://mojavelinux.com/seaminaction" target="_blank">http://mojavelinux.com/seaminaction</a><br>
<a href="http://in.relation.to/Bloggers/Dan" target="_blank">http://in.relation.to/Bloggers/Dan</a><br>
<br>
NOTE: While I make a strong effort to keep up with my email on a daily<br>
basis, personal or other work matters can sometimes keep me away<br>
from my email. If you contact me, but don&#39;t hear back for more than a week,<br>
it is very likely that I am excessively backlogged or the message was<br>
caught in the spam filters.  Please don&#39;t hesitate to resend a message if<br>
you feel that it did not reach my attention.<br>
</blockquote>
</div></div></blockquote></div><br>