You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/08/28 22:07:34 UTC
svn commit: r990432 -
/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTablePreserveRowComponentStateTest.java
Author: lu4242
Date: Sat Aug 28 20:07:34 2010
New Revision: 990432
URL: http://svn.apache.org/viewvc?rev=990432&view=rev
Log:
TOMAHAWK-1541 detailStamp state should be deleted on deleteRowStateForRow in t:dataTable
Modified:
myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTablePreserveRowComponentStateTest.java
Modified: myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTablePreserveRowComponentStateTest.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTablePreserveRowComponentStateTest.java?rev=990432&r1=990431&r2=990432&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTablePreserveRowComponentStateTest.java (original)
+++ myfaces/tomahawk/trunk/core20/src/test/java/org/apache/myfaces/component/html/ext/HtmlDataTablePreserveRowComponentStateTest.java Sat Aug 28 20:07:34 2010
@@ -291,5 +291,88 @@ public class HtmlDataTablePreserveRowCom
}
}
-
+
+ public void testPreserveRowComponentStateDetailStamp2() throws Exception
+ {
+ List<RowData> model = new ArrayList<RowData>();
+ model.add(new RowData("text1","style1"));
+ model.add(new RowData("text1","style2"));
+ model.add(new RowData("text1","style3"));
+ model.add(new RowData("text1","style4"));
+
+ //Put on request map to be resolved later
+ request.setAttribute("list", model);
+
+ UIViewRoot root = facesContext.getViewRoot();
+ HtmlDataTable table = new HtmlDataTable();
+ UIColumn column = new UIColumn();
+ UIPanel detailStampPanel = new UIPanel();
+ UIOutput text = new UIOutput();
+ UIOutput detailStampText = new UIOutput();
+
+ //This is only required if markInitiaState fix is not used
+ root.setId("root");
+ table.setId("table");
+ detailStampPanel.setId("detailStamp");
+ column.setId("column");
+ text.setId("text");
+ detailStampText.setId("detailStampText");
+
+ table.setVar("row");
+ table.setPreserveRowComponentState(true);
+ table.setValueExpression("value", application.
+ getExpressionFactory().createValueExpression(
+ facesContext.getELContext(),"#{list}",List.class));
+
+ text.setValueExpression("value", application.
+ getExpressionFactory().createValueExpression(
+ facesContext.getELContext(),"#{row.text}",String.class));
+
+ detailStampText.setValueExpression("value", application.
+ getExpressionFactory().createValueExpression(
+ facesContext.getELContext(),"#{row.text}",String.class));
+
+ root.getChildren().add(table);
+ table.getChildren().add(column);
+ table.getFacets().put(AbstractHtmlDataTable.DETAIL_STAMP_FACET_NAME, detailStampPanel);
+ column.getChildren().add(text);
+ detailStampPanel.getChildren().add(detailStampText);
+
+ //Simulate markInitialState call.
+ facesContext.getAttributes().put("org.apache.myfaces.MARK_INITIAL_STATE", Boolean.TRUE);
+ root.markInitialState();
+ table.markInitialState();
+ detailStampPanel.markInitialState();
+ detailStampText.markInitialState();
+ column.markInitialState();
+ text.markInitialState();
+ facesContext.getAttributes().remove("org.apache.myfaces.MARK_INITIAL_STATE");
+
+ //Check the value expressions are working and change the component state
+ for (int i = 0; i < model.size(); i++)
+ {
+ RowData rowData = model.get(i);
+ table.setRowIndex(i);
+ assertEquals(rowData.getText(), text.getValue());
+ assertEquals(rowData.getText(), detailStampText.getValue());
+ text.getAttributes().put("style", rowData.getStyle());
+ detailStampText.getAttributes().put("style", rowData.getStyle());
+ }
+
+ //Reset row index
+ table.setRowIndex(-1);
+
+ //Remove a row
+ table.deleteRowStateForRow(1);
+ model.remove(1);
+
+ //Check the values were not lost
+ for (int i = 0; i < model.size(); i++)
+ {
+ table.setRowIndex(i);
+ assertEquals(model.get(i).getStyle(), text.getAttributes().get("style"));
+ assertEquals(model.get(i).getStyle(), detailStampText.getAttributes().get("style"));
+ }
+
+ }
}