Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to display a message resource value using an argument via <h:outputText>

 
Daniel Haupt
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I'm using <h:outputText> to display messages from my resource bundles, e.g. in the following way:



My question now is: I have a message in my bundle using an argument, something like



How can I replace the {0}-Argument with a value using <h:outputText>?

Kind regards and thanks for your help

Daniel
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. You should be using h:outputFormat instead. The parameters are to be added using f:param.

Consult the JSF TLD documentation for details.
 
Daniel Haupt
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Can you give a short example of how to use or link the corresponding spot in the tld documentation??

f:param value will be the value I want to replace the {0} with. But how do I have to name the parameter?

Kind regards

Daniel
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don´t need to name it. Just place f:param tags consecutively in the same order as the placeholders of the message.
 
Daniel Haupt
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mmh... sorry. It doesn't works for me...

Here's my code snippet...



I only got "Attachments for milestone {0}" rendered in my browser.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That´s not a standard JSF tag. Read the TLDDOC which come along the taglib you seem to prefer over the standard taglib how to use it.
 
Daniel Haupt
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works. It was not supported by the trinidad tag. Standard jsf tag works fine.

Thanks

Daniel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic