Fixed: Use platform specific failed on CompoundWidget (OFBIZ-12283)
When you use a platform-specific element on CompoundWidget like this :
<ws:platform-specific>
<ws:html><ws:html-template location="component ..."/></ws:html>
</ws:platform-specific>
the ModelScreenWidget failed to resolve the attended type due to the
namespace presence (ws:html != html) and finally failed to rendering the screen
diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelScreenWidget.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelScreenWidget.java
index 17ce2fe..b298235 100644
--- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelScreenWidget.java
+++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelScreenWidget.java
@@ -33,8 +33,10 @@
import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.GeneralException;
+import org.apache.ofbiz.base.util.StringUtil;
import org.apache.ofbiz.base.util.UtilCodec;
import org.apache.ofbiz.base.util.UtilGenerics;
+import org.apache.ofbiz.base.util.UtilMisc;
import org.apache.ofbiz.base.util.UtilXml;
import org.apache.ofbiz.base.util.collections.MapStack;
import org.apache.ofbiz.base.util.string.FlexibleStringExpander;
@@ -1327,6 +1329,7 @@
}
public static final class PlatformSpecific extends ModelScreenWidget {
+ private static final List<String> PLATEFORM_SPECIFIC_SUPPORT_RENDERING_TYPE = UtilMisc.toList("html", "xsl-fo", "xml", "text", "csv", "xls");
public static final String TAG_NAME = "platform-specific";
private final Map<String, ModelScreenWidget> subWidgets;
@@ -1336,18 +1339,14 @@
List<? extends Element> childElements = UtilXml.childElementList(platformSpecificElement);
if (childElements != null) {
for (Element childElement: childElements) {
- if ("html".equals(childElement.getNodeName())) {
- subWidgets.put("html", new HtmlWidget(modelScreen, childElement));
- } else if ("xsl-fo".equals(childElement.getNodeName())) {
- subWidgets.put("xsl-fo", new HtmlWidget(modelScreen, childElement));
- } else if ("xml".equals(childElement.getNodeName())) {
- subWidgets.put("xml", new HtmlWidget(modelScreen, childElement));
- } else if ("text".equals(childElement.getNodeName())) {
- subWidgets.put("text", new HtmlWidget(modelScreen, childElement));
- } else if ("csv".equals(childElement.getNodeName())) {
- subWidgets.put("csv", new HtmlWidget(modelScreen, childElement));
- } else if ("xls".equals(childElement.getNodeName())) {
- subWidgets.put("xls", new HtmlWidget(modelScreen, childElement));
+ String renderingType = childElement.getNodeName();
+
+ // Remove the namespace if is present
+ if (renderingType.contains(":")) {
+ renderingType = StringUtil.split(renderingType, ":").get(1);
+ }
+ if (PLATEFORM_SPECIFIC_SUPPORT_RENDERING_TYPE.contains(renderingType)) {
+ subWidgets.put(renderingType, new HtmlWidget(modelScreen, childElement));
} else {
throw new IllegalArgumentException("Tag not supported under the platform-specific tag with name: "
+ childElement.getNodeName());