• Post Reply Bookmark Topic Watch Topic
  • New Topic

Managed Beans

 
Dennis Hopfer
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The property-value mapping...does it always assume a String as type or does it try to cast the value to whatever type of class the property name matches up against? I ask because I'd like to use this mechanism for other things than strings. For instance, could I reference a custom hashmap (also managed bean) #{myHashMap} as the value field and myHashMap as the name?

<managed-bean>
<managed-bean-name>Bean</managed-bean-name>
<managed-bean-class>roseindia.Bean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>thought_of_the_day</property-name>
<value>It's good to be important but it's more important
to be good.
</value>
</managed-property>
</managed-bean>
 
Max Katz
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use <property-class> to specify the class name.
 
Tim Holloway
Bartender
Posts: 18413
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The actual rendered page is HTML. HTML is text-only (no binary), so one of the things that every object that wants to render on the page (or be input FROM the page) needs is a Converter. The Converter handles the process of converting the object to text (outbound) and to an object (inbound). Note that inbound objects will be constructed from the string, so if you need an original copy, send out a key that can be looked up coming back in and not the value itself.

There are standard converters for the primitives and their wrappers that are invoked automatically. There are several other pre-provided converters additionally, such as the DateTimeConverter. For custom object types it's easy to provide your own. Once you have the proper converter, you can make the get/set property methods work with the raw objects since the converter will have ensured that the argument/return value is in the proper form.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!