2009/5/24 Jim Driscoll <span dir="ltr"><<a href="mailto:Jim.Driscoll@sun.com">Jim.Driscoll@sun.com</a>></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't work - but that'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're doing ajax stuff in page, you need to know what the rendered id'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'm wrong, since I'd say you'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've done that, and I understand how to use component ids with ajax (at least I think so), but something'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><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br> "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"><br>
<br><html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"<br> xmlns:f="<a href="http://java.sun.com/jsf/core">http://java.sun.com/jsf/core</a>"<br> xmlns:h="<a href="http://java.sun.com/jsf/html">http://java.sun.com/jsf/html</a>"<br>
xmlns:ui="<a href="http://java.sun.com/jsf/facelets">http://java.sun.com/jsf/facelets</a>"<br> xmlns:composite="<a href="http://java.sun.com/jsf/composite">http://java.sun.com/jsf/composite</a>"<br>
xmlns:places="<a href="http://java.sun.com/jsf/composite/components/places">http://java.sun.com/jsf/composite/components/places</a>"><br> <br> <!-- INTERFACE --><br> <composite:interface><br>
</composite:interface><br> <br> <!-- IMPLEMENTATION --> <br> <composite:implementation><br> <h:outputScript library="javascript/prototype" name="prototype-1.6.0.2.js"/><br>
<h:outputScript library="components/places" name="util.js"/><br> <br> <div class="map" id="mapDiv"><br> <div style="padding-bottom: 10px;"><br>
<h:outputText value="#{cc.attrs.title}"<br> style="color: blue"/><br> </div><br> <br> <h:panelGrid id="grid" columns="1"><br>
<h:panelGroup id="group"><br> <div style="padding-left: 5px;"><br> <i><br> <h:outputText value="#{cc.parent.attrs.location.streetAddress},"/><br>
</i><br> <br> <h:outputText value=" #{cc.parent.attrs.location.city}, " /><br> <h:outputText value="#{cc.parent.attrs.location.state}"/><br>
<hr/><br> </div><br> </h:panelGroup><br><br><b> <places:mapZoomControl/><br></b> <br> <h:graphicImage id="<b>image</b>" url="#{cc.parent.attrs.location.mapUrl}" <br>
style="border: thin solid gray"/><br> <br> </h:panelGrid><br> </div><br> </composite:implementation> <br></html><br><br>The pertinent thing is that I'm using <places:mapZoomControl/>. In that component, I have an <f:ajax> tag in a menu that should render the image beneath <places:mapZoomControl>. That mapZoomControl component looks like this:<br>
<br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br> "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"><br>
<br><html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"<br> xmlns:f="<a href="http://java.sun.com/jsf/core">http://java.sun.com/jsf/core</a>"<br> xmlns:h="<a href="http://java.sun.com/jsf/html">http://java.sun.com/jsf/html</a>"<br>
xmlns:ui="<a href="http://java.sun.com/jsf/facelets">http://java.sun.com/jsf/facelets</a>"<br> xmlns:composite="<a href="http://java.sun.com/jsf/composite">http://java.sun.com/jsf/composite</a>"><br>
<br> <!-- INTERFACE --><br> <composite:interface><br> <composite:attribute name="ccId"/><br> </composite:interface><br> <br> <!-- IMPLEMENTATION --> <br> <composite:implementation><br>
<h:outputScript library="javascript/prototype" name="prototype-1.6.0.2.js"/><br> <h:outputScript library="components/places" name="util.js"/><br> <div id="#{cc.clientId}"><br>
<br> <h:panelGrid columns="2"><br> <div class="zoomPrompt"><br> #{msgs.zoomPrompt}<br> </div><br><br> <h:selectOneMenu id="menu"<br> value="#{cc.parent.attrs.location.zoomIndex}"<br>
style="font-size:13px;font-family:Palatino"><br><br><b> <f:ajax render="#{cc.parent.clientId}:image"/><br></b> <f:selectItems value="#{places.zoomLevelItems}"/><br>
<br> <h:graphicImage id="progressbar" style="display: none" <br> library="images" name="orange-barber-pole.gif"/><br> <br> </h:selectOneMenu><br>
</h:panelGrid><br> </div><br> </composite:implementation> <br></html><br><br>Notice the <f:ajax> tag. I think I'm accessing the image from the parent component (map.xhtml) correctly. However, when I load the page I get this:<br>
<br> <f:ajax> contains an unknown id <br> 'form:j_id1186681689_16ef8569:0:j_id1186681689_16ef8513:j_id-1105909415_41ead6fe:image'<br><br>If I remove the f:ajax tag, load the page, and check the source, I see an <img> tag:<br>
<br><img id="form:j_id1186681689_16ef8569:0:j_id1186681689_16ef8513:j_id-1105909415_41ead6fe:image" src="..."/><br><br>And that id is *exactly* what <f:ajax> says it cannot find. It's in the page, but <f:ajax> cannot find it?!?<br>
<br>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.<br><br>So, if this is not correct:<br><br> <f:ajax render="#{cc.parent.clientId}:image"/><br>
<br>Then how do I access the image in the parent (map) component?<br><br>It seems to me that I'm using <f:ajax> correctly, but I'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're crippled, we're gonna get some bad press.<br>
<br>
<br>
No doubt. We definitely can'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'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't hesitate to resend a message if<br>
you feel that it did not reach my attention.<br>
</blockquote>
</div></div></blockquote></div><br>