IntelliJ Java IDE
The moose likes JSF and the fly likes How to define managed bean as String in faces-config.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "How to define managed bean as String in faces-config.xml" Watch "How to define managed bean as String in faces-config.xml" New topic
Author

How to define managed bean as String in faces-config.xml

Gaurav Ram
Ranch Hand

Joined: Feb 23, 2008
Posts: 32
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

Joined: Nov 08, 2003
Posts: 3334

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

Joined: Jun 25, 2001
Posts: 12513

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.


One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
Gaurav Ram
Ranch Hand

Joined: Feb 23, 2008
Posts: 32
Thanks all for replying.
 
 
subject: How to define managed bean as String in faces-config.xml
 
Threads others viewed
Invoking Servlet from Managed bean
Error
how to do the global initialization in JSF?
problem with jsf
managing Faces-config in jSF ...please explain.
MyEclipse, The Clear Choice