use of jakarta.faces.component.html.HtmlColumn in project myfaces by apache.
the class UIDataRowStateTest method testAddRowAfterSetRowIndex.
@Test
public void testAddRowAfterSetRowIndex() {
List<Item> list = new ArrayList<Item>();
int rowCount = 10;
facesContext.getExternalContext().getRequestMap().put("items", list);
UIViewRoot root = facesContext.getViewRoot();
UIData data = new HtmlDataTable();
data.setId("table");
root.getChildren().add(data);
data.setValue(new ListDataModel(list));
data.setVar("item");
data.setRows(rowCount);
UIColumn col = new HtmlColumn();
data.getChildren().add(col);
UIOutput text = new HtmlOutputText();
text.setId("text");
text.setValue(facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{item.name}", String.class));
col.getChildren().add(text);
data.setRowIndex(-1);
data.processDecodes(facesContext);
for (int i = 0; i < rowCount; i++) {
list.add(new Item(i, "name" + i, "lastName" + i));
}
data.processDecodes(facesContext);
}
use of jakarta.faces.component.html.HtmlColumn in project myfaces by apache.
the class UIDataRowStateTest method testChangeIdsAfterSetRowIndex2.
@Test
public void testChangeIdsAfterSetRowIndex2() {
List<Item> list = new ArrayList<Item>();
int rowCount = 10;
for (int i = 0; i < rowCount; i++) {
list.add(new Item(i, "name" + i, "lastName" + i));
}
facesContext.getExternalContext().getRequestMap().put("items", list);
UIViewRoot root = facesContext.getViewRoot();
UIData data = new HtmlDataTable();
data.setId("table");
root.getChildren().add(data);
data.setValue(new ListDataModel(list));
data.setVar("item");
data.setRows(rowCount);
UIColumn col = new HtmlColumn();
data.getChildren().add(col);
UIOutput text = new HtmlOutputText();
text.setId("text");
text.setValue(facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{item.name}", String.class));
col.getChildren().add(text);
UIInput inputText = new HtmlInputText();
inputText.setId("text");
inputText.setValue(facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{item.lastName}", String.class));
col.getChildren().add(inputText);
for (int i = 0; i < rowCount; i++) {
data.setRowIndex(i);
Assert.assertEquals(data.getId() + ":" + i + ":" + text.getId(), text.getClientId());
Assert.assertEquals(data.getId() + ":" + i + ":" + inputText.getId(), inputText.getClientId());
}
data.setRowIndex(-1);
Assert.assertEquals(data.getId() + ":" + text.getId(), text.getClientId());
Assert.assertEquals(data.getId() + ":" + inputText.getId(), inputText.getClientId());
}
use of jakarta.faces.component.html.HtmlColumn in project faces by jakartaee.
the class GridUIBean method genColumn.
private HtmlColumn genColumn(String id, int coor) {
Application application = FacesContext.getCurrentInstance().getApplication();
HtmlColumn column = (HtmlColumn) application.createComponent(HtmlColumn.COMPONENT_TYPE);
HtmlOutputText header = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
column.setId(id);
header.setValue(coor);
column.getChildren().add(header);
return column;
}
use of jakarta.faces.component.html.HtmlColumn in project faces by jakartaee.
the class DataTableUIBean method bookTableColumn.
private HtmlColumn bookTableColumn(String colheader) {
Application application = FacesContext.getCurrentInstance().getApplication();
HtmlColumn column = (HtmlColumn) application.createComponent(HtmlColumn.COMPONENT_TYPE);
HtmlOutputText header = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
column.setId(colheader);
header.setValue(colheader);
column.setHeader(header);
return column;
}
use of jakarta.faces.component.html.HtmlColumn in project myfaces by apache.
the class UIDataRowStateTest method testChangeIdsAfterSetRowIndex.
/**
*/
@Test
public void testChangeIdsAfterSetRowIndex() {
List<Item> list = new ArrayList<Item>();
int rowCount = 10;
for (int i = 0; i < rowCount; i++) {
list.add(new Item(i, "name" + i, "lastName" + i));
}
facesContext.getExternalContext().getRequestMap().put("items", list);
UIViewRoot root = facesContext.getViewRoot();
UIData data = new HtmlDataTable();
data.setId("table");
root.getChildren().add(data);
data.setValue(new ListDataModel(list));
data.setVar("item");
data.setRows(rowCount);
UIColumn col = new HtmlColumn();
data.getChildren().add(col);
UIOutput text = new HtmlOutputText();
text.setId("text");
text.setValue(facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{item.name}", String.class));
col.getChildren().add(text);
for (int i = 0; i < rowCount; i++) {
data.setRowIndex(i);
Assert.assertEquals(data.getId() + ":" + i + ":" + text.getId(), text.getClientId());
}
data.setRowIndex(-1);
Assert.assertEquals(data.getId() + ":" + text.getId(), text.getClientId());
}
Aggregations