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]
