Package org.richfaces.component

Examples of org.richfaces.component.UIOrderingList


 
  public void encodeOneRow(FacesContext context, TableHolder holder)
      throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    OrderingListRendererTableHolder tableHolder = (OrderingListRendererTableHolder) holder;
    UIOrderingList table = (UIOrderingList) holder.getTable();
    String clientId = holder.getTable().getClientId(context);
    writer.startElement(HTML.TR_ELEMENT, table);
    writer.writeAttribute("id",  clientId, null);
   
    StringBuffer rowClassName = new StringBuffer("rich-ordering-list-row");
   
    String rowClass = holder.getRowClass();
    if (rowClass != null) {
      rowClassName.append(' ');
      rowClassName.append(rowClass);
    }
   
    StringBuffer cellClassName = new StringBuffer("rich-ordering-list-cell");
   
    ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
    ItemState state = getItemState(context, table, variables);
   
    boolean active = state.isActive();
//    if (active) {
//      rowClassName.append(" rich-ordering-list-row-active");
//      cellClassName.append(" rich-ordering-list-cell-active");
//    }
   
    boolean selected = state.isSelected();
    if (selected) {
      rowClassName.append(" rich-ordering-list-row-selected");
      cellClassName.append(" rich-ordering-list-cell-selected");
    }

    SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
    selectionState.addState(selected);
   
    writer.writeAttribute("class", rowClassName.toString(), null);
   
    boolean columnRendered = false;
   
    int colCounter = 0;

    for (Iterator iterator = table.columns(); iterator.hasNext();) {
      UIComponent component = (UIComponent) iterator.next();
     
      if (component.isRendered()) {
        writer.startElement(HTML.td_ELEM, table);
       
        //if (!iterator.hasNext()) {
        //  cellClassName.append(" rich-ordering-list-cell-end");
        //}
       
        Object width = component.getAttributes().get("width");
        if (width != null) {
          writer.writeAttribute("style", "width: " + HtmlUtil.qualifySize(width.toString()), null);
        }
       
        String columnClass = holder.getColumnClass(colCounter);
        if (columnClass != null) {
          writer.writeAttribute("class", cellClassName.toString().concat(" " + columnClass), null);
        } else {
          writer.writeAttribute("class", cellClassName.toString(), null);
        }
       
        //writer.write(" ");
       
        writer.startElement(HTML.IMG_ELEMENT, table);
        writer.writeAttribute(HTML.src_ATTRIBUTE, getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null), null);
        writer.writeAttribute(HTML.style_ATTRIBUTE, "width:1px;height:1px;", null);
        writer.writeAttribute(HTML.alt_ATTRIBUTE, " ", null);
        writer.endElement(HTML.IMG_ELEMENT);
       
        renderChildren(context, component);

        if (!columnRendered) {
          writer.startElement(HTML.INPUT_ELEM, table);
          writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + "StateInput", null);
          writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
          writer.writeAttribute(HTML.NAME_ATTRIBUTE, table.getBaseClientId(context), null);
         
          StringBuffer value = new StringBuffer();
          if (selected) {
            value.append('s');
          }
         
          if (active) {
            value.append('a');
          }

          value.append(table.getRowKey());
          value.append(':');
          value.append(tableHolder.getConverter().getAsString(context, table, table.getRowData()));
         
          writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
         
          writer.endElement(HTML.INPUT_ELEM);
         
View Full Code Here


   
    writer.endElement(HTML.TR_ELEMENT);
  }
 
  public void doDecode(FacesContext context, UIComponent component) {
    UIOrderingList orderingList = (UIOrderingList) component;
   
    String clientId = orderingList.getBaseClientId(context);
        ExternalContext externalContext = context.getExternalContext();
    Map<String, String[]> requestParameterValuesMap = externalContext
                         .getRequestParameterValuesMap();
       
    String[] strings = (String[]) requestParameterValuesMap.get(clientId);
       
    if (strings != null && strings.length != 0) {
      Set selection = new HashSet();
      Object activeItem = null;
          Map map = new LinkedHashMap();
          Converter converter = getConverter(context, orderingList, false);
          for (int i = 0; i < strings.length; i++) {
        String string = strings[i];
        int idx = string.indexOf(':');
        Object value = converter.getAsObject(context, orderingList, string.substring(idx + 1));
        String substring = string.substring(0, idx);
       
        idx = 0;
       
        if (substring.charAt(idx) == 's') {
          selection.add(value);
          idx++;
        }
       
        if (substring.charAt(idx) == 'a') {
          activeItem = value;
          idx++;
        }

        substring = substring.substring(idx);
       
        Object key = new Integer(substring);
        map.put(key, value);
          }
          orderingList.setSubmittedString(map, selection, activeItem);
        }
  }
