You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Stagger Lee <st...@seznam.cz> on 2003/12/04 15:51:50 UTC

Is Velocity really a convenient replacement for JavaServer Pages?

Lets suppose, I want to create an use case named 'View Diary'. Its task will be to display a table of times and tasks for one day. Something like this

12/02/2003
----------
8 : 00 wake up
9 : 00
..
12: 00 lunch

To be able to switch to another day's tasklist, I want to display also a small calendar for one month, that will make it possible. The calendar should look like the one from the MS Windows, when you double click on the taskbar's watch. To be able to create this calendar, I need to know at least how many days does the selected month have and what day of week is on the first of the month.

THE QUESTION IS: To which tier belongs obtaining of this two values? 

When I have done this using Struts + JSP as a presentation layer technology, I thought it's pretty obvious, that it belongs in the presentation tier and I used Custom Tags and GregorianCalendar class to obtain that values.
Now, when I use Velocity instead of JSP, I'm not that sure about it. Should I move it to the Action class instead? The only solution I see, is to create a Velocity Tool to get those two values and than Velocimacro to generate the calendar. This solution unfortunately seems to me to be as ugly as moving it out of the presentation tier to an Action class.
How would you solve this problem?

Thanks,
    Stagger

____________________________________________________________
PROJEDTE ZIMOU V POHODE - SkodaFabia se zimním paketem Bernardyn s vybavou v hodnote 50 000 Kc! http://ad2.seznam.cz/redir.cgi?instance=67112%26url=http://www.skoda-auto.cz/action/FabiaBernardyn/ 


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Is Velocity really a convenient replacement for JavaServer Pages?

Posted by Daniel Graham <da...@gr8.tv>.
Really this is data-input isn't it? It's not about the model, or about 
the data/presentation layer .. it's about how you capture a data entry 
of a "date" on an HTML page.

If there was (say) a standard HTML form-element for "dates" then you'd
easily be able to do this. As it happens you are restricted to select 
boxes and so on .. so no easy data entry ..

I personally would use a JavaScript calendar for this.

	http://www.totallysmartit.com/examples.asp

Is nice and simple, and saves you worrying about the input.

HTH

Danny.

Stagger Lee wrote:

> Lets suppose, I want to create an use case named 'View Diary'. Its task will be to display a table of times and tasks for one day. Something like this
> 
> 12/02/2003
> ----------
> 8 : 00 wake up
> 9 : 00
> ..
> 12: 00 lunch
> 
> To be able to switch to another day's tasklist, I want to display also a small calendar for one month, that will make it possible. The calendar should look like the one from the MS Windows, when you double click on the taskbar's watch. To be able to create this calendar, I need to know at least how many days does the selected month have and what day of week is on the first of the month.
> 
> THE QUESTION IS: To which tier belongs obtaining of this two values? 
> 
> When I have done this using Struts + JSP as a presentation layer technology, I thought it's pretty obvious, that it belongs in the presentation tier and I used Custom Tags and GregorianCalendar class to obtain that values.
> Now, when I use Velocity instead of JSP, I'm not that sure about it. Should I move it to the Action class instead? The only solution I see, is to create a Velocity Tool to get those two values and than Velocimacro to generate the calendar. This solution unfortunately seems to me to be as ugly as moving it out of the presentation tier to an Action class.
> How would you solve this problem?
> 
> Thanks,
>     Stagger
> 
> ____________________________________________________________
> PROJEDTE ZIMOU V POHODE - SkodaFabia se zimním paketem Bernardyn s vybavou v hodnote 50 000 Kc! http://ad2.seznam.cz/redir.cgi?instance=67112%26url=http://www.skoda-auto.cz/action/FabiaBernardyn/ 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 

-- 
Dr Daniel Graham
Product Strategy Manager
Video and Image Coding Specialists
daniel.graham@videocoding.com
http://www.videocoding.com
Tel : [+44|0] 870 241 4618

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Is Velocity really a convenient replacement for JavaServer Pages?

Posted by Ted Husted <hu...@apache.org>.
I just don't understand the question.

Neither Velocity nor JSP nor JSTL nor anything else you can name "obtain 
  the values". They render HTML forms so that the client can submit the 
