Package javax.faces.component

Examples of javax.faces.component.UIData


public class SortableColumnHeaderListener implements ActionListener {
    public void processAction(ActionEvent event) throws AbortProcessingException {
        SortableColumnHeader columnHeader = (SortableColumnHeader) event.getComponent();
        String sort = columnHeader.getSort();

        UIData table = FacesComponentUtility.getAncestorOfType(columnHeader, UIData.class);
        PagedListDataModel<?> model = (PagedListDataModel<?>) table.getValue();

        // work-around to bypass stale data model caused by a4j:keepAlive for the PagedDataTableUIBean
        PageControlView pageControlView = model.getPageControlView();
        PagedDataTableUIBean pagedDataTableUIBean = pageControlView.getPagedDataTableUIBean();
        pagedDataTableUIBean.setDataModel(null);
View Full Code Here


     * @param context
     * @param process_decodes2
     */
    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

    /**
     * Renders everything inside the <tbody> tag. currently used for the autoUpdateDataTable
     */
     public void encodeInnerHtml(FacesContext facesContext, UIComponent component)throws IOException{

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

        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);
        }
        Iterator rowStyleIterator = new StyleIterator(rowClasses);
        StyleIterator columnStyleIterator = new StyleIterator(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;
            }
            columnStyleIterator.reset();
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

    {
            ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;

            broadcastToActionListener(scrollerEvent);
           
      UIData uiData = getUIData();
      if (uiData == null)
      {
        return;
      }

      int pageindex = scrollerEvent.getPageIndex();
      if (pageindex == -1)
      {
        String facet = scrollerEvent.getScrollerfacet();
        if (FACET_FIRST.equals(facet))
        {
          uiData.setFirst(0);
        }
        else if (FACET_PREVIOUS.equals(facet))
        {
          int previous = uiData.getFirst() - uiData.getRows();
          if (previous >= 0)
            uiData.setFirst(previous);
        }
        else if (FACET_NEXT.equals(facet))
        {
          int next = uiData.getFirst() + uiData.getRows();
          if (next < uiData.getRowCount())
            uiData.setFirst(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());
          uiData.setFirst(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;
          uiData.setFirst(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)
          {
            uiData.setFirst(first);
          }
          else
          {
            uiData.setFirst(0);
          }
        }
      }
      else
      {
        int pageCount = getPageCount();
        if (pageindex > pageCount)
        {
          pageindex = pageCount;
        }
        else if (pageindex <= 0)
        {
          pageindex = 1;
        }
        uiData.setFirst(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();
    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

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

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

        int rowCount = uiData.getRowCount();

        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 newspaperColumns = getNewspaperColumns(component);
        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 = null;
        String bodyrowsAttr = (String) component.getAttributes().get(JSFAttr.BODYROWS_ATTR);
        if(bodyrowsAttr != null && !"".equals(bodyrowsAttr))
        {  
            String[] bodyrowsString = StringUtils.trim(StringUtils.splitShortString(bodyrowsAttr, ','));
            // parsing with no exception handling, because of JSF-spec:
            // "If present, this must be a comma separated list of integers."
            bodyrows = new Integer[bodyrowsString.length];
            for(int i = 0; i < bodyrowsString.length; i++)
            {
                bodyrows[i] = new Integer(bodyrowsString[i]);
            }
           
        }
        else
        {
            bodyrows = ZERO_INT_ARRAY;
        }
        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 = 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

     * 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.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 newspaperColumns = getNewspaperColumns(component);
        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 = null;
        String bodyrowsAttr = (String) component.getAttributes().get(JSFAttr.BODYROWS_ATTR);
        if(bodyrowsAttr != null && !"".equals(bodyrowsAttr))
        {  
            String[] bodyrowsString = StringUtils.trim(StringUtils.splitShortString(bodyrowsAttr, ','));
            // parsing with no exception handling, because of JSF-spec:
            // "If present, this must be a comma separated list of integers."
            bodyrows = new Integer[bodyrowsString.length];
            for(int i = 0; i < bodyrowsString.length; i++)
            {
                bodyrows[i] = new Integer(bodyrowsString[i]);
            }
           
        }
        else
        {
            bodyrows = ZERO_INT_ARRAY;
        }
        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 = 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

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.