Note that there are some explanatory texts on larger screens.

plurals
  1. POJSTL, composite, NamingContainer and prependId
    primarykey
    data
    text
    <p>I have written a composite component and want to use the reserved EL <code>#{component.clientId}</code> to make a JQuery bind. To use this retrieved clientId in a another place in the page (outside the component), I use JSTL to store it in a view scope variable. The strange thing is that JSTL seems to prevent the natural composite component behavior of appending its id in front of its children (<code>NamingContainer</code> behavior). I know that JSTL is a little tricky, interfering with other components (<code>ui:repeat</code> for instance) because of lifecycle things, but here I don't understand this behavior.</p> <p>Some concrete code is better than this long speech:</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:composite="http://java.sun.com/jsf/composite"&gt; &lt;composite:interface&gt; […] &lt;/composite:interface&gt; &lt;composite:implementation&gt; &lt;rich:dataTable id="mySoLovedDataTable" […]&gt; #{component.clientId} &lt;!-- Commenting or uncommenting this line make the whole point --&gt; &lt;c:set var="targetClientId" value="#{component.clientId}" scope="view" /&gt; […] &lt;/rich:dataTable&gt; &lt;/composite:implementation&gt; &lt;/html&gt; </code></pre> <p>With the line commented on, <code>#{component.clientId}</code> gives something like <code>j_idt261:mySoLovedDataTable</code>.</p> <p>With the line commented out, it gives just <code>mySoLovedDataTable</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload