Hi again,

jira issue added:
   https://issues.apache.org/jira/browse/WICKET-1826

I've attached a quickstart project which shows my problem, has detailed
explanation, and also proposes 2 solutions (you must uncomment some code to
see it working). Of course, the solutions work for my particular case, but
as you told me, it is not the way it is supposed to be.

Meanwhile (i guess it can take a while until someone looks into it), could
you at least tell me if there could be any side effect in overriding
isInputNullable for CheckBox, DropDownChoice, and so on? (TextField already
does it).

Thanks again,

German


2008/9/10 Matej Knopp <[EMAIL PROTECTED]>

> On Wed, Sep 10, 2008 at 10:49 PM, German Morales
> <[EMAIL PROTECTED]> wrote:
> > I don't see any div inside span in my stuff (we have suffered problems
> with
> > this long ago, and we are more careful lately).
> >
> > Besides that, is it ok that the ModalWindow creates its own div at body
> > level? Isn't that the reason of my problem?
> That is intentional. I don't think that should cause you the problems.
>
> -Matej
> >
> > German
> >
> > 2008/9/10 Matej Knopp <[EMAIL PROTECTED]>
> >
> >> Check if your DOM hierarchy is valid, e.g. if you don't have any <div>
> >> tag inside <span> tags.
> >>
> >> -Matej
> >>
> >> On Wed, Sep 10, 2008 at 10:08 PM, German Morales
> >> <[EMAIL PROTECTED]> wrote:
> >> > I think that we are closer to the problem now...
> >> >
> >> > In my case (going back to the original post), the form i'm submitting
> is
> >> > inside a ModalWindow.
> >> >
> >> > I'm using Firebug to see the generated DOM in runtime, and i find this
> >> > (extracted...) before calling the ModalWindow:
> >> >
> >> > <body>
> >> >   <div here is all my content, even the placeholder for the modal
> window>
> >> >      <form here is my root form>
> >> >   </div>
> >> >   <div added by wicket for the ajax debug window>
> >> > </body>
> >> >
> >> > after calling the modal window:
> >> >
> >> > <body>
> >> >   <div here is all my content, even the placeholder for the modal
> window>
> >> >      <form here is my root form>
> >> >   </div>
> >> >   <div added by wicket for the ajax debug window>
> >> >   <div added by modal window on the fly>
> >> >      <form a second form tag for the form in my modal window>
> >> >   </div>
> >> > </body>
> >> >
> >> > I think that it's ok that the second form is rendered as form, since
> it
> >> does
> >> > not have another form outside (to be rendered as div).
> >> > The problem is that ModalWindow inserted a div outside my root form.
> >> > Therefore Wicket.Form.serialize() must be serializing up to that
> second
> >> > form.
> >> >
> >> > I'm looking at the live Modal window example
> >> > http://www.wicket-library.com/wicket-examples/ajax/modal-window.1
> >> > and i see that this behavior of adding a separated div at body level
> is
> >> > "normal", not something strange in my structure.
> >> >
> >> > German
> >> >
> >> > 2008/9/10 Matej Knopp <[EMAIL PROTECTED]>
> >> >
> >> >> You are right. It calls Wicket.Form.serialize(form) with the nested
> >> >> form, but the serialize method should find parent with <form> tag
> name
> >> >> and serialize that.
> >> >>
> >> >> -Matej
> >> >>
> >> >>
> >> >> On Wed, Sep 10, 2008 at 9:04 PM, German Morales
> >> >> <[EMAIL PROTECTED]> wrote:
> >> >> > There are no nested form tags, as expected... let me give you more
> >> >> details
> >> >> > i'm discovering:
> >> >> >
> >> >> > The AjaxSubmitLink has something like this...
> >> >> >  function onclick(event) {
> >> >> >   var wcall = wicketSubmitFormById(" < id of my nested form > ");
> >> >> >   return false;
> >> >> >  }
> >> >> >
> >> >> > This calls wicketSubmitFormById, no surprises...
> >> >> >  function wicketSubmitFormById(formId, url, submitButton,
> >> successHandler,
> >> >> > failureHandler, precondition, channel) {
> >> >> >   var call = new Wicket.Ajax.Call(url, successHandler,
> failureHandler,
> >> >> > channel);
> >> >> >   ...
> >> >> >   return call.submitFormById(formId, submitButton);
> >> >> >  }
> >> >> >
> >> >> > which calls submitFormById...
> >> >> >  submitFormById: function(formId, submitButton) {
> >> >> >   var form = Wicket.$(formId);
> >> >> >   ...
> >> >> >   return this.submitForm(form, submitButton);
> >> >> >  }
> >> >> >
> >> >> > which calls submitForm passing my nested form (i'm debugging with
> >> >> Firebug)
> >> >> >  // Submits a form using ajax.
> >> >> >  // This method serializes a form and sends it as POST body.
> >> >> >  submitForm: function(form, submitButton) {
> >> >> >   var body = function() {
> >> >> >     var s = Wicket.Form.serialize(form);
> >> >> >     if (submitButton != null) {
> >> >> >       s += Wicket.Form.encode(submitButton) + "=1";
> >> >> >     }
> >> >> >     return s;
> >> >> >   }
> >> >> >   return this.request.post(body);
> >> >> >  }
> >> >> >
> >> >> > which ultimately calls Wicket.Form.serialize(form) with my nested
> >> form,
> >> >> not
> >> >> > with the root form.
> >> >> >
> >> >> > Am i right?
> >> >> >
> >> >> > German
> >> >> >
> >> >> > PS: meanwhile i'm trying to produce a quickstart... but i guess it
> >> will
> >> >> take
> >> >> > me some time.
> >> >> > 2008/9/10 Matej Knopp <[EMAIL PROTECTED]>
> >> >> >
> >> >> >> But that is exactly what should happen. Wicket javascript should
> find
> >> >> >> root form element and serialize that. Can you please check in your
> >> >> >> markup if there are any nested form tags? (shouldn't be).
> >> >> >>
> >> >> >> -Matej
> >> >> >>
> >> >> >> On Wed, Sep 10, 2008 at 8:11 PM, German Morales
> >> >> >> <[EMAIL PROTECTED]> wrote:
> >> >> >> > That would be somehow complicated to produce right now.
> >> >> >> >
> >> >> >> > To make my question different... why the javascript side sends
> only
> >> >> the
> >> >> >> > nested form info (wicketSubmitFormById()) and on wicket side the
> >> root
> >> >> >> form
> >> >> >> > is the one that gets called?
> >> >> >> >
> >> >> >> > I've already tried and it works ok if i make the nested form do
> the
> >> >> >> > processing instead of the root form.
> >> >> >> >    protected void onEvent(AjaxRequestTarget target) {
> >> >> >> >        getForm().onFormSubmitted();  // getRootForm() removed
> >> >> >> >
> >> >> >> > Another possibility would be that javascript side sends the
> values
> >> for
> >> >> >> the
> >> >> >> > root form, and then it would be ok that the root form does the
> >> >> >> processing.
> >> >> >> >
> >> >> >> > Thanks,
> >> >> >> >
> >> >> >> > German
> >> >> >> >
> >> >> >> >
> >> >> >> > 2008/9/10 Matej Knopp <[EMAIL PROTECTED]>
> >> >> >> >
> >> >> >> >> I would need a quick start to see where it is going wrong.
> >> >> >> >>
> >> >> >> >> -Matej
> >> >> >> >>
> >> >> >> >> On Wed, Sep 10, 2008 at 7:26 PM, German Morales
> >> >> >> >> <[EMAIL PROTECTED]> wrote:
> >> >> >> >> > Investigating a little more, my problem seems to be caused by
> >> >> >> >> > AjaxFormSubmitBehavior#onEvent
> >> >> >> >> >
> >> >> >> >> >    protected void onEvent(AjaxRequestTarget target) {
> >> >> >> >> >        getForm().getRootForm().onFormSubmitted();
> >> >> >> >> >
> >> >> >> >> > which calls onFormSubmitted on the RootForm, and not in the
> Form
> >> >> i've
> >> >> >> >> passed
> >> >> >> >> > to my AjaxSubmitLink.
> >> >> >> >> >
> >> >> >> >> > could someone explain me why it does that?
> >> >> >> >> >
> >> >> >> >> > In fact, overriding onEvent to call onFormSubmitted on
> getForm()
> >> >> and
> >> >> >> not
> >> >> >> >> in
> >> >> >> >> > the root form solves my problems... but am i breaking
> something
> >> >> else?
> >> >> >> >> >
> >> >> >> >> > Thanks,
> >> >> >> >> >
> >> >> >> >> > German
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> > 2008/9/9 German Morales <[EMAIL PROTECTED]>
> >> >> >> >> >
> >> >> >> >> >> Hi Matej,
> >> >> >> >> >>
> >> >> >> >> >> Thanks for the answer.
> >> >> >> >> >>
> >> >> >> >> >> I have an AjaxSubmitLink both for opening and closing the
> modal
> >> >> >> window.
> >> >> >> >> >> Should that make any trouble?
> >> >> >> >> >> In both cases i have data to persist, so it must be a
> >> .*Submit.*
> >> >> >> >> component.
> >> >> >> >> >>
> >> >> >> >> >> Also, my problem happens when closing the window, not when
> >> opening
> >> >> >> it.
> >> >> >> >> >> I summarize it again:
> >> >> >> >> >> -the browser sends an ajax call with the values in the modal
> >> >> window
> >> >> >> >> >> -but on wicket side the main form of the page is the one
> that
> >> >> takes
> >> >> >> >> charge
> >> >> >> >> >> -the components on the page then receive the new input, but
> >> >> there's
> >> >> >> >> >> actually nothing coming from the browser for them
> >> >> >> >> >> -some components (text components) handle it well, some not
> >> >> >> (checkbox,
> >> >> >> >> >> dropdownchoice).
> >> >> >> >> >> -the misbehaving component get a rawinput of null instead of
> >> >> >> >> NO_RAW_INPUT,
> >> >> >> >> >> which then produces the side effect that the component does
> not
> >> >> get
> >> >> >> the
> >> >> >> >> >> value from the model on rendering.
> >> >> >> >> >>
> >> >> >> >> >> Please see the doubts section at the end of the original
> >> e-mail.
> >> >> >> >> >>
> >> >> >> >> >> Thanks again,
> >> >> >> >> >>
> >> >> >> >> >> German
> >> >> >> >> >>
> >> >> >> >> >> 2008/9/9 Matej Knopp <[EMAIL PROTECTED]>
> >> >> >> >> >>
> >> >> >> >> >> The link that shows the modal window must be
> >> >> AjaxButton/SubmitLink.
> >> >> >> >> >>>
> >> >> >> >> >>> -Matej
> >> >> >> >> >>>
> >> >> >> >> >>> On Tue, Sep 9, 2008 at 11:20 PM, German Morales
> >> >> >> >> >>> <[EMAIL PROTECTED]> wrote:
> >> >> >> >> >>> > Hi all,
> >> >> >> >> >>> >
> >> >> >> >> >>> > I've a problem with Forms and ModalWindows.
> >> >> >> >> >>> >
> >> >> >> >> >>> > I have this stuff:
> >> >> >> >> >>> > -a page with a main Form (the only one that is rendered
> as
> >> an
> >> >> HTML
> >> >> >> >> form
> >> >> >> >> >>> tag)
> >> >> >> >> >>> > -this my only page, since all inside it is changed by
> >> replacing
> >> >> >> >> panels
> >> >> >> >> >>> using
> >> >> >> >> >>> > ajax.
> >> >> >> >> >>> > -inside some other levels of panels, i have a panel with
> my
> >> >> >> content
> >> >> >> >> (let
> >> >> >> >> >>> me
> >> >> >> >> >>> > call it myContentPanel), which has its own (sub) Form
> (which
> >> is
> >> >> >> >> rendered
> >> >> >> >> >>> as
> >> >> >> >> >>> > a div).
> >> >> >> >> >>> > -myContentPanel has some controls... TextFields,
> >> >> DropDownChoices,
> >> >> >> >> >>> > CheckBoxes.
> >> >> >> >> >>> > -myContentPanel has also a link that opens a ModalWindow.
> >> >> >> >> >>> > -the ModalWindow has its own Form with components, and an
> >> >> >> >> AjaxSubmitLink
> >> >> >> >> >>> to
> >> >> >> >> >>> > close it.
> >> >> >> >> >>> >
> >> >> >> >> >>> > Now the problem...
> >> >> >> >> >>> > 1- I enter to myContentPanel and enter some values in the
> >> >> >> components.
> >> >> >> >> >>> > 2- I press the link to open the ModalWindow.
> >> >> >> >> >>> > 3- I work with the ModalWindow, then press an
> AjaxSubmitLink
> >> to
> >> >> >> close
> >> >> >> >> >>> it.
> >> >> >> >> >>> > 4- When refreshing myContentPanel, the values in some
> >> controls
> >> >> is
> >> >> >> >> lost:
> >> >> >> >> >>> > CheckBoxes, DropDownChoices, but NOT in TextFields.
> >> >> >> >> >>> >
> >> >> >> >> >>> > After some investigation, this is what i've discovered:
> >> >> >> >> >>> > -on step 3 (accept and close the ModalWindow), the
> >> >> AjaxSubmitLink
> >> >> >> >> calls
> >> >> >> >> >>> > (javascript) wicketSubmitFormById passing the
> ModalWindow's
> >> >> form
> >> >> >> as
> >> >> >> >> >>> > parameter.
> >> >> >> >> >>> > -this processes the ModalWindow's form and prepares the
> >> values
> >> >> to
> >> >> >> be
> >> >> >> >> >>> sent to
> >> >> >> >> >>> > wicket side.
> >> >> >> >> >>> > -but when i see the url, it mentions that the form that
> will
> >> be
> >> >> >> used
> >> >> >> >> for
> >> >> >> >> >>> the
> >> >> >> >> >>> > HTTP request is the page's form (because it's the only
> real
> >> >> form,
> >> >> >> i
> >> >> >> >> >>> think
> >> >> >> >> >>> > this is normal).
> >> >> >> >> >>> > -on wicket side, the request processing calls
> >> >> >> Form#onFormSubmitted,
> >> >> >> >> >>> which
> >> >> >> >> >>> > calls #inputChanged, which calls a visitor visiting all
> >> >> >> components...
> >> >> >> >> in
> >> >> >> >> >>> the
> >> >> >> >> >>> > main form!
> >> >> >> >> >>> > -this ends up calling FormComponent#inputChanged on the
> >> >> >> CheckBoxes,
> >> >> >> >> >>> > DropDownChoices, TextFields that where in myContentPanel
> >> (also
> >> >> for
> >> >> >> >> the
> >> >> >> >> >>> > controls in the ModalWindow, but that's no surprise).
> >> >> >> >> >>> > -given that the javascript only prepared the data for the
> >> >> >> >> ModalWindow's
> >> >> >> >> >>> > form, the values for the components in myContentPanel is
> >> empty.
> >> >> >> >> >>> > -looking deeper in #inputChanged, getInputAsArray() gives
> >> null
> >> >> for
> >> >> >> >> the
> >> >> >> >> >>> > components in myContentPanel.
> >> >> >> >> >>> > -then, since CheckBox and DropDownChoice answer true to
> >> >> >> >> >>> isInputNullable()
> >> >> >> >> >>> > (default in FormComponent), the rawInput is set to null,
> >> even
> >> >> if i
> >> >> >> >> >>> didn't
> >> >> >> >> >>> > touch the CheckBoxes/DropDownChoices at all in this call
> >> (then
> >> >> >> losing
> >> >> >> >> >>> the
> >> >> >> >> >>> > previous value: NO_RAW_INPUT).
> >> >> >> >> >>> > -on step 4, when the CheckBox/DropDownChoice wants to get
> >> >> rendered
> >> >> >> >> >>> again,
> >> >> >> >> >>> > onComponentTag calls FormComponent#getValue, which if
> >> >> >> >> >>> > (NO_RAW_INPUT.equals(rawInput)) uses the Model to get the
> >> value
> >> >> >> (what
> >> >> >> >> i
> >> >> >> >> >>> > would expect), but in my case returns the rawInput
> (null...
> >> >> ouch).
> >> >> >> >> >>> >
> >> >> >> >> >>> > I have fixed it temporaly by overriding isInputNullable
> in
> >> my
> >> >> >> >> >>> > CheckBoxes/DropDownChoice, but i understand that this is
> not
> >> a
> >> >> >> very
> >> >> >> >> good
> >> >> >> >> >>> > solution.
> >> >> >> >> >>> >
> >> >> >> >> >>> > Some doubts that remain:
> >> >> >> >> >>> > -is there anything wrong with my structure of forms and
> >> panels,
> >> >> >> which
> >> >> >> >> is
> >> >> >> >> >>> > actually producing these side effects?
> >> >> >> >> >>> > -if only the values for ModalWindow form are sent to the
> >> >> server,
> >> >> >> why
> >> >> >> >> the
> >> >> >> >> >>> is
> >> >> >> >> >>> > onFormSubmitted called on the main page form?
> >> >> >> >> >>> > -the javadoc in isInputNullable is not very clear for
> me...
> >> do
> >> >> i
> >> >> >> >> break
> >> >> >> >> >>> > something else if i override isInputNullable answering
> >> false?
> >> >> >> >> >>> >
> >> >> >> >> >>> > Thanks in advance,
> >> >> >> >> >>> >
> >> >> >> >> >>> > German
> >> >> >> >> >>> >
> >> >> >> >> >>>
> >> >> >> >> >>>
> >> >> >>
> ---------------------------------------------------------------------
> >> >> >> >> >>> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> >> >> >> >> >>> For additional commands, e-mail:
> [EMAIL PROTECTED]
> >> >> >> >> >>>
> >> >> >> >> >>>
> >> >> >> >> >>
> >> >> >> >> >
> >> >> >> >>
> >> >> >> >>
> >> ---------------------------------------------------------------------
> >> >> >> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> >> >> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >> >> >> >>
> >> >> >> >>
> >> >> >> >
> >> >> >>
> >> >> >>
> ---------------------------------------------------------------------
> >> >> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> >> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >> >> >>
> >> >> >>
> >> >> >
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >> >>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to