View Full Code Here

 
  public void encodeOneRow(FacesContext context, TableHolder holder)
      throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    OrderingListRendererTableHolder tableHolder = (OrderingListRendererTableHolder) holder;
    UIOrderingList table = (UIOrderingList) holder.getTable();
    String clientId = holder.getTable().getClientId(context);
    writer.startElement(HTML.TR_ELEMENT, table);
    writer.writeAttribute("id",  clientId, null);
   
    StringBuffer rowClassName = new StringBuffer("rich-ordering-list-row");
   
    String rowClass = holder.getRowClass();
    if (rowClass != null) {
      rowClassName.append(' ');
      rowClassName.append(rowClass);
    }
   
    StringBuffer cellClassName = new StringBuffer("rich-ordering-list-cell");
   
    ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
    ItemState state = getItemState(context, table, variables);
   
    boolean active = state.isActive();
//    if (active) {
//      rowClassName.append(" rich-ordering-list-row-active");
//      cellClassName.append(" rich-ordering-list-cell-active");
//    }
   
    boolean selected = state.isSelected();
    if (selected) {
      rowClassName.append(" rich-ordering-list-row-selected");
      cellClassName.append(" rich-ordering-list-cell-selected");
    }

    SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
    selectionState.addState(selected);
   
    writer.writeAttribute("class", rowClassName.toString(), null);
   
    boolean columnRendered = false;
   
    int colCounter = 0;

    for (Iterator iterator = table.columns(); iterator.hasNext();) {
      UIComponent component = (UIComponent) iterator.next();
     
      if (component.isRendered()) {
        writer.startElement(HTML.td_ELEM, table);
       
        //if (!iterator.hasNext()) {
        //  cellClassName.append(" rich-ordering-list-cell-end");
        //}
       
        Object width = component.getAttributes().get("width");
        if (width != null) {
          writer.writeAttribute("style", "width: " + HtmlUtil.qualifySize(width.toString()), null);
        }
       
        String columnClass = holder.getColumnClass(colCounter);
        if (columnClass != null) {
          writer.writeAttribute("class", cellClassName.toString().concat(" " + columnClass), null);
        } else {
          writer.writeAttribute("class", cellClassName.toString(), null);
        }
       
        //writer.write("&nbsp;");
       
        writer.startElement(HTML.IMG_ELEMENT, table);
        writer.writeAttribute(HTML.src_ATTRIBUTE, getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null), null);
        writer.writeAttribute(HTML.style_ATTRIBUTE, "width:1px;height:1px;", null);
        writer.endElement(HTML.IMG_ELEMENT);
       
        renderChildren(context, component);

        if (!columnRendered) {
          writer.startElement(HTML.INPUT_ELEM, table);
          writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + "StateInput", null);
          writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
          writer.writeAttribute(HTML.NAME_ATTRIBUTE, table.getBaseClientId(context), null);
         
          StringBuffer value = new StringBuffer();
          if (selected) {
            value.append('s');
          }
         
          if (active) {
            value.append('a');
          }

          value.append(table.getRowKey());
          value.append(':');
          value.append(tableHolder.getConverter().getAsString(context, table, table.getRowData()));
         
          writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
         
          writer.endElement(HTML.INPUT_ELEM);
         
View Full Code Here

   
    writer.endElement(HTML.TR_ELEMENT);
  }
 
  public void doDecode(FacesContext context, UIComponent component) {
    UIOrderingList orderingList = (UIOrderingList) component;
   
    String clientId = orderingList.getBaseClientId(context);
        ExternalContext externalContext = context.getExternalContext();
    Map requestParameterMap = externalContext
                         .getRequestParameterMap();
       
    if (requestParameterMap.containsKey(clientId)) {
      Set selection = new HashSet();
      Object activeItem = null;
      String[] strings = (String[]) externalContext.getRequestParameterValuesMap().get(clientId);
          Map map = new LinkedHashMap();
          Converter converter = getConverter(context, orderingList);
          for (int i = 0; i < strings.length; i++) {
        String string = strings[i];
        int idx = string.indexOf(':');
        Object value = converter.getAsObject(context, orderingList, string.substring(idx + 1));
        String substring = string.substring(0, idx);
       
        idx = 0;
       
        if (substring.charAt(idx) == 's') {
          selection.add(value);
          idx++;
        }
       
        if (substring.charAt(idx) == 'a') {
          activeItem = value;
          idx++;
        }

        substring = substring.substring(idx);
       
        Object key = new Integer(substring);
        map.put(key, value);
          }
          orderingList.setSubmittedString(map, selection, activeItem);
        }
  }
