be.personify.iam.frontend.wicket.panel.common.SearchPanel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of personify-frontend Show documentation
Show all versions of personify-frontend Show documentation
frontend library for different usages
package be.personify.iam.frontend.wicket.panel.common;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import be.personify.iam.api.util.SearchCriteria;
public abstract class SearchPanel extends FormPanel {
private static final long serialVersionUID = -1264501761977207670L;
private static final Logger logger = LogManager.getLogger(SearchPanel.class);
private SearchCriteria searchCriteria = new SearchCriteria();
private Form form;
public SearchPanel(String id) {
super(id);
}
@Override
protected void onInitialize() {
super.onInitialize();
form = initForm();
add(form);
}
public SearchCriteria getSearchCriteria() {
return searchCriteria;
}
public abstract Form initForm();
public abstract void search(AjaxRequestTarget target);
public abstract void composeSearchCriteria();
/**
* Adds a add button to the form
* @param form the form
* @param clazz the class
* @return the button to be returned
*/
public Button getAddButton(Form> form, Class clazz) {
return new Button(PanelConstants.BUTTON_ADD) {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit() {
setResponsePage(clazz, null);
super.onSubmit();
}
};
}
/**
* Adds a submit button to the form
* @param form the form
* @return the ajaxbutton to be returned
*/
public AjaxButton getSubmitButton(Form> form) {
return new AjaxButton(PanelConstants.BUTTON_SUBMIT) {
private static final long serialVersionUID = 8752744060226069594L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form> form) {
composeSearchCriteria();
search(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form> form) {
logger.error("error occurred : " + target);
logger.error("error occurred : " + form);
}
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy