[ 
https://issues.apache.org/jira/browse/OFBIZ-13315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18042123#comment-18042123
 ] 

ASF subversion and git services commented on OFBIZ-13315:
---------------------------------------------------------

Commit fdddf90e13ecde42d5fd64c08fa829c0002e8155 in ofbiz-framework's branch 
refs/heads/trunk from Nicolas Malin
[ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=fdddf90e13 ]

Improved: Set uniqueItemName as unique on ScreenWidget (OFBIZ-13315)

When you use a menu item with an iterate-section, the widget engine failed to 
set a correct unique id

Example :
*****
  <ws:screen name="ListElement">
    <ws:section>
      <ws:iterate-section entry="element" list="elements">
        <ws:section>
          <ws:widgets>
            <ws:include-grid name="ListElementFrom" .../>
            <ws:include-grid name="ListElementTo" .../>
          </ws:widgets>
        </ws:section>
      </ws:iterate-section>
    </ws:section>
  </[code]ws:screen>

  <wf:grid name="ListElementFrom" > ....
     <wf:field name="menuAction" title=" ">
       <wf:include-menu name="ListElementInLineBar"/>
     </wf:field>
  </wf:grid>

  <wf:grid name="ListElementTro" >...
    <wf:field name="menuAction" title=" ">
      <wf:include-menu name="ListElementInLineBar"/>
    </wf:field>
  </wf:grid>

  <wm:menu name="ListElementInLineBar" >
    <wm:menu-item name="delete">
      <wm:link target="Element/delete">...</wm:link>
    </wm:menu-item>
  </wm:menu>
****

When you click on delete link, you have twice the submission, each menu present 
because the menu id is the same.

The reason come from the process to build a unique name use on the js script to 
submit.

MacroMenuRenderer.java:223 where we concat the menu name, menu item name and 
different index present in context ('menuUniqueItemIndex', 'itemIndex' and 
'parentItemIndex'). It's possible if we manage different index on this screen 
to escape this issue, but after ready and taking a step back, this will be 
increase the screen complexity for nothing link to this problematic.

We simplify it to generate each time a real unique name that we can prefix and 
if we need to spot an element from a custom js script I suggest to use index 
instead name and a unique name to build correctly through multiple context 
index.

Follow this way, we introduce a new class UtilRandom to centralize methods to 
manage a unique id/name and propagate this logic on all unique item name using 
on the screen widget engine.


> Set uniqueItemName as unique on ScreenWidget
> --------------------------------------------
>
>                 Key: OFBIZ-13315
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-13315
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: framework/widget
>            Reporter: Nicolas Malin
>            Assignee: Nicolas Malin
>            Priority: Trivial
>         Attachments: OFBIZ-13315.patch
>
>
> Recently I was face to face with a problem of non-unique name for a link menu 
> with hidden form.
> My menu was included twice in a screen hisself included on iterate-section.
> {code:xml}
>       <ws:screen name="ListElement">
>             <ws:section>
>                    <ws:iterate-section entry="element" list="elements">
>                         <ws:section>
>                             <ws:widgets>
>                                                 <ws:include-grid 
> name="ListElementFrom" 
> location="component://naccounting/widget/staticdata/NGlAccountCpd.xml"/>
>                                                 <ws:include-grid 
> name="ListElementTo" />
>                             </ws:widgets>
>                         </ws:section>
>                     </ws:iterate-section>
>             </ws:section>
>         </[code]ws:screen>
>         <wf:grid name="ListElementFrom" >
>          ....
>             <wf:field name="menuAction" title=" ">
>                 <wf:include-menu name="ListElementInLineBar"/>
>             </wf:field>
>         </wf:grid>
>         <wf:grid name="ListElementTro" >
>          ....
>             <wf:field name="menuAction" title=" ">
>                 <wf:include-menu name="ListElementInLineBar"/>
>             </wf:field>
>         </wf:grid>
>         <wm:menu name="ListElementInLineBar" >
>             <wm:menu-item name="delete" title="${uiLabelMap.CommonDelete}">
>                 <wm:link target="Element/delete">
>                         ...
>                 </wm:link>
>             </wm:menu-item>
>         </wm:menu>
>  {code}
>  
> When I clicked on delete link, I have twice the submission, each menu present.
> The reason come from the process to build a unique name use on the js script 
> to submit.
> MacroMenuRenderer.java:223 where we concat the menu name, menu item name and 
> different index present in context ('menuUniqueItemIndex', 'itemIndex' and 
> 'parentItemIndex'). It's possible if I manage different index on my screen 
> maybe I can escape my issue, but after ready and taking a step back, this 
> will be increase my screen complexity for nothing link to my problematic.
> I propose to simplify it to generate each time a real unique name that we can 
> prefix and if we need to spot an element from a custom js script I suggest to 
> use index instead name and a unique name to build correctly through multiple 
> context index. 
> Follow this way, I introduce a new class UtilRandom to centralize methods to 
> manage a unique id/name and propagate this logic on all unique item name 
> using on the screen widget engine.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to