Hi,
I have run into a problem with datatables in my application. Values entered in some of my input fields in a datatable is disappering when the page is submitted.
The application is using Suns RI together with tomahawk, and is running on JBoss.
My application consists of a backingBean (TestBean), a jsp-page and a value object.
The jsp-page has a datatable with three inputfields, and a submit button.
This is my problem:
If I enter values in all of my three input fields, and hit the submit button, only the value in the first of my three inputfields is redisplayed after the submit. The values in the other input fields disappears.
This seems like a bug to me, has anyone else experienced this behaviour? Is there a known workaround or solution to this problem?
If I use sun's datatable all of the values are redisplayed as I expect them to.
The code is pasted below.
Regards,
Mette
--------------------------------------------------------
****** Backing Bean ********
import java.util.ArrayList;
import java.util.List;
import javax.faces.event.ActionEvent;
import org.apache.myfaces.component.html.ext.HtmlDataTable;
public class TestBean {
private HtmlDataTable myTable;
private List myValues;
public TestBean() {
if(myTable == null) {
myTable = new HtmlDataTable();
if(myValues == null) {
myValues = new ArrayList();
}
myValues.add(new TestObj());
myValues.add(new TestObj());
myValues.add(new TestObj());
myTable.setValue(myValues);
}
}
public void myActionListener(ActionEvent e) {
}
public HtmlDataTable getMyTable() {
return myTable;
}
public void setMyTable(HtmlDataTable myTable) {
this.myTable = myTable;
}
}
***** jsp ******
<%@ page language="java" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSF starting page</title>
</head>
<body>
<f:view>
<h:form>
<t:dataTable binding="#{testBean.myTable}" var="testVar">
<t:column>
<t:inputText value="#{testVar.value}"></t:inputText>
</t:column>
</t:dataTable>
<t:commandButton value="Button" actionListener="#{testBean.myActionListener}" />
</h:form>
</f:view>
</body>
</html>
**** value object ******
public class TestObj {
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

