datagrid partial ajax update

UI Components for JSF
Post Reply
Ale841
Posts: 2
Joined: 14 Sep 2011, 13:43

14 Sep 2011, 14:40

Hi all,

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>
and here the snippet of the central managed been:

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());
	}
Thanks to all
Application Server: GlassFish Version 3.1 (build 43)
JSF Version: 2.0 Mojarra
Primefaces version: 3.0.1
JDK Version: jdk1.6.0_25

mario_anta
Posts: 24
Joined: 25 Oct 2011, 09:57

25 Oct 2011, 10:01

That's an interesting question I'd love to know an answer as well :)
Tomcat 7, MyFaces 2.1.9, PF 3.4.1, PFE 0.6.1, STS 3.1, Java 1.7, W7x64

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 19 guests