View Full Code Here

 
  public void encodeOneRow(FacesContext context, TableHolder holder)
      throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    OrderingListRendererTableHolder tableHolder = (OrderingListRendererTableHolder) holder;
    UIOrderingList table = (UIOrderingList) holder.getTable();
    String clientId = holder.getTable().getClientId(context);
    writer.startElement(HTML.TR_ELEMENT, table);
    writer.writeAttribute("id",  clientId, null);
   
    StringBuffer rowClassName = new StringBuffer("rich-ordering-list-row");
   
    String rowClass = holder.getRowClass();
    if (rowClass != null) {
      rowClassName.append(' ');
      rowClassName.append(rowClass);
    }
   
    StringBuffer cellClassName = new StringBuffer("rich-ordering-list-cell");
   
    ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
    ItemState state = getItemState(context, table, variables);
   
    boolean active = state.isActive();
//    if (active) {
//      rowClassName.append(" rich-ordering-list-row-active");
//      cellClassName.append(" rich-ordering-list-cell-active");
//    }
   
    boolean selected = state.isSelected();
    if (selected) {
      rowClassName.append(" rich-ordering-list-row-selected");
      cellClassName.append(" rich-ordering-list-cell-selected");
    }

    SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
    selectionState.addState(selected);
   
    writer.writeAttribute("class", rowClassName.toString(), null);
   
    boolean columnRendered = false;
   
    int colCounter = 0;

    for (Iterator iterator = table.columns(); iterator.hasNext();) {
      UIComponent component = (UIComponent) iterator.next();
     
      if (component.isRendered()) {
        writer.startElement(HTML.td_ELEM, table);
       
        //if (!iterator.hasNext()) {
        //  cellClassName.append(" rich-ordering-list-cell-end");
        //}
       
        Object width = component.getAttributes().get("width");
        if (width != null) {
          writer.writeAttribute("style", "width: " + HtmlUtil.qualifySize(width.toString()), null);
        }
       
        String columnClass = holder.getColumnClass(colCounter);
        if (columnClass != null) {
          writer.writeAttribute("class", cellClassName.toString().concat(" " + columnClass), null);
        } else {
          writer.writeAttribute("class", cellClassName.toString(), null);
        }
       
        //writer.write("&nbsp;");
       
        writer.startElement(HTML.IMG_ELEMENT, table);
        writer.writeAttribute(HTML.src_ATTRIBUTE, getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null), null);
        writer.writeAttribute(HTML.style_ATTRIBUTE, "width:1px;height:1px;", null);
        writer.writeAttribute(HTML.alt_ATTRIBUTE, " ", null);
        writer.endElement(HTML.IMG_ELEMENT);
       
        renderChildren(context, component);

        if (!columnRendered) {
          writer.startElement(HTML.INPUT_ELEM, table);
          writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + "StateInput", null);
          writer.writeAttribute(HTML.autocomplete_ATTRIBUTE, "off", null);
          writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
          writer.writeAttribute(HTML.NAME_ATTRIBUTE, table.getBaseClientId(context), null);
         
          StringBuffer value = new StringBuffer();
          if (selected) {
            value.append('s');
          }
         
          if (active) {
            value.append('a');
          }

          value.append(table.getRowKey());
          value.append(':');
          value.append(tableHolder.getConverter().getAsString(context, table, table.getRowData()));
         
          writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
         
          writer.endElement(HTML.INPUT_ELEM);
         
View Full Code Here

   
    writer.endElement(HTML.TR_ELEMENT);
  }
 
  public void doDecode(FacesContext context, UIComponent component) {
    UIOrderingList orderingList = (UIOrderingList) component;
   
    String clientId = orderingList.getBaseClientId(context);
        ExternalContext externalContext = context.getExternalContext();
    Map<String, String[]> requestParameterValuesMap = externalContext
                         .getRequestParameterValuesMap();
       
    String[] strings = (String[]) requestParameterValuesMap.get(clientId);
       
    if (strings != null && strings.length != 0) {
      Set selection = new HashSet();
      Object activeItem = null;
          Map map = new LinkedHashMap();
          Converter converter = getConverter(context, orderingList, false);
          for (int i = 0; i < strings.length; i++) {
        String string = strings[i];
        int idx = string.indexOf(':');
        Object value = converter.getAsObject(context, orderingList, string.substring(idx + 1));
        String substring = string.substring(0, idx);
       
        idx = 0;
       
        if (substring.charAt(idx) == 's') {
          selection.add(value);
          idx++;
        }
       
        if (substring.charAt(idx) == 'a') {
          activeItem = value;
          idx++;
        }

        substring = substring.substring(idx);
       
        Object key = new Integer(substring);
        map.put(key, value);
          }
          orderingList.setSubmittedString(map, selection, activeItem);
        }
  }
