我试图建立一个数据表与对行总计的箱子,将总结该行中的任何框中的行总计的onChange JSF。 该行的样子:
<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>
所以我第一次尝试添加onChange="#{timesheet.setTotal1}"
的一天条目,但onChange事件调用JavaScript的,而不是Java / JSF代码。 一个人可以帮得到总的更新吗?
编辑:我已经接受BalusC的答案,但需要还包括event
属性的<f:ajax>
标签来得到它的工作,像这样
<h:inputText id="friday1" size="4" value="#{timesheet.friday1}" maxlength="4" required="false" >
<f:ajax event="change" render="total1" listener="#{timesheet.updateTotal1}" />
</h:inputText>