Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Best place to put formatting code?  RSS feed

 
Joe Gliniecki
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing some volunteer work for the local school district. They have a database that holds video programming that can be broadcast into classrooms. Each video has a length that is stored in the database in seconds and is represented in the domain object as an Integer.

On the presentation tier (JSP), we sometimes need to show this value as hh:mm:ss instead of just seconds. Also, to edit the length of a video, the users would like separate drop downs for hours, minutes, seconds.

My question is where would be the best place to do this formatting? It would be easy enough in the domain object, but converting seconds to a hh:mm:ss string seems like it should be in the presentation tier.


Would another option be a custom tag? Are there any other options? What have you all done for things like this?

Thanks,
Joe
 
Pat Farrell
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For big projects, you want all presentation in the presentation layer, separate from the domain logic. This lets you use common domain logic and vary the LOCALE and even language.

This is a standard split, and very useful.

But for limited use and small projects, you are allowed to cheat.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be aware that small projects have a tendency to turn into large projects. I always use proper structure regardless of the size of an app in case it turns into Frankenstein's Monster.
 
Joe Gliniecki
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would a custom tag be the typical mechanism to do this on the presentation tier? The school district is using a home grown basic front controller to handle presentation.
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSTL has formatting tags that you can use.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!