Re: ArrayLists, Actions and <logic:iterate>

Vic Cekvencih <[email protected]> Mon, 21 Jul 2003 12:35:52 -0400
Newsgroups gmane.comp.java.mvc.devel
Organization baseBeans Engineering
Message-ID <[email protected]>
One nice things about MVC programming is that it is modular, so it is 
easy to unit test (not the entire thing, but just one part) just the 
beans for example.

If a bean has 2 different DAO, each returning a collection, you can just 
append 2 collections to the same bean.

Then, to make it KISS, you can unit test the bean. For example write a 
servlet that just does:
Bean b = new Bean()
b.populate()
Collection c = b.getCollection()// pseudo code
out.println(c)

This will emit the collection, and you only unit test the bean.

Once the bean works outside of Struts, you can integrate. So try doing 
it modular.

(every complex problem can be broken down into several simpler problems)

hth,
.V

Matthew Thebert wrote:
> I am doing a section of the application that involves user 
> administration.  I have one action that works correctly that displays 
> all the users that are registered.  That is the only thing this part 
> does is query the database and display all of the users.
> 
>  
> 
> I have another action that searches for a single user via database query 
> and displays the users profile on the page where it can be edited or 
> changed, that works.  But also I want to have a second query for that 
> page, which displays any classes the user might be enrolled in.  I have 
> to do 2 result sets for a number of reasons so the solution isn’t 
> modifying my query.
> 
>  
> 
> The problem I am having is that the first query with the user data shows 
> up fine, but when I iterate through the arraylist for the 2nd query, 
> only 1 row is displayed, when there should be more.
> 
>  
> 
> Both queries are done in the Action, stored in an ArrayList and returned 
> to the view using the request and displayed using the <logic:iterate> tags.
> 
>  
> 
> If I got NO results returned, I'd figure that I was way off, but I am 
> actually getting one row back.  This is the part that is killing me is 
> only being able to display one row (the first result put in the 
> ArrayList).  That and the fact that I know I can use this method 
> correctly since I have one previous action that I can display all of the 
> users correctly on a view using this same method with an arraylist and 
> iterate tages.
> 
>  
> 
> I can provide code snippets if needed.  I appreciate the help.  I have 
> tried about everything I can think of this past week and am at wits end!
> 
>  
> 
> Thanks in advance for the help!
> 
>  
> 
> Matt Thebert
> 
>  
> 

-- 
Vic Cekvenich,
Struts Instructor,
1-800-917-JAVA

Advanced <a href ="baseBeans.com">Struts Training</a>, mentoring and 
project recovery in North East.
Open Source <a href ="baseBeans.com">Portal Content Management</a> 
basicPortal  software.