This content has been marked as final.
Show 3 replies
-
1. Re: Declaration of seam components
cash1981 Jul 28, 2009 10:36 AM (in response to bbasdeo)I am not sure what you are talking about here, but it is nothing seam specific to create an array or list.
I guess you can create an array like this, however I discourage you from using Arrays and using List instead.
@In(create=true) private CalendarDataModelItem[] calendarDataModelItemImpl;
-
2. Re: Declaration of seam components
jamesjmp Jul 28, 2009 10:53 AM (in response to bbasdeo)I agree with Shervin, it´s better for you to use Java 5 collections.
For instance, if ArrayList suits you:@In(create=true) private ArrayList<CalendarDataModelItem> list = new ArrayList<CalendarDataModelItem>();
-
3. Re: Declaration of seam components
asookazian Jul 29, 2009 8:41 PM (in response to bbasdeo)The only time I use arrays in Seam apps is when I have to.
Example:
List<Object[]> list = entityManager.createQuery("select c, o from Customer c, Order o where o.customer.customerId = c.customerId and o.orderId = :orderId") .setParameter("customerId", customerId) .setParameter("orderId", orderId) .getResultList();
When there is more than one entity in the select clause, the JPA provider returns a Object[].
Otherwise, try to use the following pattern:
List<foo> list = new ArrayList<foo>();
Same thing applies for Sets:
Set<foo> set = new HashSet<foo>();
interface on the left side, concrete implementation on the right side to support polymorphism (e.g. you can swap in a LinkedList for the ArrayList later if required).