File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes <f: attribute > value from  a resource bundle Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "<f: attribute > value from  a resource bundle" Watch "<f: attribute > value from  a resource bundle" New topic
Author

<f: attribute > value from a resource bundle

Rajesh Unnithan
Greenhorn

Joined: Feb 20, 2009
Posts: 22
Hi

I have a jsf application deployed in my jboss5.0.0GA server.

In my jsf page I have the following

<f:validator validatorId="regExpValidator"/>
<f:attribute name="regularExpr" value="[0-9a-zA-Z \t]*"/>
<f:attribute name="regExErrMssg" value="#{bundle.ACCOUNT_NAME_FORMAT_ERROR_MESSAGE}"/>

If the validation fails I will display the error message from the regExErrMssg in my validator class.
When I am trying to get the value for regExErrMssg in my validator class using component.getAttributes().get("regExErrMssg");

I am getting it as null. where as when I am trying to get the same for regularExpr I am getting the value.

Only difference between these 2 are in regularExpr I am giving the value directly where as in regExErrMssg I am trying to get the message from a resource bundle.

What could be the issue ? Any info would be really helpful.

Thanks in advance.

Regards
Hari
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
The bundle is only "evaluatable" during render response.
Change your validator so that it obtains the message from the bundly directly. You can use java.util.ResourceBundle API for this. In the f:attribute you can if necessary just pass the bundle key as string.


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
Rajesh Unnithan
Greenhorn

Joined: Feb 20, 2009
Posts: 22
Hi Scholtz

Thanks for the replay.

I tried to retrieve the value using the resource bundle API & it worked.

Appreciate your help

Regards
Harikrishnan
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <f: attribute > value from a resource bundle
 
Similar Threads
unalbe to pass attribute values to validator
Re-Render Problem after ValidationException
Custom ResourceBundle class?...
Problem with f:validator & f:attribute - EL does not evalute in f:attribute
Setting dynamic value in <f:attribute