| 1 | 0 | package jp.co.y_net.amm.page; |
| 2 | |
|
| 3 | |
import java.io.Serializable; |
| 4 | |
|
| 5 | |
import org.apache.commons.lang.StringUtils; |
| 6 | |
import org.apache.wicket.ajax.AjaxRequestTarget; |
| 7 | |
import org.apache.wicket.ajax.markup.html.form.AjaxButton; |
| 8 | |
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; |
| 9 | |
import org.apache.wicket.markup.html.WebPage; |
| 10 | |
import org.apache.wicket.markup.html.basic.Label; |
| 11 | |
import org.apache.wicket.markup.html.form.Form; |
| 12 | |
import org.apache.wicket.markup.html.panel.FeedbackPanel; |
| 13 | |
import org.apache.wicket.model.PropertyModel; |
| 14 | |
|
| 15 | |
public class CommonConfirmPage extends WebPage { |
| 16 | |
private static final long serialVersionUID = 1L; |
| 17 | |
|
| 18 | |
|
| 19 | 0 | public String confirmMessage = ""; |
| 20 | 0 | public String confirmMessageStrong = ""; |
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
public Callback callback; |
| 26 | 0 | public static abstract class Callback implements Serializable { |
| 27 | |
abstract void callback(AjaxRequestTarget target); |
| 28 | |
} |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
public Executable executable; |
| 34 | 0 | public static abstract class Executable { |
| 35 | |
abstract void execute(); |
| 36 | |
} |
| 37 | |
|
| 38 | 0 | public CommonConfirmPage() { |
| 39 | |
|
| 40 | |
|
| 41 | 0 | final FeedbackPanel fbPanel = new FeedbackPanel("feedback"); |
| 42 | 0 | fbPanel.setOutputMarkupId(true); |
| 43 | 0 | add(fbPanel); |
| 44 | |
|
| 45 | 0 | Form<Void> form = new Form<Void>("form"); |
| 46 | 0 | add(form); |
| 47 | |
|
| 48 | |
|
| 49 | 0 | form.add(new Label("confirmMessage", new PropertyModel<String>(this, "confirmMessage"))); |
| 50 | 0 | form.add(new Label("confirmMessageStrong", new PropertyModel<String>(this, "confirmMessageStrong")){ |
| 51 | |
@Override |
| 52 | |
public boolean isVisible() { |
| 53 | 0 | return StringUtils.isEmpty(confirmMessageStrong) == false; |
| 54 | |
} |
| 55 | |
|
| 56 | |
}); |
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | 0 | form.add(new AjaxButton("btnExecute"){ |
| 61 | |
@Override |
| 62 | |
protected void onSubmit(AjaxRequestTarget target, Form<?> form) { |
| 63 | 0 | executable.execute(); |
| 64 | 0 | callback.callback(target); |
| 65 | 0 | ModalWindow.closeCurrent(target); |
| 66 | 0 | } |
| 67 | |
|
| 68 | |
@Override |
| 69 | |
protected void onError(AjaxRequestTarget target, Form<?> form) { |
| 70 | |
|
| 71 | 0 | } |
| 72 | |
}); |
| 73 | |
|
| 74 | |
|
| 75 | 0 | form.add(new AjaxButton("btnBack") { |
| 76 | |
@Override |
| 77 | |
protected void onSubmit(AjaxRequestTarget target, Form<?> form) { |
| 78 | 0 | ModalWindow.closeCurrent(target); |
| 79 | 0 | } |
| 80 | |
|
| 81 | |
@Override |
| 82 | |
protected void onError(AjaxRequestTarget target, Form<?> form) { |
| 83 | |
|
| 84 | 0 | } |
| 85 | |
}); |
| 86 | 0 | } |
| 87 | |
|
| 88 | |
} |