values to another resource. In a MVC world, that other resource is a 
servlet or something like a Struts Acstion.

To display a convenient set of values for the user to select, I'd 
typically use a JavaScript calendar that would work the same regardless. 
The one I usually use renders the day, month, and year as separate input 
parameters. Then, yes, I'd do whatever other calculations that were 
needed server-side (in a Struts Action or equivalent). But, I'd base the 
input on a common set of parameters, like month, day, year.

In this way, different pages can present different types of menu but all 
submit a common set of parameters to a single action. One page might use 
buttons, another a calendar, a third plain-text input.

 From what you've said, JSP has started to lead you down the wrong path. 
The business logic of extracting a week and a weekday are being mixed 
into the presentation code (the Custom Tag). You're expecting that 
another technology will help you do the wrong thing, and that Velocity 
doesn't do.

If the question is "where can I generate complex markup", then, yeah, 
the answer is use a Velocimacro or some type of tool or other JavaBean 
in context. But, in that case, the separation between business logic and 
markup remains clear. You aren't tempted to "finish the job" by mixing 
business logic with markup.

One other thing to remember is that England is not a replacement for 
Australia. :) Templating technologies like Velocity are much older than 
most other offerings. Velocity is not trying to be a replacement for 
anything. It's a templating technology that does what templating 
technologies do. And, in my experience, templating technologies do what 
we need a presentation technology to do.

HTH, Ted.


Stagger Lee wrote:
> Lets suppose, I want to create an use case named 'View Diary'. Its task will be to display a table of times and tasks for one day. Something like this
> 
> 12/02/2003
> ----------
> 8 : 00 wake up
> 9 : 00
> ..
> 12: 00 lunch
> 
> To be able to switch to another day's tasklist, I want to display also a small calendar for one month, that will make it possible. The calendar should look like the one from the MS Windows, when you double click on the taskbar's watch. To be able to create this calendar, I need to know at least how many days does the selected month have and what day of week is on the first of the month.
> 
> THE QUESTION IS: To which tier belongs obtaining of this two values? 
> 
> When I have done this using Struts + JSP as a presentation layer technology, I thought it's pretty obvious, that it belongs in the presentation tier and I used Custom Tags and GregorianCalendar class to obtain that values.
> Now, when I use Velocity instead of JSP, I'm not that sure about it. Should I move it to the Action class instead? The only solution I see, is to create a Velocity Tool to get those two values and than Velocimacro to generate the calendar. This solution unfortunately seems to me to be as ugly as moving it out of the presentation tier to an Action class.
> How would you solve this problem?
> 
> Thanks,
>     Stagger




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Is Velocity really a convenient replacement for JavaServer Pages?

Posted by Stagger Lee <st...@seznam.cz>.
> There's no reason why you can't have Java utility or helper classes be part of your presentation layer...

I fully agree with this, but in this case it seems to me to be a bit clumsy to create a special velocity tool, just to get this two "stupid" values.

> but in a way, shouldn't that info be part of your model? it has to do with your data natively more than just how the data is presented to the user...

In this point I disagree. Lets say I would like to add support for PDA, where will be not enough space to display the calender and I replace it just with "previous day" and "following day" links. Now I don't really need those two values. The functionality of the use case remains untouched, just the way it displays changes.

I think that in some cases it could be useful to have something like jsp's custom tags in Velocity, where you could profit from full power of the Java libraries. This calendar problem isn't probably the best example, but I hope it helps to outline what I mean.

Thanks,
Stag

