本文整理汇总了Java中org.apache.wicket.markup.html.form.FormComponent.isValid方法的典型用法代码示例。如果您正苦于以下问题:Java FormComponent.isValid方法的具体用法?Java FormComponent.isValid怎么用?Java FormComponent.isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.wicket.markup.html.form.FormComponent
的用法示例。
在下文中一共展示了FormComponent.isValid方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateFormModelValidator
import org.apache.wicket.markup.html.form.FormComponent; //导入方法依赖的package包/类
private void validateFormModelValidator(IFormModelValidator validator) {
Args.notNull(validator, "validator");
final FormComponent<?>[] dependents = validator.getDependentFormComponents();
boolean validate = true;
if (dependents != null) {
for (final FormComponent<?> dependent : dependents) {
if (!dependent.isValid() || !dependent.isVisibleInHierarchy()) {
validate = false;
break;
}
}
}
if (validate) {
validator.validate(this);
}
}
示例2: onConfigure
import org.apache.wicket.markup.html.form.FormComponent; //导入方法依赖的package包/类
@Override
protected void onConfigure() {
final Component component = element.getContext()
.getComponentRegistry()
.getComponent(element.getModelWicketId());
final FormComponent<?> formComponent = Components.asFormComponent(component);
if (formComponent != null) {
final StringBuilder sb = new StringBuilder();
if (showHelpText()) {
if (!formComponent.isValid()) {
boolean firstMessage = true;
for (final FeedbackMessage message : formComponent.getFeedbackMessages()) {
if (!firstMessage) {
sb.append("<br>");
}
firstMessage = false;
sb.append(message.getMessage());
}
}
help.setDefaultModelObject(sb);
}
help.setVisible(sb.length() > 0);
}
}
示例3: afterRender
import org.apache.wicket.markup.html.form.FormComponent; //导入方法依赖的package包/类
@Override
public void afterRender(Component component) {
FormComponent fc = (FormComponent) component;
if (!fc.isValid()) {
String error;
if (fc.hasFeedbackMessage()) {
FeedbackMessage first = fc.getFeedbackMessages().first();
first.markRendered();
error = first.getMessage().toString();
} else {
error = "Your input is invalid.";
}
fc.getResponse().write("*<span id=\"helpBlock2\" class=\"help-block\">"+error+"</span>");
super.afterRender(component);
}
}
示例4: beforeRender
import org.apache.wicket.markup.html.form.FormComponent; //导入方法依赖的package包/类
@Override
public void beforeRender(Component c) {
if (c instanceof FormComponent) {
FormComponent fc = (FormComponent) c;
if (!fc.isValid()) {
super.beforeRender(c);
}
}
}
示例5: beforeRender
import org.apache.wicket.markup.html.form.FormComponent; //导入方法依赖的package包/类
public void beforeRender(Component component) {
FormComponent<?> fc = (FormComponent<?>) component;
Response r = component.getResponse();
String label = (fc.getLabel() != null) ? fc.getLabel().getObject(): null;
if (label != null) {
r.write("<span class=\"param\">");
r.write("<label for=\"");
r.write(fc.getMarkupId());
r.write("\"");
if (!fc.isValid()) {
r.write(" class=\"error\"");
}
r.write(" />");
r.write(Strings.escapeMarkup(label));
r.write("</label>");
r.write("</span>");
NotNull clazz;
try {
Field field = fc.getForm().getModelObject().getClass().getDeclaredField(fc.getInputName());
clazz = field.getAnnotation(NotNull.class);
} catch (NoSuchFieldException e) {
clazz = null;
}
if (clazz != null || fc.isRequired()) {
r.write("<span class=\"required\" title=\"");
r.write(fc.getString("portal.error.required.field.title"));
r.write("\">");
r.write(fc.getString("portal.required.field")+"</span>");
} else {
r.write("<span class=\"notrequired\"></span>");
}
r.write("<span class=\"value\">");
}
super.beforeRender(component);
}
示例6: onComponentTag
import org.apache.wicket.markup.html.form.FormComponent; //导入方法依赖的package包/类
@Override
public void onComponentTag(Component component, ComponentTag tag) {
FormComponent<?> fc = (FormComponent<?>) component;
if (!fc.isValid()) {
String c1 = tag.getAttribute("class");
if (c1 == null) {
tag.put("class", "errorField");
} else {
tag.put("class", " errorField " + c1);
}
}
}
示例7: changeCssClass
import org.apache.wicket.markup.html.form.FormComponent; //导入方法依赖的package包/类
/**
* Changes the CSS class of the linked {@link FormComponent} via AJAX.
*
* @param ajaxRequestTarget of type AjaxRequestTarget
* @param valid Was the validation succesful?
* @param cssClass The CSS class that must be set on the linked {@link FormComponent}
*/
private void changeCssClass(AjaxRequestTarget ajaxRequestTarget, boolean valid, String cssClass) {
FormComponent formComponent = getFormComponent();
if(formComponent.isValid() == valid){
formComponent.add(new AttributeModifier("class", true, new Model("formInputField " + cssClass)));
ajaxRequestTarget.add(formComponent);
}
if(updateComponent!=null){
ajaxRequestTarget.add(updateComponent);
}
}
示例8: isConvertedInputSatisfyingRequirements
import org.apache.wicket.markup.html.form.FormComponent; //导入方法依赖的package包/类
protected final boolean isConvertedInputSatisfyingRequirements(FormComponent<T> prerequisiteField, T convertedInput) {
return (!useWicketValidation || prerequisiteField.isValid()) && isObjectValid(convertedInput);
}
示例9: isCurrentModelSatisfyingRequirements
import org.apache.wicket.markup.html.form.FormComponent; //导入方法依赖的package包/类
protected final boolean isCurrentModelSatisfyingRequirements(FormComponent<T> prerequisiteField, IModel<T> currentModel) {
return (!useWicketValidation || prerequisiteField.isValid()) && isObjectValid(currentModel.getObject());
}
示例10: hasError
import org.apache.wicket.markup.html.form.FormComponent; //导入方法依赖的package包/类
private static boolean hasError(FormComponent<?> formComponent) {
return formComponent.getMetaData(HAS_ERROR) != null || !formComponent.isValid();
}