[jira] [Updated] (OFBIZ-7513) alt-target tag is not working as expected in Form Widget

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (OFBIZ-7513) alt-target tag is not working as expected in Form Widget

Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-7513?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jacques Le Roux updated OFBIZ-7513:
-----------------------------------
    Description:
While working on the issue OFBIZ-7252, I found one problem in Form Widgets. When we use <alt-target> attribute in child form, the system should consider overridden <alt-target> in child form. This is default expected behaviour. But in this case, it is always considering the <alt-target> of the parent form.

For example:
{code}
<form name="ParentForm" .....>
  <alt-target use-when="xyz != abc" target="executeParentTarget"/>
  ........
</form>
{code}
{code}
<form name="ChildForm" extends="ParentForm" extend-resource="........>
  <alt-target use-when="xyz != abc" target="executeChildTarget"/>
  ........
</form>
{code}
In above example, expectation is 'executeChildTarget' target should get executed but actually 'executeParentTarget' is getting executed.

When we looked into framework level code of Form Widgets, we got the following code snippets:

ModelForm.java (Line: 380-388)
{code}
ArrayList<AltTarget> altTargets = new ArrayList<AltTarget>();
if (parentModel != null) {
    altTargets.addAll(parentModel.altTargets);
}
for (Element altTargetElement : UtilXml.childElementList(formElement, "alt-target")) {
    altTargets.add(new AltTarget(altTargetElement));
}
altTargets.trimToSize();
this.altTargets = Collections.unmodifiableList(altTargets);
{code}

Here we can see that all alt-targets present in parent form are added to the list first and then all alt-targets present in child form are added.

This causes a problem as method getTarget() of ModelForm.java (Line: 1352-1384) returns the first element in the list as alt-target.

  was:
While working on the issue OFBIZ-7252, I found one problem in Form Widgets. When we use <alt-target> attribute in child form, the system should consider overridden <alt-target> in child form. This is default expected behaviour. But in this case, it is always considering the <alt-target> of the parent form.

For example:

<form name="ParentForm" .....>
  <alt-target use-when="xyz != abc" target="executeParentTarget"/>
  ........
</form>

<form name="ChildForm" extends="ParentForm" extend-resource="........>
  <alt-target use-when="xyz != abc" target="executeChildTarget"/>
  ........
</form>

In above example, expectation is 'executeChildTarget' target should get executed but actually 'executeParentTarget' is getting executed.

When we looked into framework level code of Form Widgets, we got the following code snippets:

ModelForm.java (Line: 380-388)

ArrayList<AltTarget> altTargets = new ArrayList<AltTarget>();
if (parentModel != null) {
    altTargets.addAll(parentModel.altTargets);
}
for (Element altTargetElement : UtilXml.childElementList(formElement, "alt-target")) {
    altTargets.add(new AltTarget(altTargetElement));
}
altTargets.trimToSize();
this.altTargets = Collections.unmodifiableList(altTargets);

Here we can see that all alt-targets present in parent form are added to the list first and then all alt-targets present in child form are added.

This causes a problem as method getTarget() of ModelForm.java (Line: 1352-1384) returns the first element in the list as alt-target.


> alt-target tag is not working as expected in Form Widget
> --------------------------------------------------------
>
>                 Key: OFBIZ-7513
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-7513
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Trunk
>            Reporter: Pritam Kute
>            Assignee: Pritam Kute
>         Attachments: OFBIZ-7513-Trunk.patch
>
>
> While working on the issue OFBIZ-7252, I found one problem in Form Widgets. When we use <alt-target> attribute in child form, the system should consider overridden <alt-target> in child form. This is default expected behaviour. But in this case, it is always considering the <alt-target> of the parent form.
> For example:
> {code}
> <form name="ParentForm" .....>
>   <alt-target use-when="xyz != abc" target="executeParentTarget"/>
>   ........
> </form>
> {code}
> {code}
> <form name="ChildForm" extends="ParentForm" extend-resource="........>
>   <alt-target use-when="xyz != abc" target="executeChildTarget"/>
>   ........
> </form>
> {code}
> In above example, expectation is 'executeChildTarget' target should get executed but actually 'executeParentTarget' is getting executed.
> When we looked into framework level code of Form Widgets, we got the following code snippets:
> ModelForm.java (Line: 380-388)
> {code}
> ArrayList<AltTarget> altTargets = new ArrayList<AltTarget>();
> if (parentModel != null) {
>     altTargets.addAll(parentModel.altTargets);
> }
> for (Element altTargetElement : UtilXml.childElementList(formElement, "alt-target")) {
>     altTargets.add(new AltTarget(altTargetElement));
> }
> altTargets.trimToSize();
> this.altTargets = Collections.unmodifiableList(altTargets);
> {code}
> Here we can see that all alt-targets present in parent form are added to the list first and then all alt-targets present in child form are added.
> This causes a problem as method getTarget() of ModelForm.java (Line: 1352-1384) returns the first element in the list as alt-target.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)