i'm quite new at jsf develop.
I've a datagrid and i need to ajax update a single "item" of the datagrid, when the value of a p:spinner change.
How can i identify and update it? How datagrid "var" and generally, repeat var can be referred in my DOM?
here a snippet of my code:
Code: Select all
<p:dataGrid value="#{central.productList.products}" rows="6"
columns="2" var="current" paginator="true" effectSpeed="fast"
effect="false" id="catalogList">
<p:column styleClass="intestaz_pannelli">
<p:panel header="#{current.label}" styleClass="intestaz_pannelli"
style="font-family: sans-serif; font-size: 15px;" >
<table width="100%">
<tr>
<td height="15%" valign="middle"><h:outputLabel value="totalPrice: " /></td>
<td height="15%" valign="middle"><h:outputText id="totPrize" value="#{current.totalPrice}"></h:outputText></td>
</tr>
<tr>
<td><p:spacer height="10" width="1"></p:spacer></td>
</tr>
<tr>
<td height="30%" valign="middle">
<p:spinner id="spinner" value="#{current.qta}" min="1" max="99"
required="true" size="2" >
<p:ajax event="keyup" update="totPrize"
actionListener="#{central.computeTotalPrice(current)}"/>
</p:spinner>
</td>
</tr>
</table>
</p:panel>
</p:column>
</p:dataGrid>
Code: Select all
public void computeTotalPrice(Product p){
log.debug("computeTotalPrice before: " + p.getTotalPrice());
p.setTotalPrice(p.getTotalPrice() * p.getQta());
log.debug("computeTotalPrice after: " + p.getTotalPrice());
}