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 define managed bean as String in faces-config.xml

 
Gaurav Ram
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have one small confusion, while reading one tutorial i come across one line that Suppose you had a single String stored
under the key clientName in the application scope. You could reference it like this: <h:inputText value="#{testString}"/>


Can you please tell me that how to define managed bean as String in faces-config.xml
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't define a managed bean as a string.
In faces-config.xml file you inform the Managed Bean Creation Facility that you want to create an instance of your bean and to register it under an alias (name).
You can then refer to that name in your views.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18012
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't define a managed bean as a java.lang.String, because a String is an immutable object and has no setter/getter methods. In other words, it fails the basic criteria for being a JavaBean - managed or otherwise.

A simple wrapper bean class that contains a single field of type java.lang.String will work, however.
 
Gaurav Ram
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all for replying.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic