aspose file tools*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
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: 3479

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: 16250
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Gaurav Ram
Ranch Hand

Joined: Feb 23, 2008
Posts: 32
Thanks all for replying.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to define managed bean as String in faces-config.xml