==================================================
> There's no reason why you can't have Java utility or helper classes be  
> part of your presentation layer... but in a way, shouldn't that info be  
> part of your model? it has to do with your data natively more than just  
> how the data is presented to the user...
> 
> Michael
> 
> On Dec 4, 2003, at 9:51 AM, Stagger Lee wrote:
> 
> > Lets suppose, I want to create an use case named 'View Diary'. Its  
> > task will be to display a table of times and tasks for one day.  
> > Something like this
> >
> > 12/02/2003
> > ----------
> > 8 : 00 wake up
> > 9 : 00
> > ..
> > 12: 00 lunch
> >
> > To be able to switch to another day's tasklist, I want to display also  
> > a small calendar for one month, that will make it possible. The  
> > calendar should look like the one from the MS Windows, when you double  
> > click on the taskbar's watch. To be able to create this calendar, I  
> > need to know at least how many days does the selected month have and  
> > what day of week is on the first of the month.
> >
> > THE QUESTION IS: To which tier belongs obtaining of this two values?
> >
> > When I have done this using Struts + JSP as a presentation layer  
> > technology, I thought it's pretty obvious, that it belongs in the  
> > presentation tier and I used Custom Tags and GregorianCalendar class  
> > to obtain that values.
> > Now, when I use Velocity instead of JSP, I'm not that sure about it.  
> > Should I move it to the Action class instead? The only solution I see,  
> > is to create a Velocity Tool to get those two values and than  
> > Velocimacro to generate the calendar. This solution unfortunately  
> > seems to me to be as ugly as moving it out of the presentation tier to  
> > an Action class.
> > How would you solve this problem?
> >
> > Thanks,
> >     Stagger
> >
> > ____________________________________________________________
> > PROJEDTE ZIMOU V POHODE - SkodaFabia se zimním paketem Bernardyn s  
> > vybavou v hodnote 50 000 Kc!  
> > http://ad2.seznam.cz/redir.cgi?instance=67112%26url=http://www.skoda- 
> > auto.cz/action/FabiaBernardyn/
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 

____________________________________________________________
NOKIA 3100 již od 2977 Kč.  Dost dobrý důvod dát svému starému telefonu kopačky! www.oskar.cz
http://ad2.seznam.cz/redir.cgi?instance=64997%26url=http://www.oskarmobil.cz/handsets/index.php

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Is Velocity really a convenient replacement for JavaServer Pages?

Posted by Michael Della Bitta <md...@columbia.edu>.
On Dec 4, 2003, at 1:27 PM, Stagger Lee wrote:

>> There's no reason why you can't have Java utility or helper classes 
>> be part of your presentation layer...
>
> I fully agree with this, but in this case it seems to me to be a bit 
> clumsy to create a special velocity tool, just to get this two 
> "stupid" values.

well, there are some convenient classes for dealing with calendars and 
dates in the java.util package.. if you want to roll your own, there's 
no reason why you have to conform to the velocity tool api; just create 
a class with methods that return those two values and throw it in your 
context.

>
>> but in a way, shouldn't that info be part of your model? it has to do 
>> with your data natively more than just how the data is presented to 
>> the user...
>
> In this point I disagree. Lets say I would like to add support for 
> PDA, where will be not enough space to display the calender and I 
> replace it just with "previous day" and "following day" links. Now I 
> don't really need those two values. The functionality of the use case 
> remains untouched, just the way it displays changes.

just because a view doesn't need part of a model doesn't mean it's not 
part of the model. the way that specific days are grouped into months 
is part of modeling how dates work. but it might be overblown to 
implement this in your model for your purposes.

michael


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Is Velocity really a convenient replacement for JavaServer Pages?

Posted by Stagger Lee <st...@seznam.cz>.
> There's no reason why you can't have Java utility or helper classes be part of your presentation layer...

I fully agree with this, but in this case it seems to me to be a bit clumsy to create a special velocity tool, just to get this two "stupid" values.

> but in a way, shouldn't that info be part of your model? it has to do with your data natively more than just how the data is presented to the user...

In this point I disagree. Lets say I would like to add support for PDA, where will be not enough space to display the calender and I replace it just with "previous day" and "following day" links. Now I don't really need those two values. The functionality of the use case remains untouched, just the way it displays changes.

I think that in some cases it could be useful to have something like jsp's custom tags in Velocity, where you could profit from full power of the Java libraries. This calendar problem isn't probably the best example, but I hope it helps to outline what I mean.

Thanks,
  Stag

