Package org.apache.myfaces.trinidad.component

Examples of org.apache.myfaces.trinidad.component.UIXCollection


  }


  private boolean _assertCurrencyKeyPreserved(Object oldKey, UIComponent table)
  {
    UIXCollection base = (UIXCollection) table;
    Object newKey = base.getRowKey();
    return (oldKey != null)?  oldKey.equals(newKey): (newKey == null);
  }
View Full Code Here


  //
  @SuppressWarnings("unchecked")
  @Override
  public void decode(FacesContext context, UIComponent component)
  {
    UIXCollection table = (UIXCollection) component;
    Object oldKey = table.getRowKey();

    table.setRowIndex(-1);
    String tableId = table.getClientId(context);

    Map<String, String[]> parameters =
      context.getExternalContext().getRequestParameterValuesMap();

    String[] unselectedBoxes =
      parameters.get(tableId+NamingContainer.SEPARATOR_CHAR+UNSELECTED_KEY);

    // check to see if there were any selection boxes in the request.
    // if there were no unselected boxes, then there can't be any selected
    // ones either:
    if ((unselectedBoxes == null) || (unselectedBoxes.length == 0))
      return;

    String[] selectedBoxes =
      parameters.get(tableId+NamingContainer.SEPARATOR_CHAR+SELECTED_KEY);

    // must work with both table and hgrid:
    final RowKeySet selectionModel;
    if (table instanceof UIXTable)
      selectionModel = ((UIXTable) table).getSelectedRowKeys();
    else
      selectionModel = ((UIXTree) table).getSelectedRowKeys();


//    Object selectMode = tableMap.get(UIConstants.SELECT_MODE_KEY);
//    // select-all/none across all ranges (both visible and invisible)
//    // is disabled for EA6. This is because it is pretty bad if in the email
//    // demo the user does a select-all followed by delete and all of his/her
//    // messages (including the ones that are currently not visible) are deleted.
//    if (false && (selectMode != null))
//    {
//      if ("all".equals(selectMode))
//        selectionModel.addAll();
//      else if ("none".equals(selectMode))
//        selectionModel.clear();
//
//      // even if we do a select all/none we still need to run through the
//      // regular per row selection code below. this is because the user might
//      // have clicked select-all and then deselected some rows before submitting:
//    }

    RowKeySet selectedDelta = selectionModel.clone();
    selectedDelta.clear();
    RowKeySet unselectedDelta = selectedDelta.clone();

    _setDeltas(table, selectedBoxes, unselectedBoxes,
               selectionModel, selectedDelta, unselectedDelta);
    if ((selectedDelta.getSize() != 0) || (unselectedDelta.getSize() != 0))
    {
      FacesEvent event =
        new SelectionEvent(table, unselectedDelta, selectedDelta);
      event.queue();
    }
    table.setRowKey(oldKey);
  }
View Full Code Here

  //
  @SuppressWarnings("unchecked")
  @Override
  public void decode(FacesContext context, UIComponent component)
  {
    UIXCollection table = (UIXCollection) component;
    Object oldKey = table.getRowKey();

    try
    {
      // Set the row key to null to force the clientId to be correct
      table.setRowKey(null);

      String selectionParam = __getSelectionParameterName(context, table);

      Map<String, String> parameters = 
        context.getExternalContext().getRequestParameterMap();
     
      _LOG.finest("Params:{0}", parameters);

      String selection = parameters.get(selectionParam);

      if (selection != null)
      {
        final RowKeySet state;
        if (table instanceof UIXTable)
          state = ((UIXTable) table).getSelectedRowKeys();
        else
          state = ((UIXTree) table).getSelectedRowKeys();

        table.setClientRowKey(selection);
        if (!state.isContained())
        {
          RowKeySet unselected = state.clone();
          // TODO : do not mutate the selectedRowKeys here.
          // instead, mutate when event is broadcast:
          state.clear();
          state.add();
          // clone, so that subsequent mutations of "state" will
          // not affect the parameters of this event: bug 4733858:
          RowKeySet selected = state.clone();
          FacesEvent event = new SelectionEvent(table, unselected, selected);
          event.queue();
        }
      }
    }
    finally
    {
      table.setRowKey(oldKey);
    }
  }
View Full Code Here

    if (!getSortable(bean))
      return SORT_NO;

    // Otherwise, look at the first sort criteria
    // =-=AEW This seems slow...
    UIXCollection table = (UIXCollection) tContext.getTable();
    List<SortCriterion> criteria = table.getSortCriteria();
    // We currently only show anything for the primary sort criterion
    if (criteria.size() > 0)
    {
      SortCriterion criterion = criteria.get(0);
      if (property.equals(criterion.getProperty()))
      {
        return criterion.isAscending() ? SORT_ASCENDING : SORT_DESCENDING;
      }
    }

    return table.isSortable(property) ? SORT_SORTABLE : SORT_NO;
  }
