struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vic <>
Subject Re: which tier?
Date Sun, 13 Feb 2005 15:50:34 GMT
You need to write object/class that you can unit test outside of 
Stuts.Lets call it
It would call a DAO (such as iBatis, there are tutorials to iBatis all 
over the place, try Rick Reuman (spelling?)).
That would call SQL.

So in Calc you might have private methods:
private long getStartTime(Interger userID);
private long getEndTime(Integer userID);
or just
private Map  getTimes(Integer userID) to get all the times at once.
Unit test that.

Then write method to compute. Unit test.
Then place in Struts.

(But before I would implement above, I would create a JSP /Struts mock 
up with fake data displayed (no db, just hard code), just to get the 
look and feel right, navigation, etc. That is allways the hard part but 
it ensurse sucess. Once you know that's what you want, then do above impl.)


Robin Ericsson wrote:

> Hi,
> I'm doing a small timesheet app with struts using PostgreSQL as 
> backend and as I'm new to struts and also somewhat new to Java I'm 
> trying to decide where I should put the logic.
> Each row contains a day, start time, end time and break time. Now, I 
> want the business layer to calculate the duration between start time, 
> end time minus the break.
> Should this be placed in the SQL-side using a special query, or should 
> I do this in Java? If so, is it possible to calculate durations and 
> intervals in Java without using third-party packages?
> I know the question is pretty vague but I'm on thin ice at the moment 
> and not really knowing what I'm doing :)
> regards,
>     Robin

Forums, Boards, Blogs and News in RiA <>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message