This content has been marked as final.
Show 5 replies
-
1. Re: How to currently achieve Seam 2.2.0GA DRY form fields validation?
ssamayoagt Mar 6, 2010 5:34 PM (in response to rodrigo.bento)Not quite sure if I understand well.
Do you check manually required fields in "validate()" because you dont like standard message?
If thats true, there is "requiredMessage" attribute in "inputText" JSF component which you can hard code in the view or use EL expression, for example (actual code):
<s:decorate id="fld1" template="/inc/edit.xhtml">
<ui:define name="label">Código</ui:define>
<h:inputText id="ed1" required="true" requiredMessage="#{messages.depto_cod_req}"
value="#{deptoHome.instance.deptoCodigo}" size="10" maxlength="10"
label="Código">
<a4j:support event="onblur" reRender="fld1" bypassUpdates="true"
ajaxSingle="true" />
</h:inputText>
</s:decorate>
Note that @NotEmpty annotation is not enforced until submit because if you dont enter anything in the field the validation isnt fired.
Regards. -
2. Re: How to currently achieve Seam 2.2.0GA DRY form fields validation?
rodrigo.bento Mar 8, 2010 5:30 AM (in response to rodrigo.bento)Sergio, thanks for the reply and the example.
I tried your example and it worked here.
You were correct, I do not like showing a message like this to the user: j_id62:title: Validation Error: Value is required.
Now my bundle message for not empty items is correctly displayed on the screen. But doing this, strangely the messages for other validations like @Length started to work too. Do you know why is it happening? When using requiredMessage somehow JSF started looking for the messages in the model?
Could you point me some link that explains that in detail?
Thanks for your time.
Rodrigo -
3. Re: How to currently achieve Seam 2.2.0GA DRY form fields validation?
ssamayoagt Mar 8, 2010 4:51 PM (in response to rodrigo.bento)Did you had "ajax support" before using the code I give to you?
By the way, you can customize the JSF messages this ways:
1. Override javax.faces.component.* keys in "messages.properties", for example:
javax.faces.component.UIInput.REQUIRED=Por favor ingrese un valor, no puede dejarlo en blanco
2. Add "label" attribute to your inputText components like the example I give to you. This will avoid the <parent component id>:<component id>:<message> like the one you show as example.
3. Hard code the message in "requiredMessage" attribute.
Regards. -
4. Re: How to currently achieve Seam 2.2.0GA DRY form fields validation?
rodrigo.bento Mar 8, 2010 9:19 PM (in response to rodrigo.bento)Yes, I had ajax support enabled. Now I'm creating a template like your '/inc/edit.xhtml'.
Well, it seems this subject will be easier to implement in Seam 3, with some improvements in JSF layer.
Thanks for the hints, it's working now.
Regards,
Rodrigo
-
5. Re: How to currently achieve Seam 2.2.0GA DRY form fields validation?
ssamayoagt Mar 9, 2010 2:51 PM (in response to rodrigo.bento)You are wellcome.
BTW,edit.xhtml
is part of seam templates.
Regards.