Sto provando a configurare una tabella dati con JSF che contiene caselle per il totale di righe che somma il totale di righe su Cambia di qualsiasi casella nella riga. la riga si presenta come:Azione JSF da onChange
<tr id="input_row_1">
<td id="mondayInput1">
<h:inputText id="monday1" size="4" value="#{timesheet.monday1}" required="false" />
<!-- <input name="monday1" class="smallInput" type="number" size="2" maxlength="4" min="0"/> -->
</td>
<td id="tuesdayInput1">
<h:inputText id="tuesday1" size="4" value="#{timesheet.tuesday1}" required="false" />
<!--<input name="tuesday1" class="smallInput" type="number" size="2" maxlength="4" min="0"/> -->
</td>
<td id="wednesdayInput1">
<h:inputText id="wednesday1" size="4" value="#{timesheet.wednesday1}" required="false" />
<!--<input name="wednesday1" class="smallInput" type="number" size="2" maxlength="4" min="0"/> -->
</td>
<td id="thursdayInput1">
<h:inputText id="thursday1" size="4" value="#{timesheet.thursday1}" required="false" />
<!--<input name="thursday1" class="smallInput" type="number" size="2" maxlength="4" min="0"/> -->
</td>
<td id="fridayInput1">
<h:inputText id="friday1" size="4" value="#{timesheet.friday1}" required="false" />
<!--<input name="friday1" class="smallInput" type="number" size="2" maxlength="4" min="0"/> -->
</td>
<td id="saturdayInput1">
<h:inputText id="saturday1" size="4" value="#{timesheet.saturday1}" required="false" />
<!--<input name="saturday1" class="smallInput" type="number" size="2" maxlength="4" min="0"/> -->
</td>
<td id="sundayInput1">
<h:inputText id="sunday1" size="4" value="#{timesheet.sunday1}" required="false" />
<!--<input name="sunday1" class="smallInput" type="number" size="2" maxlength="4" min="0"/> -->
</td>
<td>
<h:inputText id="total1" size="4" value="#{timesheet.total1}" required="false" />
<!-- <input name="total1" id="total1" type="text" size="5" readonly="readonly" /> -->
</td>
così ho cercato prima di aggiungere onChange="#{timesheet.setTotal1}"
alle voci di giorno ma l'evento onChange chiama il codice JavaScript, non java/JSF. Qualcuno può aiutarti a ottenere il totale da aggiornare?
EDIT: Ho accettato risposta di BalusC ma aveva bisogno di includere anche l'attributo event
al tag <f:ajax>
per farlo funzionare, in questo modo
<h:inputText id="friday1" size="4" value="#{timesheet.friday1}" maxlength="4" required="false" >
<f:ajax event="change" render="total1" listener="#{timesheet.updateTotal1}" />
</h:inputText>
ho fatto questo, e ora sto ottenendo: "javax.servlet.ServletException: proprietà 'updateTotal1' non trovato sul tipo com.timesheet.Timesheet", come se updateTotal1 è una proprietà piuttosto che un metodo/azione –
In "", vuoi dire? Apparentemente il namespace XML di 'f:' taglib non è stato affatto dichiarato. L'intero tag '' sarebbe quindi trattato come "testo normale" (leggi: qualsiasi EL viene quindi considerata come espressione di valore). –
BalusC
Ma è stato dichiarato, non ho appena incluso tutto il codice html –