View Full Code Here

 
  public void encodeOneRow(FacesContext context, TableHolder holder)
      throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    OrderingListRendererTableHolder tableHolder = (OrderingListRendererTableHolder) holder;
    UIOrderingList table = (UIOrderingList) holder.getTable();
    String clientId = holder.getTable().getClientId(context);
    writer.startElement(HTML.TR_ELEMENT, table);
    writer.writeAttribute("id",  clientId, null);
   
    StringBuffer rowClassName = new StringBuffer("rich-ordering-list-row");
   
    String rowClass = holder.getRowClass();
    if (rowClass != null) {
      rowClassName.append(' ');
      rowClassName.append(rowClass);
    }
   
    StringBuffer cellClassName = new StringBuffer("rich-ordering-list-cell");
   
    ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
    ItemState state = getItemState(context, table, variables);
   
    boolean active = state.isActive();
//    if (active) {
//      rowClassName.append(" rich-ordering-list-row-active");
//      cellClassName.append(" rich-ordering-list-cell-active");
//    }
   
    boolean selected = state.isSelected();
    if (selected) {
      rowClassName.append(" rich-ordering-list-row-selected");
      cellClassName.append(" rich-ordering-list-cell-selected");
    }

    SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
    selectionState.addState(selected);
   
    writer.writeAttribute("class", rowClassName.toString(), null);
   
    boolean columnRendered = false;
   
    int colCounter = 0;

    for (Iterator iterator = table.columns(); iterator.hasNext();) {
      UIComponent component = (UIComponent) iterator.next();
     
      if (component.isRendered()) {
        writer.startElement(HTML.td_ELEM, table);
       
        //if (!iterator.hasNext()) {
        //  cellClassName.append(" rich-ordering-list-cell-end");
        //}
       
        Object width = component.getAttributes().get("width");
        if (width != null) {
          writer.writeAttribute("style", "width: " + HtmlUtil.qualifySize(width.toString()), null);
        }
       
        String columnClass = holder.getColumnClass(colCounter);
        if (columnClass != null) {
          writer.writeAttribute("class", cellClassName.toString().concat(" " + columnClass), null);
        } else {
          writer.writeAttribute("class", cellClassName.toString(), null);
        }
       
        writer.startElement(HTML.DIV_ELEM, table);
        writer.writeAttribute(HTML.style_ATTRIBUTE, "white-space: nowrap;", null);
       
        writer.startElement(HTML.IMG_ELEMENT, table);
        writer.writeAttribute(HTML.src_ATTRIBUTE, getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null), null);
        writer.writeAttribute(HTML.style_ATTRIBUTE, "width:1px;height:1px;", null);
        writer.endElement(HTML.IMG_ELEMENT);
       
        renderChildren(context, component);

        if (!columnRendered) {
          writer.startElement(HTML.INPUT_ELEM, table);
          writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + "StateInput", null);
          writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
          writer.writeAttribute(HTML.NAME_ATTRIBUTE, table.getBaseClientId(context), null);
         
          StringBuffer value = new StringBuffer();
          if (selected) {
            value.append('s');
          }
         
          if (active) {
            value.append('a');
          }

          value.append(table.getRowKey());
          value.append(':');
          value.append(tableHolder.getConverter().getAsString(context, table, table.getRowData()));
         
          writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
         
          writer.endElement(HTML.INPUT_ELEM);
         
View Full Code Here

   
    writer.endElement(HTML.TR_ELEMENT);
  }
 
  public void doDecode(FacesContext context, UIComponent component) {
    UIOrderingList orderingList = (UIOrderingList) component;
   
    String clientId = orderingList.getBaseClientId(context);
        ExternalContext externalContext = context.getExternalContext();
    Map requestParameterMap = externalContext
                         .getRequestParameterMap();
       
    if (requestParameterMap.containsKey(clientId)) {
      Set selection = new HashSet();
      Object activeItem = null;
      String[] strings = (String[]) externalContext.getRequestParameterValuesMap().get(clientId);
          Map map = new LinkedHashMap();
          Converter converter = getConverter(context, orderingList);
          for (int i = 0; i < strings.length; i++) {
        String string = strings[i];
        int idx = string.indexOf(':');
        Object value = converter.getAsObject(context, orderingList, string.substring(idx + 1));
        String substring = string.substring(0, idx);
       
        idx = 0;
       
        if (substring.charAt(idx) == 's') {
          selection.add(value);
          idx++;
        }
       
        if (substring.charAt(idx) == 'a') {
          activeItem = value;
          idx++;
        }

        substring = substring.substring(idx);
       
        Object key = new Integer(substring);
        map.put(key, value);
          }
          orderingList.setSubmittedString(map, selection, activeItem);
        }
  }
View Full Code Here

TOP

Related Classes of org.richfaces.component.UIOrderingList

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.