Modified: ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java?rev=1662488&r1=1662487&r2=1662488&view=diff ============================================================================== --- ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java (original) +++ ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/artifact/ArtifactInfoGatherer.java Thu Feb 26 16:16:11 2015 @@ -23,83 +23,86 @@ import java.util.Set; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.webapp.control.ConfigXMLReader; -import org.ofbiz.widget.ModelActionVisitor; -import org.ofbiz.widget.ModelFieldVisitor; -import org.ofbiz.widget.ModelWidgetAction; -import org.ofbiz.widget.ModelWidgetAction.EntityAnd; -import org.ofbiz.widget.ModelWidgetAction.EntityCondition; -import org.ofbiz.widget.ModelWidgetAction.EntityOne; -import org.ofbiz.widget.ModelWidgetAction.GetRelated; -import org.ofbiz.widget.ModelWidgetAction.GetRelatedOne; -import org.ofbiz.widget.ModelWidgetAction.PropertyMap; -import org.ofbiz.widget.ModelWidgetAction.PropertyToField; -import org.ofbiz.widget.ModelWidgetAction.Script; -import org.ofbiz.widget.ModelWidgetAction.Service; -import org.ofbiz.widget.ModelWidgetAction.SetField; -import org.ofbiz.widget.ModelWidgetVisitor; -import org.ofbiz.widget.form.FieldInfo; -import org.ofbiz.widget.form.ModelForm; -import org.ofbiz.widget.form.ModelForm.AltTarget; -import org.ofbiz.widget.form.ModelForm.AutoFieldsEntity; -import org.ofbiz.widget.form.ModelForm.AutoFieldsService; -import org.ofbiz.widget.form.ModelFormAction; -import org.ofbiz.widget.form.ModelFormAction.CallParentActions; -import org.ofbiz.widget.form.ModelFormField; -import org.ofbiz.widget.form.ModelFormField.CheckField; -import org.ofbiz.widget.form.ModelFormField.ContainerField; -import org.ofbiz.widget.form.ModelFormField.DateFindField; -import org.ofbiz.widget.form.ModelFormField.DateTimeField; -import org.ofbiz.widget.form.ModelFormField.DisplayEntityField; -import org.ofbiz.widget.form.ModelFormField.DisplayField; -import org.ofbiz.widget.form.ModelFormField.DropDownField; -import org.ofbiz.widget.form.ModelFormField.FieldInfoWithOptions; -import org.ofbiz.widget.form.ModelFormField.FileField; -import org.ofbiz.widget.form.ModelFormField.HiddenField; -import org.ofbiz.widget.form.ModelFormField.HyperlinkField; -import org.ofbiz.widget.form.ModelFormField.IgnoredField; -import org.ofbiz.widget.form.ModelFormField.ImageField; -import org.ofbiz.widget.form.ModelFormField.LookupField; -import org.ofbiz.widget.form.ModelFormField.PasswordField; -import org.ofbiz.widget.form.ModelFormField.RadioField; -import org.ofbiz.widget.form.ModelFormField.RangeFindField; -import org.ofbiz.widget.form.ModelFormField.ResetField; -import org.ofbiz.widget.form.ModelFormField.SubmitField; -import org.ofbiz.widget.form.ModelFormField.TextField; -import org.ofbiz.widget.form.ModelFormField.TextFindField; -import org.ofbiz.widget.form.ModelFormField.TextareaField; -import org.ofbiz.widget.menu.ModelMenu; -import org.ofbiz.widget.menu.ModelMenuAction; -import org.ofbiz.widget.menu.ModelMenuItem; -import org.ofbiz.widget.screen.HtmlWidget; -import org.ofbiz.widget.screen.HtmlWidget.HtmlTemplate; -import org.ofbiz.widget.screen.HtmlWidget.HtmlTemplateDecorator; -import org.ofbiz.widget.screen.HtmlWidget.HtmlTemplateDecoratorSection; -import org.ofbiz.widget.screen.IterateSectionWidget; -import org.ofbiz.widget.screen.ModelScreen; -import org.ofbiz.widget.screen.ModelScreenWidget; -import org.ofbiz.widget.screen.ModelScreenWidget.Column; -import org.ofbiz.widget.screen.ModelScreenWidget.ColumnContainer; -import org.ofbiz.widget.screen.ModelScreenWidget.Container; -import org.ofbiz.widget.screen.ModelScreenWidget.Content; -import org.ofbiz.widget.screen.ModelScreenWidget.DecoratorScreen; -import org.ofbiz.widget.screen.ModelScreenWidget.DecoratorSection; -import org.ofbiz.widget.screen.ModelScreenWidget.DecoratorSectionInclude; -import org.ofbiz.widget.screen.ModelScreenWidget.Form; -import org.ofbiz.widget.screen.ModelScreenWidget.HorizontalSeparator; -import org.ofbiz.widget.screen.ModelScreenWidget.Image; -import org.ofbiz.widget.screen.ModelScreenWidget.IncludeScreen; -import org.ofbiz.widget.screen.ModelScreenWidget.Label; -import org.ofbiz.widget.screen.ModelScreenWidget.Link; -import org.ofbiz.widget.screen.ModelScreenWidget.Menu; -import org.ofbiz.widget.screen.ModelScreenWidget.PlatformSpecific; -import org.ofbiz.widget.screen.ModelScreenWidget.PortalPage; -import org.ofbiz.widget.screen.ModelScreenWidget.Screenlet; -import org.ofbiz.widget.screen.ModelScreenWidget.Section; -import org.ofbiz.widget.screen.ModelScreenWidget.Tree; -import org.ofbiz.widget.tree.ModelTree; -import org.ofbiz.widget.tree.ModelTree.ModelNode; -import org.ofbiz.widget.tree.ModelTree.ModelNode.ModelSubNode; -import org.ofbiz.widget.tree.ModelTreeAction; +import org.ofbiz.widget.model.AbstractModelAction.EntityAnd; +import org.ofbiz.widget.model.AbstractModelAction.EntityCondition; +import org.ofbiz.widget.model.AbstractModelAction.EntityOne; +import org.ofbiz.widget.model.AbstractModelAction.GetRelated; +import org.ofbiz.widget.model.AbstractModelAction.GetRelatedOne; +import org.ofbiz.widget.model.AbstractModelAction.PropertyMap; +import org.ofbiz.widget.model.AbstractModelAction.PropertyToField; +import org.ofbiz.widget.model.AbstractModelAction.Script; +import org.ofbiz.widget.model.AbstractModelAction.Service; +import org.ofbiz.widget.model.AbstractModelAction.SetField; +import org.ofbiz.widget.model.FieldInfo; +import org.ofbiz.widget.model.HtmlWidget; +import org.ofbiz.widget.model.HtmlWidget.HtmlTemplate; +import org.ofbiz.widget.model.HtmlWidget.HtmlTemplateDecorator; +import org.ofbiz.widget.model.HtmlWidget.HtmlTemplateDecoratorSection; +import org.ofbiz.widget.model.IterateSectionWidget; +import org.ofbiz.widget.model.ModelAction; +import org.ofbiz.widget.model.ModelActionVisitor; +import org.ofbiz.widget.model.ModelFieldVisitor; +import org.ofbiz.widget.model.ModelForm; +import org.ofbiz.widget.model.ModelForm.AltTarget; +import org.ofbiz.widget.model.ModelForm.AutoFieldsEntity; +import org.ofbiz.widget.model.ModelForm.AutoFieldsService; +import org.ofbiz.widget.model.ModelFormAction; +import org.ofbiz.widget.model.ModelFormAction.CallParentActions; +import org.ofbiz.widget.model.ModelFormField; +import org.ofbiz.widget.model.ModelFormField.CheckField; +import org.ofbiz.widget.model.ModelFormField.ContainerField; +import org.ofbiz.widget.model.ModelFormField.DateFindField; +import org.ofbiz.widget.model.ModelFormField.DateTimeField; +import org.ofbiz.widget.model.ModelFormField.DisplayEntityField; +import org.ofbiz.widget.model.ModelFormField.DisplayField; +import org.ofbiz.widget.model.ModelFormField.DropDownField; +import org.ofbiz.widget.model.ModelFormField.FieldInfoWithOptions; +import org.ofbiz.widget.model.ModelFormField.FileField; +import org.ofbiz.widget.model.ModelFormField.HiddenField; +import org.ofbiz.widget.model.ModelFormField.HyperlinkField; +import org.ofbiz.widget.model.ModelFormField.IgnoredField; +import org.ofbiz.widget.model.ModelFormField.ImageField; +import org.ofbiz.widget.model.ModelFormField.LookupField; +import org.ofbiz.widget.model.ModelFormField.PasswordField; +import org.ofbiz.widget.model.ModelFormField.RadioField; +import org.ofbiz.widget.model.ModelFormField.RangeFindField; +import org.ofbiz.widget.model.ModelFormField.ResetField; +import org.ofbiz.widget.model.ModelFormField.SubmitField; +import org.ofbiz.widget.model.ModelFormField.TextField; +import org.ofbiz.widget.model.ModelFormField.TextFindField; +import org.ofbiz.widget.model.ModelFormField.TextareaField; +import org.ofbiz.widget.model.ModelGrid; +import org.ofbiz.widget.model.ModelMenu; +import org.ofbiz.widget.model.ModelMenuAction; +import org.ofbiz.widget.model.ModelMenuItem; +import org.ofbiz.widget.model.ModelScreen; +import org.ofbiz.widget.model.ModelScreenWidget; +import org.ofbiz.widget.model.ModelScreenWidget.Column; +import org.ofbiz.widget.model.ModelScreenWidget.ColumnContainer; +import org.ofbiz.widget.model.ModelScreenWidget.Container; +import org.ofbiz.widget.model.ModelScreenWidget.Content; +import org.ofbiz.widget.model.ModelScreenWidget.DecoratorScreen; +import org.ofbiz.widget.model.ModelScreenWidget.DecoratorSection; +import org.ofbiz.widget.model.ModelScreenWidget.DecoratorSectionInclude; +import org.ofbiz.widget.model.ModelScreenWidget.Form; +import org.ofbiz.widget.model.ModelScreenWidget.Grid; +import org.ofbiz.widget.model.ModelScreenWidget.HorizontalSeparator; +import org.ofbiz.widget.model.ModelScreenWidget.IncludeScreen; +import org.ofbiz.widget.model.ModelScreenWidget.Label; +import org.ofbiz.widget.model.ModelScreenWidget.Menu; +import org.ofbiz.widget.model.ModelScreenWidget.PlatformSpecific; +import org.ofbiz.widget.model.ModelScreenWidget.PortalPage; +import org.ofbiz.widget.model.ModelScreenWidget.ScreenImage; +import org.ofbiz.widget.model.ModelScreenWidget.ScreenLink; +import org.ofbiz.widget.model.ModelScreenWidget.Screenlet; +import org.ofbiz.widget.model.ModelScreenWidget.Section; +import org.ofbiz.widget.model.ModelScreenWidget.Tree; +import org.ofbiz.widget.model.ModelSingleForm; +import org.ofbiz.widget.model.ModelTree; +import org.ofbiz.widget.model.ModelTree.ModelNode; +import org.ofbiz.widget.model.ModelTree.ModelNode.ModelSubNode; +import org.ofbiz.widget.model.ModelTreeAction; +import org.ofbiz.widget.model.ModelWidgetVisitor; /** * An object that gathers artifact information from screen widgets. @@ -113,58 +116,94 @@ public final class ArtifactInfoGatherer } @Override - public void visit(CallParentActions callParentActions) { + public void visit(CallParentActions callParentActions) throws Exception { } @Override - public void visit(EntityAnd entityAnd) { - infoContext.addEntityName(entityAnd.getFinder().getEntityName()); + public void visit(Column column) throws Exception { } @Override - public void visit(EntityCondition entityCondition) { - infoContext.addEntityName(entityCondition.getFinder().getEntityName()); + public void visit(ColumnContainer columnContainer) throws Exception { + for (Column column : columnContainer.getColumns()) { + for (ModelScreenWidget widget : column.getSubWidgets()) { + widget.accept(this); + } + } } @Override - public void visit(EntityOne entityOne) { - infoContext.addEntityName(entityOne.getFinder().getEntityName()); + public void visit(Container container) throws Exception { + for (ModelScreenWidget widget : container.getSubWidgets()) { + widget.accept(this); + } } @Override - public void visit(GetRelated getRelated) { - infoContext.addEntityName(getRelated.getRelationName()); + public void visit(Content content) throws Exception { + infoContext.addEntityName("Content"); + if (!content.getDataResourceId().isEmpty()) { + infoContext.addEntityName("DataResource"); + } } @Override - public void visit(GetRelatedOne getRelatedOne) { - infoContext.addEntityName(getRelatedOne.getRelationName()); + public void visit(DecoratorScreen decoratorScreen) throws Exception { + for (ModelScreenWidget section : decoratorScreen.getSectionMap().values()) { + section.accept(this); + } } @Override - public void visit(PropertyMap propertyMap) { + public void visit(DecoratorSection decoratorSection) throws Exception { + for (ModelScreenWidget widget : decoratorSection.getSubWidgets()) { + widget.accept(this); + } } @Override - public void visit(PropertyToField propertyToField) { + public void visit(DecoratorSectionInclude decoratorSectionInclude) throws Exception { } @Override - public void visit(Script script) { + public void visit(EntityAnd entityAnd) throws Exception { + infoContext.addEntityName(entityAnd.getFinder().getEntityName()); } @Override - public void visit(Service service) { - infoContext.addServiceName(service.getServiceNameExdr().getOriginal()); - // TODO: Look for entityName in performFind service call + public void visit(EntityCondition entityCondition) throws Exception { + infoContext.addEntityName(entityCondition.getFinder().getEntityName()); } @Override - public void visit(SetField setField) { + public void visit(EntityOne entityOne) throws Exception { + infoContext.addEntityName(entityOne.getFinder().getEntityName()); } @Override - public void visit(HtmlWidget htmlWidget) throws Exception { + public void visit(Form form) throws Exception { + String formLocation = form.getLocation().concat("#").concat(form.getName()); + infoContext.addFormLocation(formLocation); + } + + @Override + public void visit(Grid grid) throws Exception { + String gridLocation = grid.getLocation().concat("#").concat(grid.getName()); + infoContext.addFormLocation(gridLocation); + } + + @Override + public void visit(GetRelated getRelated) throws Exception { + infoContext.addEntityName(getRelated.getRelationName()); + } + + @Override + public void visit(GetRelatedOne getRelatedOne) throws Exception { + infoContext.addEntityName(getRelatedOne.getRelationName()); + } + + @Override + public void visit(HorizontalSeparator horizontalSeparator) throws Exception { } @Override @@ -180,6 +219,14 @@ public final class ArtifactInfoGatherer } @Override + public void visit(HtmlWidget htmlWidget) throws Exception { + } + + @Override + public void visit(IncludeScreen includeScreen) throws Exception { + } + + @Override public void visit(IterateSectionWidget iterateSectionWidget) throws Exception { for (Section section : iterateSectionWidget.getSectionList()) { section.accept(this); @@ -187,95 +234,25 @@ public final class ArtifactInfoGatherer } @Override - public void visit(ModelForm modelForm) throws Exception { - if (modelForm.getActions() != null) { - for (ModelWidgetAction action : modelForm.getActions()) { - action.accept(this); - } - } - if (modelForm.getRowActions() != null) { - for (ModelWidgetAction action : modelForm.getRowActions()) { - action.accept(this); - } - } - for (AutoFieldsEntity autoFieldsEntity : modelForm.getAutoFieldsEntities()) { - infoContext.addEntityName(autoFieldsEntity.entityName); - } - for (AutoFieldsService autoFieldsService : modelForm.getAutoFieldsServices()) { - infoContext.addServiceName(autoFieldsService.serviceName); - } - if (modelForm.getAltTargets() != null) { - for (AltTarget altTarget : modelForm.getAltTargets()) { - String target = altTarget.targetExdr.getOriginal(); - String urlMode = "intra-app"; - try { - Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, - urlMode); - if (controllerLocAndRequestSet != null) { - for (String requestLocation : controllerLocAndRequestSet) { - infoContext.addTargetLocation(requestLocation); - } - } - } catch (GeneralException e) { - throw new RuntimeException(e); - } - } - } - if (!modelForm.getTarget().isEmpty()) { - String target = modelForm.getTarget(); - String urlMode = UtilValidate.isNotEmpty(modelForm.getTargetType()) ? modelForm.getTargetType() : "intra-app"; - if (target.indexOf("${") < 0) { - try { - Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, - urlMode); - if (controllerLocAndRequestSet != null) { - for (String requestLocation : controllerLocAndRequestSet) { - infoContext.addTargetLocation(requestLocation); - } - } - } catch (GeneralException e) { - throw new RuntimeException(e); - } - } - } - FieldInfoGatherer fieldInfoGatherer = new FieldInfoGatherer(); - for (ModelFormField modelFormField : modelForm.getFieldList()) { - if (UtilValidate.isNotEmpty(modelFormField.getEntityName())) { - infoContext.addEntityName(modelFormField.getEntityName()); - } - if (modelFormField.getFieldInfo() instanceof ModelFormField.DisplayEntityField) { - infoContext.addEntityName(((ModelFormField.DisplayEntityField) modelFormField.getFieldInfo()).getEntityName()); - } - if (modelFormField.getFieldInfo() instanceof FieldInfoWithOptions) { - for (ModelFormField.OptionSource optionSource : ((FieldInfoWithOptions) modelFormField - .getFieldInfo()).getOptionSources()) { - if (optionSource instanceof ModelFormField.EntityOptions) { - infoContext.addEntityName(((ModelFormField.EntityOptions) optionSource).getEntityName()); - } - } - } - if (UtilValidate.isNotEmpty(modelFormField.getServiceName())) { - infoContext.addServiceName(modelFormField.getServiceName()); - } - FieldInfo fieldInfo = modelFormField.getFieldInfo(); - if (fieldInfo != null) { - fieldInfo.accept(fieldInfoGatherer); - } - } + public void visit(Label label) throws Exception { } @Override - public void visit(ModelFormAction.EntityAnd entityAnd) { - infoContext.addEntityName(entityAnd.getFinder().getEntityName()); + public void visit(Menu menu) throws Exception { } @Override - public void visit(ModelFormAction.EntityCondition entityCondition) { - infoContext.addEntityName(entityCondition.getFinder().getEntityName()); + public void visit(ModelSingleForm modelForm) throws Exception { + visitModelForm(modelForm); + } + + @Override + public void visit(ModelGrid modelGrid) throws Exception { + visitModelForm(modelGrid); } @Override - public void visit(ModelFormAction.Service service) { + public void visit(ModelFormAction.Service service) throws Exception { infoContext.addServiceName(service.getServiceName()); // TODO: Look for entityName in performFind service call } @@ -285,7 +262,7 @@ public final class ArtifactInfoGatherer } @Override - public void visit(ModelMenuAction.SetField setField) { + public void visit(ModelMenuAction.SetField setField) throws Exception { } @Override @@ -293,6 +270,10 @@ public final class ArtifactInfoGatherer } @Override + public void visit(ModelNode modelNode) throws Exception { + } + + @Override public void visit(ModelScreen modelScreen) throws Exception { String screenLocation = modelScreen.getSourceLocation().concat("#").concat(modelScreen.getName()); infoContext.addScreenLocation(screenLocation); @@ -300,71 +281,58 @@ public final class ArtifactInfoGatherer } @Override - public void visit(ColumnContainer columnContainer) throws Exception { - for (Column column : columnContainer.getColumns()) { - for (ModelScreenWidget widget : column.getSubWidgets()) { - widget.accept(this); - } - } + public void visit(ModelSubNode modelSubNode) throws Exception { } @Override - public void visit(Container container) throws Exception { - for (ModelScreenWidget widget : container.getSubWidgets()) { - widget.accept(this); - } + public void visit(ModelTree modelTree) throws Exception { } @Override - public void visit(Content content) throws Exception { - infoContext.addEntityName("Content"); - if (!content.getDataResourceId().isEmpty()) { - infoContext.addEntityName("DataResource"); - } + public void visit(ModelTreeAction.EntityAnd entityAnd) throws Exception { } @Override - public void visit(DecoratorScreen decoratorScreen) throws Exception { - for (ModelScreenWidget section : decoratorScreen.getSectionMap().values()) { - section.accept(this); - } + public void visit(ModelTreeAction.EntityCondition entityCondition) throws Exception { } @Override - public void visit(DecoratorSection decoratorSection) throws Exception { - for (ModelScreenWidget widget : decoratorSection.getSubWidgets()) { - widget.accept(this); - } + public void visit(ModelTreeAction.Script script) throws Exception { } @Override - public void visit(DecoratorSectionInclude decoratorSectionInclude) throws Exception { + public void visit(ModelTreeAction.Service service) throws Exception { } @Override - public void visit(Form form) throws Exception { - String formLocation = form.getLocation().concat("#").concat(form.getName()); - infoContext.addFormLocation(formLocation); + public void visit(PlatformSpecific platformSpecific) throws Exception { } @Override - public void visit(HorizontalSeparator horizontalSeparator) throws Exception { + public void visit(PortalPage portalPage) throws Exception { } @Override - public void visit(Image image) throws Exception { + public void visit(PropertyMap propertyMap) throws Exception { } @Override - public void visit(IncludeScreen includeScreen) throws Exception { + public void visit(PropertyToField propertyToField) throws Exception { } @Override - public void visit(Label label) throws Exception { + public void visit(ScreenImage image) throws Exception { } @Override - public void visit(Link link) throws Exception { + public void visit(Screenlet screenlet) throws Exception { + for (ModelScreenWidget widget : screenlet.getSubWidgets()) { + widget.accept(this); + } + } + + @Override + public void visit(ScreenLink link) throws Exception { String target = link.getTarget(null); String urlMode = link.getUrlMode(); try { @@ -380,27 +348,12 @@ public final class ArtifactInfoGatherer } @Override - public void visit(Menu menu) throws Exception { - } - - @Override - public void visit(PlatformSpecific platformSpecific) throws Exception { - } - - @Override - public void visit(PortalPage portalPage) throws Exception { - } - - @Override - public void visit(Screenlet screenlet) throws Exception { - for (ModelScreenWidget widget : screenlet.getSubWidgets()) { - widget.accept(this); - } + public void visit(Script script) throws Exception { } @Override public void visit(Section section) throws Exception { - for (ModelWidgetAction action : section.getActions()) { + for (ModelAction action : section.getActions()) { action.accept(this); } for (ModelScreenWidget subWidget : section.getSubWidgets()) { @@ -412,35 +365,17 @@ public final class ArtifactInfoGatherer } @Override - public void visit(Tree tree) throws Exception { - } - - @Override - public void visit(ModelTree modelTree) throws Exception { - } - - @Override - public void visit(ModelNode modelNode) throws Exception { - } - - @Override - public void visit(ModelSubNode modelSubNode) throws Exception { - } - - @Override - public void visit(ModelTreeAction.EntityAnd entityAnd) { - } - - @Override - public void visit(ModelTreeAction.EntityCondition entityCondition) { + public void visit(Service service) throws Exception { + infoContext.addServiceName(service.getServiceNameExdr().getOriginal()); + // TODO: Look for entityName in performFind service call } @Override - public void visit(ModelTreeAction.Script script) { + public void visit(SetField setField) throws Exception { } @Override - public void visit(ModelTreeAction.Service service) { + public void visit(Tree tree) throws Exception { } private class FieldInfoGatherer implements ModelFieldVisitor { @@ -479,7 +414,7 @@ public final class ArtifactInfoGatherer public void visit(DisplayEntityField displayField) { if (displayField.getSubHyperlink() != null) { String target = displayField.getSubHyperlink().getTarget(null); - String urlMode = displayField.getSubHyperlink().getTargetType(); + String urlMode = displayField.getSubHyperlink().getUrlMode(); addRequestLocations(target, urlMode); } } @@ -492,7 +427,7 @@ public final class ArtifactInfoGatherer public void visit(DropDownField dropDownField) { if (dropDownField.getSubHyperlink() != null) { String target = dropDownField.getSubHyperlink().getTarget(null); - String urlMode = dropDownField.getSubHyperlink().getTargetType(); + String urlMode = dropDownField.getSubHyperlink().getUrlMode(); addRequestLocations(target, urlMode); } } @@ -501,7 +436,7 @@ public final class ArtifactInfoGatherer public void visit(FileField textField) { if (textField.getSubHyperlink() != null) { String target = textField.getSubHyperlink().getTarget(null); - String urlMode = textField.getSubHyperlink().getTargetType(); + String urlMode = textField.getSubHyperlink().getUrlMode(); addRequestLocations(target, urlMode); } } @@ -513,7 +448,7 @@ public final class ArtifactInfoGatherer @Override public void visit(HyperlinkField hyperlinkField) { String target = hyperlinkField.getTarget(null); - String urlMode = hyperlinkField.getTargetType(); + String urlMode = hyperlinkField.getUrlMode(); addRequestLocations(target, urlMode); } @@ -525,7 +460,7 @@ public final class ArtifactInfoGatherer public void visit(ImageField imageField) { if (imageField.getSubHyperlink() != null) { String target = imageField.getSubHyperlink().getTarget(null); - String urlMode = imageField.getSubHyperlink().getTargetType(); + String urlMode = imageField.getSubHyperlink().getUrlMode(); addRequestLocations(target, urlMode); } } @@ -566,4 +501,81 @@ public final class ArtifactInfoGatherer public void visit(TextFindField textField) { } } + + public void visitModelForm(ModelForm modelForm) throws Exception { + if (modelForm.getActions() != null) { + for (ModelAction action : modelForm.getActions()) { + action.accept(this); + } + } + if (modelForm.getRowActions() != null) { + for (ModelAction action : modelForm.getRowActions()) { + action.accept(this); + } + } + for (AutoFieldsEntity autoFieldsEntity : modelForm.getAutoFieldsEntities()) { + infoContext.addEntityName(autoFieldsEntity.entityName); + } + for (AutoFieldsService autoFieldsService : modelForm.getAutoFieldsServices()) { + infoContext.addServiceName(autoFieldsService.serviceName); + } + if (modelForm.getAltTargets() != null) { + for (AltTarget altTarget : modelForm.getAltTargets()) { + String target = altTarget.targetExdr.getOriginal(); + String urlMode = "intra-app"; + try { + Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, + urlMode); + if (controllerLocAndRequestSet != null) { + for (String requestLocation : controllerLocAndRequestSet) { + infoContext.addTargetLocation(requestLocation); + } + } + } catch (GeneralException e) { + throw new RuntimeException(e); + } + } + } + if (!modelForm.getTarget().isEmpty()) { + String target = modelForm.getTarget(); + String urlMode = UtilValidate.isNotEmpty(modelForm.getTargetType()) ? modelForm.getTargetType() : "intra-app"; + if (target.indexOf("${") < 0) { + try { + Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, + urlMode); + if (controllerLocAndRequestSet != null) { + for (String requestLocation : controllerLocAndRequestSet) { + infoContext.addTargetLocation(requestLocation); + } + } + } catch (GeneralException e) { + throw new RuntimeException(e); + } + } + } + FieldInfoGatherer fieldInfoGatherer = new FieldInfoGatherer(); + for (ModelFormField modelFormField : modelForm.getFieldList()) { + if (UtilValidate.isNotEmpty(modelFormField.getEntityName())) { + infoContext.addEntityName(modelFormField.getEntityName()); + } + if (modelFormField.getFieldInfo() instanceof ModelFormField.DisplayEntityField) { + infoContext.addEntityName(((ModelFormField.DisplayEntityField) modelFormField.getFieldInfo()).getEntityName()); + } + if (modelFormField.getFieldInfo() instanceof FieldInfoWithOptions) { + for (ModelFormField.OptionSource optionSource : ((FieldInfoWithOptions) modelFormField + .getFieldInfo()).getOptionSources()) { + if (optionSource instanceof ModelFormField.EntityOptions) { + infoContext.addEntityName(((ModelFormField.EntityOptions) optionSource).getEntityName()); + } + } + } + if (UtilValidate.isNotEmpty(modelFormField.getServiceName())) { + infoContext.addServiceName(modelFormField.getServiceName()); + } + FieldInfo fieldInfo = modelFormField.getFieldInfo(); + if (fieldInfo != null) { + fieldInfo.accept(fieldInfoGatherer); + } + } + } } Modified: ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/CommonWidgetModels.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/CommonWidgetModels.java?rev=1662488&r1=1652852&r2=1662488&view=diff ============================================================================== --- ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/CommonWidgetModels.java (original) +++ ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/CommonWidgetModels.java Thu Feb 26 16:16:11 2015 @@ -204,38 +204,34 @@ public final class CommonWidgetModels { private final FlexibleStringExpander widthExdr; public Image(Element imageElement) { - this.name = imageElement.getAttribute("name"); - String src = imageElement.getAttribute("image-location"); - if (src.isEmpty()) { - src = imageElement.getAttribute("src"); - } else { + if (!imageElement.getAttribute("image-location").isEmpty()) { // Form field version, log warning. - } - this.srcExdr = FlexibleStringExpander.getInstance(src); - this.idExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("id")); - this.styleExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("style")); - this.widthExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("width")); - this.heightExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("height")); - this.borderExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("border")); - String alt = imageElement.getAttribute("alternate"); - if (alt.isEmpty()) { - alt = imageElement.getAttribute("alt"); // Common version, no warning. + this.srcExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("image-location")); + this.alt = FlexibleStringExpander.getInstance(imageElement.getAttribute("alternate")); + this.titleExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("image-title")); + this.name = ""; + this.idExdr = FlexibleStringExpander.getInstance(""); + this.styleExdr = FlexibleStringExpander.getInstance(""); + this.widthExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("width")); + this.heightExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("height")); + this.borderExdr = FlexibleStringExpander.getInstance(""); + this.urlMode = "content"; } else { - // Form field version, log warning. - } - this.alt = FlexibleStringExpander.getInstance(alt); - String urlMode = imageElement.getAttribute("url-mode"); - if (urlMode.isEmpty()) { - urlMode = "content"; - } - this.urlMode = urlMode; - String title = imageElement.getAttribute("image-title"); - if (title.isEmpty()) { - title = imageElement.getAttribute("title"); - } else { - // Form field version, log warning. + this.srcExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("src")); + this.alt = FlexibleStringExpander.getInstance(imageElement.getAttribute("alt")); + this.titleExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("title")); + this.name = imageElement.getAttribute("name"); + this.idExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("id")); + this.styleExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("style")); + this.widthExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("width")); + this.heightExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("height")); + this.borderExdr = FlexibleStringExpander.getInstance(imageElement.getAttribute("border")); + String urlMode = imageElement.getAttribute("url-mode"); + if (urlMode.isEmpty()) { + urlMode = "content"; + } + this.urlMode = urlMode; } - this.titleExdr = FlexibleStringExpander.getInstance(title); } public FlexibleStringExpander getAlt() { @@ -333,7 +329,7 @@ public final class CommonWidgetModels { private final FlexibleStringExpander targetWindowExdr; private final FlexibleStringExpander textExdr; private final String urlMode; - // FIXME: These don't belong in this class + // FIXME: These don't belong in this class (might have been used for image) private final String height; private final String width; @@ -353,8 +349,12 @@ public final class CommonWidgetModels { if (imageElement != null) { this.image = new Image(imageElement); } else { - // TODO: Look for ModelFormField attributes - this.image = null; + if (!linkElement.getAttribute("image-location").isEmpty()) { + // Backwards compatibility + this.image = new Image(linkElement); + } else { + this.image = null; + } } this.linkType = linkElement.getAttribute("link-type"); List<? extends Element> parameterElementList = UtilXml.childElementList(linkElement, "parameter"); Modified: ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/FormFactory.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/FormFactory.java?rev=1662488&r1=1652852&r2=1662488&view=diff ============================================================================== --- ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/FormFactory.java (original) +++ ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/FormFactory.java Thu Feb 26 16:16:11 2015 @@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletReq import javax.xml.parsers.ParserConfigurationException; import org.ofbiz.base.location.FlexibleLocation; +import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.cache.UtilCache; @@ -40,7 +41,6 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; - /** * Widget Library - Form factory class */ @@ -90,7 +90,7 @@ public class FormFactory { URL formFileUrl = servletContext.getResource(resourceName); Document formFileDoc = UtilXml.readXmlDocument(formFileUrl, true, true); Element formElement = UtilXml.firstChildElement(formFileDoc.getDocumentElement(), "form", "name", formName); - modelForm = new ModelForm(formElement, resourceName, delegator.getModelReader(), dispatcher.getDispatchContext()); + modelForm = createModelForm(formElement, delegator.getModelReader(), dispatcher.getDispatchContext(), resourceName, formName); modelForm = formWebappCache.putIfAbsentAndGet(cacheKey, modelForm); } if (modelForm == null) { @@ -125,7 +125,11 @@ public class FormFactory { } public static ModelForm createModelForm(Element formElement, ModelReader entityModelReader, DispatchContext dispatchContext, String formLocation, String formName) { - ModelForm modelForm = new ModelForm(formElement, formLocation, entityModelReader, dispatchContext); - return modelForm; + String formType = formElement.getAttribute("type"); + if (formType.isEmpty() || "single".equals(formType) || "upload".equals(formType)) { + return new ModelSingleForm(formElement, formLocation, entityModelReader, dispatchContext); + } else { + return new ModelGrid(formElement, formLocation, entityModelReader, dispatchContext); + } } } Added: ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/GridFactory.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/GridFactory.java?rev=1662488&view=auto ============================================================================== --- ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/GridFactory.java (added) +++ ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/GridFactory.java Thu Feb 26 16:16:11 2015 @@ -0,0 +1,134 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.widget.model; + +import java.io.IOException; +import java.net.URL; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.xml.parsers.ParserConfigurationException; + +import org.ofbiz.base.location.FlexibleLocation; +import org.ofbiz.base.util.UtilHttp; +import org.ofbiz.base.util.UtilXml; +import org.ofbiz.base.util.cache.UtilCache; +import org.ofbiz.entity.Delegator; +import org.ofbiz.entity.model.ModelReader; +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.LocalDispatcher; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + + +/** + * Widget Library - Grid factory class + */ +public class GridFactory { + + public static final String module = GridFactory.class.getName(); + private static final UtilCache<String, ModelGrid> gridLocationCache = UtilCache.createUtilCache("widget.grid.locationResource", 0, 0, false); + private static final UtilCache<String, ModelGrid> gridWebappCache = UtilCache.createUtilCache("widget.grid.webappResource", 0, 0, false); + + public static Map<String, ModelGrid> getGridsFromLocation(String resourceName, ModelReader entityModelReader, DispatchContext dispatchContext) + throws IOException, SAXException, ParserConfigurationException { + URL gridFileUrl = FlexibleLocation.resolveLocation(resourceName); + Document gridFileDoc = UtilXml.readXmlDocument(gridFileUrl, true, true); + return readGridDocument(gridFileDoc, entityModelReader, dispatchContext, resourceName); + } + + public static ModelGrid getGridFromLocation(String resourceName, String gridName, ModelReader entityModelReader, DispatchContext dispatchContext) + throws IOException, SAXException, ParserConfigurationException { + StringBuilder sb = new StringBuilder(dispatchContext.getDelegator().getDelegatorName()); + sb.append(":").append(resourceName).append("#").append(gridName); + String cacheKey = sb.toString(); + ModelGrid modelGrid = gridLocationCache.get(cacheKey); + if (modelGrid == null) { + URL gridFileUrl = FlexibleLocation.resolveLocation(resourceName); + Document gridFileDoc = UtilXml.readXmlDocument(gridFileUrl, true, true); + if (gridFileDoc == null) { + throw new IllegalArgumentException("Could not find resource [" + resourceName + "]"); + } + modelGrid = createModelGrid(gridFileDoc, entityModelReader, dispatchContext, resourceName, gridName); + modelGrid = gridLocationCache.putIfAbsentAndGet(cacheKey, modelGrid); + } + if (modelGrid == null) { + throw new IllegalArgumentException("Could not find grid with name [" + gridName + "] in class resource [" + resourceName + "]"); + } + return modelGrid; + } + + public static ModelGrid getGridFromWebappContext(String resourceName, String gridName, HttpServletRequest request) + throws IOException, SAXException, ParserConfigurationException { + String webappName = UtilHttp.getApplicationName(request); + String cacheKey = webappName + "::" + resourceName + "::" + gridName; + ModelGrid modelGrid = gridWebappCache.get(cacheKey); + if (modelGrid == null) { + ServletContext servletContext = (ServletContext) request.getAttribute("servletContext"); + Delegator delegator = (Delegator) request.getAttribute("delegator"); + LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); + URL gridFileUrl = servletContext.getResource(resourceName); + Document gridFileDoc = UtilXml.readXmlDocument(gridFileUrl, true, true); + Element gridElement = UtilXml.firstChildElement(gridFileDoc.getDocumentElement(), "grid", "name", gridName); + modelGrid = createModelGrid(gridElement, delegator.getModelReader(), dispatcher.getDispatchContext(), resourceName, gridName); + modelGrid = gridWebappCache.putIfAbsentAndGet(cacheKey, modelGrid); + } + if (modelGrid == null) { + throw new IllegalArgumentException("Could not find grid with name [" + gridName + "] in webapp resource [" + resourceName + "] in the webapp [" + webappName + "]"); + } + return modelGrid; + } + + public static Map<String, ModelGrid> readGridDocument(Document gridFileDoc, ModelReader entityModelReader, DispatchContext dispatchContext, String gridLocation) { + Map<String, ModelGrid> modelGridMap = new HashMap<String, ModelGrid>(); + if (gridFileDoc != null) { + // read document and construct ModelGrid for each grid element + Element rootElement = gridFileDoc.getDocumentElement(); + List<? extends Element> gridElements = UtilXml.childElementList(rootElement, "grid"); + for (Element gridElement : gridElements) { + String gridName = gridElement.getAttribute("name"); + String cacheKey = gridLocation + "#" + gridName; + ModelGrid modelGrid = gridLocationCache.get(cacheKey); + if (modelGrid == null) { + modelGrid = createModelGrid(gridElement, entityModelReader, dispatchContext, gridLocation, gridName); + modelGrid = gridLocationCache.putIfAbsentAndGet(cacheKey, modelGrid); + } + modelGridMap.put(gridName, modelGrid); + } + } + return modelGridMap; + } + + public static ModelGrid createModelGrid(Document gridFileDoc, ModelReader entityModelReader, DispatchContext dispatchContext, String gridLocation, String gridName) { + Element gridElement = UtilXml.firstChildElement(gridFileDoc.getDocumentElement(), "grid", "name", gridName); + if (gridElement == null) { + // Backwards compatibility - look for form definition + gridElement = UtilXml.firstChildElement(gridFileDoc.getDocumentElement(), "form", "name", gridName); + } + return createModelGrid(gridElement, entityModelReader, dispatchContext, gridLocation, gridName); + } + + public static ModelGrid createModelGrid(Element gridElement, ModelReader entityModelReader, DispatchContext dispatchContext, String gridLocation, String gridName) { + return new ModelGrid(gridElement, gridLocation, entityModelReader, dispatchContext); + } +} Modified: ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/ModelForm.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/ModelForm.java?rev=1662488&r1=1652852&r2=1662488&view=diff ============================================================================== --- ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/ModelForm.java (original) +++ ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/ModelForm.java Thu Feb 26 16:16:11 2015 @@ -57,12 +57,12 @@ import bsh.EvalError; import bsh.Interpreter; /** - * Models the <form> element. + * Abstract base class for the <form> and <grid> elements. * * @see <code>widget-form.xsd</code> */ @SuppressWarnings("serial") -public class ModelForm extends ModelWidget { +public abstract class ModelForm extends ModelWidget { /* * ----------------------------------------------------------------------- * @@ -174,7 +174,7 @@ public class ModelForm extends ModelWidg private final FlexibleStringExpander paginateTarget; private final String paginateTargetAnchor; private final FlexibleStringExpander paginateViewSizeLabel; - private final ModelForm parentModelForm; + private final ModelForm parentModel; private final List<ModelAction> rowActions; private final FlexibleStringExpander rowCountExdr; private final boolean separateColumns; @@ -194,15 +194,15 @@ public class ModelForm extends ModelWidg private final Set<String> useWhenFields; /** XML Constructor */ - public ModelForm(Element formElement, String formLocation, ModelReader entityModelReader, DispatchContext dispatchContext) { + protected ModelForm(Element formElement, String formLocation, ModelReader entityModelReader, DispatchContext dispatchContext, String defaultType) { super(formElement); this.formLocation = formLocation; - parentModelForm = getParentForm(formElement, entityModelReader, dispatchContext); + parentModel = getParentModel(formElement, entityModelReader, dispatchContext); int defaultViewSizeInt = DEFAULT_PAGE_SIZE; String viewSize = formElement.getAttribute("view-size"); if (viewSize.isEmpty()) { - if (parentModelForm != null) { - defaultViewSizeInt = parentModelForm.defaultViewSize; + if (parentModel != null) { + defaultViewSizeInt = parentModel.defaultViewSize; } else { defaultViewSizeInt = UtilProperties.getPropertyAsInteger("widget.properties", "widget.form.defaultViewSize", defaultViewSizeInt); @@ -215,167 +215,171 @@ public class ModelForm extends ModelWidg } this.defaultViewSize = defaultViewSizeInt; String type = formElement.getAttribute("type"); - if (type.isEmpty() && parentModelForm != null) { - type = parentModelForm.type; + if (type.isEmpty()) { + if (parentModel != null) { + type = parentModel.type; + } else { + type = defaultType; + } } this.type = type; FlexibleStringExpander target = FlexibleStringExpander.getInstance(formElement.getAttribute("target")); - if (target.isEmpty() && parentModelForm != null) { - target = parentModelForm.target; + if (target.isEmpty() && parentModel != null) { + target = parentModel.target; } this.target = target; String containerId = formElement.getAttribute("id"); - if (containerId.isEmpty() && parentModelForm != null) { - containerId = parentModelForm.containerId; + if (containerId.isEmpty() && parentModel != null) { + containerId = parentModel.containerId; } this.containerId = containerId; String containerStyle = formElement.getAttribute("style"); - if (containerStyle.isEmpty() && parentModelForm != null) { - containerStyle = parentModelForm.containerStyle; + if (containerStyle.isEmpty() && parentModel != null) { + containerStyle = parentModel.containerStyle; } this.containerStyle = containerStyle; String title = formElement.getAttribute("title"); - if (title.isEmpty() && parentModelForm != null) { - title = parentModelForm.title; + if (title.isEmpty() && parentModel != null) { + title = parentModel.title; } this.title = title; String tooltip = formElement.getAttribute("tooltip"); - if (tooltip.isEmpty() && parentModelForm != null) { - tooltip = parentModelForm.tooltip; + if (tooltip.isEmpty() && parentModel != null) { + tooltip = parentModel.tooltip; } this.tooltip = tooltip; String listName = formElement.getAttribute("list-name"); if (listName.isEmpty()) { - if (parentModelForm != null) { - listName = parentModelForm.listName; + if (parentModel != null) { + listName = parentModel.listName; } else { listName = DEFAULT_FORM_RESULT_LIST_NAME; } } this.listName = listName; String listEntryName = formElement.getAttribute("list-entry-name"); - if (listEntryName.isEmpty() && parentModelForm != null) { - listEntryName = parentModelForm.listEntryName; + if (listEntryName.isEmpty() && parentModel != null) { + listEntryName = parentModel.listEntryName; } this.listEntryName = listEntryName; String defaultEntityName = formElement.getAttribute("default-entity-name"); - if (defaultEntityName.isEmpty() && parentModelForm != null) { - defaultEntityName = parentModelForm.defaultEntityName; + if (defaultEntityName.isEmpty() && parentModel != null) { + defaultEntityName = parentModel.defaultEntityName; } this.defaultEntityName = defaultEntityName; String defaultServiceName = formElement.getAttribute("default-service-name"); - if (defaultServiceName.isEmpty() && parentModelForm != null) { - defaultServiceName = parentModelForm.defaultServiceName; + if (defaultServiceName.isEmpty() && parentModel != null) { + defaultServiceName = parentModel.defaultServiceName; } this.defaultServiceName = defaultServiceName; String formTitleAreaStyle = formElement.getAttribute("form-title-area-style"); - if (formTitleAreaStyle.isEmpty() && parentModelForm != null) { - formTitleAreaStyle = parentModelForm.formTitleAreaStyle; + if (formTitleAreaStyle.isEmpty() && parentModel != null) { + formTitleAreaStyle = parentModel.formTitleAreaStyle; } this.formTitleAreaStyle = formTitleAreaStyle; String formWidgetAreaStyle = formElement.getAttribute("form-widget-area-style"); - if (formWidgetAreaStyle.isEmpty() && parentModelForm != null) { - formWidgetAreaStyle = parentModelForm.formWidgetAreaStyle; + if (formWidgetAreaStyle.isEmpty() && parentModel != null) { + formWidgetAreaStyle = parentModel.formWidgetAreaStyle; } this.formWidgetAreaStyle = formWidgetAreaStyle; String defaultTitleAreaStyle = formElement.getAttribute("default-title-area-style"); - if (defaultTitleAreaStyle.isEmpty() && parentModelForm != null) { - defaultTitleAreaStyle = parentModelForm.defaultTitleAreaStyle; + if (defaultTitleAreaStyle.isEmpty() && parentModel != null) { + defaultTitleAreaStyle = parentModel.defaultTitleAreaStyle; } this.defaultTitleAreaStyle = defaultTitleAreaStyle; String defaultWidgetAreaStyle = formElement.getAttribute("default-widget-area-style"); - if (defaultWidgetAreaStyle.isEmpty() && parentModelForm != null) { - defaultWidgetAreaStyle = parentModelForm.defaultWidgetAreaStyle; + if (defaultWidgetAreaStyle.isEmpty() && parentModel != null) { + defaultWidgetAreaStyle = parentModel.defaultWidgetAreaStyle; } this.defaultWidgetAreaStyle = defaultWidgetAreaStyle; String oddRowStyle = formElement.getAttribute("odd-row-style"); - if (oddRowStyle.isEmpty() && parentModelForm != null) { - oddRowStyle = parentModelForm.oddRowStyle; + if (oddRowStyle.isEmpty() && parentModel != null) { + oddRowStyle = parentModel.oddRowStyle; } this.oddRowStyle = oddRowStyle; String evenRowStyle = formElement.getAttribute("even-row-style"); - if (evenRowStyle.isEmpty() && parentModelForm != null) { - evenRowStyle = parentModelForm.evenRowStyle; + if (evenRowStyle.isEmpty() && parentModel != null) { + evenRowStyle = parentModel.evenRowStyle; } this.evenRowStyle = evenRowStyle; String defaultTableStyle = formElement.getAttribute("default-table-style"); - if (defaultTableStyle.isEmpty() && parentModelForm != null) { - defaultTableStyle = parentModelForm.defaultTableStyle; + if (defaultTableStyle.isEmpty() && parentModel != null) { + defaultTableStyle = parentModel.defaultTableStyle; } this.defaultTableStyle = defaultTableStyle; String headerRowStyle = formElement.getAttribute("header-row-style"); - if (headerRowStyle.isEmpty() && parentModelForm != null) { - headerRowStyle = parentModelForm.headerRowStyle; + if (headerRowStyle.isEmpty() && parentModel != null) { + headerRowStyle = parentModel.headerRowStyle; } this.headerRowStyle = headerRowStyle; String defaultTitleStyle = formElement.getAttribute("default-title-style"); - if (defaultTitleStyle.isEmpty() && parentModelForm != null) { - defaultTitleStyle = parentModelForm.defaultTitleStyle; + if (defaultTitleStyle.isEmpty() && parentModel != null) { + defaultTitleStyle = parentModel.defaultTitleStyle; } this.defaultTitleStyle = defaultTitleStyle; String defaultWidgetStyle = formElement.getAttribute("default-widget-style"); - if (defaultWidgetStyle.isEmpty() && parentModelForm != null) { - defaultWidgetStyle = parentModelForm.defaultWidgetStyle; + if (defaultWidgetStyle.isEmpty() && parentModel != null) { + defaultWidgetStyle = parentModel.defaultWidgetStyle; } this.defaultWidgetStyle = defaultWidgetStyle; String defaultTooltipStyle = formElement.getAttribute("default-tooltip-style"); - if (defaultTooltipStyle.isEmpty() && parentModelForm != null) { - defaultTooltipStyle = parentModelForm.defaultTooltipStyle; + if (defaultTooltipStyle.isEmpty() && parentModel != null) { + defaultTooltipStyle = parentModel.defaultTooltipStyle; } this.defaultTooltipStyle = defaultTooltipStyle; String itemIndexSeparator = formElement.getAttribute("item-index-separator"); - if (itemIndexSeparator.isEmpty() && parentModelForm != null) { - itemIndexSeparator = parentModelForm.itemIndexSeparator; + if (itemIndexSeparator.isEmpty() && parentModel != null) { + itemIndexSeparator = parentModel.itemIndexSeparator; } this.itemIndexSeparator = itemIndexSeparator; String separateColumns = formElement.getAttribute("separate-columns"); - if (separateColumns.isEmpty() && parentModelForm != null) { - this.separateColumns = parentModelForm.separateColumns; + if (separateColumns.isEmpty() && parentModel != null) { + this.separateColumns = parentModel.separateColumns; } else { this.separateColumns = "true".equals(separateColumns); } String groupColumns = formElement.getAttribute("group-columns"); - if (groupColumns.isEmpty() && parentModelForm != null) { - this.groupColumns = parentModelForm.groupColumns; + if (groupColumns.isEmpty() && parentModel != null) { + this.groupColumns = parentModel.groupColumns; } else { this.groupColumns = !"false".equals(groupColumns); } String targetType = formElement.getAttribute("target-type"); - if (targetType.isEmpty() && parentModelForm != null) { - targetType = parentModelForm.targetType; + if (targetType.isEmpty() && parentModel != null) { + targetType = parentModel.targetType; } this.targetType = targetType; FlexibleMapAccessor<Map<String, ? extends Object>> defaultMapName = FlexibleMapAccessor.getInstance(formElement .getAttribute("default-map-name")); - if (defaultMapName.isEmpty() && parentModelForm != null) { - defaultMapName = parentModelForm.defaultMapName; + if (defaultMapName.isEmpty() && parentModel != null) { + defaultMapName = parentModel.defaultMapName; } this.defaultMapName = defaultMapName; FlexibleStringExpander targetWindowExdr = FlexibleStringExpander.getInstance(formElement.getAttribute("target-window")); - if (targetWindowExdr.isEmpty() && parentModelForm != null) { - targetWindowExdr = parentModelForm.targetWindowExdr; + if (targetWindowExdr.isEmpty() && parentModel != null) { + targetWindowExdr = parentModel.targetWindowExdr; } this.targetWindowExdr = targetWindowExdr; String hideHeader = formElement.getAttribute("hide-header"); - if (hideHeader.isEmpty() && parentModelForm != null) { - this.hideHeader = parentModelForm.hideHeader; + if (hideHeader.isEmpty() && parentModel != null) { + this.hideHeader = parentModel.hideHeader; } else { this.hideHeader = "true".equals(hideHeader); } String clientAutocompleteFields = formElement.getAttribute("client-autocomplete-fields"); - if (clientAutocompleteFields.isEmpty() && parentModelForm != null) { - this.clientAutocompleteFields = parentModelForm.clientAutocompleteFields; + if (clientAutocompleteFields.isEmpty() && parentModel != null) { + this.clientAutocompleteFields = parentModel.clientAutocompleteFields; } else { this.clientAutocompleteFields = !"false".equals(formElement.getAttribute("client-autocomplete-fields")); } FlexibleStringExpander paginateTarget = FlexibleStringExpander.getInstance(formElement.getAttribute("paginate-target")); - if (paginateTarget.isEmpty() && parentModelForm != null) { - paginateTarget = parentModelForm.paginateTarget; + if (paginateTarget.isEmpty() && parentModel != null) { + paginateTarget = parentModel.paginateTarget; } this.paginateTarget = paginateTarget; ArrayList<AltTarget> altTargets = new ArrayList<AltTarget>(); - if (parentModelForm != null) { - altTargets.addAll(parentModelForm.altTargets); + if (parentModel != null) { + altTargets.addAll(parentModel.altTargets); } for (Element altTargetElement : UtilXml.childElementList(formElement, "alt-target")) { altTargets.add(new AltTarget(altTargetElement)); @@ -383,8 +387,8 @@ public class ModelForm extends ModelWidg altTargets.trimToSize(); this.altTargets = Collections.unmodifiableList(altTargets); ArrayList<ModelAction> actions = new ArrayList<ModelAction>(); - if (parentModelForm != null) { - actions.addAll(parentModelForm.actions); + if (parentModel != null) { + actions.addAll(parentModel.actions); } Element actionsElement = UtilXml.firstChildElement(formElement, "actions"); if (actionsElement != null) { @@ -393,8 +397,8 @@ public class ModelForm extends ModelWidg actions.trimToSize(); this.actions = Collections.unmodifiableList(actions); ArrayList<ModelAction> rowActions = new ArrayList<ModelAction>(); - if (parentModelForm != null) { - rowActions.addAll(parentModelForm.rowActions); + if (parentModel != null) { + rowActions.addAll(parentModel.rowActions); } Element rowActionsElement = UtilXml.firstChildElement(formElement, "row-actions"); if (rowActionsElement != null) { @@ -405,10 +409,10 @@ public class ModelForm extends ModelWidg ArrayList<UpdateArea> onPaginateUpdateAreas = new ArrayList<UpdateArea>(); ArrayList<UpdateArea> onSubmitUpdateAreas = new ArrayList<UpdateArea>(); ArrayList<UpdateArea> onSortColumnUpdateAreas = new ArrayList<UpdateArea>(); - if (parentModelForm != null) { - onPaginateUpdateAreas.addAll(parentModelForm.onPaginateUpdateAreas); - onSubmitUpdateAreas.addAll(parentModelForm.onSubmitUpdateAreas); - onSortColumnUpdateAreas.addAll(parentModelForm.onSortColumnUpdateAreas); + if (parentModel != null) { + onPaginateUpdateAreas.addAll(parentModel.onPaginateUpdateAreas); + onSubmitUpdateAreas.addAll(parentModel.onSubmitUpdateAreas); + onSortColumnUpdateAreas.addAll(parentModel.onSortColumnUpdateAreas); } for (Element updateAreaElement : UtilXml.childElementList(formElement, "on-event-update-area")) { UpdateArea updateArea = new UpdateArea(updateAreaElement, defaultServiceName, defaultEntityName); @@ -452,8 +456,8 @@ public class ModelForm extends ModelWidg onSortColumnUpdateAreas.trimToSize(); this.onSortColumnUpdateAreas = Collections.unmodifiableList(onSortColumnUpdateAreas); ArrayList<AltRowStyle> altRowStyles = new ArrayList<AltRowStyle>(); - if (parentModelForm != null) { - altRowStyles.addAll(parentModelForm.altRowStyles); + if (parentModel != null) { + altRowStyles.addAll(parentModel.altRowStyles); } for (Element altRowStyleElement : UtilXml.childElementList(formElement, "alt-row-style")) { AltRowStyle altRowStyle = new AltRowStyle(altRowStyleElement); @@ -462,14 +466,14 @@ public class ModelForm extends ModelWidg altRowStyles.trimToSize(); this.altRowStyles = Collections.unmodifiableList(altRowStyles); Set<String> useWhenFields = new HashSet<String>(); - if (parentModelForm != null) { - useWhenFields.addAll(parentModelForm.useWhenFields); + if (parentModel != null) { + useWhenFields.addAll(parentModel.useWhenFields); } ArrayList<ModelFormFieldBuilder> fieldBuilderList = new ArrayList<ModelFormFieldBuilder>(); Map<String, ModelFormFieldBuilder> fieldBuilderMap = new HashMap<String, ModelFormFieldBuilder>(); - if (parentModelForm != null) { - // Create this fieldList/Map from clones of parentModelForm's - for (ModelFormField parentChildField : parentModelForm.fieldList) { + if (parentModel != null) { + // Create this fieldList/Map from clones of parentModel's + for (ModelFormField parentChildField : parentModel.fieldList) { ModelFormFieldBuilder builder = new ModelFormFieldBuilder(parentChildField); builder.setModelForm(this); fieldBuilderList.add(builder); @@ -477,131 +481,131 @@ public class ModelForm extends ModelWidg } } Map<String, FieldGroupBase> fieldGroupMap = new HashMap<String, FieldGroupBase>(); - if (parentModelForm != null) { - fieldGroupMap.putAll(parentModelForm.fieldGroupMap); + if (parentModel != null) { + fieldGroupMap.putAll(parentModel.fieldGroupMap); } ArrayList<FieldGroupBase> fieldGroupList = new ArrayList<FieldGroupBase>(); - if (parentModelForm != null) { - fieldGroupList.addAll(parentModelForm.fieldGroupList); + if (parentModel != null) { + fieldGroupList.addAll(parentModel.fieldGroupList); } ArrayList<String> lastOrderFields = new ArrayList<String>(); - if (parentModelForm != null) { - lastOrderFields.addAll(parentModelForm.lastOrderFields); + if (parentModel != null) { + lastOrderFields.addAll(parentModel.lastOrderFields); } String sortFieldParameterName = formElement.getAttribute("sort-field-parameter-name"); - if (sortFieldParameterName.isEmpty() && parentModelForm != null) { - this.sortFieldParameterName = parentModelForm.targetType; + if (sortFieldParameterName.isEmpty() && parentModel != null) { + this.sortFieldParameterName = parentModel.targetType; } else { this.sortFieldParameterName = "sortField"; } String defaultRequiredFieldStyle = formElement.getAttribute("default-required-field-style"); - if (defaultRequiredFieldStyle.isEmpty() && parentModelForm != null) { - defaultRequiredFieldStyle = parentModelForm.defaultRequiredFieldStyle; + if (defaultRequiredFieldStyle.isEmpty() && parentModel != null) { + defaultRequiredFieldStyle = parentModel.defaultRequiredFieldStyle; } this.defaultRequiredFieldStyle = defaultRequiredFieldStyle; String defaultSortFieldStyle = formElement.getAttribute("default-sort-field-style"); - if (defaultSortFieldStyle.isEmpty() && parentModelForm != null) { - this.defaultSortFieldStyle = parentModelForm.defaultSortFieldStyle; + if (defaultSortFieldStyle.isEmpty() && parentModel != null) { + this.defaultSortFieldStyle = parentModel.defaultSortFieldStyle; } else { this.defaultSortFieldStyle = DEFAULT_SORT_FIELD_STYLE; } String defaultSortFieldAscStyle = formElement.getAttribute("default-sort-field-asc-style"); - if (defaultSortFieldAscStyle.isEmpty() && parentModelForm != null) { - this.defaultSortFieldAscStyle = parentModelForm.defaultSortFieldAscStyle; + if (defaultSortFieldAscStyle.isEmpty() && parentModel != null) { + this.defaultSortFieldAscStyle = parentModel.defaultSortFieldAscStyle; } else { this.defaultSortFieldAscStyle = DEFAULT_SORT_FIELD_ASC_STYLE; } String defaultSortFieldDescStyle = formElement.getAttribute("default-sort-field-desc-style"); - if (defaultSortFieldDescStyle.isEmpty() && parentModelForm != null) { - this.defaultSortFieldDescStyle = parentModelForm.defaultSortFieldDescStyle; + if (defaultSortFieldDescStyle.isEmpty() && parentModel != null) { + this.defaultSortFieldDescStyle = parentModel.defaultSortFieldDescStyle; } else { this.defaultSortFieldDescStyle = DEFAULT_SORT_FIELD_DESC_STYLE; } String paginateTargetAnchor = formElement.getAttribute("paginate-target-anchor"); - if (paginateTargetAnchor.isEmpty() && parentModelForm != null) { - paginateTargetAnchor = parentModelForm.paginateTargetAnchor; + if (paginateTargetAnchor.isEmpty() && parentModel != null) { + paginateTargetAnchor = parentModel.paginateTargetAnchor; } this.paginateTargetAnchor = paginateTargetAnchor; FlexibleStringExpander paginateIndexField = FlexibleStringExpander.getInstance(formElement .getAttribute("paginate-index-field")); - if (paginateIndexField.isEmpty() && parentModelForm != null) { - paginateIndexField = parentModelForm.paginateIndexField; + if (paginateIndexField.isEmpty() && parentModel != null) { + paginateIndexField = parentModel.paginateIndexField; } this.paginateIndexField = paginateIndexField; FlexibleStringExpander paginateSizeField = FlexibleStringExpander.getInstance(formElement .getAttribute("paginate-size-field")); - if (paginateSizeField.isEmpty() && parentModelForm != null) { - paginateSizeField = parentModelForm.paginateSizeField; + if (paginateSizeField.isEmpty() && parentModel != null) { + paginateSizeField = parentModel.paginateSizeField; } this.paginateSizeField = paginateSizeField; FlexibleStringExpander overrideListSize = FlexibleStringExpander.getInstance(formElement .getAttribute("override-list-size")); - if (overrideListSize.isEmpty() && parentModelForm != null) { - overrideListSize = parentModelForm.overrideListSize; + if (overrideListSize.isEmpty() && parentModel != null) { + overrideListSize = parentModel.overrideListSize; } this.overrideListSize = overrideListSize; FlexibleStringExpander paginateFirstLabel = FlexibleStringExpander.getInstance(formElement .getAttribute("paginate-first-label")); - if (paginateFirstLabel.isEmpty() && parentModelForm != null) { - paginateFirstLabel = parentModelForm.paginateFirstLabel; + if (paginateFirstLabel.isEmpty() && parentModel != null) { + paginateFirstLabel = parentModel.paginateFirstLabel; } this.paginateFirstLabel = paginateFirstLabel; FlexibleStringExpander paginatePreviousLabel = FlexibleStringExpander.getInstance(formElement .getAttribute("paginate-previous-label")); - if (paginatePreviousLabel.isEmpty() && parentModelForm != null) { - paginatePreviousLabel = parentModelForm.paginatePreviousLabel; + if (paginatePreviousLabel.isEmpty() && parentModel != null) { + paginatePreviousLabel = parentModel.paginatePreviousLabel; } this.paginatePreviousLabel = paginatePreviousLabel; FlexibleStringExpander paginateNextLabel = FlexibleStringExpander.getInstance(formElement .getAttribute("paginate-next-label")); - if (paginateNextLabel.isEmpty() && parentModelForm != null) { - paginateNextLabel = parentModelForm.paginateNextLabel; + if (paginateNextLabel.isEmpty() && parentModel != null) { + paginateNextLabel = parentModel.paginateNextLabel; } this.paginateNextLabel = paginateNextLabel; FlexibleStringExpander paginateLastLabel = FlexibleStringExpander.getInstance(formElement .getAttribute("paginate-last-label")); - if (paginateLastLabel.isEmpty() && parentModelForm != null) { - paginateLastLabel = parentModelForm.paginateLastLabel; + if (paginateLastLabel.isEmpty() && parentModel != null) { + paginateLastLabel = parentModel.paginateLastLabel; } this.paginateLastLabel = paginateLastLabel; FlexibleStringExpander paginateViewSizeLabel = FlexibleStringExpander.getInstance(formElement .getAttribute("paginate-viewsize-label")); - if (paginateViewSizeLabel.isEmpty() && parentModelForm != null) { - paginateViewSizeLabel = parentModelForm.paginateViewSizeLabel; + if (paginateViewSizeLabel.isEmpty() && parentModel != null) { + paginateViewSizeLabel = parentModel.paginateViewSizeLabel; } this.paginateViewSizeLabel = paginateViewSizeLabel; String paginateStyle = formElement.getAttribute("paginate-style"); - if (paginateStyle.isEmpty() && parentModelForm != null) { - this.paginateStyle = parentModelForm.paginateStyle; + if (paginateStyle.isEmpty() && parentModel != null) { + this.paginateStyle = parentModel.paginateStyle; } else { this.paginateStyle = DEFAULT_PAG_STYLE; } FlexibleStringExpander paginate = FlexibleStringExpander.getInstance(formElement.getAttribute("paginate")); - if (paginate.isEmpty() && parentModelForm != null) { - paginate = parentModelForm.paginate; + if (paginate.isEmpty() && parentModel != null) { + paginate = parentModel.paginate; } this.paginate = paginate; String skipStart = formElement.getAttribute("skip-start"); - if (skipStart.isEmpty() && parentModelForm != null) { - this.skipStart = parentModelForm.skipStart; + if (skipStart.isEmpty() && parentModel != null) { + this.skipStart = parentModel.skipStart; } else { this.skipStart = "true".equals(skipStart); } String skipEnd = formElement.getAttribute("skip-end"); - if (skipEnd.isEmpty() && parentModelForm != null) { - this.skipEnd = parentModelForm.skipEnd; + if (skipEnd.isEmpty() && parentModel != null) { + this.skipEnd = parentModel.skipEnd; } else { this.skipEnd = "true".equals(skipEnd); } String useRowSubmit = formElement.getAttribute("use-row-submit"); - if (useRowSubmit.isEmpty() && parentModelForm != null) { - this.useRowSubmit = parentModelForm.useRowSubmit; + if (useRowSubmit.isEmpty() && parentModel != null) { + this.useRowSubmit = parentModel.useRowSubmit; } else { this.useRowSubmit = "true".equals(useRowSubmit); } FlexibleStringExpander rowCountExdr = FlexibleStringExpander.getInstance(formElement.getAttribute("row-count")); - if (rowCountExdr.isEmpty() && parentModelForm != null) { - rowCountExdr = parentModelForm.rowCountExdr; + if (rowCountExdr.isEmpty() && parentModel != null) { + rowCountExdr = parentModel.rowCountExdr; } this.rowCountExdr = paginate; ArrayList<ModelFormFieldBuilder> multiSubmitBuilders = new ArrayList<ModelFormFieldBuilder>(); @@ -728,17 +732,12 @@ public class ModelForm extends ModelWidg sortOrderFields.trimToSize(); this.sortOrderFields = Collections.unmodifiableList(sortOrderFields); String focusFieldName = formElement.getAttribute("focus-field-name"); - if (focusFieldName.isEmpty() && parentModelForm != null) { - focusFieldName = parentModelForm.focusFieldName; + if (focusFieldName.isEmpty() && parentModel != null) { + focusFieldName = parentModel.focusFieldName; } this.focusFieldName = focusFieldName; } - @Override - public void accept(ModelWidgetVisitor visitor) throws Exception { - visitor.visit(this); - } - private void addAutoFieldsFromEntity(AutoFieldsEntity autoFieldsEntity, ModelReader entityModelReader, Set<String> useWhenFields, List<ModelFormFieldBuilder> fieldBuilderList, Map<String, ModelFormFieldBuilder> fieldBuilderMap) { // read entity def and auto-create fields @@ -1245,51 +1244,18 @@ public class ModelForm extends ModelWidg return field; } - private ModelForm getParentForm(Element formElement, ModelReader entityModelReader, DispatchContext dispatchContext) { - ModelForm parent = null; - String parentResource = formElement.getAttribute("extends-resource"); - String parentForm = formElement.getAttribute("extends"); - if (parentForm.length() > 0) { - // check if we have a resource name (part of the string before the ?) - if (parentResource.length() > 0) { - try { - parent = FormFactory.getFormFromLocation(parentResource, parentForm, entityModelReader, dispatchContext); - } catch (Exception e) { - Debug.logError(e, "Failed to load parent form definition '" + parentForm + "' at resource '" + parentResource - + "'", module); - } - } else if (!parentForm.equals(formElement.getAttribute("name"))) { - // try to find a form definition in the same file - Element rootElement = formElement.getOwnerDocument().getDocumentElement(); - List<? extends Element> formElements = UtilXml.childElementList(rootElement, "form"); - //Uncomment below to add support for abstract forms - //formElements.addAll(UtilXml.childElementList(rootElement, "abstract-form")); - for (Element formElementEntry : formElements) { - if (formElementEntry.getAttribute("name").equals(parentForm)) { - parent = new ModelForm(formElementEntry, parentResource, entityModelReader, dispatchContext); - break; - } - } - if (parent == null) { - Debug.logError("Failed to find parent form definition '" + parentForm + "' in same document.", module); - } - } else { - Debug.logError("Recursive form definition found for '" + formElement.getAttribute("name") + ".'", module); - } - } - return parent; - } + protected abstract ModelForm getParentModel(Element formElement, ModelReader entityModelReader, DispatchContext dispatchContext); public String getParentFormLocation() { - return this.parentModelForm == null ? null : this.parentModelForm.getFormLocation(); + return this.parentModel == null ? null : this.parentModel.getFormLocation(); } public String getParentFormName() { - return this.parentModelForm == null ? null : this.parentModelForm.getName(); + return this.parentModel == null ? null : this.parentModel.getName(); } public ModelForm getParentModelForm() { - return parentModelForm; + return parentModel; } public String getPassedRowCount(Map<String, Object> context) { Modified: ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java?rev=1662488&r1=1652852&r2=1662488&view=diff ============================================================================== --- ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java (original) +++ ofbiz/branches/release14.12/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java Thu Feb 26 16:16:11 2015 @@ -2102,12 +2102,15 @@ public class ModelFormField { private final FlexibleStringExpander description; private final boolean requestConfirmation; private final Link link; + public HyperlinkField(Element element, ModelFormField modelFormField) { super(element, modelFormField); this.alsoHidden = !"false".equals(element.getAttribute("also-hidden")); this.confirmationMsgExdr = FlexibleStringExpander.getInstance(element.getAttribute("confirmation-message")); this.description = FlexibleStringExpander.getInstance(element.getAttribute("description")); this.requestConfirmation = "true".equals(element.getAttribute("request-confirmation")); + // Backwards-compatible fix + element.setAttribute("url-mode", element.getAttribute("target-type")); this.link = new Link(element); } @@ -3145,6 +3148,9 @@ public class ModelFormField { public SubHyperlink(Element element, ModelFormField modelFormField) { this.description = FlexibleStringExpander.getInstance(element.getAttribute("description")); this.useWhen = FlexibleStringExpander.getInstance(element.getAttribute("use-when")); + // Backwards compatible support + element.setAttribute("style", element.getAttribute("link-style")); + element.setAttribute("url-mode", element.getAttribute("target-type")); this.link = new Link(element); this.modelFormField = modelFormField; } |
Free forum by Nabble | Edit this page |