I'm not sure if it is what you want, but I did something that may help you.
In my case, the rules change depending on some business rules. For example, in one scenario my form has fields A anb B required, but in another, it has fields B and C required.
I didn't find a way to recreate the bean that extends the DefaultRulesSource, because it is registered by another bean that aplyes the rules on the forms.
So, the solution was to change the existing rules.
First, take form context the DefaultRulesSource bean.
In the context:
Code:
<bean id="rulesSource" class="br.com.xxx.ValidationRulesSource" />
In your class, call that:
Code:
ValidationRulesSource rulesSource = (ValidationRulesSource) Application.instance()
.getApplicationContext().getBean("rulesSource");
Now you have access to the bean tha has all your rules.
The rules can be grouped by the bean class. Using this information, the framework know waht rules to apply to each form.
You can get the rules os a specific class like that:
Code:
Rules rules = rulesSource.getRules(YOURBEAN.getClass());
So, you can create new rules and set them to the rulesSource, like that:
Code:
List<Rules> regras = new ArrayList<Rules>();
// add your Rules to the list
rulesSource.setRules(regras);
Do this before construct the form and it should work.
I hope this can help you.
Charles