当前位置: 首页>>代码示例>>Java>>正文


Java FormComponent类代码示例

本文整理汇总了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;
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:20,代码来源:ConditionalRequiredFormModelValidator.java

示例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());
            }
        });
    }
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:25,代码来源:PrismValuePanel.java

示例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;
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:24,代码来源:JasperReportConfigurationPanel.java

示例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");
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:18,代码来源:OneRequiredFormValidator.java

示例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;
 		
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:17,代码来源:QModelFormValidator.java

示例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));
//   		}
	}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:21,代码来源:QMQualityObjectiveFormValidator.java

示例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);
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:21,代码来源:ModelValidatingForm.java

示例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;
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:22,代码来源:DefaultBindingBuilder.java

示例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);
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:26,代码来源:DefaultSubmitButtonCallback.java

示例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);
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:25,代码来源:GridColumnBorder.java

示例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);
    }
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:25,代码来源:GridColumnBorder.java

示例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;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:23,代码来源:ComponentPersister.java

示例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);
	}
}
 
开发者ID:MarcGiffing,项目名称:wicket-spring-boot,代码行数:18,代码来源:ValidationMsgBehavior.java

示例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>");
    }
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:23,代码来源:FieldFeedbackDecorator.java

示例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);
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:15,代码来源:InputChangeBehavior.java


注:本文中的org.apache.wicket.markup.html.form.FormComponent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。