Fixed: Compound-widget not works with condition
rootElement is not correct for a compound file, it's necessary to do a
UtilXml.firstChildElement(rootElement, "forms"); to be correct.
It's done for screen, form but not for grid !
So correction is now added the correct read of rootElement.
Thanks: Olivier
@@ -118,6 +118,9 @@ public class GridFactory {
if (gridFileDoc != null) {
// read document and construct ModelGrid for each grid element
Element rootElement = gridFileDoc.getDocumentElement();
+ if (!"forms".equalsIgnoreCase(rootElement.getTagName())) {
+ rootElement = UtilXml.firstChildElement(rootElement, "forms");
+ }
List<? extends Element> gridElements = UtilXml.childElementList(rootElement, "grid");
for (Element gridElement : gridElements) {
String gridName = gridElement.getAttribute("name");
@@ -140,11 +143,18 @@ public class GridFactory {
public static ModelGrid createModelGrid(Document gridFileDoc, ModelReader entityModelReader, VisualTheme visualTheme,
DispatchContext dispatchContext, String gridLocation, String gridName) {
- Element gridElement = UtilXml.firstChildElement(gridFileDoc.getDocumentElement(), "grid", "name", gridName);
+ Element rootElement = gridFileDoc.getDocumentElement();
+ if (!"forms".equalsIgnoreCase(rootElement.getTagName())) {
+ rootElement = UtilXml.firstChildElement(rootElement, "forms");
+ }
+ Element gridElement = UtilXml.firstChildElement(rootElement, "grid", "name", gridName);
if (gridElement == null) {
// Backwards compatibility - look for form definition
gridElement = UtilXml.firstChildElement(gridFileDoc.getDocumentElement(), "form", "name", gridName);
}
+ if (gridElement == null) {
+ throw new IllegalArgumentException("Could not find grid with name [" + gridName + "] in class resource [" + gridLocation + "]");
+ }
return createModelGrid(gridElement, entityModelReader, visualTheme, dispatchContext, gridLocation, gridName);
}
