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

ASF subversion and git services commented on WICKET-6921:
---------------------------------------------------------

Commit e77bfa21dfb774db6d895c13bb19d9552449d00d in wicket's branch 
refs/heads/wicket-9.x from Mathieu Mitchell
[ https://gitbox.apache.org/repos/asf?p=wicket.git;h=e77bfa2 ]

WICKET-6921 Avoid updating hidden forms (#478)

Currently, MultipartFormComponentListener ensures form enctype is
correct on the client-side when visibility for multipart-enabling
components is toggled. It does so by visiting all form components,
detecting multipart-enabling components and emitting javascript code
to refresh the encoding type on the client-side.

There are a few issues solved by this commit:

- The identified form component could be part of a hidden hierarchy.
  This prevents finding it in the DOM, and using it's form attribute
  to set the form enctype.

- There could be more than one form with multipart-enabling components
  which would require an enctype refresh on the client-side.

This commit modifies MultipartFormComponentListener to find all forms,
ensure they are visible in the hierarchy, then visiting all form
components to find multipart-enabling. A single statement is emitted
per form.

(cherry picked from commit 9bfb7794d18ff441590ff86ae0e0dc35d9f2048f)


> MultipartFormComponentListener breaks on hidden components
> ----------------------------------------------------------
>
>                 Key: WICKET-6921
>                 URL: https://issues.apache.org/jira/browse/WICKET-6921
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 9.5.0
>            Reporter: Mathieu Mitchell
>            Assignee: Martin Tzvetanov Grigorov
>            Priority: Minor
>         Attachments: WICKET-6914-demo.zip
>
>
> MultipartFormComponentListener does not seem to handle hidden components, or 
> components included in an hidden container.
> Currently, javascript errors in browser console appear when rendering any 
> component while forms are included inside unrelated hidden containers.
> This problem first appeared in Wicket 9.5.0.
> {{Uncaught TypeError: Cannot read properties of null (reading 'form')}}
> This appears to be caused because the component cannot be found in the DOM.
> {{Wicket.$('fileUpload9').form.enctype='application/x-www-form-urlencoded'}}} 
> This unhandled error stops further evaluation of javascript statements.
> This regression appears to be caused by the MultipartFormComponentListener 
> that was recently added while fixing WICKET-6914.
> Generally, form components and forms can be included in an hidden container 
> without problem.
> Furthermore, the MultipartFormComponentListener stops after handling the 
> first component of a multipart form. A single page could container multiple 
> forms and the other forms would not have the right encoding-type set.
> Attached is the democase for WICKET-6914, edited to demonstrate the problems 
> caused by the regression.
> I also added a test case and modified the code to satisfy the new 
> requirements.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to