Search in sources :

Example 1 with HtmlColumn

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);
}
Also used : HtmlDataTable(jakarta.faces.component.html.HtmlDataTable) UIColumn(jakarta.faces.component.UIColumn) ArrayList(java.util.ArrayList) ListDataModel(jakarta.faces.model.ListDataModel) UIData(jakarta.faces.component.UIData) HtmlColumn(jakarta.faces.component.html.HtmlColumn) UIOutput(jakarta.faces.component.UIOutput) HtmlOutputText(jakarta.faces.component.html.HtmlOutputText) UIViewRoot(jakarta.faces.component.UIViewRoot) Test(org.junit.Test)

Example 2 with HtmlColumn

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());
}
Also used : HtmlDataTable(jakarta.faces.component.html.HtmlDataTable) UIColumn(jakarta.faces.component.UIColumn) ArrayList(java.util.ArrayList) HtmlInputText(jakarta.faces.component.html.HtmlInputText) UIInput(jakarta.faces.component.UIInput) ListDataModel(jakarta.faces.model.ListDataModel) UIData(jakarta.faces.component.UIData) HtmlColumn(jakarta.faces.component.html.HtmlColumn) UIOutput(jakarta.faces.component.UIOutput) HtmlOutputText(jakarta.faces.component.html.HtmlOutputText) UIViewRoot(jakarta.faces.component.UIViewRoot) Test(org.junit.Test)

Example 3 with HtmlColumn

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;
}
Also used : HtmlOutputText(jakarta.faces.component.html.HtmlOutputText) Application(jakarta.faces.application.Application) HtmlColumn(jakarta.faces.component.html.HtmlColumn)

Example 4 with HtmlColumn

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;
}
Also used : HtmlOutputText(jakarta.faces.component.html.HtmlOutputText) Application(jakarta.faces.application.Application) HtmlColumn(jakarta.faces.component.html.HtmlColumn)

Example 5 with HtmlColumn

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());
}
Also used : HtmlDataTable(jakarta.faces.component.html.HtmlDataTable) UIColumn(jakarta.faces.component.UIColumn) ArrayList(java.util.ArrayList) ListDataModel(jakarta.faces.model.ListDataModel) UIData(jakarta.faces.component.UIData) HtmlColumn(jakarta.faces.component.html.HtmlColumn) UIOutput(jakarta.faces.component.UIOutput) HtmlOutputText(jakarta.faces.component.html.HtmlOutputText) UIViewRoot(jakarta.faces.component.UIViewRoot) Test(org.junit.Test)

Aggregations

HtmlColumn (jakarta.faces.component.html.HtmlColumn)6 HtmlOutputText (jakarta.faces.component.html.HtmlOutputText)6 UIColumn (jakarta.faces.component.UIColumn)4 UIData (jakarta.faces.component.UIData)4 UIOutput (jakarta.faces.component.UIOutput)4 UIViewRoot (jakarta.faces.component.UIViewRoot)4 HtmlDataTable (jakarta.faces.component.html.HtmlDataTable)4 ListDataModel (jakarta.faces.model.ListDataModel)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 Application (jakarta.faces.application.Application)2 UIInput (jakarta.faces.component.UIInput)2 HtmlInputText (jakarta.faces.component.html.HtmlInputText)2