==================================================
> There's no reason why you can't have Java utility or helper classes be  
> part of your presentation layer... but in a way, shouldn't that info be  
> part of your model? it has to do with your data natively more than just  
> how the data is presented to the user...
> 
> Michael
> 
> On Dec 4, 2003, at 9:51 AM, Stagger Lee wrote:
> 
> > Lets suppose, I want to create an use case named 'View Diary'. Its  
> > task will be to display a table of times and tasks for one day.  
> > Something like this
> >
> > 12/02/2003
> > ----------
> > 8 : 00 wake up
> > 9 : 00
> > ..
> > 12: 00 lunch
> >
> > To be able to switch to another day's tasklist, I want to display also  
> > a small calendar for one month, that will make it possible. The  
> > calendar should look like the one from the MS Windows, when you double  
> > click on the taskbar's watch. To be able to create this calendar, I  
> > need to know at least how many days does the selected month have and  
> > what day of week is on the first of the month.
> >
> > THE QUESTION IS: To which tier belongs obtaining of this two values?
> >
> > When I have done this using Struts + JSP as a presentation layer  
> > technology, I thought it's pretty obvious, that it belongs in the  
> > presentation tier and I used Custom Tags and GregorianCalendar class  
> > to obtain that values.
> > Now, when I use Velocity instead of JSP, I'm not that sure about it.  
> > Should I move it to the Action class instead? The only solution I see,  
> > is to create a Velocity Tool to get those two values and than  
> > Velocimacro to generate the calendar. This solution unfortunately  
> > seems to me to be as ugly as moving it out of the presentation tier to  
> > an Action class.
> > How would you solve this problem?
> >
> > Thanks,
> >     Stagger
> >
> > ____________________________________________________________
> > PROJEDTE ZIMOU V POHODE - SkodaFabia se zimním paketem Bernardyn s  
> > vybavou v hodnote 50 000 Kc!  
> > http://ad2.seznam.cz/redir.cgi?instance=67112%26url=http://www.skoda- 
> > auto.cz/action/FabiaBernardyn/
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 

____________________________________________________________
Eurotel Data Nonstop  - neomezený přístup na internet za 649,- (s DPH 681,45)  Kč měsíčně! http://ad2.seznam.cz/redir.cgi?instance=67071%26url=http://www.eurotel.cz/site/cz/servicesAndTariffs/specialOffer.html?list=34995


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Is Velocity really a convenient replacement for JavaServer Pages?

Posted by Michael Della Bitta <md...@columbia.edu>.
There's no reason why you can't have Java utility or helper classes be  
part of your presentation layer... but in a way, shouldn't that info be  
part of your model? it has to do with your data natively more than just  
how the data is presented to the user...

Michael

On Dec 4, 2003, at 9:51 AM, Stagger Lee wrote:

> Lets suppose, I want to create an use case named 'View Diary'. Its  
> task will be to display a table of times and tasks for one day.  
> Something like this
>
> 12/02/2003
> ----------
> 8 : 00 wake up
> 9 : 00
> ..
> 12: 00 lunch
>
> To be able to switch to another day's tasklist, I want to display also  
> a small calendar for one month, that will make it possible. The  
> calendar should look like the one from the MS Windows, when you double  
> click on the taskbar's watch. To be able to create this calendar, I  
> need to know at least how many days does the selected month have and  
> what day of week is on the first of the month.
>
> THE QUESTION IS: To which tier belongs obtaining of this two values?
>
> When I have done this using Struts + JSP as a presentation layer  
> technology, I thought it's pretty obvious, that it belongs in the  
> presentation tier and I used Custom Tags and GregorianCalendar class  
> to obtain that values.
> Now, when I use Velocity instead of JSP, I'm not that sure about it.  
> Should I move it to the Action class instead? The only solution I see,  
> is to create a Velocity Tool to get those two values and than  
> Velocimacro to generate the calendar. This solution unfortunately  
> seems to me to be as ugly as moving it out of the presentation tier to  
> an Action class.
> How would you solve this problem?
>
> Thanks,
>     Stagger
>
> ____________________________________________________________
> PROJEDTE ZIMOU V POHODE - SkodaFabia se zimním paketem Bernardyn s  
> vybavou v hodnote 50 000 Kc!  
> http://ad2.seznam.cz/redir.cgi?instance=67112%26url=http://www.skoda- 
> auto.cz/action/FabiaBernardyn/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org