ICEfaces
  1. ICEfaces
  2. ICE-5051

DataExporter doesn't use Converters to export data

    Details

    • Assignee Priority:
      P1
    • Affects:
      Documentation (User Guide, Ref. Guide, etc.), Compatibility/Configuration

      Description

      The method DataExporter.encodeParentAndChildrenAsString(FacesContext fc, UIComponent uic) indirectly calls the toString method of a value instead of using a converter.
      The problem is situated at this line: str.append(value).

      Current implementation:

      private String encodeParentAndChildrenAsString(FacesContext fc,
                  UIComponent uic) {
              StringBuffer str = new StringBuffer();
              Object value = uic.getAttributes().get("value");
              if (value != null)
                  str.append(value);
              else {
                  ValueBinding vb = uic.getValueBinding("value");
                  if (vb != null)
                      str.append(vb.getValue(fc));
              }

              if (uic.getChildCount() > 0) {
                  Iterator iter = uic.getChildren().iterator();
                  while (iter.hasNext()) {
                      UIComponent child = (UIComponent) iter.next();
                      str.append(encodeParentAndChildrenAsString(fc, child));
                  }
              }
              return str.toString();
          }

      I think that it would be necessary to change this method with an implementation like this:

      private String encodeParentAndChildrenAsString(FacesContext fc,
                  UIComponent uic) {
              StringBuffer str = new StringBuffer();
              Object value = uic.getAttributes().get("value");
              if (value != null) {
               Converter converter = null;
               if(uic instanceof UIOutput) {
               converter = ((UIOutput)uic).getConverter();
               }
               if(converter == null) {
               converter = FacesContext.getCurrentInstance().getApplication().createConverter(value.getClass());
               }
               if(converter != null) {
               str.append(converter.getAsString(FacesContext.getCurrentInstance(), uic, value));
               } else {
               str.append(value);
               }
              }
              else {
                  ValueBinding vb = uic.getValueBinding("value");
                  if (vb != null)
                      str.append(vb.getValue(fc));
              }

              if (uic.getChildCount() > 0) {
                  Iterator iter = uic.getChildren().iterator();
                  while (iter.hasNext()) {
                      UIComponent child = (UIComponent) iter.next();
                      str.append(encodeParentAndChildrenAsString(fc, child));
                  }
              }
              return str.toString();
          }

        Issue Links

          Activity

            People

            • Assignee:
              Adnan Durrani
              Reporter:
              Christophe Rodriguez
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: