本文整理汇总了Java中org.apache.wicket.markup.html.form.FormComponent类的典型用法代码示例。如果您正苦于以下问题:Java FormComponent类的具体用法?Java FormComponent怎么用?Java FormComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FormComponent类属于org.apache.wicket.markup.html.form包,在下文中一共展示了FormComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doCheck
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
private boolean doCheck(FormComponent<?> formComponent) {
boolean onError = false;
formComponent.setRequired(true);
if (
(emptyMode && formComponent.checkRequired())
|| (!emptyMode && !formComponent.checkRequired())
) {
ValidationError validationError = new ValidationError();
if (errorRessourceKey != null) {
validationError.addKey(errorRessourceKey);
}
(formComponentOnError != null ? formComponentOnError : formComponent).error(validationError.addKey(emptyMode ? "EmptyRequired" : "Required"));
onError = true;
}
formComponent.setRequired(false);
return onError;
}
示例2: initAccessBehaviour
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
private void initAccessBehaviour(InputPanel panel) {
List<FormComponent> components = panel.getFormComponents();
for (FormComponent component : components) {
component.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
ValueWrapper wrapper = valueWrapperModel.getObject();
ItemWrapper itemWrapper = wrapper.getItem();
if (valueWrapperModel.getObject().isReadonly()) {
return false;
}
if (itemWrapper.getContainer() == null) {
return true; // TODO
}
ObjectWrapper object = itemWrapper.getContainer().getObject();
ItemDefinition def = itemWrapper.getItem().getDefinition();
return object == null || isAccessible(def, object.getStatus());
}
});
}
}
示例3: createTextPanel
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private <J> Component createTextPanel(String componentId, final IModel<J> model, String expression,
final Boolean mandatory) {
TextPanel<String> textPanel = new TextPanel<String>(componentId, new PropertyModel<String>(model, expression));
FormComponent input = textPanel.getBaseFormComponent();
input.add(new AttributeAppender("style", "width: 100%"));
input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
input.add(new IValidator() {
private static final long serialVersionUID = 1L;
@Override
public void validate(IValidatable validatable) {
if (!mandatory) {
return;
}
if (validatable.getValue() == null) {
validatable.error(new ValidationError("JasperReportConfigurationPanel.errormsg"));
}
}
});
return textPanel;
}
示例4: onError
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
protected void onError(Form<?> form) {
Joiner labelJoiner = Joiner.on(form.getString("common.validator.oneRequired.labels.separator"));
String labels = labelJoiner.join(Iterables.transform(requiredFormComponents, new Function<FormComponent<?>, String>() {
@Override
public String apply(FormComponent<?> input) {
return input.getLabel().getObject();
}
}));
if (mode == OneRequiredMode.ONE_ONLY) {
error(requiredFormComponents.iterator().next(), "common.validator.oneRequired.oneOnly", ImmutableMap.<String, Object>of("labels", labels));
} else if (mode == OneRequiredMode.ONE_OR_MORE) {
error(requiredFormComponents.iterator().next(), "common.validator.oneRequired.oneOrMore", ImmutableMap.<String, Object>of("labels", labels));
} else {
error(requiredFormComponents.iterator().next(), "common.error");
}
}
示例5: QModelFormValidator
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
public QModelFormValidator(FormComponent f1, FormComponent f2, String oldKey, boolean f3) {
if (f1 == null) {
throw new IllegalArgumentException(
"FormComponent1 cannot be null");
}
if (f2 == null) {
throw new IllegalArgumentException(
"FormComponent2 cannot be null");
}
components = new FormComponent[] { f1, f2};
newEntity = f3;
previousKey = oldKey;
}
示例6: validate
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
@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);
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));
// }
}
示例7: 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);
}
}
示例8: configure
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
@Override
public boolean configure(final IHtmlElement<?, ?> e, final Component c) {
if (e.isModelElement() && !(e.getModelElement() instanceof TableHtmlElement)) {
c.add(new ModelComponentBehavior(e, c, e.getTargetObjectModel()));
}
final FormComponent<?> formComponent = Components.asFormComponent(c);
if (formComponent != null) {
if (e.isModelElement()) {
formComponent.setLabel(e.getTitleModel());
}
if (e.getContext().isUseSqlInjectionValidation()) {
formComponent.add(new SQLInjectionValidator(c));
}
if (e.getModelElement().getBeanPathElement().isProperty()) {
FormComponentAwarePropertyResolver.maybeRegisterElement(e, c, formComponent);
formComponent.add(new ModelPropertyValidator(c));
}
}
c.setOutputMarkupId(true);
return true;
}
示例9: invokeForcedButtonOnValidationError
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
protected void invokeForcedButtonOnValidationError(final Component component) {
/*
* On forced button method we need to synchronize all valid properties into the model and reset all invalid ones
* with the values of the model.
*/
final Component root = Components.findRoot(component);
final Form<?> form = Components.findForm(root);
FormComponent.visitFormComponentsPostOrder(form, new IVisitor<FormComponent<?>, Void>() {
@Override
public void component(final FormComponent<?> object, final IVisit<Void> visit) {
if (object.isEnabledInHierarchy() && object.isVisibleInHierarchy() && !object.isValid()) {
/*
* need to clear individual components besides the form to make GridColumnBorder not display error
* even though there should be none because form was cleared
*/
object.clearInput();
object.getFeedbackMessages().clear();
}
}
});
//clear the form itself
form.clearInput();
form.getSession().getFeedbackMessages().clear();
invokeButtonMethod(component);
}
示例10: GridColumnBorder
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
public GridColumnBorder(final GridColumnHtmlElement element) {
super(element.getWicketId());
this.element = element;
final AttributeModifier hasError = AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
final Component component = element.getContext()
.getComponentRegistry()
.getComponent(element.getModelWicketId());
final FormComponent<?> formComponent = Components.asFormComponent(component);
if (formComponent != null) {
if (!formComponent.isValid()) {
return "has-error";
}
}
return null;
}
});
add(hasError);
this.help = new Label("help", Model.of()); //needs to escape markup or modals do not close
help.setEscapeModelStrings(false);
addToBorder(help);
}
示例11: 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);
}
}
示例12: load
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
/**
* Override wicket's cookie utils to enable encoding and decoding of cookie content.
* See RTFACT-6086
* @param formComponent
* @return
*/
protected static String load(final FormComponent<?> formComponent) {
String value = COOKIE_UTILS.load(formComponent.getPageRelativePath());
if (value != null) {
// Assign the retrieved/persisted value to the component
String[] values = value.split(FormComponent.VALUE_SEPARATOR);
for (int i = 0; i < values.length; i++) {
try {
values[i] = URLDecoder.decode(values[i], "UTF-8");
} catch (UnsupportedEncodingException e) {
log.debug("Failed to decode cookie value: {}", e.getMessage());
}
}
formComponent.setModelValue(values);
}
return value;
}
示例13: 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);
}
}
示例14: afterRender
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
@Override
public void afterRender(Component component) {
FormComponent<?> fc = (FormComponent<?>) component;
Response r = component.getResponse();
r.write("</span>");
if (fc.hasFeedbackMessage()) {
r.write("<span class=\"feedbackPanelTextField\">");
IFeedbackMessageFilter filter = new ComponentFeedbackMessageFilter(component);
for (FeedbackMessage message : fc.getFeedbackMessages().messages(filter)) {
r.write("<span class=\"feedbackPanel");
r.write(message.getLevelAsString().toUpperCase());
r.write("\">");
r.write(Strings.escapeMarkup(message.getMessage().toString()));
}
r.write("</span>");
}
}
示例15: onUpdate
import org.apache.wicket.markup.html.form.FormComponent; //导入依赖的package包/类
@Override
protected void onUpdate(AjaxRequestTarget target) {
FormComponent<?> component = (FormComponent<?>) getComponent();
// IE triggers "input" event when the focused on the search input even if nothing is
// input into search box yet. To work around this issue, we compare search string
// against previous value to only update the branches table if there is an actual
// change.
String newInput = component.getInput();
if (!Objects.equals(newInput, input)) {
input = newInput;
onInputChange(target);
}
}