Mind taking this discussion over to the user list?  Thanks Rob!

On Fri, 2005-07-15 at 08:17 -0700, Rob Ratner wrote:
> Hello Ms. Falco, I don't mean to be ignorant but I am new to Velocity. May I 
> ask a couple probably stupid questions.  ParserCommons is a Java class part 
> of the Velocity API? Where does it sit on the webserver and where does 
> ParserDateUtils.java sit as a .class/jar file so it will communicate with 
> with the velocity template/*.vm file.  My web application sits on WebLogic 
> 8.1 and has the current structure when deployed.
>  
> appname/templates/.....*.vm
> appname/WEB-INF/lib/velocity-1.1.jar
> appname/WEB-INF/lib/app.jar
>  
> velocity-1.1.jar contains the following apache packages:
>  
> org.apache.velocity.util.*
> org.apache.velocity.test.*
> org.apache.velocity.runtime.parser.*
> org.apache.velocity.runtime.*
> org.apache.velocity.io.*
> org.apache.velocity.exception.*
> org.apache.velocity.context.*
> org.apache.velocity.app.*
> org.apache.velocity.anakia.*
> org.apache.velocity.util.introspection.*
> org.apache.commons.collections.*
> org.apache.log.*
>  
> 
> The app.jar just contain the business logic api.
>  
> Any comments/suggestions would be tremendously appreciated.
>  
> Thanks
> Rob
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Llewellyn Falco <[EMAIL PROTECTED]> wrote:
> yeah, here's a utility class, i usually place a accessor method to it in my 
> ParserCommons.
> 
>  #foreach($month in $commons.getDateUtils().getMonths()) 
> $month.getDisplayText()#end
>  #foreach($day in $commons.getDateUtils().getDaysOfMonth()) 
> $day.getDisplayText()#end
>  #foreach($year in $commons.getDateUtils().getNextXYears(10)) 
> $year.getDisplayText()#end 
> package com.spun.util.velocity;
> 
> import java.util.Calendar;
> import java.util.GregorianCalendar;
> import com.spun.util.StringUtils;
> 
> /***********************************************************************/
> public class ParserDateUtils
> {
> public static final ParserDateUtils INSTANCE = new ParserDateUtils();
> public static Month[] getMonths()
> {
> return new Month[]{new Month("00", "------"), new Month("01", "Jan (01)"), 
> new Month("02", "Feb (02)"), new Month("03", "Mar (03)"), new Month("04", 
> "Apr (04)"), new Month("05", "May (05)"), new Month("06", "Jun (06)"), new 
> Month("07", "Jul (07)"), new Month("08", "Aug (08)"),
> new Month("09", "Sep (09)"), new Month("10", "Oct (10)"), new Month("11", 
> "Nov (11)"), new Month("12", "Dec (12)")};
> }
> /***********************************************************************/
> public static Day[] getDaysOfMonth()
> {
> Day[] days = new Day[32];
> days[0] = new Day("00", "--");
> for (int i = 1; i <= 31; i++)
> {
> days[i] = new Day(i);
> }
> return days;
> }
> /***********************************************************************/
> public static Year[] getNextXYears(int x)
> {
> Year[] years = new Year[x + 1];
> years[0] = new Year("0000", "----");
> int startingYear = new GregorianCalendar().get(Calendar.YEAR);
> for (int i = 0; i < x; i++)
> {
> years[i + 1] = new Year(startingYear + i);
> }
> return years;
> }
> /***********************************************************************/
> /***********************************************************************/
> /***********************************************************************/
> public static class Year extends DateValue
> { 
> /***********************************************************************/
> public String getTwoDigitNumber()
> {
> return getNumber().substring(2);
> }
> public Year(String number, String displayText)
> {
> super(number, displayText);
> }
> /***********************************************************************/
> public Year(int i)
> {
> super("" + i, "" + i);
> }
> 
> }
> /***********************************************************************/
> public static class Day extends DateValue
> {
> public Day(int i)
> {
> super(StringUtils.padNumber(i, 2), "" + i);
> }
> public Day(String number, String displayText)
> {
> super(number, displayText);
> } 
> }
> /***********************************************************************/
> public static class Month extends DateValue
> { 
> public Month(String number, String displayText)
> {
> super(number, displayText);
> }
> }
> /***********************************************************************/
> public static class DateValue
> {
> private String number;
> private String displayText;
> /***********************************************************************/
> public boolean isDefault()
> {
> return displayText.startsWith("--");
> }
> /***********************************************************************/
> public DateValue(String number, String displayText)
> {
> this.number= number;
> this.displayText = displayText;
> }
> /***********************************************************************/
> public String getNumber()
> {
> return number;
> }
> /***********************************************************************/
> public String getDisplayText()
> {
> return displayText;
> }
> /***********************************************************************/
> }
> }
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to