PPR does not R: Table rows are not refreshed
--------------------------------------------
Key: TRINIDAD-750
URL: https://issues.apache.org/jira/browse/TRINIDAD-750
Project: MyFaces Trinidad
Issue Type: Bug
Reporter: Stephen Friedrich
Priority: Critical
I try to implement a table with inline editing.
In a checkbox above the table I initially select a value (a department in my
real app) which populates the table via autosubmit.
However I have not managed to get it working. PPR does not recognize that it
must update the individual table rows.
It only adds/removes rows if the row count changed, but is always showing the
very same value, even if they changed on the server.
I coded an example to show the problem:
Simple bean:
{code}package com.corejsf;
public class Datum {
private String name;
private int count;
public Datum(String name, int count) {
this.name = name;
this.count = count;
}
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public int getCount() { return count; }
public void setCount(int count) { this.count = count; }
}{code}
Bean that provides the table date (you may just replace the seam component
definition with a JSF managed bean:
{code}package com.corejsf;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import java.util.Random;
@Name("tableData")
@Scope(ScopeType.SESSION)
public class TableData {
private Random random = new Random();
private Datum[] data;
private String selectedValue = "2";
public TableData() {
refresh();
}
public Datum[] getData() { return data; }
public void setSelectedValue(String selectedValue) {
this.selectedValue = selectedValue;
refresh();
}
public String getSelectedValue() { return selectedValue; }
public void refresh() {
int i = random.nextInt(4);
int length = i == 3 ? 4 : 3;
data = new Datum[length];
for (int i1 = 0; i1 < data.length; i1++) {
data[i1] = new Datum(Character.toString((char) ('A' +
random.nextInt(26))), random.nextInt(100) + 1);
}
}
}
{code}
This is my page (using facelets). When you change the selection in the
dropwdown the table data is randomly changed and sometimes the row count is
changed from 3 to 4 or back. PPR is working somehow: The table will add/delete
the additional row. But it will never show current values:
{code:html}<?xml version="1.0" encoding="utf-8"?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:tr="http://myfaces.apache.org/trinidad"
xmlns:trh="http://myfaces.apache.org/trinidad/html">
<trh:head/>
<trh:body>
<tr:messages globalOnly="true"/>
<tr:form>
<tr:subform id="selectForm">
<tr:selectOneChoice id="selectId"
value="#{tableData.selectedValue}" autoSubmit="true">
<f:selectItem itemLabel="Eins" itemValue="1"/>
<f:selectItem itemLabel="Zwei" itemValue="2"/>
</tr:selectOneChoice>
</tr:subform>
<tr:subform>
<tr:table value="#{tableData.data}" var="datum"
partialTriggers=":selectForm:selectId">
<tr:column headerText="Name">
<tr:inputText value="#{datum.name}"/>
</tr:column>
<tr:column headerText="Count">
<h:inputText value="#{datum.count}"/>
</tr:column>
</tr:table>
</tr:subform>
</tr:form>
</trh:body>
</html>{code}
This is the same page using only pure JSF without PPR, no autosubmit. It is
working fine:
{code:html}<?xml version="1.0" encoding="utf-8"?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:tr="http://myfaces.apache.org/trinidad"
xmlns:trh="http://myfaces.apache.org/trinidad/html">
<trh:head title="m/score/engine"/>
<trh:body>
<tr:messages globalOnly="true"/>
<h:form>
<h:selectOneMenu value="#{tableData.selectedValue}">
<f:selectItem itemLabel="Eins" itemValue="1"/>
<f:selectItem itemLabel="Zwei" itemValue="2"/>
</h:selectOneMenu>
<tr:commandButton text="Refresh Table"/>
</h:form>
<h:form>
<h:dataTable value="#{tableData.data}" var="datum">
<h:column>
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<h:inputText value="#{datum.name}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Count"/>
</f:facet>
<h:inputText value="#{datum.count}"/>
</h:column>
</h:dataTable>
</h:form>
</trh:body>
</html>
{code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.