[jboss-user] [JBoss Seam] - Interpolator: FacesMessages from resource bundle with parame

mars1412 do-not-reply at jboss.com
Tue Oct 30 09:55:13 EDT 2007


short explanation:

the registration.success string in the resource bundle is:
registration.success={0} has been registered sucessfully

in my java file, I just want to add a faces massage like this:
facesMessages.add("#{messages['registration.success']}", "#{webUser.name}");

but this will render to:
{0} has been registered sucessfully

as you can see the parameter {0} has not been replaced with the given parameter

so how would you make seam replace the parameter as expected?

a workaround would of course be, to include the parameter #{webUser.name} directly in the .properties file, like:
anonymous wrote : registration.success=#{webUser.name} has been registered sucessfully
and to omit the parameter when calling facesMessages.add:
facesMessages.add("#{messages['registration.success']}");
this will of course work, but I do not want to use this, because:
 * I don't think it's good practice to inlcude buissnes intelligence in my resource files, because:
  | 
  |   |   *  I will have to teach the translators another syntax exception
  |   |   * if I will ever rename the class of class member, I will probably forget to adopt the .properties file
  |   | 
  | *  I cannot re-use the same message. e.g. if I had another registration for customers, I would need another translation: e.g.
  | anonymous wrote : registration.success.customer=#{customer.name} has been registered sucessfully
  | 

thanks in advance

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100271#4100271

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100271



More information about the jboss-user mailing list