<f: ajax> multiple Java method call - how to do this only once?

I am using ajax to call the java method bean.findDetail(). If the method finds the detailItem object in the database, the rest of the inputTexts is displayed.

<h:inputText id="worker" value="#{bean.item.id}">
 <f:ajax event="change" render="name" listener="#{bean.findDetail}"/>
 <f:ajax event="change" render="surname"/>
 <f:ajax event="change" render="age"/>
</h:inputText>

<h:panelGroup>
 <h:inputText id="name" value="#{bean.detailItem.name}" disabled="true"/>
 <h:inputText id="surname" value="#{bean.detailItem.surname}" disabled="true"/>
 <h:inputText id="age" value="#{bean.detailItem.age}" disabled="true"/>
</h:panelGroup>

Everything works fine, but the method is called three times!

Is there a way to visualize all three input texts at once?

+3
source share
1 answer

Yes, just select the selected places in the rendering element

<h:inputText id="worker" value="#{bean.item.id}">
 <f:ajax event="change" render="name surname age" listener="#{bean.findDetail}"/>
</h:inputText>
+4
source

All Articles