Package javax.faces.component

Examples of javax.faces.component.UIData$State


    /**
     * @return the page count of the uidata
     */
    public int getPageCount()
    {
        UIData uiData = getUIData();
        int rows = uiData.getRows();
        int pageCount;
        if (rows > 0)
        {
            pageCount = rows <= 0 ? 1 : uiData.getRowCount() / rows;
            if (uiData.getRowCount() % rows > 0)
            {
                pageCount++;
            }
        }
        else
View Full Code Here


        }
        setRowIndex(-1);
    }

    private void processRows(FacesContext context, int processAction) {
        UIData parentUIData = getParentUIData();
        int first = parentUIData.getFirst();
        int rows = parentUIData.getRows();
        int last;
        if (rows == 0) {
            last = parentUIData.getRowCount();
        } else {
            last = first + rows;
        }

        for (int rowIndex = first; rowIndex < last; rowIndex++) {
            parentUIData.setRowIndex(rowIndex);
            if (parentUIData.isRowAvailable()) {
                processColumns(context, processAction);
            }
        }
    }
View Full Code Here

     * This method is separated from the encodeChildren so that it can be overridden by
     * subclasses. One class that uses this functionality is autoUpdateDataTable.
     */
     public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException{

        UIData uiData = (UIData) component;
        ResponseWriter writer = facesContext.getResponseWriter();

        int rowCount = uiData.getRowCount();

        if (rowCount == 0) {
            //nothing to render, to get valid xhtml we render an empty dummy row
            writer.startElement(HTML.TR_ELEM, uiData);
            writer.startElement(HTML.TD_ELEM, uiData);
            writer.endElement(HTML.TD_ELEM);
            writer.endElement(HTML.TR_ELEM);
            return;
        }

        // begin the table
        // get the CSS styles
        Styles styles = getStyles(uiData);

        int first = uiData.getFirst();
        int rows = uiData.getRows();
        int last;

        if (rows <= 0)
        {
           last = rowCount;
        }
        else
        {
           last = first + rows;
           if (last > rowCount)
           {
               last = rowCount;
           }
        }

        int newspaperColumns = getNewspaperColumns(component);
        int newspaperRows;
        if((last - first) % newspaperColumns == 0)
            newspaperRows = (last - first) / newspaperColumns;
        else newspaperRows = ((last - first) / newspaperColumns) + 1;
        boolean newspaperHorizontalOrientation = isNewspaperHorizontalOrientation(component);

        // walk through the newspaper rows
        for(int nr = 0; nr < newspaperRows; nr++)
        {
            beforeRow(facesContext, uiData);

            // walk through the newspaper columns
            for(int nc = 0; nc < newspaperColumns; nc++) {

                // the current row in the 'real' table
                int currentRow;
                if (newspaperHorizontalOrientation)
                    currentRow = nr * newspaperColumns + nc + first;
                else
                    currentRow = nc * newspaperRows + nr + first;
               
                // if this row is not to be rendered
                if(currentRow >= last) continue;

                // bail if any row does not exist
                uiData.setRowIndex(currentRow);
                if(!uiData.isRowAvailable()) {
                    log.error("Row is not available. Rowindex = " + currentRow);
                    break;
                }
   
                if (nc == 0) {
                    // first column in table, start new row
                    beforeRow(facesContext, uiData);

                    HtmlRendererUtils.writePrettyLineSeparator(facesContext);
                    renderRowStart(facesContext, writer, uiData, styles, nr);
                }

                List children = getChildren(component);
                for (int j = 0, size = getChildCount(component); j < size; j++)
                {
                    UIComponent child = (UIComponent) children.get(j);
                    if (child.isRendered())
                    {
                        boolean columnRendering = child instanceof UIColumn;
                       
                        if (columnRendering)
                            beforeColumn(facesContext, uiData, j);
                          
                        encodeColumnChild(facesContext, writer, uiData, child, styles, nc * uiData.getChildCount() + j);                   
                      
                        if (columnRendering)
                            afterColumn(facesContext, uiData, j);
                    }
                }
View Full Code Here

     * This method is separated from the encodeChildren so that it can be overridden by
     * subclasses. One class that uses this functionality is autoUpdateDataTable.
     */
     public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException{

        UIData uiData = (UIData) component;
        ResponseWriter writer = facesContext.getResponseWriter();

        int rowCount = uiData.getRowCount();

        int newspaperColumns = getNewspaperColumns(component);

        if (rowCount == -1 && newspaperColumns == 1)
        {
            encodeInnerHtmlUnknownRowCount(facesContext, component);
            return;
        }
       
        if (rowCount == 0)
        {
            //nothing to render, to get valid xhtml we render an empty dummy row
            writer.startElement(HTML.TR_ELEM, uiData);
            writer.startElement(HTML.TD_ELEM, uiData);
            writer.endElement(HTML.TD_ELEM);
            writer.endElement(HTML.TR_ELEM);
            return;
        }

        // begin the table
        // get the CSS styles
        Styles styles = getStyles(uiData);

        int first = uiData.getFirst();
        int rows = uiData.getRows();
        int last;

        if (rows <= 0)
        {
           last = rowCount;
        }
        else
        {
           last = first + rows;
           if (last > rowCount)
           {
               last = rowCount;
           }
        }

        int newspaperRows;
        if((last - first) % newspaperColumns == 0)
        {
            newspaperRows = (last - first) / newspaperColumns;
        }
        else
        {
            newspaperRows = ((last - first) / newspaperColumns) + 1;
        }
        boolean newspaperHorizontalOrientation = isNewspaperHorizontalOrientation(component);

        // walk through the newspaper rows
        for(int nr = 0; nr < newspaperRows; nr++)
        {
            boolean rowStartRendered = false;
            // walk through the newspaper columns
            for(int nc = 0; nc < newspaperColumns; nc++)
            {

                // the current row in the 'real' table
                int currentRow;
                if (newspaperHorizontalOrientation)
                {
                    currentRow = nr * newspaperColumns + nc + first;
                }
                else
                {
                    currentRow = nc * newspaperRows + nr + first;
                }
               
                // if this row is not to be rendered
                if(currentRow >= last)
                {
                    continue;
                }

                // bail if any row does not exist
                uiData.setRowIndex(currentRow);
                if(!uiData.isRowAvailable())
                {
                    log.error("Row is not available. Rowindex = " + currentRow);
                    break;
                }
   
                if (nc == 0)
                {
                    // first column in table, start new row
                    beforeRow(facesContext, uiData);

                    HtmlRendererUtils.writePrettyLineSeparator(facesContext);
                    renderRowStart(facesContext, writer, uiData, styles, nr);
                    rowStartRendered = true;
                }

                List children = null;
                for (int j = 0, size = getChildCount(component); j < size; j++)
                {
                    if (children == null)
                    {
                        children = getChildren(component);
                    }
                    UIComponent child = (UIComponent) children.get(j);
                    if (child.isRendered())
                    {
                        boolean columnRendering = child instanceof UIColumn;
                       
                        if (columnRendering)
                        {
                            beforeColumn(facesContext, uiData, j);
                        }
                          
                        encodeColumnChild(facesContext, writer, uiData, child,
                                styles, nc * uiData.getChildCount() + j);                   
                      
                        if (columnRendering)
                        {
                            afterColumn(facesContext, uiData, j);
                        }
View Full Code Here

        }
    }

    private void encodeInnerHtmlUnknownRowCount(FacesContext facesContext, UIComponent component)throws IOException
    {
        UIData uiData = (UIData) component;
        ResponseWriter writer = facesContext.getResponseWriter();

        Styles styles = getStyles(uiData);
       
        int first = uiData.getFirst();
        int rows = uiData.getRows();
        int currentRow = first;
        boolean isRowRendered = false;
       
        while(true)
        {
            uiData.setRowIndex(currentRow);
            if (!uiData.isRowAvailable())
            {
                break;
            }
           
            isRowRendered = true;
View Full Code Here

        };
        ;
        childChildFacetInvoked = 0;
        childChildFacet.setId("childChildFacet");
        childChild.getFacets().put("facet", childChildFacet);
        data = new UIData();
        renderKit.addRenderer(child.getFamily(), child.getRendererType(), new MockUIInputRenderer());
        renderKit.addRenderer(adaptor.getFamily(), adaptor.getRendererType(), new MockUIInputRenderer());
    }
View Full Code Here

        adaptor.encodeBegin(facesContext);

        UIViewRoot viewRoot = facesContext.getViewRoot();
        Object treeState = viewRoot.processSaveState(facesContext);
        UIViewRoot root = (UIViewRoot) viewRoot.getClass().newInstance();
        UIData restoredData = new UIData();
        UIDataAdaptor restoredAdaptor = new MockDataAdaptor();

        root.getChildren().add(restoredData);

        UIColumn column = new UIColumn();

        restoredData.getChildren().add(column);
        column.getChildren().add(restoredAdaptor);
        root.processRestoreState(facesContext, treeState);
        restoredData.setRowIndex(0);
        mockState = (MockComponentState) restoredAdaptor.getComponentState();
        assertEquals(123, mockState.getCount());
        restoredData.setRowIndex(1);
        mockState = (MockComponentState) restoredAdaptor.getComponentState();
        assertEquals(321, mockState.getCount());
    }
View Full Code Here

        ResponseWriter writer = context.getResponseWriter();
       
       
        log.debug("Childern: " + component.getChildCount() + " of Component " + component.getFamily());
       
        UIData comp = (UIData)component;
       
        int first = comp.getFirst();
        int rows = comp.getRows();
        int rowCount = comp.getRowCount();
        if (rows <= 0) {
            rows = rowCount - first;
        }
        int last = first + rows;
        if (last > rowCount) last = rowCount;
       
        for (int i = first; i < last; i++){
            writer.startElement(Attributes.TR, component);
            comp.setRowIndex(i);
           
            if (!comp.isRowAvailable()){
                log.error("Row: " + i + " is not available.");
                continue;
            }
           
            Iterator columns = component.getChildren().iterator();
View Full Code Here

    public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException
    {
        RendererUtils.checkParamValidity(facesContext, component, UIData.class);

        UIData uiData = (UIData)component;
        String layout = getLayout(component);
        //Map requestMap = facesContext.getExternalContext().getRequestMap();

        ResponseWriter writer = facesContext.getResponseWriter();

        int first = uiData.getFirst();
        int rows = uiData.getRows();
        int rowCount = uiData.getRowCount();
        if (rows <= 0)
        {
            rows = rowCount - first;
        }
        int last = first + rows;
        if (last > rowCount) last = rowCount;

        /*
        String rowIndexVar = getRowIndexVar(component);
        String rowCountVar = getRowCountVar(component);

        if (rowCountVar != null)
        {
            requestMap.put(rowCountVar, new Integer(rowCount));
        }
        */

        for (int i = first; i < last; i++)
        {
            uiData.setRowIndex(i);
            if (uiData.isRowAvailable())
            {
                /*
                if (rowIndexVar != null)
                {
                    requestMap.put(rowIndexVar, new Integer(i));
View Full Code Here

    {
        RendererUtils.checkParamValidity(context, component, HtmlDataScroller.class);

        HtmlDataScroller scroller = (HtmlDataScroller)component;

        UIData uiData = findUIData(scroller, component);
        if (uiData == null)
        {
            return;
        }

        Map parameter = context.getExternalContext().getRequestParameterMap();
        String param = (String)parameter.get(component.getClientId(context));
        if (param != null)
        {
            if (param.equals(FACET_FIRST))
            {
                uiData.setFirst(0);
            }
            else if (param.equals(FACET_PREVOIUS))
            {
                int previous = uiData.getFirst() - uiData.getRows();
                if (previous >= 0)
                    uiData.setFirst(previous);
            }
            else if (param.equals(FACET_NEXT))
            {
                int next = uiData.getFirst() + uiData.getRows();
                if (next < uiData.getRowCount())
                    uiData.setFirst(next);
            }
            else if (param.equals(FACET_FAST_FORWARD))
            {
                int fastStep = scroller.getFastStep();
                if (fastStep <= 0)
                    fastStep = 1;
                int next = uiData.getFirst() + uiData.getRows() * fastStep;
                int rowcount = uiData.getRowCount();
                if (next > rowcount)
                     next = (rowcount - 1) - ((rowcount - 1) % uiData.getRows());
                uiData.setFirst(next);
            }
            else if (param.equals(FACET_FAST_REWIND))
            {
                int fastStep = scroller.getFastStep();
                if (fastStep <= 0)
                    fastStep = 1;
                int previous = uiData.getFirst() - uiData.getRows() * fastStep;
                if (previous < 0)
                    previous = 0;
                uiData.setFirst(previous);
            }
            else if (param.equals(FACET_LAST))
            {
                int rowcount = uiData.getRowCount();
                int rows = uiData.getRows();
                int delta = rowcount % rows;
                int first = delta > 0 && delta < rows ? rowcount - delta : rowcount - rows;
                if (first >= 0)
                {
                    uiData.setFirst(first);
                }
                else
                {
                    uiData.setFirst(0);
                }
            }
            else if (param.startsWith(PAGE_NAVIGATION))
            {
                int index = Integer.parseInt(param.substring(PAGE_NAVIGATION.length(), param.length()));
                int pageCount = getPageCount(uiData);
                if (index > pageCount)
                {
                    index = pageCount;
                }
                else if (index <= 0)
                {
                    index = 1;
                }
                uiData.setFirst(uiData.getRows() * (index - 1));
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.faces.component.UIData$State

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.