You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Vladimir Kovalyuk <ko...@gmail.com> on 2010/03/31 18:40:26 UTC

possible bug?

It seems the following trick does not work for nested forms:

    protected void onRender(final MarkupStream markupStream)
    {
        // clear multipart hint, it will be set if necessary by the visitor
        this.multiPart &= ~MULTIPART_HINT;

        // Force multi-part on if any child form component is multi-part
        visitFormComponents(new FormComponent.AbstractVisitor()
        {
            @Override
            public void onFormComponent(FormComponent<?> formComponent)
            {
                if (formComponent.isVisible() &&
formComponent.isMultiPart())
                {
                    multiPart |= MULTIPART_HINT;
                }
            }
        });

        super.onRender(markupStream);
    }

Since multiPart is serializable it will remember multipart hint for the next
render on nested form even when the component tree does not contain file
upload component anymore. As the result the form will be multipart encoded
(see onComponentTag) but then handled with stardard request handler because
the hint in nested form is cleared only on its own onRender invocation.

Does it sound like a bug? Should I proceed with creating a test for that?

Re: possible bug?

Posted by "vladimir.kovalyuk" <ko...@gmail.com>.
There is JIRA issue for the problem 
https://issues.apache.org/jira/browse/WICKET-2933
https://issues.apache.org/jira/browse/WICKET-2933 

Igor I believe what you wrote works fine for single form. But when the page
contains nested forms the outer form still finds component - inner form.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/possible-bug-tp1894220p2330830.html
Sent from the Wicket - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: possible bug?

Posted by Igor Vaynberg <ig...@gmail.com>.
the first thing it does is clear the multipart flag, it then tries to
find a multipart component which will set the flag to true again...so
if you remove the component that caused multipart to be true it would
reset before the render....

-igor

On Wed, Mar 31, 2010 at 9:40 AM, Vladimir Kovalyuk <ko...@gmail.com> wrote:
> It seems the following trick does not work for nested forms:
>
>    protected void onRender(final MarkupStream markupStream)
>    {
>        // clear multipart hint, it will be set if necessary by the visitor
>        this.multiPart &= ~MULTIPART_HINT;
>
>        // Force multi-part on if any child form component is multi-part
>        visitFormComponents(new FormComponent.AbstractVisitor()
>        {
>            @Override
>            public void onFormComponent(FormComponent<?> formComponent)
>            {
>                if (formComponent.isVisible() &&
> formComponent.isMultiPart())
>                {
>                    multiPart |= MULTIPART_HINT;
>                }
>            }
>        });
>
>        super.onRender(markupStream);
>    }
>
> Since multiPart is serializable it will remember multipart hint for the next
> render on nested form even when the component tree does not contain file
> upload component anymore. As the result the form will be multipart encoded
> (see onComponentTag) but then handled with stardard request handler because
> the hint in nested form is cleared only on its own onRender invocation.
>
> Does it sound like a bug? Should I proceed with creating a test for that?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org