Package javax.faces.component

Examples of javax.faces.component.UIData


        RendererUtils.checkParamValidity(facescontext, uicomponent, HtmlDataScroller.class);

        Map requestMap = facescontext.getExternalContext().getRequestMap();
        HtmlDataScroller scroller = (HtmlDataScroller)uicomponent;

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



        String pageCountVar = scroller.getPageCountVar();
        if (pageCountVar != null)
        {
            int pageCount = getPageCount(uiData);
            requestMap.put(pageCountVar, new Integer(pageCount));
        }
        String pageIndexVar = scroller.getPageIndexVar();
        if (pageIndexVar != null)
        {
            int pageIndex = getPageIndex(uiData);
            requestMap.put(pageIndexVar, new Integer(pageIndex));
        }
        String rowsCountVar = scroller.getRowsCountVar();
        if (rowsCountVar != null)
        {
            int rowsCount = uiData.getRowCount();
            requestMap.put(rowsCountVar, new Integer(rowsCount));
        }
        String displayedRowsCountVar = scroller.getDisplayedRowsCountVar();
        if (displayedRowsCountVar != null)
        {
            int displayedRowsCount = uiData.getRows();
            int max = uiData.getRowCount()-uiData.getFirst();
            if( displayedRowsCount > max )
                displayedRowsCount = max;
            requestMap.put(displayedRowsCountVar, new Integer(displayedRowsCount));
        }
        String firstRowIndexVar = scroller.getFirstRowIndexVar();
        if (firstRowIndexVar != null)
        {
            int firstRowIndex = uiData.getFirst()+1;
            requestMap.put(firstRowIndexVar, new Integer(firstRowIndex));
        }
        String lastRowIndexVar = scroller.getLastRowIndexVar();
        if (lastRowIndexVar != null)
        {
            int lastRowIndex = uiData.getFirst()+uiData.getRows();
            int count = uiData.getRowCount();
            if( lastRowIndex > count )
                lastRowIndex = count;
            requestMap.put(lastRowIndexVar, new Integer(lastRowIndex));
        }
View Full Code Here


        RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlDataScroller.class);

        ResponseWriter writer = facesContext.getResponseWriter();
        HtmlDataScroller scroller = (HtmlDataScroller)uiComponent;

        UIData uiData = findUIData(scroller, uiComponent);
        if (uiData == null)
        {
            return;
        }
View Full Code Here

    }


    private DataModel getDataModel()
    {
        UIData embeddingUIData = getEmbeddingUIData();
        if (embeddingUIData != null)
        {
            //This UIData is nested in another UIData, so we must not
            //do simple caching of the current DataModel. We must associate
            //the DataModel that we want to cache with the clientId of the
            //embedding UIData. This clientId will be different for every
            //row of the embedding UIData.
            if (_dataModelMap == null)
            {
                _dataModelMap = new HashMap();
            }
            String embeddingClientId = embeddingUIData.getClientId(FacesContext.getCurrentInstance());
            DataModel dataModel = (DataModel) _dataModelMap.get(embeddingClientId);
            if (dataModel == null)
            {
                dataModel = createDataModel();
                _dataModelMap.put(embeddingClientId, dataModel);
View Full Code Here

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

        UIData uiData = (UIData) component;

        ResponseWriter writer = facesContext.getResponseWriter();

        HtmlRendererUtils.writePrettyLineSeparator(facesContext);
        writer.startElement(HTML.TBODY_ELEM, component);

        String rowClasses;
        String columnClasses;
        if (component instanceof HtmlDataTable)
        {
            rowClasses = ((HtmlDataTable) component).getRowClasses();
            columnClasses = ((HtmlDataTable) component).getColumnClasses();
        }
        else
        {
            rowClasses = (String) component.getAttributes().get(JSFAttr.ROW_CLASSES_ATTR);
            columnClasses = (String) component.getAttributes().get(JSFAttr.COLUMN_CLASSES_ATTR);
        }
        Styles styles = new Styles(rowClasses, columnClasses);

        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;

        for (int i = first; i < last; i++)
        {
            uiData.setRowIndex(i);
            if (!uiData.isRowAvailable())
            {
                log.error("Row is not available. Rowindex = " + i);
                return;
            }

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.TBODY_ELEM, uiData);
            writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext) + ":tbody_element", null);
            writer.startElement(HTML.TR_ELEM, uiData);
            writer.startElement(HTML.TD_ELEM, uiData);
            writer.endElement(HTML.TD_ELEM);
            writer.endElement(HTML.TR_ELEM);
            writer.endElement(HTML.TBODY_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);
       
        // get the row indizes for which a new TBODY element should be created
        Integer[] bodyrows = getBodyRows(facesContext, component);
        int bodyrowsCount = 0;

        // 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.severe("Row is not available. Rowindex = " + currentRow);
                    break;
                }
   
                if (nc == 0)
                {
                    // first column in table, start new row
                    beforeRow(facesContext, uiData);

                    // is the current row listed in the bodyrows attribute
                    if(ArrayUtils.contains(bodyrows, currentRow)) 
                    {
                        // close any preopened TBODY element first
                        if(bodyrowsCount != 0)
                        {
                            HtmlRendererUtils.writePrettyLineSeparator(facesContext);
                            writer.endElement(HTML.TBODY_ELEM);
                        }
                        HtmlRendererUtils.writePrettyLineSeparator(facesContext);
                        writer.startElement(HTML.TBODY_ELEM, uiData);
                        // Do not attach bodyrowsCount to the first TBODY element, because of backward compatibility
                        writer.writeAttribute(HTML.ID_ATTR, component.getClientId(facesContext) + ":tbody_element" +
                            (bodyrowsCount == 0 ? "" : bodyrowsCount), null);
                        bodyrowsCount++;
                    }
                   
                    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);
       
        Integer[] bodyrows = getBodyRows(facesContext, component);
        int bodyrowsCount = 0;
       
        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

        return "ok";
    }

  public void deleteCountry(ActionEvent ev)
  {
    UIData datatable = findParentHtmlDataTable(ev.getComponent());
    getCountries().remove(datatable.getRowIndex() + datatable.getFirst());
  }
View Full Code Here

    return null;
  }

  public void deleteCity(ActionEvent ev)
  {
    UIData datatable = findParentHtmlDataTable(ev.getComponent());
    getCities().remove(datatable.getRowIndex() + datatable.getFirst());
  }
View Full Code Here

        Integer maximum = selectedRowsCommandButton.getMaximum();
        if (maximum != null) {
            writer.writeAttribute("maximum", maximum, "maximum");
        }

        UIData data = getTargetUIData(selectedRowsCommandButton);
        RowSelectorComponent rowSelector = getRowSelector(data);
        String rowSelectorClientId = rowSelector.getClientId(context);
        writer.writeAttribute("target", rowSelectorClientId, null);       
    }
View Full Code Here

        RowSelectorComponent rowSelector = rowSelectors.get(0);
        return rowSelector;
    }

    private UIData getTargetUIData(SelectedRowsCommandButtonComponent selectedRowsCommandButton) {
        UIData data;
        String dataTableId = selectedRowsCommandButton.getDataTableId();
        if (dataTableId != null) {
            data = (UIData) selectedRowsCommandButton.findComponent(dataTableId);
            if (data == null) {
                throw new IllegalStateException("UIData component (i.e. h:dataTable or rich:*dataTable) with id '" + dataTableId + "' not found within naming scope of component "
View Full Code Here

TOP

Related Classes of javax.faces.component.UIData

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.