Richfaces editable dataTable not setting changed Bean Values
ravishankar.srinivasan Jun 5, 2012 8:45 AMI have tried a bunch of suggestions after googling but none has so far worked for me. I am trying to display a simple datatable with editable inputText values in each row. table is being populated from database via a usual List of objects. Here is my xhtml page
Richfaces 4.2.1, JSF 2 mojarra bundled with JBoss 7.1, JDK 1.6
<rich:dataTable value="#{wlScoreBean.scoreList}" binding="#{wlScoreBean.scoreTable}" var="item" id="table" style="width:100%">
<rich:column>
<f:facet name="header">PARAM NAME</f:facet>
<h:outputText value="#{item.paramName}" />
</rich:column>
<rich:column>
<f:facet name="header">Portability Score</f:facet>
<h:inputText value="#{item.portabilityScore}" />
</rich:column>
<rich:column>
<f:facet name="header">Virtualization Score</f:facet>
<h:inputText value="#{item.virtualizationScore}" />
</rich:column>
</rich:dataTable>
<br/>
<h:panelGrid columns="3" id="buttonRow">
<a4j:commandButton value="Save" render="table" execute="@this" action="#{wlScoreBean.update()}">
</a4j:commandButton>
</h:panelGrid>
and here is my ManagedBean
package com.redhat.gsso.wlprofiler.beans;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.event.ValueChangeEvent;
import org.richfaces.component.UIDataTable;
import com.redhat.gsso.wlprofiler.entity.WorkloadScore;
import com.redhat.gsso.wlprofiler.services.WorkloadScoreManagerService;
@ManagedBean(name = "wlScoreBean")
@ViewScoped
public class WorkloadScoreBean implements Serializable
{
private static final long serialVersionUID = 1L;
private HtmlDataTable scoreTable;
private List<WorkloadScore> scoreList;
public void watchScore(ValueChangeEvent e)
{
System.out.println("old value="+e.getOldValue() + ", New Value="+e.getNewValue());
}
public List<WorkloadScore> getScoreList() {
return scoreList;
}
public void setScoreList(List<WorkloadScore> scoreList) {
this.scoreList = scoreList;
}
@EJB
private WorkloadScoreManagerService wlScoreManager;
public HtmlDataTable getScoreTable() {
return scoreTable;
}
public void setScoreTable(HtmlDataTable scoreTable) {
this.scoreTable = scoreTable;
}
public WorkloadScoreBean()
{
}
@PostConstruct
private void getAllScores()
{
this.scoreList = wlScoreManager.getAllScores();
}
public void update()
{
for (WorkloadScore wls : getScoreList())
{
System.out.println(wls.getParamName()+"="+wls.getPortabilityScore()+","+wls.getVirtualizationScore());
}
//wlScoreManager.update(workloadScore);
}
}
Here's all the things I tried. All of them result in only the OLD VALUES being printed to console in the update() method.
1. Changed from rich:dataTable to plain old JSF h:dataTable, same result
2. Bound the dataTable to a Managed Bean property, checked in update() method, old values are being printed here too. I just did a getVlaue() on the UIDataTable object and cast it to List<WorkloadScore>.
The List is supposed to have been updated with changed values from the form, but I do not see it happening. I did make sure to put the MBean in ViewScope.