We are facing issue in getting RTF text if we use any HTML tag in RTF(Simple text working fine in all conditions).
case 1. when i use simple one level text field as RTF in schema and use below code:
public String getzeroLevelRTF(GenericComponent comp) {
String zerolevelrtf = "";
if (comp != null && comp.getContent().containsKey(Constants.ZERO_LEVEL_RTF)) {
if (comp.getContent().get(Constants.ZERO_LEVEL_RTF) instanceof XhtmlField) {
XhtmlField xhtmlField = (XhtmlField) comp.getContent().get(Constants.ZERO_LEVEL_RTF);
zerolevelrtf = getValueFromXhtmlField(xhtmlField);
}
}
return zerolevelrtf;
}
Its working as expected on Tomcat but when it is deployed on Webshpere it returns empty string(only when i use any html tags in component otherwise for plain text its working fine on Webshpere also)
case 2.when i use RTF as component link in schema and use below code:
public String getcompLevelRTF(GenericComponent comp) {
String complevelrtf = "";
if (comp != null && comp.getContent().containsKey(Constants.COMP_LEVEL_RTF)) {
if (comp.getContent().get(Constants.COMP_LEVEL_RTF) != null
&& comp.getContent().get(Constants.COMP_LEVEL_RTF) instanceof ComponentLinkField) {
ComponentLinkField compLinked = (ComponentLinkField) comp.getContent().get(Constants.COMP_LEVEL_RTF);
for (Object obj : compLinked.getValues()) {
if (obj != null && obj instanceof GenericComponent) {
GenericComponent rtfComp = (GenericComponent) obj;
if (rtfComp.getContent().containsKey(Constants.RTF_DISCLAIMER)) {
XhtmlField xhtmlField = (XhtmlField) rtfComp.getContent().get(Constants.RTF_DISCLAIMER);
complevelrtf = getValueFromXhtmlField(xhtmlField);
}
}
}
}
}
return complevelrtf;
}
Its working as expected on Tomcat as well as on Webshpere.
Don't understand what i'm doing wrong in case 1.
getValueFromXhtmlField
. Maybe you can start debugging this method with the EXACT same HTML as in the working (complink) example? My guess would be that thisgetValueFromXhtmlField
plays a role in this mystery :)