You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by German Morales <ge...@gmail.com> on 2008/09/01 22:11:22 UTC
Problem rendering not visible Form with OutputMarkupPlaceholderTag
Hi all,
We had suffered an strange behavior, which i would like to share for
comments.
We have a Panel (loaded with ajax) with many Forms inside (because each
needs different models).
Some of these Forms are only visible under certain conditions, so we
overwrote isVisible with the condition.
Also, the Panel can be updated, so the Forms have
setOutputMarkupPlaceholderTag(true) to make them visible later.
That triggered a problem in the rendering of the ajax response.
After some investigation, the problem seems to be:
-When a Form is visible, Form#onComponentTag replaces the tag "form" by
"div" (because it's nor the Root form of the page), this works ok.
-When a Form is invisible, Form#onComponentTag is never called. Instead,
Component#render builds the response by itself, using
markupStream.getTag().getName(), which answers the tag "form".
-Then, the ajax response has a mix of "div" and "form". Apparently, all goes
ok until the first "form" is found, then the parsing goes somehow crazy and
this first "form" gets lost from the DOM, and the next forms and divs get
inserted outside (one level in DOM) the main component being replaced by the
ajax call.
We have found no way to fix it in the Form class itself. Component uses
markupStream.getTag() (which answers "form"). That is, it does not ask the
component for the tag to answer, but instead trusts in the HTML side. And we
can't change our html to say "div", because Form also checks (when visible)
that the tag says "form" (checkComponentTag(tag, "form")).
The solution was to put the missbehaving forms inside Panels, which do not
suffer this problem, and then make the panels visible/invisible (also with
OutputMarkupPlaceholderTag).
We have it running now, but we wanted to know if there was some better
solution, or perpahs something should be fixed to prevent future problems,
for example:
-inform somehow if a form is being set as invisible with
setOutputMarkupPlaceholderTag(true)?
-let Component ask itself for the tag to output in case of invisible +
setOutputMarkupPlaceholderTag(true), instead of just putting what the markup
says... then Form could say "no, i want a div here".
-other?
Thanks in advance,
German
Re: Problem rendering not visible Form with OutputMarkupPlaceholderTag
Posted by German Morales <ge...@gmail.com>.
Hi again,
Thanks for the answer.
https://issues.apache.org/jira/browse/WICKET-1815
I just copied the e-mail in a jira issue, is this enough?
Bye,
German
2008/9/1 Matej Knopp <ma...@gmail.com>
> This looks like a bug/design flaw. Can you please open a jira issue?
> This could be solved by having (yet another) method in component that
> would allow to postprocess the placeholder tag.
> The implementation would be fairly simple. Or maybe we could call
> onComponentTag and then strip all the attributes. This might be better
> idea as it would be consistent with the behavior when component is
> actually rendered.
>
> -Matej
>
> On Mon, Sep 1, 2008 at 10:11 PM, German Morales
> <ge...@gmail.com> wrote:
> > Hi all,
> >
> > We had suffered an strange behavior, which i would like to share for
> > comments.
> > We have a Panel (loaded with ajax) with many Forms inside (because each
> > needs different models).
> > Some of these Forms are only visible under certain conditions, so we
> > overwrote isVisible with the condition.
> > Also, the Panel can be updated, so the Forms have
> > setOutputMarkupPlaceholderTag(true) to make them visible later.
> > That triggered a problem in the rendering of the ajax response.
> >
> > After some investigation, the problem seems to be:
> > -When a Form is visible, Form#onComponentTag replaces the tag "form" by
> > "div" (because it's nor the Root form of the page), this works ok.
> > -When a Form is invisible, Form#onComponentTag is never called. Instead,
> > Component#render builds the response by itself, using
> > markupStream.getTag().getName(), which answers the tag "form".
> > -Then, the ajax response has a mix of "div" and "form". Apparently, all
> goes
> > ok until the first "form" is found, then the parsing goes somehow crazy
> and
> > this first "form" gets lost from the DOM, and the next forms and divs get
> > inserted outside (one level in DOM) the main component being replaced by
> the
> > ajax call.
> >
> > We have found no way to fix it in the Form class itself. Component uses
> > markupStream.getTag() (which answers "form"). That is, it does not ask
> the
> > component for the tag to answer, but instead trusts in the HTML side. And
> we
> > can't change our html to say "div", because Form also checks (when
> visible)
> > that the tag says "form" (checkComponentTag(tag, "form")).
> >
> > The solution was to put the missbehaving forms inside Panels, which do
> not
> > suffer this problem, and then make the panels visible/invisible (also
> with
> > OutputMarkupPlaceholderTag).
> >
> > We have it running now, but we wanted to know if there was some better
> > solution, or perpahs something should be fixed to prevent future
> problems,
> > for example:
> > -inform somehow if a form is being set as invisible with
> > setOutputMarkupPlaceholderTag(true)?
> > -let Component ask itself for the tag to output in case of invisible +
> > setOutputMarkupPlaceholderTag(true), instead of just putting what the
> markup
> > says... then Form could say "no, i want a div here".
> > -other?
> >
> > Thanks in advance,
> >
> > German
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Problem rendering not visible Form with OutputMarkupPlaceholderTag
Posted by Matej Knopp <ma...@gmail.com>.
This looks like a bug/design flaw. Can you please open a jira issue?
This could be solved by having (yet another) method in component that
would allow to postprocess the placeholder tag.
The implementation would be fairly simple. Or maybe we could call
onComponentTag and then strip all the attributes. This might be better
idea as it would be consistent with the behavior when component is
actually rendered.
-Matej
On Mon, Sep 1, 2008 at 10:11 PM, German Morales
<ge...@gmail.com> wrote:
> Hi all,
>
> We had suffered an strange behavior, which i would like to share for
> comments.
> We have a Panel (loaded with ajax) with many Forms inside (because each
> needs different models).
> Some of these Forms are only visible under certain conditions, so we
> overwrote isVisible with the condition.
> Also, the Panel can be updated, so the Forms have
> setOutputMarkupPlaceholderTag(true) to make them visible later.
> That triggered a problem in the rendering of the ajax response.
>
> After some investigation, the problem seems to be:
> -When a Form is visible, Form#onComponentTag replaces the tag "form" by
> "div" (because it's nor the Root form of the page), this works ok.
> -When a Form is invisible, Form#onComponentTag is never called. Instead,
> Component#render builds the response by itself, using
> markupStream.getTag().getName(), which answers the tag "form".
> -Then, the ajax response has a mix of "div" and "form". Apparently, all goes
> ok until the first "form" is found, then the parsing goes somehow crazy and
> this first "form" gets lost from the DOM, and the next forms and divs get
> inserted outside (one level in DOM) the main component being replaced by the
> ajax call.
>
> We have found no way to fix it in the Form class itself. Component uses
> markupStream.getTag() (which answers "form"). That is, it does not ask the
> component for the tag to answer, but instead trusts in the HTML side. And we
> can't change our html to say "div", because Form also checks (when visible)
> that the tag says "form" (checkComponentTag(tag, "form")).
>
> The solution was to put the missbehaving forms inside Panels, which do not
> suffer this problem, and then make the panels visible/invisible (also with
> OutputMarkupPlaceholderTag).
>
> We have it running now, but we wanted to know if there was some better
> solution, or perpahs something should be fixed to prevent future problems,
> for example:
> -inform somehow if a form is being set as invisible with
> setOutputMarkupPlaceholderTag(true)?
> -let Component ask itself for the tag to output in case of invisible +
> setOutputMarkupPlaceholderTag(true), instead of just putting what the markup
> says... then Form could say "no, i want a div here".
> -other?
>
> Thanks in advance,
>
> German
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org