Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Managed-Bean Data"

m
 
(Direct Entries)
Line 31: Line 31:
 
<pre>
 
<pre>
 
   #{myBean.size}
 
   #{myBean.size}
 +
</pre>
 +
 +
or this
 +
 +
<pre>
 +
  #{myBean['size']}
 
</pre>
 
</pre>
  
Line 39: Line 45:
 
   <map-entries>
 
   <map-entries>
 
       <key-class>java.lang.String</key-class>
 
       <key-class>java.lang.String</key-class>
       <value-class>java.l
+
       <value-class>java.lang.String</value-class>
 +
      <map-entry>
 +
          <key>color</key>
 +
          <value>blue</key>
 +
      </map-entry>
 +
    ...
 +
</pre>
  
 +
In this case we can further validate the type of an expression such as:
 +
 +
<pre>
 +
  #{bean.color}
 
</pre>
 
</pre>
 +
 +
as a String type.
 +
 +
 +
== Property Values ==

Revision as of 13:34, 4 October 2006

Background

Managed bean data allows a JSF application configuration file to set values on managed beans automatically when they are placed in scope. There are two types of managed-bean data: direct entries and managed properties.

Direct Entries

If a managed bean implements the Map or List interface, then managed-bean data can be configured directly on the bean itself. Consider the following snippet of application configuration XML for a managed bean whose class implements Map:

   <managed-bean>
      <managed-bean-name>myBean</managed-bean-name>
      ...
      <map-entries>
         <map-entry>
            <key>size</key>
            <value>10</value>
         </map-entry>

         <map-entry>
            <key>color</key>
            <value>blue</value>
         </map-entry>
      </map-entries>
      ...
   </managed-bean>

Instances of the bean can referenced in EL like this:

   #{myBean.size}

or this

   #{myBean['size']}

JSF EL tooling will add support for these types of properties. There is also an option to specify the type of either the key or the value or both:

   ...
   <map-entries>
      <key-class>java.lang.String</key-class>
      <value-class>java.lang.String</value-class>
      <map-entry>
          <key>color</key>
          <value>blue</key>
      </map-entry>
    ...

In this case we can further validate the type of an expression such as:

   #{bean.color}

as a String type.


Property Values

Back to the top