Package org.richfaces.component

Examples of org.richfaces.component.UIListShuttle


    return stringWriter.getBuffer().toString();
  }
 
  public void encodeOneRow(FacesContext context, TableHolder holder)
  throws IOException {
    UIListShuttle table = (UIListShuttle) holder.getTable();
    ListShuttleRendererTableHolder shuttleRendererTableHolder = (ListShuttleRendererTableHolder) holder;
   
    ListShuttleRowKey listShuttleRowKey = (ListShuttleRowKey) table.getRowKey();
    if (listShuttleRowKey != null) {
      boolean source = shuttleRendererTableHolder.isSource();
      if (source == listShuttleRowKey.isFacadeSource()) {
       
        ResponseWriter writer = context.getResponseWriter();
        String clientId = table.getClientId(context);
        writer.startElement(HTML.TR_ELEMENT, table);
        writer.writeAttribute("id",  clientId, null);

        StringBuffer rowClassName = new StringBuffer();
        StringBuffer cellClassName = new StringBuffer();
        if (source) {
          rowClassName.append("rich-shuttle-source-row");
          cellClassName.append("rich-shuttle-source-cell");
        } else {
          rowClassName.append("rich-shuttle-target-row");
          cellClassName.append("rich-shuttle-target-cell");
        }

        String rowClass = holder.getRowClass();
        if (rowClass != null) {
          rowClassName.append(' ');
          rowClassName.append(rowClass);
        }

        ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
        SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
        ItemState itemState = getItemState(context, table, variables);
       
        boolean active = itemState.isActive();
        boolean selected = itemState.isSelected();
        selectionState.addState(selected);
        if (selected) {
          if (source) {
            rowClassName.append(" rich-shuttle-source-row-selected");
            cellClassName.append(" rich-shuttle-source-cell-selected");
          } else {
            rowClassName.append(" rich-shuttle-target-row-selected");
            cellClassName.append(" rich-shuttle-target-cell-selected");
          }
        }
       
        writer.writeAttribute("class", rowClassName.toString(), null);

        int colCounter = 0;
        boolean columnRendered = false;

        for (Iterator iterator = table.columns(); iterator.hasNext();) {
          UIComponent component = (UIComponent) iterator.next();

          if (component.isRendered()) {
            writer.startElement(HTML.td_ELEM, table);

            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.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.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(shuttleRendererTableHolder.getConverter().getAsString(context, table, table.getRowData()));
             
              writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
             
              writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + "StateInput", null);
             
View Full Code Here


  private boolean isEmpty(String s) {
    return s == null || s.length() == 0;
  }
 
  public void doDecode(FacesContext context, UIComponent component) {
    UIListShuttle listShuttle = (UIListShuttle) component;
   
    String clientId = listShuttle.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 sourceSelection = new HashSet();
      Set targetSelection = new HashSet();
      Object activeItem = null;
          Map map = new LinkedHashMap();
         
          boolean facadeSource = true;
         
          Converter converter = getConverter(context, listShuttle, false);
         
          for (int i = 0; i < strings.length; i++) {
        String string = strings[i];
       
        if (":".equals(string)) {
          facadeSource = false;
          continue;
        }
       
        int idx = string.indexOf(':');
        Object value = converter.getAsObject(context, listShuttle, string.substring(idx + 1));
        String substring = string.substring(0, idx);
       
        idx = 0;
        boolean source = true;

        boolean selected = false;
       
        if (substring.charAt(idx) == 's') {
          (facadeSource ? sourceSelection : targetSelection).add(value);
          idx++;
        }

        if (substring.charAt(idx) == 'a') {
          activeItem = value;
          idx++;
        }

        if (substring.charAt(idx) == 't') {
          source = false;
          idx++;
        }

        substring = substring.substring(idx);
       
        Object key = new ListShuttleRowKey(new Integer(substring), source, facadeSource);
        map.put(key, value);
          }
          listShuttle.setSubmittedStrings(map, sourceSelection, targetSelection, activeItem);
        }
  }
View Full Code Here

          listShuttle.setSubmittedStrings(map, sourceSelection, targetSelection, activeItem);
        }
  }
 
  public String getCaptionDisplay(FacesContext context, UIComponent component) {
    UIListShuttle shuttle = (UIListShuttle)component;
    if ((shuttle.getSourceCaptionLabel() != null && !"".equals(shuttle.getSourceCaptionLabel())) ||
        (shuttle.getTargetCaptionLabel() != null && !"".equals(shuttle.getTargetCaptionLabel())) ||
        (shuttle.getFacet("sourceCaption") != null && shuttle.getFacet("sourceCaption").isRendered()) ||
        (shuttle.getFacet("targetCaption") != null && shuttle.getFacet("targetCaption").isRendered())) {
     
      return "";
    }
   
    return "display: none;";
View Full Code Here

    return stringWriter.getBuffer().toString();
  }
 
  public void encodeOneRow(FacesContext context, TableHolder holder)
  throws IOException {
    UIListShuttle table = (UIListShuttle) holder.getTable();
    ListShuttleRendererTableHolder shuttleRendererTableHolder = (ListShuttleRendererTableHolder) holder;
   
    ListShuttleRowKey listShuttleRowKey = (ListShuttleRowKey) table.getRowKey();
    if (listShuttleRowKey != null) {
      boolean source = shuttleRendererTableHolder.isSource();
      if (source == listShuttleRowKey.isFacadeSource()) {
       
        ResponseWriter writer = context.getResponseWriter();
        String clientId = table.getClientId(context);
        writer.startElement(HTML.TR_ELEMENT, table);
        writer.writeAttribute("id",  clientId, null);

        StringBuffer rowClassName = new StringBuffer();
        StringBuffer cellClassName = new StringBuffer();
        if (source) {
          rowClassName.append("rich-shuttle-source-row");
          cellClassName.append("rich-shuttle-source-cell");
        } else {
          rowClassName.append("rich-shuttle-target-row");
          cellClassName.append("rich-shuttle-target-cell");
        }

        String rowClass = holder.getRowClass();
        if (rowClass != null) {
          rowClassName.append(' ');
          rowClassName.append(rowClass);
        }

        ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
        SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
        ItemState itemState = getItemState(context, table, variables);
       
        boolean active = itemState.isActive();
        boolean selected = itemState.isSelected();
        selectionState.addState(selected);
        if (selected) {
          if (source) {
            rowClassName.append(" rich-shuttle-source-row-selected");
            cellClassName.append(" rich-shuttle-source-cell-selected");
          } else {
            rowClassName.append(" rich-shuttle-target-row-selected");
            cellClassName.append(" rich-shuttle-target-cell-selected");
          }
        }
       
        writer.writeAttribute("class", rowClassName.toString(), null);

        int colCounter = 0;
        boolean columnRendered = false;

        for (Iterator iterator = table.columns(); iterator.hasNext();) {
          UIComponent component = (UIComponent) iterator.next();

          if (component.isRendered()) {
            writer.startElement(HTML.td_ELEM, table);

            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.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.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(shuttleRendererTableHolder.getConverter().getAsString(context, table, table.getRowData()));
             
              writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
             
              writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + "StateInput", null);
             
View Full Code Here

  private boolean isEmpty(String s) {
    return s == null || s.length() == 0;
  }
 
  public void doDecode(FacesContext context, UIComponent component) {
    UIListShuttle listShuttle = (UIListShuttle) component;
   
    String clientId = listShuttle.getBaseClientId(context);
    ExternalContext externalContext = context.getExternalContext();
    Map requestParameterMap = externalContext
                         .getRequestParameterMap();
       
   
   
    if (requestParameterMap.containsKey(clientId)) {
      Set sourceSelection = new HashSet();
      Set targetSelection = new HashSet();
      Object activeItem = null;
      String[] strings = (String[]) externalContext.getRequestParameterValuesMap().get(clientId);
          Map map = new LinkedHashMap();
         
          boolean facadeSource = true;
         
          Converter converter = getConverter(context, listShuttle);
         
          for (int i = 0; i < strings.length; i++) {
        String string = strings[i];
       
        if (":".equals(string)) {
          facadeSource = false;
          continue;
        }
       
        int idx = string.indexOf(':');
        Object value = converter.getAsObject(context, listShuttle, string.substring(idx + 1));
        String substring = string.substring(0, idx);
       
        idx = 0;
        boolean source = true;

        boolean selected = false;
       
        if (substring.charAt(idx) == 's') {
          (facadeSource ? sourceSelection : targetSelection).add(value);
          idx++;
        }

        if (substring.charAt(idx) == 'a') {
          activeItem = value;
          idx++;
        }

        if (substring.charAt(idx) == 't') {
          source = false;
          idx++;
        }

        substring = substring.substring(idx);
       
        Object key = new ListShuttleRowKey(new Integer(substring), source, facadeSource);
        map.put(key, value);
          }
          listShuttle.setSubmittedStrings(map, sourceSelection, targetSelection, activeItem);
        }
  }
View Full Code Here

          listShuttle.setSubmittedStrings(map, sourceSelection, targetSelection, activeItem);
        }
  }
 
  public String getCaptionDisplay(FacesContext context, UIComponent component) {
    UIListShuttle shuttle = (UIListShuttle)component;
    if ((shuttle.getSourceCaptionLabel() != null && !"".equals(shuttle.getSourceCaptionLabel())) ||
        (shuttle.getTargetCaptionLabel() != null && !"".equals(shuttle.getTargetCaptionLabel())) ||
        (shuttle.getFacet("sourceCaption") != null && shuttle.getFacet("sourceCaption").isRendered()) ||
        (shuttle.getFacet("targetCaption") != null && shuttle.getFacet("targetCaption").isRendered())) {
     
      return "";
    }
   
    return "display: none;";
View Full Code Here

    return stringWriter.getBuffer().toString();
  }
 
  public void encodeOneRow(FacesContext context, TableHolder holder)
  throws IOException {
    UIListShuttle table = (UIListShuttle) holder.getTable();
    ListShuttleRendererTableHolder shuttleRendererTableHolder = (ListShuttleRendererTableHolder) holder;
   
    ListShuttleRowKey listShuttleRowKey = (ListShuttleRowKey) table.getRowKey();
    if (listShuttleRowKey != null) {
      boolean source = shuttleRendererTableHolder.isSource();
      if (source == listShuttleRowKey.isFacadeSource()) {
       
        ResponseWriter writer = context.getResponseWriter();
        String clientId = table.getClientId(context);
        writer.startElement(HTML.TR_ELEMENT, table);
        writer.writeAttribute("id",  clientId, null);

        StringBuffer rowClassName = new StringBuffer();
        StringBuffer cellClassName = new StringBuffer();
        if (source) {
          rowClassName.append("rich-shuttle-source-row");
          cellClassName.append("rich-shuttle-source-cell");
        } else {
          rowClassName.append("rich-shuttle-target-row");
          cellClassName.append("rich-shuttle-target-cell");
        }

        String rowClass = holder.getRowClass();
        if (rowClass != null) {
          rowClassName.append(' ');
          rowClassName.append(rowClass);
        }

        ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
        SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
        ItemState itemState = getItemState(context, table, variables);
       
        boolean active = itemState.isActive();
        boolean selected = itemState.isSelected();
        selectionState.addState(selected);
        if (selected) {
          if (source) {
            rowClassName.append(" rich-shuttle-source-row-selected");
            cellClassName.append(" rich-shuttle-source-cell-selected");
          } else {
            rowClassName.append(" rich-shuttle-target-row-selected");
            cellClassName.append(" rich-shuttle-target-cell-selected");
          }
        }
       
        writer.writeAttribute("class", rowClassName.toString(), null);

        int colCounter = 0;
        boolean columnRendered = false;

        for (Iterator iterator = table.columns(); iterator.hasNext();) {
          UIComponent component = (UIComponent) iterator.next();

          if (component.isRendered()) {
            writer.startElement(HTML.td_ELEM, table);

            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.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.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(shuttleRendererTableHolder.getConverter().getAsString(context, table, table.getRowData()));
             
              writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
             
              writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + "StateInput", null);
             
View Full Code Here

  private boolean isEmpty(String s) {
    return s == null || s.length() == 0;
  }
 
  public void doDecode(FacesContext context, UIComponent component) {
    UIListShuttle listShuttle = (UIListShuttle) component;
   
    String clientId = listShuttle.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 sourceSelection = new HashSet();
      Set targetSelection = new HashSet();
      Object activeItem = null;
          Map map = new LinkedHashMap();
         
          boolean facadeSource = true;
         
          Converter converter = getConverter(context, listShuttle, false);
         
          for (int i = 0; i < strings.length; i++) {
        String string = strings[i];
       
        if (":".equals(string)) {
          facadeSource = false;
          continue;
        }
       
        int idx = string.indexOf(':');
        Object value = converter.getAsObject(context, listShuttle, string.substring(idx + 1));
        String substring = string.substring(0, idx);
       
        idx = 0;
        boolean source = true;

        boolean selected = false;
       
        if (substring.charAt(idx) == 's') {
          (facadeSource ? sourceSelection : targetSelection).add(value);
          idx++;
        }

        if (substring.charAt(idx) == 'a') {
          activeItem = value;
          idx++;
        }

        if (substring.charAt(idx) == 't') {
          source = false;
          idx++;
        }

        substring = substring.substring(idx);
       
        Object key = new ListShuttleRowKey(new Integer(substring), source, facadeSource);
        map.put(key, value);
          }
          listShuttle.setSubmittedStrings(map, sourceSelection, targetSelection, activeItem);
        }
  }
View Full Code Here

          listShuttle.setSubmittedStrings(map, sourceSelection, targetSelection, activeItem);
        }
  }
 
  public String getCaptionDisplay(FacesContext context, UIComponent component) {
    UIListShuttle shuttle = (UIListShuttle)component;
    if ((shuttle.getSourceCaptionLabel() != null && !"".equals(shuttle.getSourceCaptionLabel())) ||
        (shuttle.getTargetCaptionLabel() != null && !"".equals(shuttle.getTargetCaptionLabel())) ||
        (shuttle.getFacet("sourceCaption") != null && shuttle.getFacet("sourceCaption").isRendered()) ||
        (shuttle.getFacet("targetCaption") != null && shuttle.getFacet("targetCaption").isRendered())) {
     
      return "";
    }
   
    return "display: none;";
View Full Code Here

    return stringWriter.getBuffer().toString();
  }
 
  public void encodeOneRow(FacesContext context, TableHolder holder)
  throws IOException {
    UIListShuttle table = (UIListShuttle) holder.getTable();
    ListShuttleRendererTableHolder shuttleRendererTableHolder = (ListShuttleRendererTableHolder) holder;
   
    ListShuttleRowKey listShuttleRowKey = (ListShuttleRowKey) table.getRowKey();
    if (listShuttleRowKey != null) {
      boolean source = shuttleRendererTableHolder.isSource();
      if (source == listShuttleRowKey.isFacadeSource()) {
       
        ResponseWriter writer = context.getResponseWriter();
        String clientId = table.getClientId(context);
        writer.startElement(HTML.TR_ELEMENT, table);
        writer.writeAttribute("id",  clientId, null);

        StringBuffer rowClassName = new StringBuffer();
        StringBuffer cellClassName = new StringBuffer();
        if (source) {
          rowClassName.append("rich-shuttle-source-row");
          cellClassName.append("rich-shuttle-source-cell");
        } else {
          rowClassName.append("rich-shuttle-target-row");
          cellClassName.append("rich-shuttle-target-cell");
        }

        String rowClass = holder.getRowClass();
        if (rowClass != null) {
          rowClassName.append(' ');
          rowClassName.append(rowClass);
        }

        ComponentVariables variables = ComponentsVariableResolver.getVariables(this, table);
        SelectionState selectionState = (SelectionState) variables.getVariable(SELECTION_STATE_VAR_NAME);
        ItemState itemState = getItemState(context, table, variables);
       
        boolean active = itemState.isActive();
        boolean selected = itemState.isSelected();
        selectionState.addState(selected);
        if (selected) {
          if (source) {
            rowClassName.append(" rich-shuttle-source-row-selected");
            cellClassName.append(" rich-shuttle-source-cell-selected");
          } else {
            rowClassName.append(" rich-shuttle-target-row-selected");
            cellClassName.append(" rich-shuttle-target-cell-selected");
          }
        }
       
        writer.writeAttribute("class", rowClassName.toString(), null);

        int colCounter = 0;
        boolean columnRendered = false;

        for (Iterator iterator = table.columns(); iterator.hasNext();) {
          UIComponent component = (UIComponent) iterator.next();

          if (component.isRendered()) {
            writer.startElement(HTML.td_ELEM, table);

            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.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.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
              writer.writeAttribute(HTML.autocomplete_ATTRIBUTE, "off", 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(shuttleRendererTableHolder.getConverter().getAsString(context, table, table.getRowData()));
             
              writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
             
              writer.writeAttribute(HTML.id_ATTRIBUTE, clientId + "StateInput", null);
             
View Full Code Here

TOP

Related Classes of org.richfaces.component.UIListShuttle

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.