Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple Ajax interfering with PrimeFaces items
    text
    copied!<p>I am experiencing a problem with Ajax and PrimeFaces.</p> <p>What the page should do :</p> <p>-User choses between "Cas 1" and "Cas 2" (radiobuttons)</p> <p>-Once a case is validated, an Ajax query should display one input text area for "cas 1" and several for "cas 2". The text in input text area should be saved in a database</p> <p>What really happens :</p> <p>-User choses between "Cas 1" and "Cas 2"</p> <p>-The input text area(s) display correctly on the first time and then wont change again if you switch between "Cas 1" and "Cas 2". Also, the text isnt saved in the database.</p> <p>Separately (without the radiobuttons), both "Cas 1" and "Cas 2" work correctly</p> <p>Here is the code I am using :</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core"&gt; &lt;h:body&gt; &lt;h:form id="form"&gt; &lt;p:messages id="messages" showDetail="true" autoUpdate="true"/&gt; &lt;h:panelGrid columns="1" &gt; &lt;h:outputText value="Cas 1 : sélection « travail identique pour l’ensemble des CDC » ou un seul CDC" /&gt; &lt;h:outputText value=" " /&gt; &lt;h:outputText value="Cas 2 : sélection « travail différent suivant les CDC »" /&gt; &lt;p:selectOneRadio id="CasTrois" value="#{growlBean.casTrois}" required="true"&gt; &lt;f:selectItem itemLabel="Cas 1" itemValue="1" /&gt; &lt;f:selectItem itemLabel="Cas 2" itemValue="2" /&gt; &lt;p:ajax event="change" update="displayTrois" /&gt; &lt;/p:selectOneRadio&gt; &lt;/h:panelGrid&gt; &lt;h:panelGrid columns="1" id="displayTrois"&gt; &lt;c:if test="${growlBean.casTrois == 1}"&gt; &lt;h:outputText value="Expliquer succinctement en quoi consiste l’affaire." /&gt; &lt;h:outputText value="Donner notamment les informations liées à l’affaire mais ne figurant pas dans les CDC." /&gt; &lt;h:outputText value=" " /&gt; &lt;h:outputText value="Exemple" style="font-weight:bold; color: green"/&gt; &lt;h:outputText value="Relance en quantité 1 de tous les sous-ensembles de tous les CDC" style="font-weight:bold; color: green"/&gt; &lt;h:panelGrid columns="2"&gt; &lt;h:panelGrid columns="1"&gt; &lt;p:inputTextarea rows="8" cols="100" required="false" validatorMessage="Le champ doit être rempli" value="#{growlBean.natureDesTravaux}" autoResize="true" &gt; &lt;p:ajax event="keyup" listener="#{growlBean.setNatureDesTravaux(natureDesTravaux)}"/&gt; &lt;/p:inputTextarea&gt; &lt;/h:panelGrid&gt; &lt;/h:panelGrid&gt; &lt;/c:if&gt; &lt;c:if test="${growlBean.casTrois == 2}"&gt; &lt;h:outputText value="Expliquer succinctement en quoi consiste l’affaire." /&gt; &lt;h:outputText value="Donner notamment les informations liées à l’affaire mais ne figurant pas dans les CDC." /&gt; &lt;p:dataTable id="TableauNatrureTravaux" value="#{growlBean.listCdcAffaire2}" var="detailCdc" &gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="Nature des Travaux"/&gt; &lt;/f:facet&gt; &lt;p:column &gt; &lt;h:panelGrid columns="1"&gt; &lt;p:outputLabel for="textTravaux" value="#{detailCdc.cdcId.outillageId.numeroOutil} #{detailCdc.cdcId.outillageId.designation}" /&gt; &lt;p:inputTextarea id="textTravaux" rows="8" cols="100" value="#{detailCdc.natureTravauxPourFla}" autoResize="true" required="false" validatorMessage="test" &gt; &lt;f:validateLength minimum="1" /&gt; &lt;p:ajax event="keyup" listener="#{detailCdc.setNatureTravauxPourFla(natureTravauxPourFla)}"/&gt; &lt;/p:inputTextarea&gt; &lt;/h:panelGrid&gt; &lt;/p:column&gt; &lt;/p:dataTable&gt; &lt;/c:if&gt; &lt;/h:panelGrid&gt; &lt;/h:form&gt; &lt;/h:body&gt; </code></pre> <p> </p> <p>Can someone help me trying to refresh the page and save the text?</p>
 

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