List of usage examples for org.apache.wicket.markup.html.form FormComponent getInput
public String getInput()
From source file:com.pushinginertia.wicket.core.form.validation.NotEqualInputValidator.java
License:Open Source License
/** * @see org.apache.wicket.markup.html.form.validation.IFormValidator#validate(org.apache.wicket.markup.html.form.Form) *//*from w ww.j av a 2 s.com*/ public void validate(final Form<?> form) { // we have a choice to validate the type converted values or the raw // input values, we validate the raw input final FormComponent<String> formComponent1 = components[0]; final FormComponent<String> formComponent2 = components[1]; if (Objects.equal(formComponent1.getInput(), formComponent2.getInput())) { error(formComponent2); } }
From source file:de.tudarmstadt.ukp.csniper.webapp.support.wicket.LocalizerUtil.java
License:Apache License
public static String getString(FormComponent<?> aComponent, String aKey) { Map<String, Object> args = new HashMap<String, Object>(); String arg = "label"; IModel<?> label = aComponent.getLabel(); if (label != null) { args.put(arg, label.getObject()); } else {// w w w . j a v a 2 s.c o m args.put(arg, aComponent.getLocalizer().getString(aComponent.getId(), aComponent.getParent(), aComponent.getId())); } args.put("input", aComponent.getInput()); args.put("name", aComponent.getId()); return aComponent.getString(aKey, new MapModel<String, Object>(args)); }
From source file:eu.uqasar.web.pages.qmtree.metric.QMMetricFormValidator.java
License:Apache License
@Override public void validate(Form<?> form) { final FormComponent name = components[0]; final FormComponent<Double> lowerLimit = components[1]; final FormComponent<Double> upperLimit = components[2]; Localizer loc = getLocalizer(form);// ww w . j a va2 s.co m String nameValue = Objects.stringValue(name.getInput(), true); if ("".equals(nameValue)) { name.error(loc.getString("form.name.required", name)); } else if (nameValue.length() > 255) { name.error(loc.getString("form.name.max", name)); } // if (Double.valueOf(lowerLimit.getValue()) > Double.valueOf(upperLimit.getValue())){ // upperLimit.error(loc.getString("form.upperLimit.low", upperLimit)); // } }
From source file:eu.uqasar.web.pages.qmtree.qmodels.QModelFormValidator.java
License:Apache License
@Override public void validate(Form<?> form) { final FormComponent name = components[0]; final FormComponent key = components[1]; final boolean isNew = newEntity; final String oldKey = previousKey; Localizer loc = getLocalizer(form);/*w ww . jav a 2 s.co m*/ String f1Value = Objects.stringValue(name.getInput(), true); String f2Value = Objects.stringValue(key.getInput(), true); if ("".equals(f1Value)) { name.error(loc.getString("form.name.required", name)); } else if (f1Value.length() > 255) { name.error(loc.getString("form.name.max", name)); } if ("".equals(f2Value)) { key.error(loc.getString("form.key.required", key)); } List<String> nodeKeyList = qmodelService.getAllNodeKeys(); if (!previousKey.equals(f2Value) && !isNew && Collections.frequency(nodeKeyList, f2Value) >= 1) { key.error(loc.getString("form.key.repeated", key)); } else if (!previousKey.equals(f2Value) && isNew && (Collections.frequency(nodeKeyList, f2Value) > 0)) { key.error(loc.getString("form.key.repeated", key)); } }
From source file:eu.uqasar.web.pages.qmtree.quality.indicator.QMQualityIndicatorFormValidator.java
License:Apache License
@Override public void validate(Form<?> form) { final FormComponent name = components[0]; final FormComponent<Double> lowerLimit = components[1]; final FormComponent<Double> upperLimit = components[2]; Localizer loc = getLocalizer(form);//from w w w.jav a 2 s .c o m String f1Value = Objects.stringValue(name.getInput(), true); if ("".equals(f1Value)) { name.error(loc.getString("form.name.required", name)); } else if (f1Value.length() > 255) { name.error(loc.getString("form.name.max", name)); } // if (Double.valueOf(lowerLimit.getValue()) > Double.valueOf(upperLimit.getValue())){ // upperLimit.error(loc.getString("form.upperLimit.low", upperLimit)); // } }
From source file:jp.go.nict.langrid.management.web.view.page.language.service.composite.component.form.validator.BPELUploaderValidator.java
License:Open Source License
/** * //w ww .j av a2 s . com * */ private void checkWSDL(FileUploaderPanel panel) throws ResourceStreamNotFoundException, IOException { String fileName = ""; FormComponent component = panel.getSelectedFormComponent(); if (component == null) { panel.error(MessageManager.getMessage("ProvidingServices.language.service.error.BPEL.Selected", panel.getLocale())); return; } String inputString = component.getInput(); if (inputString == null) { panel.error(MessageManager.getMessage("ProvidingServices.language.service.error.BPEL.Required", panel.getLocale())); return; } if (panel.getSelectedFormComponentID().equals("URLField")) { URLField url = (URLField) component; fileName = FileUtil.getFileNameWithoutPathWithWsdl(url.getInput()); if (fileName.equals("")) { url.error(MessageManager.getMessage("ProvidingServices.language.service.error.BPELExtension", url.getLocale())); } else { UrlResourceStream urs; int totalSize = 0; InputStream is = null; urs = new UrlResourceStream(new URL(url.getInput())); is = urs.getInputStream(); byte[] buffer = new byte[1024]; while (true) { int size = is.read(buffer); if (size == -1) { break; } totalSize += size; } is.close(); if (totalSize > Integer.parseInt(MessageUtil.LIMIT_WSDL_FILE_SIZE)) { url.error(MessageManager.getMessage( "ProvidingServices.language.service.error.RemoteBPELLFileSize", url.getLocale())); } } } else if (panel.getSelectedFormComponentID().equals("FileUploadField")) { FileUploadField file = (FileUploadField) component; fileName = file.getFileUpload().getClientFileName(); if (!fileName.equals("") && !checkExtension(fileName, "wsdl")) { file.error(MessageManager.getMessage("ProvidingServices.language.service.error.BPELExtension", file.getLocale())); } else { if (file.getFileUpload().getSize() > Long.parseLong(MessageUtil.LIMIT_WSDL_FILE_SIZE)) { file.error(MessageManager.getMessage("ProvidingServices.language.service.error.BPELFileSize", file.getLocale())); } } } }
From source file:jp.xet.uncommons.wicket.behavior.NotEqualInputValidator.java
License:Apache License
@Override public void validate(Form<?> form) { // we have a choice to validate the type converted values or the raw // input values, we validate the raw input final FormComponent<?> formComponent1 = components[0]; final FormComponent<?> formComponent2 = components[1]; if (Objects.equal(formComponent1.getInput(), formComponent2.getInput())) { error(formComponent2);/*from ww w . j av a 2 s. c om*/ } }
From source file:nl.knaw.dans.common.wicket.util.UnEqualInputValidator.java
License:Apache License
@Override public void validate(Form form) { final FormComponent formComponent1 = getDependentFormComponents()[0]; final FormComponent formComponent2 = getDependentFormComponents()[1]; if (Objects.equal(formComponent1.getInput(), formComponent2.getInput())) { error(formComponent2);/*from w w w . j ava 2s . c o m*/ } }
From source file:org.apache.syncope.client.console.tasks.CrontabPanel.java
License:Apache License
private String getCronField(final FormComponent<?> formComponent, final int field) { String cronField = null;//from w w w .ja va 2 s .c o m if (formComponent != null) { cronField = getCronField(formComponent.getInput(), field); } return cronField; }
From source file:org.apache.syncope.client.console.wicket.markup.html.CrontabContainer.java
License:Apache License
private String getCronField(final FormComponent formComponent, final int field) { String cronField = null;/*from www . j a va 2 s . c o m*/ if (formComponent != null) { cronField = getCronField(formComponent.getInput(), field); } return cronField; }