Package javax.faces.component

Examples of javax.faces.component.UIData$State


       UIComponent uiComponent = parent;
       do
       {
          if (uiComponent instanceof UIData)
          {
             UIData uiData = (UIData)uiComponent;
             //System.out.println("$$$ Adding " + uiData.getClientId(javax.faces.context.FacesContext.getCurrentInstance())
             //                   + " to uiDataRowMap with index=" + uiData.getRowIndex());
             uiDataRowMap.put(uiData, uiData.getRowIndex());
          }
          uiComponent = uiComponent.getParent();
       }
       while (uiComponent != null);
    }
View Full Code Here


       Map<UIData, Integer> savedRowIndexes = new HashMap<UIData, Integer>();
      
       // save current row and set row needed to get value
       for (Iterator<UIData> i = reverse(uiDataRowMap.keySet().iterator()); i.hasNext();)
       {
          UIData uiData = i.next();
          savedRowIndexes.put(uiData, uiData.getRowIndex());
          uiData.setRowIndex(uiDataRowMap.get(uiData));
       }
      
       Object value = component.getValue();
      
       // restore rows
       for (Iterator<UIData> i = reverse(savedRowIndexes.keySet().iterator()); i.hasNext();)
       {
          UIData uiData = i.next();
          uiData.setRowIndex(savedRowIndexes.get(uiData));
       }
      
       return value;
    }
View Full Code Here

        if (!shouldEncode(component)) {
            return;
        }

        UIData data = (UIData) component;
        data.setRowIndex(-1);

        // Render the beginning of the table
        ResponseWriter writer = context.getResponseWriter();

        renderTableStart(context, component, writer, ATTRIBUTES);
View Full Code Here

        if (!shouldEncodeChildren(component)) {
            return;
        }

        UIData data = (UIData) component;

        ResponseWriter writer = context.getResponseWriter();
       
        // Check if any columns are being rendered, if not
        // render the minimal markup and exit
        TableMetaInfo info = getMetaInfo(context, data);
        if(info.columns.isEmpty()) {
          renderEmptyTableBody(writer,data);
          return;
        }
        // Iterate over the rows of data that are provided
        int processed = 0;
        int rowIndex = data.getFirst() - 1;
        int rows = data.getRows();
        List<Integer> bodyRows = getBodyRows(context.getExternalContext().getApplicationMap(), data);
        boolean hasBodyRows = (bodyRows != null && !bodyRows.isEmpty());
        boolean wroteTableBody = false;
        if (!hasBodyRows) {
            renderTableBodyStart(context, component, writer);
        }
        boolean renderedRow = false;
        while (true) {

            // Have we displayed the requested number of rows?
            if ((rows > 0) && (++processed > rows)) {
                break;
            }
            // Select the current row
            data.setRowIndex(++rowIndex);
            if (!data.isRowAvailable()) {
                break; // Scrolled past the last row
            }

            // render any table body rows
            if (hasBodyRows && bodyRows.contains(data.getRowIndex())) {
                if (wroteTableBody) {
                    writer.endElement("tbody");
                }
                writer.startElement("tbody", data);
                wroteTableBody = true;
            }

            // Render the beginning of this row
            renderRowStart(context, component, writer);

            // Render the row content
            renderRow(context, component, null, writer);

            // Render the ending of this row
            renderRowEnd(context, component, writer);
            renderedRow = true;

        }

        // fill an empty tbody, if no row has been rendered
        if(!renderedRow) {
          this.renderEmptyTableRow(writer, data);
        }
        renderTableBodyEnd(context, component, writer);

        // Clean up after ourselves
        data.setRowIndex(-1);

    }
View Full Code Here

                        _removeVisitedFacetCount(parent);
                       
                        // check for componentes that visit their children multiple times
                        if (parent instanceof UIData)
                        {
                            UIData uidata = (UIData) parent;
                            if (uidata.getRowIndex() != uidata.getRowCount() - 1)
                            {
                                // only continue if we're in the last row
                                break;
                            }
                        }
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();

        // 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 = uiData.getRowCount();
        }
        else
        {
           last = first + rows;
           if (last > uiData.getRowCount())
           {
               last=uiData.getRowCount();
           }
        }

        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++)
        {

            // 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

    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));
        }
        */

        if (layout != null && layout.equals(LAYOUT_GRID)){
            // output table row
            writer.startElement(HTML.TR_ELEM, null);
        }
        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

     * 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();

        // 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 = uiData.getRowCount();
        }
        else
        {
           last = first + rows;
           if (last > uiData.getRowCount())
           {
               last=uiData.getRowCount();
           }
        }

        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++)
        {

            // 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

            ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;

            broadcastToActionListener(scrollerEvent);
           
            // huh? getUIData never returns null.
            UIData uiData = getUIData();
            if (uiData == null)
            {
                return;
            }

            int pageindex = scrollerEvent.getPageIndex();
            if (pageindex == -1)
            {
                String facet = scrollerEvent.getScrollerfacet();
                if (FACET_FIRST.equals(facet))
                {
                    setFirst(uiData, 0);
                }
                else if (FACET_PREVIOUS.equals(facet))
                {
                    int previous = uiData.getFirst() - uiData.getRows();
                    if (previous >= 0)
                        setFirst(uiData, previous);
                }
                else if (FACET_NEXT.equals(facet))
                {
                    int next = uiData.getFirst() + uiData.getRows();
                    if (next < uiData.getRowCount())
                        setFirst(uiData, next);
                }
                else if (FACET_FAST_FORWARD.equals(facet))
                {
                    int fastStep = 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());
                    setFirst(uiData, next);
                }
                else if (FACET_FAST_REWIND.equals(facet))
                {
                    int fastStep = getFastStep();
                    if (fastStep <= 0)
                        fastStep = 1;
                    int previous = uiData.getFirst() - uiData.getRows() * fastStep;
                    if (previous < 0)
                        previous = 0;
                    setFirst(uiData, previous);
                }
                else if (FACET_LAST.equals(facet))
                {
                    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)
                    {
                        setFirst(uiData, first);
                    }
                    else
                    {
                        setFirst(uiData, 0);
                    }
                }
            }
            else
            {
                int pageCount = getPageCount();
                if (pageindex > pageCount)
                {
                    pageindex = pageCount;
                }
                else if (pageindex <= 0)
                {
                    pageindex = 1;
                }
                setFirst(uiData, uiData.getRows() * (pageindex - 1));
            }
        }
    }
View Full Code Here

    /**
     * @return the page index of the uidata
     */
    public int getPageIndex()
    {
        UIData uiData = getUIData();
        int rows = uiData.getRows();
        if (0 == rows)
        {
            throw new FacesException("You need to set a value to the 'rows' attribute of component '" + uiData.getClientId(getFacesContext()) + "'" );
        }

        int pageIndex;
        if (rows > 0)
        {
            pageIndex = uiData.getFirst() / rows + 1;
        }
        else
        {
            log.warn("DataTable " + uiData.getClientId(FacesContext.getCurrentInstance())
                            + " has invalid rows attribute.");
            pageIndex = 0;
        }
        if (uiData.getFirst() % rows > 0)
        {
            pageIndex++;
        }
        return pageIndex;
    }
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.