Hi,
We create A Page with an unknown amount of Customfields using a Loop with
Blocks for the different Types, currently only Text and Date.
We now face the Problem setting individual Validators to certain fields. We use
a Property with a FieldValidator which we provide with the correct Validator at
the time of Render. Unfortunatly all fields of the same type are provided with
the same type of Validator.
<div>
<t:form >
<t:beaneditor t:object="object"/>
<t:loop t:source="object.renderobjects" t:value="current"
encoder="encoder">
<t:submitNotifier>
<t:delegate to="activeBlock"/>
</t:submitNotifier>
</t:loop>
<input type="submit"/>
</t:form>
</div>
<div>
<t:pagelink t:page="index">reload</t:pagelink>
</div>
<t:block t:id="stringBlock">
<div class="stringInput">
<t:label for="text"/>
<t:textfield t:id="text" t:label="prop:current.name"
value="current.value" translate="string"
t:validate="prop:validator"/>
</div>
</t:block>
<t:block t:id="dateBlock">
<div class="dateInput">
<t:label for="date"/>
<t:datefield t:id="date" t:label="prop:current.name"
value="current.value" />
</div>
</t:block>
Inside the Encoder we (re)create the Validator.
@InjectComponent(value = "text")
private TextField text;
@Property
private FieldValidator<String> validator;
.
.
.
@Override
public String toClient(RenderObject<?> value) {
String name = value.getName();
String validatorName =
validatorFieldMapping.get(name);
if (validatorName != null) {
validator =
validatorSource.createValidators(text, validatorName);
}
return name;
}
It would be highly appreciated if someone could provide us with a better
solution or a hint how to differently approach the Problem.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]