Reputation: 847
I have a <h:dataTable>
with a <h:commandLink>
in a column and a <h:outputext>
outside the <h:dataTable>
which I need to render by the command link.
<h:form>
<h:dataTable value="#{userControl.lista}" var="c">
<h:column>
<f:facet name="header" >
<h:outputText styleClass="leftColumn" value="Nombre"/>
</f:facet>
#{c.nombre}
</h:column>
<h:column>
<f:facet name="header" >
Usuario
</f:facet>
<h:commandLink actionListener="#{userControl.setAdmin_user(c.user)}" value="#{c.user}">
<f:ajax render="output" />
</h:commandLink>
</h:column>
</h:dataTable>
<h:outputText id="output" value="#{userControl.admin_user}"/>
</h:form>
It does not work. If I move the <h:outputText>
inside the same column, then it works.
How is this caused and how can I solve it?
Upvotes: 1
Views: 2912
Reputation: 1108632
The client ID as you currently have in the <f:ajax render>
does not start with the default NamingContainer
separator character :
and is therefore relative to the current NamingContainer
component, which is in your case the <h:dataTable>
. So it will work only when the outputtext component is also in the same datatable.
You need to refer the outputtext component by an absolute client ID instead. For starters who do not have memorized all NamingContainer
components yet, the easiest way to find it out is to check the id
attribute of the generated HTML element in the webbrowser. Open the page in webbrowser and do View Source and locate the <span>
element generated by <h:outputText id="output">
and take exactly this ID and prefix it with :
to make it absolute to the view root.
E.g.
<span id="formId:output">
where formId
is the ID of any <h:form>
for the case the outputtext is enclosed in a <h:form>
. If you don't have specified a fixed ID for the <h:form>
, then JSF will autogenerate one. You'd like to specify a fixed ID then like <h:form id="formId">
.
So the <f:ajax render>
should look like this then
<f:ajax render=":formId:output" />
Upvotes: 4