0
votes

I am running into a peculiar problem when I am trying to invoke h:inputText label field value on validation. It only works when I pass a static value to label field. The time I pass a dynamic value to it, it fails to render the label when some validation fails for that field.

<h:inputText id="fullNameField" value="#{newUserFormBean.fullName}"
       **label="${nlsSupport.label_fullName}"** required="true" size="32"  styleClass="required">                        
               <f:validateLength minimum="3" maximum="64"/>
</h:inputText>

If the validation fails for Minimum length, the error message is displayed as:

no label rendered here: must be minimum 3 characters

But when I hard code the label instead of passing a dynamic value to it, it displays a valid validation message, with label name printed on screen.

<h:inputText id="fullNameField" value="#{newUserFormBean.fullName}"
      **label="Full Name"** required="true" size="32" styleClass="required">      
      <f:validateLength minimum="3" maximum="64"/>
     </h:inputText>

Now, if the validation fails for Minimum length, the error message is displayed as:

Full Name: must be minimum 3 characters

I have also looked at the JSF documentation, and it reads that the label accepts expression language expressions. So why is the dynamic value passed not rendering after failure validation?

Also, I need to pass the label dynamically (from Resource bundle), so as to add National Language Feature for different languages. This is the reason which forces me to pass a dynamic value to the label attribute instead of a static field.

Thanks.

1

1 Answers

1
votes

Got the solution.

I was loading the resource bundle in xhtml using

<f:loadBundle basename="com.myproject.i18n.nls" var="nlsSupport" />,

which would cause a problem loading the resource bundle field on Ajax validation. Now I modified it to be implement Ajax support

<a4j:loadBundle basename="com.myproject.i18n.nls" var="nlsSupport" />

and it works now.