You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Zoltán Nagy (JIRA)" <ji...@apache.org> on 2009/07/03 13:27:47 UTC

[jira] Commented: (WICKET-2214) Form tag in ModalWindow html code causes nested html forms when ModalWindow is used with panel that contain forms

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

Zoltán Nagy commented on WICKET-2214:
-------------------------------------

I have the same problem. I have a ModalWindow and a Wizard with AjaxButtons.
Whern I show the ModalWindow it sends back the content with correct form tag. The Firefox (Iceweasel 2.0.0.17) insert this with the client side generated ModalWindow markup.
When I click an AjaxButton ("Next >" for example) my AjaxWizard component sends back the full ModalWindow in the ajax response. It contains the correct form tag of the Wizard. But this form tag (and only the form tag) disappears while client side js inserts it to the document dom structure. So the outer extra form tag take over the wizard's form role. From this point the ajax callback codes references to an unexist form id...

As a workaround I have done the following: on startup I load the modal.js resource, modify it and register as a shared resource:


// import org.apache.commons.lang.StringUtils;

    private void fixModalWindowFormError() {
        final String scopeName = "org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow";
        final String name = "res/modal.js";

        InputStream inputStream = null;
        try {
            // get Content
            String content = null;
            IResourceStream resourceStream;
            StringBuilder sb = new StringBuilder();
            char[] buffer = new char[16834];
            PackageResource sourceRsc = PackageResource.get(Classes.resolveClass(scopeName), name);
            resourceStream = sourceRsc.getResourceStream();
            inputStream = resourceStream.getInputStream();
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream, Charset.forName("ascii"));
            while (true) {
                int read = inputStreamReader.read(buffer);
                if (read == -1) {
                    break;
                }
                sb.append(buffer, 0, read);
            }

            // filter out <form> tag
            content = sb.toString();
            content = StringUtils.replaceEach(content, new String[]{"<form", "</form"}, new String[]{"<div", "</div"});

            // store sharedResource
            ByteArrayResource targetRsc = new ByteArrayResource(resourceStream.getContentType(), content.getBytes(Charset.forName("ascii")));
            getSharedResources().add(Classes.resolveClass(scopeName), name, null, null, targetRsc);
        } catch (IOException ex) {
            log.error("", ex);
        } catch (ResourceStreamNotFoundException ex) {
            log.error("", ex);
        } finally {
            try {
                inputStream.close();
            } catch (IOException ex) {
                log.error("", ex);
            }
        }
    }


> Form tag in ModalWindow html code causes nested html forms when ModalWindow is used with panel that contain forms
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-2214
>                 URL: https://issues.apache.org/jira/browse/WICKET-2214
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-extensions
>    Affects Versions: 1.3.5, 1.3.6, 1.4-RC2
>            Reporter: Jor
>            Assignee: Matej Knopp
>         Attachments: modal.js.patch
>
>
> There is an extra form tag in modal window html code (modal.js -> Wicket.Window.getMarkup function), it causes problems when ModalWindow is used with panel that contain forms. 
> I haven't found any use for that form tag as it cannot be referenced from java code (it has no wicket id) and it only causes problems by creating nested form tags (outter form from modal html with no wicket id and inner form from panel with wicket id) that some browsers cant handle and its againts W3C html specification.
> I had to replace it with div tag to get my panel working.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.