On Wed, Dec 8, 2010 at 10:44 AM, Martin Grigorov <[email protected]> wrote:
>> Could we create an Html5AutoConfigurationBehavior that could be added
>> to components if people wanted to auto-configure their components from
>> markup? We might even provide an icomponentinstantiationlistener to
>> automagically add this to all components for users. Or, make it a
>> markup setting on the application.
>>
>> instanctiationlistener will not work because the markup is not available
> yet at construction time of FormComponent
> I like the idea with markupsettings
I didn't say "do the configuration in the instantiation listener". I
said "automagically add this [AutoConfigureBehavior mentioned in
previous sentence] to all components".
Example:
class AutoConfigureBehavior extends AbstractBehavior {
@Override
public void onComponentTag(Component component, ComponentTag tag) {
super.onComponentTag(component, tag);
if (component instanceof FormComponent<?> &&
!Strings.isEmpty(tag.getAttribute("required"))) {
((FormComponent) component).setRequired(true);
}
}
}
class AddAutoConfigureBehaviorToAllComponents implements
IComponentInstantiationListener {
@Override
public void onInstantiation(Component component) {
component.add(new AutoConfigureBehavior());
}
}
--
Jeremy Thomerson
http://wickettraining.com
Need a CMS for Wicket? Use Brix! http://brixcms.org