Package javax.faces.component.html

Examples of javax.faces.component.html.HtmlDataTable


        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);
    }
View Full Code Here


        }
       
        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);
            inputText.setSubmittedValue("someString"+i);
        }
        data.setRowIndex(-1);
       
        for (int i = 0; i < rowCount ; i++)
        {
            data.setRowIndex(i);
            Assert.assertEquals("someString"+i, inputText.getSubmittedValue());
        }
    }
View Full Code Here

        setupRequest("/table.xhtml");
        processLifecycleExecuteAndRender();
       
        UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
        Assert.assertEquals(1, comp.getChildCount());
        HtmlDataTable dataTable = (HtmlDataTable) comp.getChildren().get(0);
        Assert.assertEquals(1, dataTable.getChildCount());

        UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
        submit(button);
        processLifecycleExecuteAndRender();

        comp = facesContext.getViewRoot().findComponent("mainForm:component");
        Assert.assertEquals(1, comp.getChildCount());
        dataTable = (HtmlDataTable) comp.getChildren().get(0);
        Assert.assertEquals(1, dataTable.getChildCount());
    }
View Full Code Here

    public void setUp() throws Exception
    {
        super.setUp();

        dataTable = new HtmlDataTable();

        writer = new MockResponseWriter(new StringWriter(), null, null);
        facesContext.setResponseWriter(writer);

        facesContext.getViewRoot().setRenderKitId(MockRenderKitFactory.HTML_BASIC_RENDER_KIT);
View Full Code Here

            captionClass = panelGrid.getCaptionClass();
            captionStyle = panelGrid.getCaptionStyle();
        }
        else if (component instanceof HtmlDataTable)
        {
            HtmlDataTable dataTable = (HtmlDataTable) component;
            captionClass = dataTable.getCaptionClass();
            captionStyle = dataTable.getCaptionStyle();
        }
        else
        {
            captionClass = (String)component.getAttributes().get(org.apache.myfaces.shared_impl.renderkit.JSFAttr.CAPTION_CLASS_ATTR);
            captionStyle = (String)component.getAttributes().get(org.apache.myfaces.shared_impl.renderkit.JSFAttr.CAPTION_STYLE_ATTR);
View Full Code Here

            captionClass = panelGrid.getCaptionClass();
            captionStyle = panelGrid.getCaptionStyle();
        }
        else if (component instanceof HtmlDataTable)
        {
            HtmlDataTable dataTable = (HtmlDataTable) component;
            captionClass = dataTable.getCaptionClass();
            captionStyle = dataTable.getCaptionStyle();
        }
        else
        {
            captionClass = (String) component.getAttributes()
                    .get(org.apache.myfaces.shared.renderkit.JSFAttr.CAPTION_CLASS_ATTR);
View Full Code Here

        if (component instanceof HtmlPanelGrid) {
            HtmlPanelGrid panelGrid = (HtmlPanelGrid) component;
            captionClass = panelGrid.getCaptionClass();
            captionStyle = panelGrid.getCaptionStyle();
        } else if (component instanceof HtmlDataTable) {
            HtmlDataTable dataTable = (HtmlDataTable) component;
            captionClass = dataTable.getCaptionClass();
            captionStyle = dataTable.getCaptionStyle();
        } else {
            captionClass = (String) component.getAttributes().get(org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr.CAPTION_CLASS_ATTR);
            captionStyle = (String) component.getAttributes().get(org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr.CAPTION_STYLE_ATTR);
        }
View Full Code Here

        if (component instanceof HtmlPanelGrid) {
            HtmlPanelGrid panelGrid = (HtmlPanelGrid) component;
            captionClass = panelGrid.getCaptionClass();
            captionStyle = panelGrid.getCaptionStyle();
        } else if (component instanceof HtmlDataTable) {
            HtmlDataTable dataTable = (HtmlDataTable) component;
            captionClass = dataTable.getCaptionClass();
            captionStyle = dataTable.getCaptionStyle();
        } else {
            captionClass = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.CAPTION_CLASS_ATTR);
            captionStyle = (String) component.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.CAPTION_STYLE_ATTR);
        }
View Full Code Here

        if (component instanceof HtmlPanelGrid) {
            HtmlPanelGrid panelGrid = (HtmlPanelGrid) component;
            captionClass = panelGrid.getCaptionClass();
            captionStyle = panelGrid.getCaptionStyle();
        } else if (component instanceof HtmlDataTable) {
            HtmlDataTable dataTable = (HtmlDataTable) component;
            captionClass = dataTable.getCaptionClass();
            captionStyle = dataTable.getCaptionStyle();
        } else {
            captionClass = (String) component.getAttributes().get(org.apache.myfaces.shared_impl.renderkit.JSFAttr.CAPTION_CLASS_ATTR);
            captionStyle = (String) component.getAttributes().get(org.apache.myfaces.shared_impl.renderkit.JSFAttr.CAPTION_STYLE_ATTR);
        }
View Full Code Here

    private void populateActionDataTable() {

        // Create <h:dataTable binding="#{myBean.dataTable}"
        // value="#{myBean.dataList}" var="dataItem">.
        HtmlDataTable actionDataTable = new HtmlDataTable();
        actionDataTable.setValueExpression("binding",
            createValueExpression("#{myBean.actionDataTable}", HtmlDataTable.class));
       
        actionDataTable.setValueExpression("value",
            createValueExpression("#{myBean.dataList}", List.class));
        actionDataTable.setVar("dataItem");

        // Create <h:column> for 'ID' column.
        HtmlColumn idColumn = new HtmlColumn();
        actionDataTable.getChildren().add(idColumn);

        // Create <h:outputText value="ID"> for <f:facet name="header"> of 'ID' column.
        HtmlOutputText idHeader = new HtmlOutputText();
        idHeader.setValue("ID");
        idColumn.setHeader(idHeader);

        // Create <h:commandLink value="#{dataItem.id}" action="#{myBean.editPopulatedDataItem}" />
        // for the body of 'ID' column.
        HtmlCommandLink idLink = new HtmlCommandLink();
        idLink.setId("edit"); // Custom ID is required in dynamic UIInput and UICommand.
        idLink.setValueExpression("value",
            createValueExpression("#{dataItem.id}", Long.class));
        idLink.setActionExpression(
            createActionExpression("#{myBean.editPopulatedDataItem}", String.class));
        idColumn.getChildren().add(idLink);

        // Create <h:column> for 'Name' column.
        HtmlColumn nameColumn = new HtmlColumn();
        actionDataTable.getChildren().add(nameColumn);

        // Create <h:outputText value="Name"> for <f:facet name="header"> of 'Name' column.
        HtmlOutputText nameHeader = new HtmlOutputText();
        nameHeader.setValue("Name");
        nameColumn.setHeader(nameHeader);

        // Create <h:outputText value="#{dataItem.name}"> for the body of 'Name' column.
        HtmlOutputText nameOutput = new HtmlOutputText();
        nameOutput.setValueExpression("value",
            createValueExpression("#{dataItem.name}", String.class));
        nameColumn.getChildren().add(nameOutput);

        // Create <h:column> for 'Value' column.
        HtmlColumn valueColumn = new HtmlColumn();
        actionDataTable.getChildren().add(valueColumn);

        // Create <h:outputText value="Value"> for <f:facet name="header"> of 'Value' column.
        HtmlOutputText valueHeader = new HtmlOutputText();
        valueHeader.setValue("Value");
        valueColumn.setHeader(valueHeader);
View Full Code Here

TOP

Related Classes of javax.faces.component.html.HtmlDataTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.