List of usage examples for org.apache.wicket.markup.html.form FormComponent getDefaultModelObject
Object getDefaultModelObject();
From source file:gr.interamerican.wicket.bo2.utils.SelfDrawnUtils.java
License:Open Source License
/** * Code called on any self-drawn form component. * /*from www . jav a2 s. co m*/ * @param component * FormComponent * @param descriptor * BoPropertyDescriptor * * @param <T> * Type of component's model object. */ public static <T> void standardSelfDrawnFormComponentStuff(FormComponent<T> component, BoPropertyDescriptor<T> descriptor) { component.setOutputMarkupPlaceholderTag(true); component.add(ValidationStyleBehavior.INSTANCE); component.add(new BoPropertyDescriptorValidatorWrapper<T>(descriptor)); if (descriptor.isHasDefault() && component.getDefaultModelObject() == null) { component.setDefaultModelObject(descriptor.getDefaultValue()); } if (descriptor.isReadOnly()) { disableComponent(component); } /* * This check cannot be off-loaded to the NotNullValidator, since * in this case, wicket will not process any validators attached * on the component. Having to set this here means that state changes * of the nullAllowed property of the BoPropertyDescriptor are not * propagated to the self-drawn Component. This is not, however, a * major issue, since it is not expected that the BoPropertyDescriptor * of a self-drawn Component will have this property changed after * the Component is created. */ component.setRequired(!descriptor.isNullAllowed()); }