Reputation: 829
The concise version of the question I have is this: How do I in response of a blur event on a
<h:inputText>
get the same value to show in a
<h:outputText>
located outside the scope of the inputText field.
The inputtext field has the following xpath:
//*[@id="form:j_idt40:src_table:0:j_idt137"]
The outputtext is located here:
//*[@id="form:j_idt40:target_table:0:target_id"]
I am using primefaces datatable and the two paths are located in two separate datatables
The jsf code for the input field is the following:
<p:dataTable id="src_table">
<p:column id="src_id" headerText="srcHeader">
<h:inputText value="#{bean.myAttribute}">
<f:ajax event="blur" render="src_id WHAT_SHOULD_GO_HERE?" ></f:ajax>
</h:inputText>
</p:column>
</p:datatable>
and the code for the output is the following
<p:dataTable id="target_table">
<p:column headerText="TargetHeader">
<h:outputText id="target_id" value="#{bean.myAttribute}" />
</p:column>
</p:datatable>
i have tried several paths on the WHAT_SHOULD_GO_HERE? placeholder but I can't seem to get it right. They have all ended up throwing faces exceptions like the following:
javax.faces.FacesException: <f:ajax> contains an unknown id ':target_id' - cannot locate it in the context of the component j_idt137
this was of course when I replaced WHAT_SHOULD_GO_HERE? with :target_id
I have also tried:
form:j_idt40:target_table:0:target_id,
:form:j_idt40:target_table:0:target_id
but no luck.
Can anyone help with my understanding of xpath or maybe even f:ajax and rendering specific parts of a view?
Upvotes: 1
Views: 1351
Reputation: 1108722
Can anyone help with my understanding of xpath
JSF doesn't use Xpath in <f:ajax>
at all. It just expects a relative or absolute client ID. This is in detail explained in How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar".
You should only change the component represented by the autogenerated ID j_idt40
to have a fixed ID set, otherwise it would break again when you add or remove a component in the view later.
Upvotes: 1