I'm confused with use of render attribute of h:ajax inside tables.
I'm using Glassfish 2.1.1 and Mojarra 2.0.1 (FCS b02).
The question is:
I want refresh table which has the h:commandButton which throws event.
¿Why refresh nothing when push "add updating :sumForm:tableId" and "add updating tableId" buttons of this simplify absolutely absurd example ( my real case is more complex ):
This is my code:
<pre>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml"
xmlns:h="
http://java.sun.com/jsf/html"
xmlns:f="
http://java.sun.com/jsf/core">
<h:head>
<style>
table {
border: 10px solid;
}
</style>
</h:head>
<h:body>
<div align="center">
<h:form id="sumForm">
<h:panelGroup id="tableWrapperId" >
<h:dataTable value="#{sumtable.table}" var="lst1" id="tableId">
<h:column>
<h:commandButton action="#{sumtable.add}" value="add updating :sumForm:tableId">
<f:ajax execute="@this" render=":sumForm:tableId"/>
</h:commandButton>
<h:commandButton action="#{sumtable.add}" value="add updating tableId">
<f:ajax execute="@this" render="tableId"/>
</h:commandButton>
<h:commandButton action="#{sumtable.add}" value="add updating tableWrapperId">
<f:ajax execute="@this" render=":sumForm:tableWrapperId "/>
</h:commandButton>
<h:commandButton action="#{sumtable.add}" value="add updating subtotals">
<f:ajax execute="@this" render=":sumForm:sumsId"/>
</h:commandButton>
<h:commandButton action="#{sumtable.add}" value="add updating form">
<f:ajax execute="@this" render="@form"/>
</h:commandButton>
#{lst1[0]}
</h:column>
<h:column>
#{lst1[1]}
</h:column>
</h:dataTable>
</h:panelGroup>
<h:dataTable value="#{sumtable.sums}" var="sums" id="sumsId">
<h:column>
#{sums[0]}
</h:column>
<h:column>
#{sums[1]}
</h:column>
</h:dataTable>
</h:form>
</div>
</h:body>
</html>
</pre>
package com.silyan.pruebas;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
/**
* @author angel
*
*/
@ManagedBean(name="sumtable")
@SessionScoped
public class SumController {
private final static int COLUMNS_LEN = 2;
private List<List<Integer>> table = new ArrayList<List<Integer>>();
private List<Integer[]> sums = new ArrayList<Integer[]>();
@PostConstruct
public void init() {
fill();
}
private int base = 0;
public void fill() {
sums.clear();
Integer[] arrSum = new Integer[COLUMNS_LEN];
sums.add(arrSum);
table.clear();
for (int i = 0; i < COLUMNS_LEN; i++) {
arrSum[i] = 0;
}
for (int i = 0; i < 10; i++) {
List<Integer> integers = new ArrayList<Integer>();
table.add(integers);
for (int j = 0; j < COLUMNS_LEN; j++) {
integers.add(new Integer(j + base));
arrSum[j] = arrSum[j] + j + base;
}
}
}
public String add() {
base++;
fill();
return null;
}
public List<List<Integer>> getTable() {
return table;
}
public void setTable(List<List<Integer>> table) {
this.table = table;
}
public List<Integer[]> getSums() {
return sums;
}
public void setSums(List<Integer[]> sums) {
this.sums = sums;
}
}
[Message sent by forum member 'angelcervera' ]
http://forums.java.net/jive/thread.jspa?messageID=373932