I have a p:dataTable where each row has a p:commondButton and an h:outputText to display a project's name.
A click on the p:commandButton calls the anfrageErfassenModel.applyProjekt() actionListener and should immediately
update the value in the p:inputText for anfrageErfassenModel.anfrage.name.
JSF page - anfrageErfassen.xhtml:
<h:form id="formAnfrageErfassen">
<p:panelGrid columns="3" id="anfrage">
<p:outputLabel for="name" value="#{bundle['anfrage.name']}"/>
<p:inputText id="name" value="#{anfrageErfassenModel.anfrage.name}" required="true" />
<p:message for="name" id="message4name" display="text"/>
</p:panelGrid>
<p:dataTable var="projekt" ...>
<p:column>
<p:commandButton icon="fa fa-check"
title="Apply Project"
update=":formAnfrageErfassen:anfrage"
immediate="true"
actionListener="#{anfrageErfassenModel.applyProjekt(projekt)}"/>
</p:column>
<p:column>
<h:outputText value="#{projekt.name}"/>
</p:column>
</p:dataTable>
</h:form>
Bean - AnfrageErfassenModel.java:
@Named
@ViewScoped
public class AnfrageErfassenModel implements Serializable {
private Anfrage anfrage; // with getter / setter
public void applyProjekt(final Projekt projekt) {
logger.entry(projekt);
anfrage = anfrageRestClient.create();
anfrage.setName(projekt.getName()); // take name from projekt
logger.debug("anfrage.name=" + anfrage.getName());
logger.exit();
}
}
The actionListener calls anfrage.setName(projekt.getName()) which results that the model's value is set as expected
-> But the p:inputText is not updated!
I know that immediate="true" means, that the APPLY_REQUEST_VALUES phase is followed by the RENDER_RESPONSE phase!
What must I do to get the inputText field's value updated with the current value of the model?
Using p:outputText instead of p:inputText works, but I need the inputText because the field must be editable by the user!
I'm using Primefaces 6.0 on WildFly 10.0.0.Final.
Thanks and Regards, Rainer
<p:ajax listner="#{managedBean.yourMethod()}" update =":Yourcomponante" />??? - Yagami Lightp:commandButton. Adding an ajax tag is not needed there. - Kukeltje