<alt-target> is not working as expected in Form Widget

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

<alt-target> is not working as expected in Form Widget

Pritam Kute
Hello OFBiz Developers,

While working on the issue OFBIZ-7252
<https://issues.apache.org/jira/browse/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.

Is this is intentionally done or we are missing something?

Thanks & Regards,
--
*Pritam Kute*
*HotWax Systems* | www.hotwaxsystems.com
Reply | Threaded
Open this post in threaded view
|

Re: <alt-target> is not working as expected in Form Widget

Pritam Kute
Hello Devs,

Any thoughts on this? Should I log JIRA issue for the same??

Thanks & Regards,
--
*Pritam Kute*
*HotWax Systems* | www.hotwaxsystems.com

On Wed, Jun 15, 2016 at 2:26 PM, Pritam Kute <[hidden email]>
wrote:

> Hello OFBiz Developers,
>
> While working on the issue OFBIZ-7252
> <https://issues.apache.org/jira/browse/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.
>
> Is this is intentionally done or we are missing something?
>
> Thanks & Regards,
> --
> *Pritam Kute*
> *HotWax Systems* | www.hotwaxsystems.com
>
Reply | Threaded
Open this post in threaded view
|

Re: <alt-target> is not working as expected in Form Widget

Jacques Le Roux
Administrator
It's a bug for me

Jacques


Le 18/06/2016 à 14:19, Pritam Kute a écrit :

> Hello Devs,
>
> Any thoughts on this? Should I log JIRA issue for the same??
>
> Thanks & Regards,
> --
> *Pritam Kute*
> *HotWax Systems* | www.hotwaxsystems.com
>
> On Wed, Jun 15, 2016 at 2:26 PM, Pritam Kute <[hidden email]>
> wrote:
>
>> Hello OFBiz Developers,
>>
>> While working on the issue OFBIZ-7252
>> <https://issues.apache.org/jira/browse/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.
>>
>> Is this is intentionally done or we are missing something?
>>
>> Thanks & Regards,
>> --
>> *Pritam Kute*
>> *HotWax Systems* | www.hotwaxsystems.com
>>

Reply | Threaded
Open this post in threaded view
|

Re: <alt-target> is not working as expected in Form Widget

Mridul Pathak-4
In reply to this post by Pritam Kute
Yes, it seems like a bug. A JIRA ticket can be logged for it.

--
Thanks & Regards,
Mridul Pathak
Senior Manager
HotWax Systems
http://www.hotwaxsystems.com

> On Jun 18, 2016, at 5:49 PM, Pritam Kute <[hidden email]> wrote:
>
> Hello Devs,
>
> Any thoughts on this? Should I log JIRA issue for the same??
>
> Thanks & Regards,
> --
> *Pritam Kute*
> *HotWax Systems* | www.hotwaxsystems.com
>
> On Wed, Jun 15, 2016 at 2:26 PM, Pritam Kute <[hidden email]>
> wrote:
>
>> Hello OFBiz Developers,
>>
>> While working on the issue OFBIZ-7252
>> <https://issues.apache.org/jira/browse/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.
>>
>> Is this is intentionally done or we are missing something?
>>
>> Thanks & Regards,
>> --
>> *Pritam Kute*
>> *HotWax Systems* | www.hotwaxsystems.com
>>

Reply | Threaded
Open this post in threaded view
|

Re: <alt-target> is not working as expected in Form Widget

Pranay Pandey-3
In reply to this post by Pritam Kute
+1 Pritam, we should log it in JIRA.

Best regards,

Pranay Pandey
HotWax Systems
http://www.hotwaxsystems.com/

On Sat, Jun 18, 2016 at 5:49 PM, Pritam Kute <[hidden email]>
wrote:

> Hello Devs,
>
> Any thoughts on this? Should I log JIRA issue for the same??
>
> Thanks & Regards,
> --
> *Pritam Kute*
> *HotWax Systems* | www.hotwaxsystems.com
>
> On Wed, Jun 15, 2016 at 2:26 PM, Pritam Kute <
> [hidden email]>
> wrote:
>
> > Hello OFBiz Developers,
> >
> > While working on the issue OFBIZ-7252
> > <https://issues.apache.org/jira/browse/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.
> >
> > Is this is intentionally done or we are missing something?
> >
> > Thanks & Regards,
> > --
> > *Pritam Kute*
> > *HotWax Systems* | www.hotwaxsystems.com
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: <alt-target> is not working as expected in Form Widget

Pritam Kute
Thanks, Jacques, Pranay and Mridul for your comments on this.

Logged JIRA issue for the same (OFBIZ-7513
<https://issues.apache.org/jira/browse/OFBIZ-7513>). I will work on the fix
and upload the patch soon.

Thanks & Regards,
--
*Pritam Kute*
*HotWax Systems* | www.hotwaxsystems.com

On Mon, Jun 20, 2016 at 12:31 PM, Pranay Pandey <
[hidden email]> wrote:

> +1 Pritam, we should log it in JIRA.
>
> Best regards,
>
> Pranay Pandey
> HotWax Systems
> http://www.hotwaxsystems.com/
>
> On Sat, Jun 18, 2016 at 5:49 PM, Pritam Kute <
> [hidden email]>
> wrote:
>
> > Hello Devs,
> >
> > Any thoughts on this? Should I log JIRA issue for the same??
> >
> > Thanks & Regards,
> > --
> > *Pritam Kute*
> > *HotWax Systems* | www.hotwaxsystems.com
> >
> > On Wed, Jun 15, 2016 at 2:26 PM, Pritam Kute <
> > [hidden email]>
> > wrote:
> >
> > > Hello OFBiz Developers,
> > >
> > > While working on the issue OFBIZ-7252
> > > <https://issues.apache.org/jira/browse/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.
> > >
> > > Is this is intentionally done or we are missing something?
> > >
> > > Thanks & Regards,
> > > --
> > > *Pritam Kute*
> > > *HotWax Systems* | www.hotwaxsystems.com
> > >
> >
>