List of usage examples for org.apache.wicket.validation.validator DateValidator maximum
public static DateValidator maximum(Date maximum, String format)
From source file:au.org.theark.core.web.component.customfield.dataentry.CustomDataEditorDataView.java
License:Open Source License
@Override protected void populateItem(Item<T> item) { ICustomFieldData aCustomData = item.getModelObject(); CustomField cf = aCustomData.getCustomFieldDisplay().getCustomField(); CustomFieldDisplay cfd = aCustomData.getCustomFieldDisplay(); // Determine label of component, also used for error messages String labelModel = new String(); if (cf.getFieldLabel() != null) { labelModel = cf.getFieldLabel(); } else {/*from w w w . j ava2s .co m*/ // Defaults to name if no fieldLabel labelModel = cf.getName(); } Label fieldLabelLbl = new Label("fieldLabel", labelModel); Panel dataValueEntryPanel; String fieldTypeName = cf.getFieldType().getName(); String encodedValues = cf.getEncodedValues(); Boolean requiredField = aCustomData.getCustomFieldDisplay().getRequired(); if (fieldTypeName.equals(au.org.theark.core.web.component.customfield.Constants.DATE_FIELD_TYPE_NAME)) { if (cf.getDefaultValue() != null && item.getModelObject().getDateDataValue() == null) { try { item.getModelObject().setDateDataValue( new SimpleDateFormat(Constants.DD_MM_YYYY).parse(cf.getDefaultValue())); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } DateDataEntryPanel dateDataEntryPanel = new DateDataEntryPanel("dataValueEntryPanel", new PropertyModel<Date>(item.getModel(), "dateDataValue"), new Model<String>(labelModel)); dateDataEntryPanel.setErrorDataValueModel(new PropertyModel<String>(item.getModel(), "errorDataValue")); dateDataEntryPanel.setUnitsLabelModel( new PropertyModel<String>(item.getModel(), "customFieldDisplay.customField.unitType.name")); if (cf.getMinValue() != null && !cf.getMinValue().isEmpty()) { IConverter<Date> dateConverter = dateDataEntryPanel.getDateConverter(); try { Date minDate = (Date) dateConverter.convertToObject(cf.getMinValue(), getLocale()); dateDataEntryPanel.addValidator(DateValidator.minimum(minDate, Constants.DD_MM_YYYY)); } catch (ConversionException ce) { // This should not occur because it means the data is corrupted on the backend database getLog().error("Unexpected error: customfield.minValue is not in the DD/MM/YYYY date format"); this.error( "An unexpected error occurred loading the field validators from database. Please contact your System Administrator."); getParentContainer().setEnabled(false); } } if (cf.getMaxValue() != null && !cf.getMaxValue().isEmpty()) { IConverter<Date> dateConverter = dateDataEntryPanel.getDateConverter(); try { Date maxDate = (Date) dateConverter.convertToObject(cf.getMaxValue(), getLocale()); dateDataEntryPanel.addValidator(DateValidator.maximum(maxDate, Constants.DD_MM_YYYY)); } catch (ConversionException ce) { // This should not occur because it means the data is corrupted on the backend database getLog().error("Unexpected error: customfield.maxValue is not in the DD/MM/YYYY date format"); this.error( "An unexpected error occurred loading the field validators from database. Please contact your System Administrator."); getParentContainer().setEnabled(false); } } if (requiredField != null && requiredField == true) { dateDataEntryPanel.setRequired(true); } dataValueEntryPanel = dateDataEntryPanel; } else {//ie if its not a date... if (encodedValues != null && !encodedValues.isEmpty()) { // The presence of encodedValues means it should be a DropDownChoice List<String> encodeKeyValueList = Arrays.asList(encodedValues.split(";")); ArrayList<EncodedValueVO> choiceList = new ArrayList<EncodedValueVO>(); for (String keyValue : encodeKeyValueList) { // Only split for the first instance of the '=' (allows the '=' character in the actual value) String[] keyValueArray = keyValue.split("=", 2); EncodedValueVO encodedValueVo = new EncodedValueVO(); encodedValueVo.setKey(keyValueArray[0]); encodedValueVo.setValue(keyValueArray[1]); choiceList.add(encodedValueVo); } ChoiceRenderer<EncodedValueVO> choiceRenderer = new ChoiceRenderer<EncodedValueVO>("value", "key"); if (cfd.getAllowMultiselect()) { CheckGroupDataEntryPanel cgdePanel = new CheckGroupDataEntryPanel("dataValueEntryPanel", new PropertyModel<String>(item.getModel(), "textDataValue"), new Model<String>(labelModel), choiceList, choiceRenderer); cgdePanel.setErrorDataValueModel(new PropertyModel<String>(item.getModel(), "errorDataValue")); cgdePanel.setUnitsLabelModel(new PropertyModel<String>(item.getModel(), "customFieldDisplay.customField.unitType.name")); if (cf.getMissingValue() != null && !cf.getMissingValue().isEmpty()) { cgdePanel.setMissingValue(cf.getMissingValue()); } if (requiredField != null && requiredField == true) { cgdePanel.setRequired(true); } dataValueEntryPanel = cgdePanel; } else { if (cf.getDefaultValue() != null && item.getModelObject().getTextDataValue() == null) { item.getModelObject().setTextDataValue(cf.getDefaultValue()); } DropDownChoiceDataEntryPanel ddcPanel = new DropDownChoiceDataEntryPanel("dataValueEntryPanel", new PropertyModel<String>(item.getModel(), "textDataValue"), new Model<String>(labelModel), choiceList, choiceRenderer); ddcPanel.setErrorDataValueModel(new PropertyModel<String>(item.getModel(), "errorDataValue")); ddcPanel.setUnitsLabelModel(new PropertyModel<String>(item.getModel(), "customFieldDisplay.customField.unitType.name")); if (cf.getMissingValue() != null && !cf.getMissingValue().isEmpty()) { ddcPanel.setMissingValue(cf.getMissingValue()); } if (requiredField != null && requiredField == true) { ddcPanel.setRequired(true); } dataValueEntryPanel = ddcPanel; } } else { if (fieldTypeName .equals(au.org.theark.core.web.component.customfield.Constants.CHARACTER_FIELD_TYPE_NAME)) { // Text data if (cf.getDefaultValue() != null && item.getModelObject().getTextDataValue() == null) { item.getModelObject().setTextDataValue(cf.getDefaultValue()); } TextDataEntryPanel textDataEntryPanel = new TextDataEntryPanel("dataValueEntryPanel", new PropertyModel<String>(item.getModel(), "textDataValue"), new Model<String>(labelModel)); textDataEntryPanel .setErrorDataValueModel(new PropertyModel<String>(item.getModel(), "errorDataValue")); textDataEntryPanel.setUnitsLabelModel(new PropertyModel<String>(item.getModel(), "customFieldDisplay.customField.unitType.name")); textDataEntryPanel.setTextFieldSize(60); if (requiredField != null && requiredField == true) { textDataEntryPanel.setRequired(true); } dataValueEntryPanel = textDataEntryPanel; } else if (fieldTypeName .equals(au.org.theark.core.web.component.customfield.Constants.NUMBER_FIELD_TYPE_NAME)) { // Number data if (cf.getDefaultValue() != null && item.getModelObject().getNumberDataValue() == null) { item.getModelObject().setNumberDataValue(Double.parseDouble(cf.getDefaultValue())); ; } NumberDataEntryPanel numberDataEntryPanel = new NumberDataEntryPanel("dataValueEntryPanel", new PropertyModel<Double>(item.getModel(), "numberDataValue"), new Model<String>(labelModel)); numberDataEntryPanel .setErrorDataValueModel(new PropertyModel<String>(item.getModel(), "errorDataValue")); numberDataEntryPanel.setUnitsLabelModel(new PropertyModel<String>(item.getModel(), "customFieldDisplay.customField.unitType.name")); if (cf.getMinValue() != null && !cf.getMinValue().isEmpty()) { IConverter<Double> doubleConverter = numberDataEntryPanel.getNumberConverter(); try { Double minNumber = (Double) doubleConverter.convertToObject(cf.getMinValue(), getLocale()); numberDataEntryPanel.addValidator(new MinimumValidator<Double>(minNumber)); } catch (ConversionException ce) { // This should not occur because it means the data is corrupted on the backend database getLog().error( "Unexpected error: customfield.maxValue is not in a valid number format"); this.error( "An unexpected error occurred loading the field validators from database. Please contact your System Administrator."); getParentContainer().setEnabled(false); } } if (cf.getMaxValue() != null && !cf.getMaxValue().isEmpty()) { IConverter<Double> doubleConverter = numberDataEntryPanel.getNumberConverter(); try { Double maxNumber = (Double) doubleConverter.convertToObject(cf.getMaxValue(), getLocale()); numberDataEntryPanel.addValidator(new MaximumValidator<Double>(maxNumber)); } catch (ConversionException ce) { // This should not occur because it means the data is corrupted on the backend database getLog().error( "Unexpected error: customfield.maxValue is not in a valid number format"); this.error( "An unexpected error occurred loading the field validators from database. Please contact your System Administrator."); getParentContainer().setEnabled(false); } } if (requiredField != null && requiredField == true) { numberDataEntryPanel.setRequired(true); } dataValueEntryPanel = numberDataEntryPanel; } else { // TODO: Unknown type should display an UnsupportedValueEntryPanel dataValueEntryPanel = new EmptyPanel("dataValueEntryPanel"); } } } item.add(fieldLabelLbl); item.add(dataValueEntryPanel); }
From source file:au.org.theark.phenotypic.web.component.phenodataentry.PhenoDataSetDataEditorDataView.java
License:Open Source License
@Override protected void populateItem(Item<T> item) { IPhenoDataSetFieldData aCustomData = item.getModelObject(); PhenoDataSetField pf = aCustomData.getPhenoDataSetFieldDisplay().getPhenoDataSetField(); PhenoDataSetFieldDisplay pfd = aCustomData.getPhenoDataSetFieldDisplay(); // Determine label of component, also used for error messages String labelModel = new String(); if (pf.getFieldLabel() != null) { labelModel = pf.getFieldLabel(); } else {//w w w.jav a2 s . co m // Defaults to name if no fieldLabel labelModel = pf.getName(); } Label fieldLabelLbl = new Label("fieldLabel", labelModel); Panel dataValueEntryPanel; String fieldTypeName = pf.getFieldType().getName(); String encodedValues = pf.getEncodedValues(); Boolean requiredField = aCustomData.getPhenoDataSetFieldDisplay().getRequired(); if (fieldTypeName.equals(au.org.theark.core.web.component.customfield.Constants.DATE_FIELD_TYPE_NAME)) { if (pf.getDefaultValue() != null && item.getModelObject().getDateDataValue() == null) { try { item.getModelObject().setDateDataValue( new SimpleDateFormat(Constants.DD_MM_YYYY).parse(pf.getDefaultValue())); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } DateDataEntryPanel dateDataEntryPanel = new DateDataEntryPanel("dataValueEntryPanel", new PropertyModel<Date>(item.getModel(), "dateDataValue"), new Model<String>(labelModel)); dateDataEntryPanel.setErrorDataValueModel(new PropertyModel<String>(item.getModel(), "errorDataValue")); dateDataEntryPanel.setUnitsLabelModel(new PropertyModel<String>(item.getModel(), "phenoDataSetFieldDisplay.phenoDataSetField.unitType.name")); if (pf.getMinValue() != null && !pf.getMinValue().isEmpty()) { IConverter<Date> dateConverter = dateDataEntryPanel.getDateConverter(); try { Date minDate = (Date) dateConverter.convertToObject(pf.getMinValue(), getLocale()); dateDataEntryPanel.addValidator(DateValidator.minimum(minDate, Constants.DD_MM_YYYY)); } catch (ConversionException ce) { // This should not occur because it means the data is corrupted on the backend database getLog().error( "Unexpected error: phenoDataSetField.minValue is not in the DD/MM/YYYY date format"); this.error( "An unexpected error occurred loading the field validators from database. Please contact your System Administrator."); getParentContainer().setEnabled(false); } } if (pf.getMaxValue() != null && !pf.getMaxValue().isEmpty()) { IConverter<Date> dateConverter = dateDataEntryPanel.getDateConverter(); try { Date maxDate = (Date) dateConverter.convertToObject(pf.getMaxValue(), getLocale()); dateDataEntryPanel.addValidator(DateValidator.maximum(maxDate, Constants.DD_MM_YYYY)); } catch (ConversionException ce) { // This should not occur because it means the data is corrupted on the backend database getLog().error( "Unexpected error: phenoDataSetField.maxValue is not in the DD/MM/YYYY date format"); this.error( "An unexpected error occurred loading the field validators from database. Please contact your System Administrator."); getParentContainer().setEnabled(false); } } if (requiredField != null && requiredField == true) { dateDataEntryPanel.setRequired(true); } dataValueEntryPanel = dateDataEntryPanel; } else {//ie if its not a date... if (encodedValues != null && !encodedValues.isEmpty()) { // The presence of encodedValues means it should be a DropDownChoice List<String> encodeKeyValueList = Arrays.asList(encodedValues.split(";")); ArrayList<EncodedValueVO> choiceList = new ArrayList<EncodedValueVO>(); for (String keyValue : encodeKeyValueList) { // Only split for the first instance of the '=' (allows the '=' character in the actual value) String[] keyValueArray = keyValue.split("=", 2); EncodedValueVO encodedValueVo = new EncodedValueVO(); encodedValueVo.setKey(keyValueArray[0]); encodedValueVo.setValue(keyValueArray[1]); choiceList.add(encodedValueVo); } ChoiceRenderer<EncodedValueVO> choiceRenderer = new ChoiceRenderer<EncodedValueVO>("value", "key"); if (pfd.getAllowMultiselect()) { CheckGroupDataEntryPanel cgdePanel = new CheckGroupDataEntryPanel("dataValueEntryPanel", new PropertyModel<String>(item.getModel(), "textDataValue"), new Model<String>(labelModel), choiceList, choiceRenderer); cgdePanel.setErrorDataValueModel(new PropertyModel<String>(item.getModel(), "errorDataValue")); cgdePanel.setUnitsLabelModel(new PropertyModel<String>(item.getModel(), "phenoDataSetFieldDisplay.phenoDataSetField.unitType.name")); if (pf.getMissingValue() != null && !pf.getMissingValue().isEmpty()) { cgdePanel.setMissingValue(pf.getMissingValue()); } if (requiredField != null && requiredField == true) { cgdePanel.setRequired(true); } dataValueEntryPanel = cgdePanel; } else { if (pf.getDefaultValue() != null && item.getModelObject().getTextDataValue() == null) { item.getModelObject().setTextDataValue(pf.getDefaultValue()); } DropDownChoiceDataEntryPanel ddcPanel = new DropDownChoiceDataEntryPanel("dataValueEntryPanel", new PropertyModel<String>(item.getModel(), "textDataValue"), new Model<String>(labelModel), choiceList, choiceRenderer); ddcPanel.setErrorDataValueModel(new PropertyModel<String>(item.getModel(), "errorDataValue")); ddcPanel.setUnitsLabelModel(new PropertyModel<String>(item.getModel(), "phenoDataSetFieldDisplay.phenoDataSetField.unitType.name")); if (pf.getMissingValue() != null && !pf.getMissingValue().isEmpty()) { ddcPanel.setMissingValue(pf.getMissingValue()); } if (requiredField != null && requiredField == true) { ddcPanel.setRequired(true); } dataValueEntryPanel = ddcPanel; } } else { if (fieldTypeName .equals(au.org.theark.core.web.component.customfield.Constants.CHARACTER_FIELD_TYPE_NAME)) { // Text data if (pf.getDefaultValue() != null && item.getModelObject().getTextDataValue() == null) { item.getModelObject().setTextDataValue(pf.getDefaultValue()); } TextDataEntryPanel textDataEntryPanel = new TextDataEntryPanel("dataValueEntryPanel", new PropertyModel<String>(item.getModel(), "textDataValue"), new Model<String>(labelModel)); textDataEntryPanel .setErrorDataValueModel(new PropertyModel<String>(item.getModel(), "errorDataValue")); textDataEntryPanel.setUnitsLabelModel(new PropertyModel<String>(item.getModel(), "phenoDataSetFieldDisplay.phenoDataSetField.unitType.name")); textDataEntryPanel.setTextFieldSize(60); if (requiredField != null && requiredField == true) { textDataEntryPanel.setRequired(true); } dataValueEntryPanel = textDataEntryPanel; } else if (fieldTypeName .equals(au.org.theark.core.web.component.customfield.Constants.NUMBER_FIELD_TYPE_NAME)) { // Number data if (pf.getDefaultValue() != null && item.getModelObject().getNumberDataValue() == null) { item.getModelObject().setNumberDataValue(Double.parseDouble(pf.getDefaultValue())); ; } NumberDataEntryPanel numberDataEntryPanel = new NumberDataEntryPanel("dataValueEntryPanel", new PropertyModel<Double>(item.getModel(), "numberDataValue"), new Model<String>(labelModel)); numberDataEntryPanel .setErrorDataValueModel(new PropertyModel<String>(item.getModel(), "errorDataValue")); numberDataEntryPanel.setUnitsLabelModel(new PropertyModel<String>(item.getModel(), "phenoDataSetFieldDisplay.phenoDataSetField.unitType.name")); if (pf.getMinValue() != null && !pf.getMinValue().isEmpty()) { IConverter<Double> doubleConverter = numberDataEntryPanel.getNumberConverter(); try { Double minNumber = (Double) doubleConverter.convertToObject(pf.getMinValue(), getLocale()); numberDataEntryPanel.addValidator(new MinimumValidator<Double>(minNumber)); } catch (ConversionException ce) { // This should not occur because it means the data is corrupted on the backend database getLog().error( "Unexpected error: phenoDataSetField.maxValue is not in a valid number format"); this.error( "An unexpected error occurred loading the field validators from database. Please contact your System Administrator."); getParentContainer().setEnabled(false); } } if (pf.getMaxValue() != null && !pf.getMaxValue().isEmpty()) { IConverter<Double> doubleConverter = numberDataEntryPanel.getNumberConverter(); try { Double maxNumber = (Double) doubleConverter.convertToObject(pf.getMaxValue(), getLocale()); numberDataEntryPanel.addValidator(new MaximumValidator<Double>(maxNumber)); } catch (ConversionException ce) { // This should not occur because it means the data is corrupted on the backend database getLog().error( "Unexpected error: phenoDataSetField.maxValue is not in a valid number format"); this.error( "An unexpected error occurred loading the field validators from database. Please contact your System Administrator."); getParentContainer().setEnabled(false); } } if (requiredField != null && requiredField == true) { numberDataEntryPanel.setRequired(true); } dataValueEntryPanel = numberDataEntryPanel; } else { // TODO: Unknown type should display an UnsupportedValueEntryPanel dataValueEntryPanel = new EmptyPanel("dataValueEntryPanel"); } } } item.add(fieldLabelLbl); item.add(dataValueEntryPanel); }
From source file:com.axway.ats.testexplorer.pages.runs.RunsFilter.java
License:Apache License
@SuppressWarnings({ "rawtypes" })
public RunsFilter(String id, final DataGrid dataGrid, final PageParameters parameters) {
super(id);// www.jav a 2s . com
// filter fields
searchByRun.setEscapeModelStrings(false);
searchByRun.setOutputMarkupId(true);
searchByProduct.setEscapeModelStrings(false);
searchByProduct.setOutputMarkupId(true);
searchByVersion.setEscapeModelStrings(false);
searchByVersion.setOutputMarkupId(true);
searchByBuild.setEscapeModelStrings(false);
searchByBuild.setOutputMarkupId(true);
searchByOs.setEscapeModelStrings(false);
searchByOs.setOutputMarkupId(true);
searchByUserNote.setOutputMarkupId(true);
searchByUserNote.setEscapeModelStrings(false);
searchByAfterDate.setOutputMarkupId(true);
searchByBeforeDate.setOutputMarkupId(true);
searchByAfterDate.add(DateValidator.maximum(new Date(), "dd.MM.yyyy"));
add(searchByRun);
add(searchByProduct);
add(searchByVersion);
add(searchByBuild);
add(searchByOs);
add(searchByUserNote);
add(searchByAfterDate);
add(searchByBeforeDate);
// attach a Date Picker component
searchByAfterDate.add(new TEDatePicker().setShowOnFieldClick(true).setAutoHide(true));
searchByBeforeDate.add(new TEDatePicker().setShowOnFieldClick(true).setAutoHide(true));
// search button
AjaxButton searchButton = new AjaxButton("search_button") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
clearPageParameters(parameters);
target.add(dataGrid);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
super.onError(target, form);
}
};
add(searchButton);
// search button is the button to trigger when user hit the enter key
this.setDefaultButton(searchButton);
// reset button
add(new AjaxButton("reset_button") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
// reset the filter
searchByRun.setModelObject("");
searchByProduct.setModelObject("");
searchByVersion.setModelObject("");
searchByBuild.setModelObject("");
searchByOs.setModelObject("");
searchByUserNote.setModelObject("");
searchByAfterDate.setModelObject(null);
searchByBeforeDate.setModelObject(null);
target.add(searchByRun);
target.add(searchByProduct);
target.add(searchByVersion);
target.add(searchByBuild);
target.add(searchByOs);
target.add(searchByUserNote);
target.add(searchByAfterDate);
target.add(searchByBeforeDate);
// automatically trigger a new search
target.add(dataGrid);
}
});
// copy URL button
add(new AjaxButton("copy_url_button") {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
String jsQuery = "window.prompt(\"Press 'Ctrl+C' to copy the following URL containing all Runs filter data\", window.location";
if (StringUtils.isNullOrEmpty(urlParameters)) {
jsQuery = jsQuery + ")";
} else {
jsQuery = jsQuery + "+'&" + urlParameters + "')";
}
target.appendJavaScript(jsQuery);
target.add(dataGrid);
}
});
setSearchValuesOnLoad(parameters);
}
From source file:com.axway.ats.testexplorer.pages.testcasesByGroups.TestcasesByGroupFilter.java
License:Apache License
public TestcasesByGroupFilter(String id) { super(id);/* w w w . ja v a 2 s.c o m*/ searchByProduct = createSearchByProductComponent(); searchByVersion = createSearchByVersionComponent(); searchByAllGroups = createSearchByAllGroupsComponent(); searchByGroupContains = new TextField<String>("search_by_group_contains", new Model<String>("")); searchByGroupContains.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { if (StringUtils.isNullOrEmpty(searchByGroupContains.getModel().getObject())) { TestExplorerSession session = (TestExplorerSession) Session.get(); try { groupNames = session.getDbReadConnection().getAllGroupNames(selectedProductName, selectedVersionNames); } catch (DatabaseAccessException e) { LOG.error("Unable to get all group names", e); error("Unable to get all group names"); } } else { groupNames = new ArrayList<String>(); } selectedGroupNames = groupNames; searchByAllGroups.getModel().setObject(selectedGroupNames); searchByAllGroups.setChoices(groupNames); target.add(searchByAllGroups); } }); searchByAfterDate.setOutputMarkupId(true); searchByAfterDate.add(DateValidator.maximum(new Date(), "dd.MM.yyyy")); searchByBeforeDate.setOutputMarkupId(true); searchByGroupContains.setEscapeModelStrings(false); searchByGroupContains.setOutputMarkupId(true); add(searchByProduct); add(searchByVersion); add(searchByAllGroups); add(searchByAfterDate); add(searchByBeforeDate); add(searchByGroupContains); searchByAfterDate.add(new DatePicker().setShowOnFieldClick(true).setAutoHide(true)); searchByBeforeDate.add(new DatePicker().setShowOnFieldClick(true).setAutoHide(true)); AjaxButton searchButton = new AjaxButton("submit") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (StringUtils.isNullOrEmpty(selectedProductName) && selectedVersionNames.size() == 0 && selectedGroupNames.size() == 0 && StringUtils.isNullOrEmpty(searchByGroupContains.getModel().getObject()) && StringUtils.isNullOrEmpty(searchByAfterDate.getInput()) && StringUtils.isNullOrEmpty(searchByBeforeDate.getInput())) { return; } TestExplorerSession session = (TestExplorerSession) Session.get(); TestcaseInfoPerGroupStorage perGroupStorage = null; try { perGroupStorage = session.getDbReadConnection().getTestcaseInfoPerGroupStorage( selectedProductName, selectedVersionNames, selectedGroupNames, searchByAfterDate.getValue(), searchByBeforeDate.getValue(), searchByGroupContains.getModel().getObject()); } catch (DatabaseAccessException e) { LOG.error("Unable to get Testcases and groups data", e); error("Unable to get Testcases and groups data"); } if (perGroupStorage != null) { String treemapData = perGroupStorage.generateTreemapData(); String testcasesIdsMap = perGroupStorage.generateTestcasesIdsMap(); String script = ";setHiddenValue(\"groups\");drawTreemap(" + treemapData + "," + TestcaseInfoPerGroupStorage.TREEMAP_OPTIONS + ");$('.filterHeader').click();populateFilterDataPanel(" + getFilterData() + ");setTestcasesIdsMap(" + testcasesIdsMap + ");"; target.appendJavaScript(script); } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { super.onError(target, form); } }; add(searchButton); // search button is the button to trigger when user hit the enter key this.setDefaultButton(searchButton); add(new AjaxButton("clear") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { selectedProductName = null; selectedVersionNames = new ArrayList<String>(1); versionNames = new ArrayList<String>(1); selectedGroupNames = new ArrayList<String>(1); groupNames = new ArrayList<String>(1); searchByProduct.getModel().setObject(selectedProductName); searchByVersion.getModel().setObject(selectedVersionNames); searchByVersion.setChoices(new ListModel<String>(versionNames)); searchByAllGroups.getModel().setObject(selectedGroupNames); searchByAllGroups.setChoices(new ListModel<String>(groupNames)); searchByAfterDate.getModel().setObject(null); searchByAfterDate.clearInput(); searchByBeforeDate.clearInput(); searchByBeforeDate.getModel().setObject(null); searchByGroupContains.getModel().setObject(null); target.add(searchByProduct); target.add(searchByVersion); target.add(searchByAllGroups); target.add(searchByAfterDate); target.add(searchByBeforeDate); target.add(searchByGroupContains); target.appendJavaScript( ";$('#chart_div').empty();populateFilterDataPanel(" + getFilterData() + ");"); } }); }