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

Reply via email to