add(new AjaxSubmitLink(id, form){ private static final long serialVersionUID = 1L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form){ String selectedValue = ((Thingy) form.getModelObject()).getFooProperty(); } });
@Override protected void populateItem(final ListItem<Type> listItem) { final Component element = createComponent(listItem.getModel()); listItem.add(element); final int index = listItem.getIndex(); listItem.add(new AjaxSubmitLink("remove") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { getList().remove(index); target.add(wrapper); } }.setDefaultFormProcessing(false));
From<RequestInfo> uploadFrm = new Form<RequestInfo>("uploadFrm", getModel()); AjaxSubmitLink ajaxSubmitLink = new AjaxSubmitLink("ajaxSubmitLink", uploadFrm) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { target.appendJavaScript("you javascript"); } }; uploadFrm.add(ajaxSubmitLink);
protected void populateItem(final ListItem<Data> item) { final Data data = item.getModelObject(); AjaxSubmitLink delete = new AjaxSubmitLink("delete") { protected void onSubmit(AjaxRequestTarget target, Form<?> form) { DB.delete(data.getId()); target.add(form); } } }
protected void populateItem(ListItem<Data> item) { Data data = item.getModelObject(); final Serializable id = data.getId(); // the primary key AjaxSubmitLink delete = new AjaxSubmitLink("delete") { protected void onSubmit(AjaxRequestTarget target, Form<?> form) { DB.delete(id); target.add(form); } } }
add(textField); AjaxSubmitLink removeButton = new AjaxSubmitLink("removeButton", multiTextForm) { add(listView); AjaxSubmitLink addButton = new AjaxSubmitLink("addButton", multiTextForm) {
import java.io.File import org.apache.wicket.markup.html.form.upload.FileUploadField import org.apache.wicket.markup.html.form.Form import org.apache.wicket.markup.html.WebPage import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink import org.apache.wicket.ajax.AjaxRequestTarget class TestPage extends WebPage { val uploadForm = new Form("form") val fileField = new FileUploadField("file") uploadForm.add(fileField) add(form) add(new AjaxSubmitLink("submit", uploadForm) { def onSubmit(target: AjaxRequestTarget, form: Form[_]) { val upload = fileField.getFileUpload if (upload != null) { val file: File = upload.writeToTempFile } } }) }
public class HomePage extends WebPage { private String inputValue; public HomePage(final PageParameters parameters) { super(parameters); final Label output = new Label("output", new PropertyModel<String>( this, "inputValue")); output.setOutputMarkupId(true); add(output); Form form = new Form("form"); form.add(new AjaxSubmitLink("submit") { @Override protected void onAfterSubmit(AjaxRequestTarget target, Form<?> form) { super.onAfterSubmit(target, form); target.add(output); } }); add(form); form.add(new TextField<String>("input", new PropertyModel<String>(this, "inputValue"))); } }
ArrayList rows = new ArrayList(2); rows.add(new String()); rows.add(new String()); final ListView lv = new ListView("rows", rows) { @Override protected void populateItem(ListItem item) { int index = item.getIndex() + 1; item.add(new Label("index", index + ".")); TextField text = new TextField("text", item.getModel())); item.add(text); } }; rowPanel.add(lv); AjaxSubmitLink addLink = new AjaxSubmitLink("addRow", form) { @Override public void onSubmit(AjaxRequestTarget target, Form form) { lv.getModelObject().add(new String()); if (target != null) target.addComponent(rowPanel); } }; addLink.setDefaultFormProcessing(false); rowPanel.add(addLink);
AjaxSubmitLink aj = new AjaxSubmitLink("submit"){
AjaxSubmitLink addBtn = new AjaxSubmitLink("addBtn") {
protected void populateItem(final ListItem<Type> listItem) { WebMarkupContainer cont = new WebMarkupContainer("cont"); cont.setOutputMarkupId(true); cont.setOutputMarkupPlaceholderTag(true); final Component element = createComponent(listItem.getModel()); cont.add(element); cont.add(new AjaxSubmitLink("remove") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { getList().remove(listItem.getIndex()); target.add(cont); } }.setDefaultFormProcessing(false)); listItem.add(cont); }
form.add(feedbackPanel); AjaxSubmitLink submit = new AjaxSubmitLink("submit", form) {