a bollocks thats gonna make a lotta sense!
If i forward to july the ist begins on Monday carrys through to friday 5th
then skips Saturday
and starts Monday outputting the 6th,

its wrong effectively,
a well!!

-----Original Message-----
From: John McCosker [mailto:[EMAIL PROTECTED]
Sent: 03 June 2003 18:24
To: CF-Talk
Subject: cfx Calendar from WROX professional 5.0


Greetings,

I have copied the java Calendar from WROX professional CF 5.0 <CFX>
tutorial,
if you do not specify a month the calendar defaults to the current month
like so,

Su  Mo  Tu  We  Th  Fr  Sa
1    2     3    4     5    6   7
7    8     9    10   11  12  13
14  15   16   17   18  19  20
21  22   23   24   25  26  27
28  29   30

backwards / forwards buttons

         ---    ---
        |< |   |> |
         ---    ---

if I forward to July its outputs like this,

Su  Mo  Tu  We  Th  Fr  Sa
      1     2    3     4    5
6    7     8    9     10  11  12
13  14  15   16    17  18  19
20  21  22   23    24  25  26
27  28  29   30    31

infact it just completely mucks up if you go backwards or forwards, it
always gets this month correct though.

Its only a small app but my eyes and head is burning trying see where the
bug lies,

if anyone would like to see if they can spot it I would be very grateful,

JAVA file
-----------------

import com.allaire.cfx.*;
import java.util.*;
import java.text.DateFormatSymbols;

public class CFXCalendar implements CustomTag {
        public void processRequest(Request request, Response response)
                throws Exception
                {
                        if(!request.attributeExists("TEMPLATE"))
                                throw new Exception("The TEMPLATE attribute
is required by the CFX_Calendar tag");
                                
                        String template=request.getAttribute("TEMPLATE");
                        Calendar cal = Calendar.getInstance();
                        
                        int day;
                        int month;
                        int year;
                        
                        if(request.attributeExists("DAY"))
        
day=Integer.parseInt(request.getAttribute("DAY"));
                        else
                                day=cal.get(Calendar.DAY_OF_MONTH);
                        
                        if(request.attributeExists("MONTH"))
        
month=Integer.parseInt(request.getAttribute("MONTH"));
                        else
                                month=cal.get(Calendar.MONTH);
                                
                        if(request.attributeExists("YEAR"))
        
year=Integer.parseInt(request.getAttribute("YEAR"));
                        else
                                year=cal.get(Calendar.YEAR);
                                
                        int today=day;
                        if(day==0)day=1;
                        
                        cal.set(year,month,day);
                        
                        int
daysInMonth=cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                        int
oldMonthDays=cal.get(Calendar.DAY_OF_WEEK)-(day%7);
                        
                        if(oldMonthDays < 0) oldMonthDays +=7;
                        
                        int newMonthDays = (daysInMonth + oldMonthDays) % 7;
                        
                        String[] months = new
DateFormatSymbols().getMonths();
                        response.write("<b>"+months[month]+"
"+Integer.toString(year)+"</b><br>\n");
                        
                        response.write("<table border='0' class='main'>");
        
response.write("<thead><th>Su</th><th>Mo</th><th>Tu</th><th>We</th><th>Th</t
h><th>Fr</th><th>Sa</th></thead>");
                        response.write("<tbody>\n<tr>");
                        
                        for(int i=1; i<oldMonthDays; i++){
                                response.write("<td>&nbsp;</td>");
                        }
                        
                        for(int i=1; i<=daysInMonth; i++){
                                
                                if(((i+oldMonthDays)%7)==1)
                                        response.write("</tr><tr>");
                                
                                if(i==today)
                                        response.write("<td
bgcolor='red'>");
                                else
                                        response.write("<td>");
                                        
                                response.write("<a
href='javascript:CFXCalendar_Submit("+i+")'>");
        
response.write(Integer.toString(i)+"</a></td>");
                        }
                        
                        for(int i=1; i<newMonthDays; i++){
                                response.write("<td>&nbsp;</td>");
                        }
                        
                        response.write("</tr></tbody></table>");
                        
                        response.write("<form name='frmCFXCalendar'
action='"+template+"' method='post'>\n");
                        response.write("<input type='HIDDEN'
name='CFXCalendar_day'>\n");
                        response.write("<input type='HIDDEN'
name='CFXCalendar_month' value='"+months[month]+"'>\n");
                        response.write("<input type='HIDDEN'
name='CFXCalendar_year' value='"+Integer.toString(year)+"'>\n");
                        response.write("</form>\n");
                        response.write("<script language='javascript'>\n");
                        response.write("function
CFXCalendar_Submit(x){\n"+"CFXCalendar_day=document.forms['frmCFXCalendar']"
+".elements['CFXCalendar_day'];\n");
                        response.write("CFXCalendar_day.value=x;\n");
                        response.write("frmCFXCalendar.submit();\n}\n");
                        response.write("</script>\n");
                        
                }
}

JavaCalandar.cfm
----------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
        <title>Untitled</title>
</head>
<style>
        .main{color:#ffffff; font-family:arial, helvetica, sans-serif;
font-size:9px; text-decoration: none;}
</style>

<body bgcolor="#2B475D">
<CFIF ISDEFINED("FORM.ACTION")>
        <CFSET ACTION=FORM.ACTION>
        <CFSET MONTH=FORM.MONTH>
        <CFSET YEAR=FORM.YEAR>
        
        <CFIF ACTION EQ ">">
                <CFSET MONTH=MONTH+1>
                <CFIF MONTH EQ 12>
                        <CFSET MONTH=0>
                        <CFSET YEAR=YEAR+1>
                </CFIF>
        </CFIF>
        
        <CFIF ACTION EQ "<">
                <CFSET MONTH=MONTH-1>
                <CFIF MONTH EQ -1>
                        <CFSET MONTH=11>
                        <CFSET YEAR=YEAR-1>
                </CFIF>
        </CFIF>
        
        <CFIF (MONTH EQ MONTH(NOW())-1) AND (YEAR EQ YEAR(NOW()))>
                <CFSET DAY=DAY(NOW())>
        <CFELSE>
                <CFSET DAY="0">
        </CFIF>
        
        <CFX_Calendar TEMPLATE="calendar.cfm" MONTH=#JavaCast("int",MONTH)#
DAY=#JavaCast("int",DAY)# YEAR=#JavaCast("int",YEAR)#>
<CFELSE>
        <CFSET MONTH=MONTH(NOW())-1>
        <CFSET YEAR=YEAR(NOW())>
        <CFX_Calendar TEMPLATE="calendar.cfm">
</CFIF>
<CFOUTPUT>
        <FORM name="frmNavigate" action="javaCalender.cfm" method="post">
                <INPUT TYPE="HIDDEN" NAME="month" VALUE="#month#">
                <INPUT TYPE="HIDDEN" NAME="year" VALUE="#year#">
                <INPUT TYPE="submit" NAME="action" VALUE="<">
                <INPUT TYPE="submit" NAME="action" VALUE=">">
        </FORM>
</CFOUTPUT>


</body>
</html>

and calender.cfm
-------------------------

<html>
<head><title>java output</title></head>
<body>
You Clicked on:<br>
<CFOUTPUT>
<b>#FORM.CFXCalendar_day# #FORM.CFXCalendar_month#
#FORM.CFXCalendar_year#</b><BR><br>
<a href="#cgi.http_referer#">BACK</a>
</CFOUTPUT>
</body>
</html>






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to