FieldValidation regexp using 'component-id'-regexp

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FieldValidation regexp using 'component-id'-regexp

Michael Capper
Hi,
thanks for all the help so far!

Here is someting i can't seem to be able to fix "elegantly". I've made a component which i want to use within a BeanEditForm within the <parameter name="password">-Tags like this:
<t:Bean...>
 <t:parameter name="username"><t:RandomFieldFiller t:id="usernamegenerator"></parameter> 
<t:parameter name="password"><t:RandomFieldFiller t:id="passwordgenerator"></parameter>
</t:Bean..>

for this Component, the Template  RandomFieldFiller.tml has a
        <t:TextField/>
and in its Class RandomFieldFiller.java
        @Component(parameters = { "validate=regexp", "value=value",
                                                                "clientid=prop:label", "label=prop:label" })
        private TextField textfield;
for this textfield.


Now my problem is that the regexp-validator looks for a "textfield-regexp"-message in my message-catalog. I would want it to look for a "username-regexp" and "password-regexp" message instead, but the validator only uses the component-Id, which I can't seem to be able to set dynamically (i.e. t:id="${fieldname}" does not work, and setting it to some constant would look for "constant-regexp" for both fields). So I was thinking it would be better to use the clientId instead, unless the componentId could be set dynamically. Would that be possible? I dont know if the component knows its clientId whereever it is needed, so maybe I can enter the regexp somewhere else?

Is there an easier way to fix this other than duplicating the Component using a different id for textfield. Maybe some parameters for the Regexp - FieldValidator which i overlooked? (validate="regexp=/patterb/" maybe...?

Thanks for your thoughts on this,
Michael Capper