I have a panel containing two other panels.  One panel contains a dropdown,
which I'll call "Main Dropdown", and the other contains a list of "Secondary
Inputs" which are essentially either text fields or dropdowns, but could be
anything used to capture data.  The user can add or remove "Secondary
Inputs" so they are stored within a RefreshingView, which is itself
contained within a form.  
Now, depending on what is selected from the "Main Dropdown", I may need to
remove certain "Secondary Inputs" but I want to keep all the other
"Secondary Inputs" unchanged, which includes keeping their values the same. 
However, when the selection of the "Main Dropdown" changes and I perform my
updates (using an AjaxFormComponentUpdatingBehavior), the final one of the
"Secondary Inputs" is often reset, meaning if it is a text field it is
blanked out and if it is a dropdown, it resets to the first choice in the
list.  Now, I have come up with a solution to this issue, but I'm not sure
it's the best.  Here is my solutions:

In each "Secondary Input", add a form around the input component (ie text
field, dropdown, or whatever) and then whenever the input component is
changed, use ajax to refresh the form as follows:
        inputGuy.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                        target.addComponent(formAroundInputGuy);
                }
        });
The concerns I have with this solution are:  a) This needs to be added to
every "Secondary Input", including "Secondary Inputs" I may add in the
future after I have forgotten this is even an issue.  Adding an additional
layer around each of the "Secondary Inputs" to handle this form could
potentially mitgate this concern.  b) I'm not sure how this may affect
performance.

As a note, I also tried the following but it did NOT work for me:
In the code where I am responding to changes in the "Main Dropdown", I tried
to explicitly submit the form containing the list of "Secondary Inputs" as
follows: 
        mainDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") {
                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                        target.appendJavascript("$('#formId').submit();");
                        //OTHER CODE FOR UPDATING THE SECONDARY INPUTS BASED ON 
THE CHANGE IN
MAIN DROPDOWN
                }
        });

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Data-in-Input-Fields-Resetting-Clearing-on-Update-tp4129359p4129359.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to