Details
-
Type: Improvement
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.8.2
-
Fix Version/s: EE-1.8.2.GA_P03, 2.1-Beta, 3.0, EE-2.0.0.GA_P01
-
Component/s: ICE-Components
-
Labels:None
-
Environment:Ubuntu, Tomcat 6.0.18, Spring, Icefaces 1.8.2
-
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();
}
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
- duplicates
-
ICE-5043 Have the dataExporter use the converted value for the table cell values
- Closed
Command: Commit
Modified: D:\work\development\head\svn\ossrepo\icefaces2\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\dataexporter\DataExporter.java
Sending content: D:\work\development\head\svn\ossrepo\icefaces2\trunk\icefaces\compat\components\src\main\java\com\icesoft\faces\component\dataexporter\DataExporter.java
Completed: At revision: 24553