Discussion:
Ajax add listview item into form issue
ShengChe Hsiao
2018-11-27 08:29:15 UTC
Permalink
Dears

I have a form with listview which dynamically add TextField in it, but when
i enter some text in other fields and click add button to add TextField in
listview, the form cleared and I don't want this, do you have any
suggestions?


redirecturis = new ListView<String>("rows",
serviceProviderModel.getRedirecturi()) {
@Override
protected void populateItem(ListItem<String> listItem) {
listItem.add(new RequiredTextField("redirecturi", listItem.getModel()));
}
};



AjaxSubmitLinkBlockUI btnAdd = new AjaxSubmitLinkBlockUI("btnAdd", spregform) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
super.onSubmit(target, form);
logger.info("Form Data Add uri : {}", serviceProviderModel.toString());
//serviceProviderModel.setRedirecturi(serviceProviderModel.getRedirecturi());
serviceProviderModel.getRedirecturi().add("");
//spregform.setDefaultModelObject(serviceProviderModel);
spregform.modelChanged();
target.add(spregform);
target.add(container);
//target.add(formUpdateIcon);

//target.add(container);
}
};


--------------------------------------------------------------------
----------------------------------->
To boldly go where no man has gone before.
--------------------------------------------------------------------
----------------------------------->
We do this not because it is easy. We do this because it is hard.
-----------------------------------------------------------------
-------------------------------------->
If I have seen further it is by standing on the shoulders of giants.
----------------------------------------------------------
--------------------------------------------->
***@gmail.com
--------------------------------------------------------------------------------------------->
Martin Grigorov
2018-11-27 08:35:59 UTC
Permalink
Hi,

Please read
http://wicketinaction.com/2008/10/repainting-only-newly-created-repeater-items-via-ajax/
Post by ShengChe Hsiao
Dears
I have a form with listview which dynamically add TextField in it, but when
i enter some text in other fields and click add button to add TextField in
listview, the form cleared and I don't want this, do you have any
suggestions?
redirecturis = new ListView<String>("rows",
serviceProviderModel.getRedirecturi()) {
@Override
protected void populateItem(ListItem<String> listItem) {
listItem.add(new RequiredTextField("redirecturi",
listItem.getModel()));
}
};
AjaxSubmitLinkBlockUI btnAdd = new AjaxSubmitLinkBlockUI("btnAdd", spregform) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
super.onSubmit(target, form);
logger.info("Form Data Add uri : {}",
serviceProviderModel.toString());
//serviceProviderModel.setRedirecturi(serviceProviderModel.getRedirecturi());
serviceProviderModel.getRedirecturi().add("");
//spregform.setDefaultModelObject(serviceProviderModel);
spregform.modelChanged();
target.add(spregform);
target.add(container);
//target.add(formUpdateIcon);
//target.add(container);
}
};
--------------------------------------------------------------------
----------------------------------->
To boldly go where no man has gone before.
--------------------------------------------------------------------
----------------------------------->
We do this not because it is easy. We do this because it is hard.
-----------------------------------------------------------------
-------------------------------------->
If I have seen further it is by standing on the shoulders of giants.
----------------------------------------------------------
--------------------------------------------->
--------------------------------------------------------------------------------------------->
Shengche Hsiao
2018-11-27 08:47:24 UTC
Permalink
Thanks, Martin.
Post by Martin Grigorov
Hi,
Please read
http://wicketinaction.com/2008/10/repainting-only-newly-created-repeater-items-via-ajax/
Post by ShengChe Hsiao
Dears
I have a form with listview which dynamically add TextField in it, but
when
Post by ShengChe Hsiao
i enter some text in other fields and click add button to add TextField
in
Post by ShengChe Hsiao
listview, the form cleared and I don't want this, do you have any
suggestions?
redirecturis = new ListView<String>("rows",
serviceProviderModel.getRedirecturi()) {
@Override
protected void populateItem(ListItem<String> listItem) {
listItem.add(new RequiredTextField("redirecturi",
listItem.getModel()));
}
};
AjaxSubmitLinkBlockUI btnAdd = new AjaxSubmitLinkBlockUI("btnAdd", spregform) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
super.onSubmit(target, form);
logger.info("Form Data Add uri : {}",
serviceProviderModel.toString());
//serviceProviderModel.setRedirecturi(serviceProviderModel.getRedirecturi());
Post by ShengChe Hsiao
serviceProviderModel.getRedirecturi().add("");
//spregform.setDefaultModelObject(serviceProviderModel);
spregform.modelChanged();
target.add(spregform);
target.add(container);
//target.add(formUpdateIcon);
//target.add(container);
}
};
--------------------------------------------------------------------
----------------------------------->
To boldly go where no man has gone before.
--------------------------------------------------------------------
----------------------------------->
We do this not because it is easy. We do this because it is hard.
-----------------------------------------------------------------
-------------------------------------->
If I have seen further it is by standing on the shoulders of giants.
----------------------------------------------------------
--------------------------------------------->
--------------------------------------------------------------------------------------------->
--
----------------------------------------------------------------------->
We do this not because it is easy. We do this because it is hard.
----------------------------------------------------------------------->
ShengChe Hsiao
----------------------------------------------------------------------->
***@gmail.com
***@tc.edu.tw
----------------------------------------------------------------------->
VoIP : 070-910-2450
----------------------------------------------------------------------->
Loading...