View Full Code Here

    if (!getSortable(bean))
      return SORT_NO;

    // Otherwise, look at the first sort criteria
    // =-=AEW This seems slow...
    UIXCollection table = (UIXCollection) tContext.getTable();
    List<SortCriterion> criteria = table.getSortCriteria();
    // We currently only show anything for the primary sort criterion
    if (criteria.size() > 0)
    {
      SortCriterion criterion = criteria.get(0);
      if (property.equals(criterion.getProperty()))
      {
        return criterion.isAscending() ? SORT_ASCENDING : SORT_DESCENDING;
      }
    }

    return table.isSortable(property) ? SORT_SORTABLE : SORT_NO;
  }
View Full Code Here

  }


  private boolean _assertCurrencyKeyPreserved(Object oldKey, UIComponent table)
  {
    UIXCollection base = (UIXCollection) table;
    Object newKey = base.getRowKey();
    return (oldKey != null)?  oldKey.equals(newKey): (newKey == null);
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public void performReport(ActionEvent action)
  {
    UIXCollection table = (UIXCollection) _table;
    final RowKeySet state;
    if (table instanceof UIXTable)
      state = ((UIXTable) table).getSelectedRowKeys();
    else
      state = ((UIXTree) table).getSelectedRowKeys();
    Iterator<Object> selection = state.iterator();
    Object oldKey = table.getRowKey();
    _selection = new ArrayList<Object>();
    while (selection.hasNext())
    {
      table.setRowKey(selection.next());
      _selection.add(table.getRowData());
    }
    table.setRowKey(oldKey);
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message =
      new FacesMessage("Report Performed","Report was performed on "+
                       _selection.size()+" records");
    context.addMessage(null, message);
View Full Code Here

  private boolean _assertCurrencyKeyPreserved(
    Object      oldKey,
    UIComponent table)
  {
    UIXCollection base = (UIXCollection) table;
    Object newKey = base.getRowKey();
    return (oldKey != null)?  oldKey.equals(newKey): (newKey == null);
  }
View Full Code Here

    UIComponent  component,
    @SuppressWarnings("unused")
    FacesBean    facesBean,
    String       clientId)
  {
    UIXCollection table = (UIXCollection) component;
    Object oldKey = table.getRowKey();

    table.setRowIndex(-1);
    String tableId = clientId == null ? table.getClientId(facesContext) : clientId;

    Map<String, String[]> parameters =
      facesContext.getExternalContext().getRequestParameterValuesMap();

    String[] unselectedBoxes =
      parameters.get(tableId+NamingContainer.SEPARATOR_CHAR+UNSELECTED_KEY);

    // check to see if there were any selection boxes in the request.
    // if there were no unselected boxes, then there can't be any selected
    // ones either:
    if ((unselectedBoxes == null) || (unselectedBoxes.length == 0))
      return;

    String[] selectedBoxes =
      parameters.get(tableId+NamingContainer.SEPARATOR_CHAR+SELECTED_KEY);

    // must work with both table and hgrid:
    final RowKeySet selectionModel;
    if (table instanceof UIXTable)
      selectionModel = ((UIXTable) table).getSelectedRowKeys();
    else
      selectionModel = ((UIXTree) table).getSelectedRowKeys();


//    Object selectMode = tableMap.get(UIConstants.SELECT_MODE_KEY);
//    // select-all/none across all ranges (both visible and invisible)
//    // is disabled for EA6. This is because it is pretty bad if in the email
//    // demo the user does a select-all followed by delete and all of his/her
//    // messages (including the ones that are currently not visible) are deleted.
//    if (false && (selectMode != null))
//    {
//      if ("all".equals(selectMode))
//        selectionModel.addAll();
//      else if ("none".equals(selectMode))
//        selectionModel.clear();
//
//      // even if we do a select all/none we still need to run through the
//      // regular per row selection code below. this is because the user might
//      // have clicked select-all and then deselected some rows before submitting:
//    }

    RowKeySet selectedDelta = selectionModel.clone();
    selectedDelta.clear();
    RowKeySet unselectedDelta = selectedDelta.clone();

    _setDeltas(table, selectedBoxes, unselectedBoxes,
               selectionModel, selectedDelta, unselectedDelta);
    if ((selectedDelta.getSize() != 0) || (unselectedDelta.getSize() != 0))
    {
      FacesEvent event =
        new SelectionEvent(table, unselectedDelta, selectedDelta);
      event.queue();
    }
    table.setRowKey(oldKey);
  }
View Full Code Here

    @Override
    protected String getValueParameter(
      UIComponent component)
    {
      UIXCollection cb = (UIXCollection) component;
      int rowIndex = cb.getRowIndex();
      return IntegerUtils.getString(rowIndex);
    }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.trinidad.component.UIXCollection

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.