Java Reference
In-Depth Information
The first thing we did was to add an instance variable of type
CustomerFacadeLocal
and decorate it with the
@EJB
annotation.
CustomerFacadeLocal
is the local interface
for the
CustomerFacade
stateless session bean we generated in the previous section.
The
@EJB
annotation allows an instance of a class of type
CustomerFacadeLocal
to
be injected into our managed bean at runtime, freeing us from having to do a JNDI
lookup to initialize this variable.
Next we added a private instance variable that will hold the array of customer
objects, which will be used to populate the table. Then we implemented a getter
method for this variable.
The
java.util.List
interface provides a method to convert the list
to an array. This method takes a single parameter which is an array of
the type we wish the returned array to have. We are taking advantage
of this method to simplify the conversion from the list returned by the
findAll()
method in the session bean to an array of
Customer
objects.
Populating the Table
At this point we are ready to bind our array of customers to the table. In order to do
this, we simply need to right-click on the table in either the design window or the
navigator window and select
Bind to Data
. In the resulting window, we then need to
select the
customerArray
property in the drop-down box labeled
Get Data From.