You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sv...@apache.org on 2004/12/01 21:25:10 UTC
cvs commit: incubator-myfaces/src/components/org/apache/myfaces/custom/calendar HtmlCalendarRenderer.java
svieujot 2004/12/01 12:25:10
Modified: src/components/org/apache/myfaces/component/html/util
ExtensionsFilter.java AddResource.java
webapps/examples/web/inc head.inc
src/components/org/apache/myfaces/custom/calendar
HtmlCalendarRenderer.java
Added: src/components/org/apache/myfaces/custom/calendar/resource/DB
right1.gif left2.gif drop2.gif right2.gif left1.gif
drop1.gif theme.css divider.gif close.gif
src/components/org/apache/myfaces/custom/calendar/resource/WH
divider.gif drop2.gif theme.css drop1.gif left2.gif
left1.gif right2.gif right1.gif close.gif
src/components/org/apache/myfaces/custom/calendar/resource
popcalendar.js jscalendar.html
src/components/org/apache/myfaces/component/html/util
ExtensionsResponseWrapper.java
src/components/org/apache/myfaces/custom/calendar/resource/images
close.gif left2.gif right2.gif right1.gif left1.gif
drop2.gif divider.gif drop1.gif
Removed: webapps/examples/web/jscalendar/jscalendar-DB .cvsignore
webapps/examples/web/jscalendar .cvsignore
webapps/examples/web/jscalendar/images .cvsignore
webapps/examples/web/jscalendar/jscalendar-WH .cvsignore
Log:
Make the Extensions filter support css and image resources.
Convert the popup calendar to use this new filter.
Revision Changes Path
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/DB/right1.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/DB/left2.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/DB/drop2.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/DB/right2.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/DB/left1.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/DB/drop1.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/DB/theme.css
Index: theme.css
===================================================================
/* Default attributes of table container for entire calendar */
.jscalendar-DB-table-style {
font-family:arial;
font-size:11px;
border-width:1;
border-style:solid;
border-color:#a0a0a0;
background-color: #ffffff;
}
/* Default attributes of DIV containing table container for entire calendar.
* You probably don't want to alter this style.
*/
.jscalendar-DB-div-style {
z-index: +999;
position: absolute;
visibility: hidden;
}
/* Default attributes used in calendar title (month and year columns).*/
.jscalendar-DB-title-style {
padding:2px;
font-family:arial;
font-size:11px;
font-weight:bold;
color:#FFFFFF;
}
/* Default attributes used in calendar title background.*/
.jscalendar-DB-title-background-style {
background-color: #0000aa;
}
/* Normal appearance of controls in calendar title. */
/* Note: The right, left and down icons are images, jscalendar-DBich must be edited if you need to change them. */
.jscalendar-DB-title-control-normal-style {
border-style: solid;
border-width: 1px;
border-color: #3366FF;
cursor: pointer;
}
/* Moused-over (selected) appearance of controls in calendar title. */
.jscalendar-DB-title-control-select-style {
border-style: solid;
border-width: 1;
border-color: #88AAFF;
cursor: pointer;
}
/* Default attributes of drop down lists (month and year). */
.jscalendar-DB-dropdown-style {
font-family: arial;
font-size: 11px;
border-width: 1px;
border-style: solid;
border-color: #a0a0a0;
background-color: #FFFFDD;
cursor: pointer;
}
/* Default attributes selected (mouse-over) item in drop down lists (month and year). */
.jscalendar-DB-dropdown-select-style {
background-color: #FFCC99;
}
/* Default attributes unselected (mouse-off) item in drop down lists (month and year). */
.jscalendar-DB-dropdown-normal-style {
background-color: #0;
}
/* Default attributes of calendar body (weekday titles and numbers). */
.jscalendar-DB-body-style {
background-color: #FFFFFF;
font-family: verdana;
font-size: 10px;
}
/* Attributes of current day in calendar body. */
.jscalendar-DB-current-day-style {
color: red;
font-weight: bold;
text-decoration: none;
}
/* Attributes of end-of-week days (Sundays) in calendar body. */
.jscalendar-DB-end-of-weekday-style {
color: #909090;
text-decoration: none;
}
/* Attributes of all other days in calendar body. */
.jscalendar-DB-normal-day-style {
color: black;
text-decoration: none;
}
.jscalendar-DB-would-be-selected-day-style {
background-color: #EEEEEE;
}
/* Attributes of border around selected day in calendar body. */
.jscalendar-DB-selected-day-style {
border-style: solid;
border-width: 1px;
border-color: #a0a0a0;
}
/* Default attributes of designated holidays. */
.jscalendar-DB-holiday-style {
background-color: #FFDDDD;
}
/* Attributes of today display at bottom on calendar */
.jscalendar-DB-today-style {
padding: 0px;
color: black;
background-color: #f0f0f0;
text-align: center;
text-decoration: none;
}
/* Attributes of today display label at bottom on calendar */
.jscalendar-DB-today-lbl-style {
padding: 5px;
text-align: center;
}
/* Attributes of week number division (divider.gif) */
.jscalendar-DB-weeknumber-div-style {
background-color: #d0d0d0;
padding: 0px;
}
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/DB/divider.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/DB/close.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/WH/divider.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/WH/drop2.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/WH/theme.css
Index: theme.css
===================================================================
/* Default attributes of table container for entire calendar */
.jscalendar-WH-table-style {
font-family:arial;
font-size:11px;
border-width:1;
border-style:solid;
border-color:#000000;
color:#000000;
background-color: #ffffff;
}
/* Default attributes of DIV containing table container for entire calendar.
* You probably don't want to alter this style.
*/
.jscalendar-WH-div-style {
z-index: +999;
position: absolute;
visibility: hidden;
}
/* Default attributes used in calendar title (month and year columns).*/
.jscalendar-WH-title-style {
padding:2px;
font-family:arial;
font-size:11px;
font-weight:bold;
color:#000000;
}
/* Default attributes used in calendar title background.*/
.jscalendar-WH-title-background-style {
background-color: #EEEEEE;
}
/* Normal appearance of controls in calendar title. */
/* Note: The right, left and down icons are images, jscalendar-WHich must be edited if you need to change them. */
.jscalendar-WH-title-control-normal-style {
border-style: solid;
border-width: 1px;
border-color: #CCCCCC;
cursor: pointer;
}
/* Moused-over (selected) appearance of controls in calendar title. */
.jscalendar-WH-title-control-select-style {
border-style: solid;
border-width: 1;
border-color: #FFFFFF;
cursor: pointer;
}
/* Default attributes of drop down lists (month and year). */
.jscalendar-WH-dropdown-style {
font-family: arial;
font-size: 11px;
border-width: 1px;
border-style: solid;
border-color: #DDDDDD;
background-color: #EEEEEE;
cursor: pointer;
}
/* Default attributes selected (mouse-over) item in drop down lists (month and year). */
.jscalendar-WH-dropdown-select-style {
background-color: #F3F3F3;
}
/* Default attributes unselected (mouse-off) item in drop down lists (month and year). */
.jscalendar-WH-dropdown-normal-style {
background-color: #0;
}
/* Default attributes of calendar body (weekday titles and numbers). */
.jscalendar-WH-body-style {
background-color: #FFFFFF;
font-family: verdana;
font-size: 10px;
}
/* Attributes of current day in calendar body. */
.jscalendar-WH-current-day-style {
color: red;
font-weight: bold;
text-decoration: none;
}
/* Attributes of end-of-week days (Sundays) in calendar body. */
.jscalendar-WH-end-of-weekday-style {
color: #909090;
text-decoration: none;
}
/* Attributes of all other days in calendar body. */
.jscalendar-WH-normal-day-style {
color: black;
text-decoration: none;
}
.jscalendar-WH-would-be-selected-day-style {
background-color: #EEEEEE;
}
/* Attributes of border around selected day in calendar body. */
.jscalendar-WH-selected-day-style {
border-style: solid;
border-width: 1px;
border-color: #a0a0a0;
}
/* Default attributes of designated holidays. */
.jscalendar-WH-holiday-style {
background-color: #FFDDDD;
}
/* Attributes of today display at bottom on calendar */
.jscalendar-WH-today-style {
padding: 0px;
color: black;
background-color: #f0f0f0;
text-align: center;
text-decoration: none;
}
/* Attributes of today display label at bottom on calendar */
.jscalendar-WH-today-lbl-style {
padding: 5px;
text-align: center;
}
/* Attributes of week number division (divider.gif) */
.jscalendar-WH-weeknumber-div-style {
background-color: #d0d0d0;
padding: 0px;
}
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/WH/drop1.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/WH/left2.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/WH/left1.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/WH/right2.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/WH/right1.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/WH/close.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/popcalendar.js
Index: popcalendar.js
===================================================================
// written by Tan Ling Wee on 2 Dec 2001
// last updated 20 June 2003
// email : fuushikaden@yahoo.com
//
// Modified to use the MyFaces lib resources
var jscalendarFixedX = -1 // x position (-1 if to appear below control)
var jscalendarFixedY = -1 // y position (-1 if to appear below control)
var jscalendarStartAt = 1 // 0 - sunday ; 1 - monday
var jscalendarShowWeekNumber = 1 // 0 - don't show; 1 - show
var jscalendarShowToday = 1 // 0 - don't show; 1 - show
var jscalendarImgDir = "jscalendar/jscalendar-DB/" // directory for images ... e.g. var jscalendarImgDir="/img/"
var jscalendarThemePrefix = "jscalendar-DB"
var jscalendarGotoString = "Go To Current Month"
var jscalendarTodayString = "Today is"
var jscalendarWeekString = "Wk"
var jscalendarScrollLeftMessage = "Click to scroll to previous month. Hold mouse button to scroll automatically."
var jscalendarScrollRightMessage = "Click to scroll to next month. Hold mouse button to scroll automatically."
var jscalendarSelectMonthMessage = "Click to select a month."
var jscalendarSelectYearMessage = "Click to select a year."
var jscalendarSelectDateMessage = "Select [date] as date." // do not replace [date], it will be replaced by date.
var jscalendarCrossobj, jscalendarCrossMonthObj, jscalendarCrossYearObj,
jscalendarMonthSelected, jscalendarYearSelected, jscalendarDateSelected,
jscalendarOmonthSelected, jscalendarOyearSelected, jscalendarOdateSelected,
jscalendarMonthConstructed, jscalendarYearConstructed, jscalendarIntervalID1, jscalendarIntervalID2,
jscalendarTimeoutID1, jscalendarTimeoutID2, jscalendarCtlToPlaceValue, jscalendarCtlNow, jscalendarDateFormat, jscalendarNStartingYear
var jscalendarBPageLoaded=false
var jscalendarIe=document.all
var jscalendarDom=document.getElementById
var jscalendarNs4=document.layers
var jscalendarToday = new Date()
var jscalendarDateNow = jscalendarToday.getDate()
var jscalendarMonthNow = jscalendarToday.getMonth()
var jscalendarYearNow = jscalendarToday.getYear()
var jscalendarImgsrc = new Array("drop1.gif","drop2.gif","left1.gif","left2.gif","right1.gif","right2.gif")
var jscalendarImg = new Array()
var jscalendarBShow = false;
function jscalendarSetImageDirectory(dir){ // For MyFaces only
jscalendarImgDir = dir;
}
/* hides <select> and <applet> objects (for IE only) */
function jscalendarHideElement( elmID, overDiv )
{
if( jscalendarIe )
{
for( i = 0; i < document.all.tags( elmID ).length; i++ )
{
obj = document.all.tags( elmID )[i];
if( !obj || !obj.offsetParent )
{
continue;
}
// Find the element's offsetTop and offsetLeft relative to the BODY tag.
objLeft = obj.offsetLeft;
objTop = obj.offsetTop;
objParent = obj.offsetParent;
while( objParent.tagName.toUpperCase() != "BODY" )
{
objLeft += objParent.offsetLeft;
objTop += objParent.offsetTop;
objParent = objParent.offsetParent;
}
objHeight = obj.offsetHeight;
objWidth = obj.offsetWidth;
if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
else if( overDiv.offsetTop >= ( objTop + objHeight ));
else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
else
{
obj.style.visibility = "hidden";
}
}
}
}
/*
* unhides <select> and <applet> objects (for IE only)
*/
function jscalendarShowElement( elmID )
{
if( jscalendarIe )
{
for( i = 0; i < document.all.tags( elmID ).length; i++ )
{
obj = document.all.tags( elmID )[i];
if( !obj || !obj.offsetParent )
{
continue;
}
obj.style.visibility = "";
}
}
}
function jscalendarHolidayRec (d, m, y, desc)
{
this.d = d
this.m = m
this.y = y
this.desc = desc
}
var jscalendarHolidaysCounter = 0
var jscalendarHolidays = new Array()
function jscalendarAddHoliday (d, m, y, desc)
{
jscalendarHolidays[jscalendarHolidaysCounter++] = new jscalendarHolidayRec ( d, m, y, desc )
}
if (jscalendarDom)
{
for (i=0;i<jscalendarImgsrc.length;i++)
{
jscalendarImg[i] = new Image
jscalendarImg[i].src = jscalendarImgDir + jscalendarImgsrc[i]
}
document.write ("<div onclick='jscalendarBShow=true' id='calendar' class='"+jscalendarThemePrefix+"-div-style'><table width="+((jscalendarShowWeekNumber==1)?250:220)+" class='"+jscalendarThemePrefix+"-table-style'><tr class='"+jscalendarThemePrefix+"-title-background-style'><td><table width='"+((jscalendarShowWeekNumber==1)?248:218)+"'><tr><td class='"+jscalendarThemePrefix+"-title-style'><span id='caption'></span></td><td align=right><a href='javascript:jscalendarHideCalendar()'><IMG SRC='"+jscalendarImgDir+"close.gif' WIDTH='15' HEIGHT='13' BORDER='0' ALT='Close the Calendar'></a></td></tr></table></td></tr><tr><td class='"+jscalendarThemePrefix+"-body-style'><span id='content'></span></td></tr>")
if (jscalendarShowToday==1)
{
document.write ("<tr class='"+jscalendarThemePrefix+"-today-style'><td class='"+jscalendarThemePrefix+"-today-lbl-style'><span id='lblToday'></span></td></tr>")
}
document.write ("</table></div><div id='selectMonth' class='"+jscalendarThemePrefix+"-div-style'></div><div id='selectYear' class='"+jscalendarThemePrefix+"-div-style'></div>");
}
var jscalendarMonthName = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var jscalendarMonthName2 = new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC")
var jscalendarDayName;
if (jscalendarStartAt==0)
{
jscalendarDayName = new Array ("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
}
else
{
jscalendarDayName = new Array ("Mon","Tue","Wed","Thu","Fri","Sat","Sun")
}
function jscalendarSwapImage(srcImg, destImg){
if (jscalendarIe) { document.getElementById(srcImg).setAttribute("src",jscalendarImgDir + destImg) }
}
function jscalendarInit() {
if (!jscalendarNs4)
{
if (!jscalendarIe) { jscalendarYearNow += 1900 }
jscalendarCrossobj=(jscalendarDom)?document.getElementById("calendar").style : jscalendarIe? document.all.calendar : document.calendar
jscalendarHideCalendar()
jscalendarCrossMonthObj=(jscalendarDom)?document.getElementById("selectMonth").style : jscalendarIe? document.all.selectMonth : document.selectMonth
jscalendarCrossYearObj=(jscalendarDom)?document.getElementById("selectYear").style : jscalendarIe? document.all.jscalendarSelectYear : document.jscalendarSelectYear
jscalendarMonthConstructed=false;
jscalendarYearConstructed=false;
if (jscalendarShowToday==1)
{
document.getElementById("lblToday").innerHTML = jscalendarTodayString + " <a onmousemove='window.status=\""+jscalendarGotoString+"\"' onmouseout='window.status=\"\"' title='"+jscalendarGotoString+"' class='"+jscalendarThemePrefix+"-today-style' href='javascript:jscalendarMonthSelected=jscalendarMonthNow;jscalendarYearSelected=jscalendarYearNow;jscalendarConstructCalendar();'>"+jscalendarDayName[(jscalendarToday.getDay()-jscalendarStartAt==-1)?6:(jscalendarToday.getDay()-jscalendarStartAt)]+", " + jscalendarDateNow + " " + jscalendarMonthName[jscalendarMonthNow].substring(0,3) + " " + jscalendarYearNow + "</a>"
}
sHTML1 ="<span id='spanLeft' class='"+jscalendarThemePrefix+"-title-control-normal-style' onmouseover='jscalendarSwapImage(\"changeLeft\",\"left2.gif\"); this.className=\""+jscalendarThemePrefix+"-title-control-select-style\"; window.status=\""+jscalendarScrollLeftMessage+"\"' onclick='javascript:jscalendarDecMonth()' onmouseout='clearInterval(jscalendarIntervalID1);jscalendarSwapImage(\"changeLeft\",\"left1.gif\"); this.className=\""+jscalendarThemePrefix+"-title-control-normal-style\"; window.status=\"\"' onmousedown='clearTimeout(jscalendarTimeoutID1);jscalendarTimeoutID1=setTimeout(\"jscalendarStartDecMonth()\",500)' onmouseup='clearTimeout(jscalendarTimeoutID1);clearInterval(jscalendarIntervalID1)'> <IMG id='changeLeft' SRC='"+jscalendarImgDir+"left1.gif' width=10 height=11 BORDER=0> </span> "
sHTML1+="<span id='spanRight' class='"+jscalendarThemePrefix+"-title-control-normal-style' onmouseover='jscalendarSwapImage(\"changeRight\",\"right2.gif\");this.className=\""+jscalendarThemePrefix+"-title-control-select-style\"; window.status=\""+jscalendarScrollRightMessage+"\"' onmouseout='clearInterval(jscalendarIntervalID1);jscalendarSwapImage(\"changeRight\",\"right1.gif\"); this.className=\""+jscalendarThemePrefix+"-title-control-normal-style\"; window.status=\"\"' onclick='jscalendarIncMonth()' onmousedown='clearTimeout(jscalendarTimeoutID1);jscalendarTimeoutID1=setTimeout(\"jscalendarStartIncMonth()\",500)' onmouseup='clearTimeout(jscalendarTimeoutID1);clearInterval(jscalendarIntervalID1)'> <IMG id='changeRight' SRC='"+jscalendarImgDir+"right1.gif' width=10 height=11 BORDER=0> </span> "
sHTML1+="<span id='spanMonth' class='"+jscalendarThemePrefix+"-title-control-normal-style' onmouseover='jscalendarSwapImage(\"changeMonth\",\"drop2.gif\"); this.className=\""+jscalendarThemePrefix+"-title-control-select-style\"; window.status=\""+jscalendarSelectMonthMessage+"\"' onmouseout='jscalendarSwapImage(\"changeMonth\",\"drop1.gif\"); this.className=\""+jscalendarThemePrefix+"-title-control-normal-style\"; window.status=\"\"' onclick='jscalendarPopUpMonth()'></span> "
sHTML1+="<span id='spanYear' class='"+jscalendarThemePrefix+"-title-control-normal-style' onmouseover='jscalendarSwapImage(\"changeYear\",\"drop2.gif\"); this.className=\""+jscalendarThemePrefix+"-title-control-select-style\"; window.status=\""+jscalendarSelectYearMessage+"\"' onmouseout='jscalendarSwapImage(\"changeYear\",\"drop1.gif\"); this.className=\""+jscalendarThemePrefix+"-title-control-normal-style\"; window.status=\"\"' onclick='jscalendarPopUpYear()'></span> "
document.getElementById("caption").innerHTML = sHTML1
jscalendarBPageLoaded=true
}
}
function jscalendarHideCalendar() {
jscalendarCrossobj.visibility="hidden"
if (jscalendarCrossMonthObj != null){jscalendarCrossMonthObj.visibility="hidden"}
if (jscalendarCrossYearObj != null){jscalendarCrossYearObj.visibility="hidden"}
jscalendarShowElement( 'SELECT' );
jscalendarShowElement( 'APPLET' );
}
function jscalendarPadZero(num) {
return (num < 10)? '0' + num : num ;
}
function jscalendarConstructDate(d,m,y)
{
sTmp = jscalendarDateFormat
sTmp = sTmp.replace ("dd","<e>")
sTmp = sTmp.replace ("d","<d>")
sTmp = sTmp.replace ("<e>",jscalendarPadZero(d))
sTmp = sTmp.replace ("<d>",d)
sTmp = sTmp.replace ("mmmm","<p>")
sTmp = sTmp.replace ("MMMM","<p>")
sTmp = sTmp.replace ("mmm","<o>")
sTmp = sTmp.replace ("MMM","<o>")
sTmp = sTmp.replace ("mm","<n>")
sTmp = sTmp.replace ("MM","<n>")
sTmp = sTmp.replace ("m","<m>")
sTmp = sTmp.replace ("M","<m>")
sTmp = sTmp.replace ("<m>",m+1)
sTmp = sTmp.replace ("<n>",jscalendarPadZero(m+1))
sTmp = sTmp.replace ("<o>",jscalendarMonthName[m])
sTmp = sTmp.replace ("<p>",jscalendarMonthName2[m])
sTmp = sTmp.replace ("yyyy",y)
return sTmp.replace ("yy",jscalendarPadZero(y%100))
}
function jscalendarCloseCalendar() {
var sTmp
jscalendarHideCalendar();
jscalendarCtlToPlaceValue.value = jscalendarConstructDate(jscalendarDateSelected,jscalendarMonthSelected,jscalendarYearSelected)
}
/*** Month Pulldown ***/
function jscalendarStartDecMonth()
{
jscalendarIntervalID1=setInterval("jscalendarDecMonth()",80)
}
function jscalendarStartIncMonth()
{
jscalendarIntervalID1=setInterval("jscalendarIncMonth()",80)
}
function jscalendarIncMonth () {
jscalendarMonthSelected++
if (jscalendarMonthSelected>11) {
jscalendarMonthSelected=0
jscalendarYearSelected++
}
jscalendarConstructCalendar()
}
function jscalendarDecMonth () {
jscalendarMonthSelected--
if (jscalendarMonthSelected<0) {
jscalendarMonthSelected=11
jscalendarYearSelected--
}
jscalendarConstructCalendar()
}
function jscalendarConstructMonth() {
jscalendarPopDownYear()
if (!jscalendarMonthConstructed) {
sHTML = ""
for (i=0; i<12; i++) {
sName = jscalendarMonthName[i];
if (i==jscalendarMonthSelected){
sName = "<B>" + sName + "</B>"
}
sHTML += "<tr><td id='m" + i + "' onmouseover='this.className=\""+jscalendarThemePrefix+"-dropdown-select-style\"' onmouseout='this.className=\""+jscalendarThemePrefix+"-dropdown-normal-style\"' onclick='jscalendarMonthConstructed=false;jscalendarMonthSelected=" + i + ";jscalendarConstructCalendar();jscalendarPopDownMonth();event.cancelBubble=true'> " + sName + " </td></tr>"
}
document.getElementById("selectMonth").innerHTML = "<table width='70' class='"+jscalendarThemePrefix+"-dropdown-style' cellspacing=0 onmouseover='clearTimeout(jscalendarTimeoutID1)' onmouseout='clearTimeout(jscalendarTimeoutID1);jscalendarTimeoutID1=setTimeout(\"jscalendarPopDownMonth()\",100);event.cancelBubble=true'>" + sHTML + "</table>"
jscalendarMonthConstructed=true
}
}
function jscalendarPopUpMonth() {
jscalendarConstructMonth()
jscalendarCrossMonthObj.visibility = (jscalendarDom||jscalendarIe)? "visible" : "show"
jscalendarCrossMonthObj.left = parseInt(jscalendarCrossobj.left) + 50 + "px";
jscalendarCrossMonthObj.top = parseInt(jscalendarCrossobj.top) + 26 + "px";
jscalendarHideElement( 'SELECT', document.getElementById("selectMonth") );
jscalendarHideElement( 'APPLET', document.getElementById("selectMonth") );
}
function jscalendarPopDownMonth() {
jscalendarCrossMonthObj.visibility= "hidden"
}
/*** Year Pulldown ***/
function jscalendarIncYear() {
for (i=0; i<7; i++){
newYear = (i+jscalendarNStartingYear)+1
if (newYear==jscalendarYearSelected)
{ txtYear = " <B>" + newYear + "</B> " }
else
{ txtYear = " " + newYear + " " }
document.getElementById("y"+i).innerHTML = txtYear
}
jscalendarNStartingYear ++;
jscalendarBShow=true
}
function jscalendarDecYear() {
for (i=0; i<7; i++){
newYear = (i+jscalendarNStartingYear)-1
if (newYear==jscalendarYearSelected)
{ txtYear = " <B>" + newYear + "</B> " }
else
{ txtYear = " " + newYear + " " }
document.getElementById("y"+i).innerHTML = txtYear
}
jscalendarNStartingYear --;
jscalendarBShow=true
}
function jscalendarSelectYear(nYear) {
jscalendarYearSelected=parseInt(nYear+jscalendarNStartingYear);
jscalendarYearConstructed=false;
jscalendarConstructCalendar();
jscalendarPopDownYear();
}
function jscalendarConstructYear() {
jscalendarPopDownMonth()
sHTML = ""
if (!jscalendarYearConstructed) {
sHTML = "<tr><td align='center' onmouseover='this.className=\""+jscalendarThemePrefix+"-dropdown-select-style\"' onmouseout='clearInterval(jscalendarIntervalID1); this.className=\""+jscalendarThemePrefix+"-dropdown-normal-style\"' onmousedown='clearInterval(jscalendarIntervalID1);jscalendarIntervalID1=setInterval(\"jscalendarDecYear()\",30)' onmouseup='clearInterval(jscalendarIntervalID1)'>-</td></tr>"
j = 0
jscalendarNStartingYear = jscalendarYearSelected-3
for (i=(jscalendarYearSelected-3); i<=(jscalendarYearSelected+3); i++) {
sName = i;
if (i==jscalendarYearSelected){
sName = "<B>" + sName + "</B>"
}
sHTML += "<tr><td id='y" + j + "' onmouseover='this.className=\""+jscalendarThemePrefix+"-dropdown-select-style\"' onmouseout='this.className=\""+jscalendarThemePrefix+"-dropdown-normal-style\"' onclick='jscalendarSelectYear("+j+");event.cancelBubble=true'> " + sName + " </td></tr>"
j ++;
}
sHTML += "<tr><td align='center' onmouseover='this.className=\""+jscalendarThemePrefix+"-dropdown-select-style\"' onmouseout='clearInterval(jscalendarIntervalID2); this.className=\""+jscalendarThemePrefix+"-dropdown-normal-style\"' onmousedown='clearInterval(jscalendarIntervalID2);jscalendarIntervalID2=setInterval(\"jscalendarIncYear()\",30)' onmouseup='clearInterval(jscalendarIntervalID2)'>+</td></tr>"
document.getElementById("selectYear").innerHTML = "<table width=44 class='"+jscalendarThemePrefix+"-dropdown-style' onmouseover='clearTimeout(jscalendarTimeoutID2)' onmouseout='clearTimeout(jscalendarTimeoutID2);jscalendarTimeoutID2=setTimeout(\"jscalendarPopDownYear()\",100)' cellspacing=0>" + sHTML + "</table>"
jscalendarYearConstructed = true
}
}
function jscalendarPopDownYear() {
clearInterval(jscalendarIntervalID1)
clearTimeout(jscalendarTimeoutID1)
clearInterval(jscalendarIntervalID2)
clearTimeout(jscalendarTimeoutID2)
jscalendarCrossYearObj.visibility= "hidden"
}
function jscalendarPopUpYear() {
var leftOffset
jscalendarConstructYear()
jscalendarCrossYearObj.visibility = (jscalendarDom||jscalendarIe)? "visible" : "show"
leftOffset = parseInt(jscalendarCrossobj.left) + document.getElementById("spanYear").offsetLeft
if (jscalendarIe)
{
leftOffset += 6
}
jscalendarCrossYearObj.left = leftOffset + "px";
jscalendarCrossYearObj.top = parseInt(jscalendarCrossobj.top) + 26 + "px";
}
/*** calendar ***/
function jscalendarWeekNbr(n) {
// Algorithm used:
// From Klaus Tondering's Calendar document (The Authority/Guru)
// hhtp://www.tondering.dk/claus/calendar.html
// a = (14-month) / 12
// y = year + 4800 - a
// m = month + 12a - 3
// J = day + (153m + 2) / 5 + 365y + y / 4 - y / 100 + y / 400 - 32045
// d4 = (J + 31741 - (J mod 7)) mod 146097 mod 36524 mod 1461
// L = d4 / 1460
// d1 = ((d4 - L) mod 365) + L
// WeekNumber = d1 / 7 + 1
year = n.getFullYear();
month = n.getMonth() + 1;
if (jscalendarStartAt == 0) {
day = n.getDate() + 1;
}
else {
day = n.getDate();
}
a = Math.floor((14-month) / 12);
y = year + 4800 - a;
m = month + 12 * a - 3;
b = Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400);
J = day + Math.floor((153 * m + 2) / 5) + 365 * y + b - 32045;
d4 = (((J + 31741 - (J % 7)) % 146097) % 36524) % 1461;
L = Math.floor(d4 / 1460);
d1 = ((d4 - L) % 365) + L;
week = Math.floor(d1/7) + 1;
return week;
}
function jscalendarConstructCalendar () {
var aNumDays = Array (31,0,31,30,31,30,31,31,30,31,30,31)
var dateMessage
var startDate = new Date (jscalendarYearSelected,jscalendarMonthSelected,1)
var endDate
if (jscalendarMonthSelected==1)
{
endDate = new Date (jscalendarYearSelected,jscalendarMonthSelected+1,1);
endDate = new Date (endDate - (24*60*60*1000));
numDaysInMonth = endDate.getDate()
}
else
{
numDaysInMonth = aNumDays[jscalendarMonthSelected];
}
datePointer = 0
dayPointer = startDate.getDay() - jscalendarStartAt
if (dayPointer<0)
{
dayPointer = 6
}
sHTML = "<table border=0 class='"+jscalendarThemePrefix+"-body-style'><tr>"
if (jscalendarShowWeekNumber==1)
{
sHTML += "<td width=27><b>" + jscalendarWeekString + "</b></td><td width=1 rowspan=7 class='"+jscalendarThemePrefix+"-weeknumber-div-style'><img src='"+jscalendarImgDir+"divider.gif' width=1></td>"
}
for (i=0; i<7; i++) {
sHTML += "<td width='27' align='right'><B>"+ jscalendarDayName[i]+"</B></td>"
}
sHTML +="</tr><tr>"
if (jscalendarShowWeekNumber==1)
{
sHTML += "<td align=right>" + jscalendarWeekNbr(startDate) + " </td>"
}
for ( var i=1; i<=dayPointer;i++ )
{
sHTML += "<td> </td>"
}
for ( datePointer=1; datePointer<=numDaysInMonth; datePointer++ )
{
dayPointer++;
sHTML += "<td align=right>"
var sStyle=jscalendarThemePrefix+"-normal-day-style"; //regular day
if ((datePointer==jscalendarDateNow)&&(jscalendarMonthSelected==jscalendarMonthNow)&&(jscalendarYearSelected==jscalendarYearNow)) //today
{ sStyle = jscalendarThemePrefix+"-current-day-style"; }
else if (dayPointer % 7 == (jscalendarStartAt * -1) +1) //end-of-the-week day
{ sStyle = jscalendarThemePrefix+"-end-of-weekday-style"; }
//selected day
if ((datePointer==jscalendarOdateSelected) && (jscalendarMonthSelected==jscalendarOmonthSelected) && (jscalendarYearSelected==jscalendarOyearSelected))
{ sStyle += " "+jscalendarThemePrefix+"-selected-day-style"; }
sHint = ""
for (k=0;k<jscalendarHolidaysCounter;k++)
{
if ((parseInt(jscalendarHolidays[k].d)==datePointer)&&(parseInt(jscalendarHolidays[k].m)==(jscalendarMonthSelected+1)))
{
if ((parseInt(jscalendarHolidays[k].y)==0)||((parseInt(jscalendarHolidays[k].y)==jscalendarYearSelected)&&(parseInt(jscalendarHolidays[k].y)!=0)))
{
sStyle += " "+jscalendarThemePrefix+"-holiday-style";
sHint+=sHint==""?jscalendarHolidays[k].desc:"\n"+jscalendarHolidays[k].desc
}
}
}
var regexp= /\"/g
sHint=sHint.replace(regexp,""")
sSelectStyle = sStyle+" "+jscalendarThemePrefix+"-would-be-selected-day-style";
sNormalStyle = sStyle;
dateMessage = "onmousemove='window.status=\""+jscalendarSelectDateMessage.replace("[date]",jscalendarConstructDate(datePointer,jscalendarMonthSelected,jscalendarYearSelected))+"\"' onmouseout='this.className=\""+sNormalStyle+"\"; window.status=\"\"' "
sHTML += "<a class='"+sStyle+"' "+dateMessage+" title=\"" + sHint + "\" href='javascript:jscalendarDateSelected="+datePointer+";jscalendarCloseCalendar();' onmouseover='this.className=\""+sSelectStyle+"\";' > " + datePointer + " </a>"
sHTML += ""
if ((dayPointer+jscalendarStartAt) % 7 == jscalendarStartAt) {
sHTML += "</tr><tr>"
if ((jscalendarShowWeekNumber==1)&&(datePointer<numDaysInMonth))
{
sHTML += "<td align=right>" + (jscalendarWeekNbr(new Date(jscalendarYearSelected,jscalendarMonthSelected,datePointer+1))) + " </td>"
}
}
}
document.getElementById("content").innerHTML = sHTML
document.getElementById("spanMonth").innerHTML = " " + jscalendarMonthName[jscalendarMonthSelected] + " <IMG id='changeMonth' SRC='"+jscalendarImgDir+"drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>"
document.getElementById("spanYear").innerHTML = " " + jscalendarYearSelected + " <IMG id='changeYear' SRC='"+jscalendarImgDir+"drop1.gif' WIDTH='12' HEIGHT='10' BORDER=0>"
}
function jscalendarPopUpCalendar(ctl, ctl2, format) {
var leftpos=0
var toppos=0
if (jscalendarBPageLoaded)
{
if ( jscalendarCrossobj.visibility == "hidden" ) {
jscalendarCtlToPlaceValue = ctl2
jscalendarDateFormat=format;
formatChar = " "
aFormat = jscalendarDateFormat.split(formatChar)
if (aFormat.length<3)
{
formatChar = "/"
aFormat = jscalendarDateFormat.split(formatChar)
if (aFormat.length<3)
{
formatChar = "."
aFormat = jscalendarDateFormat.split(formatChar)
if (aFormat.length<3)
{
formatChar = "-"
aFormat = jscalendarDateFormat.split(formatChar)
if (aFormat.length<3)
{
// invalid date format
formatChar=""
}
}
}
}
tokensChanged = 0
if ( formatChar != "" )
{
// use user's date
aData = ctl2.value.split(formatChar)
for (i=0;i<3;i++)
{
if ((aFormat[i]=="d") || (aFormat[i]=="dd"))
{
jscalendarDateSelected = parseInt(aData[i], 10)
tokensChanged ++
}
else if ((aFormat[i]=="m") || (aFormat[i]=="mm") || (aFormat[i]=="M") || (aFormat[i]=="MM"))
{
jscalendarMonthSelected = parseInt(aData[i], 10) - 1
tokensChanged ++
}
else if (aFormat[i]=="yyyy")
{
jscalendarYearSelected = parseInt(aData[i], 10)
tokensChanged ++
}
else if (aFormat[i]=="yy")
{
newYear = parseInt(aData[i], 10);
if(newYear>50)
jscalendarYearSelected = 1900+newYear;
else
jscalendarYearSelected = 2000+newYear;
tokensChanged ++
}
else if (aFormat[i]=="mmm" || aFormat[i]=="MMM")
{
for (j=0; j<12; j++)
{
if (aData[i]==jscalendarMonthName[j])
{
jscalendarMonthSelected=j
tokensChanged ++
}
}
}
else if (aFormat[i]=="mmmm" || aFormat[i]=="MMMM")
{
for (j=0; j<12; j++)
{
if (aData[i]==jscalendarMonthName2[j])
{
jscalendarMonthSelected=j
tokensChanged ++
}
}
}
}
}
if ((tokensChanged!=3)||isNaN(jscalendarDateSelected)||isNaN(jscalendarMonthSelected)||isNaN(jscalendarYearSelected))
{
jscalendarDateSelected = jscalendarDateNow
jscalendarMonthSelected = jscalendarMonthNow
jscalendarYearSelected = jscalendarYearNow
}
jscalendarOdateSelected=jscalendarDateSelected
jscalendarOmonthSelected=jscalendarMonthSelected
jscalendarOyearSelected=jscalendarYearSelected
aTag = ctl
do {
aTag = aTag.offsetParent;
leftpos += aTag.offsetLeft;
toppos += aTag.offsetTop;
} while(aTag.tagName!="BODY");
jscalendarCrossobj.left = jscalendarFixedX==-1 ? ctl.offsetLeft + leftpos + "px": jscalendarFixedX
jscalendarCrossobj.top = jscalendarFixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 + "px": jscalendarFixedY
jscalendarConstructCalendar (1, jscalendarMonthSelected, jscalendarYearSelected);
jscalendarCrossobj.visibility=(jscalendarDom||jscalendarIe)? "visible" : "show"
jscalendarHideElement( 'SELECT', document.getElementById("calendar") );
jscalendarHideElement( 'APPLET', document.getElementById("calendar") );
jscalendarBShow = true;
}
else
{
jscalendarHideCalendar()
if (jscalendarCtlNow!=ctl) {jscalendarPopUpCalendar(ctl, ctl2, format)}
}
jscalendarCtlNow = ctl
}
}
document.onkeypress = function jscalendarHidecal1 () {
if (event.keyCode==27)
{
jscalendarHideCalendar()
}
}
document.onclick = function jscalendarHidecal2 () {
if (!jscalendarBShow)
{
jscalendarHideCalendar()
}
jscalendarBShow = false
}
if(jscalendarIe)
{
jscalendarInit()
}
else
{
window.onload=jscalendarInit
}
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/jscalendar.html
Index: jscalendar.html
===================================================================
<HTML>
<HEAD>
<script language='javascript' src="popcalendar.js"></script>
<SCRIPT LANGUAGE="JavaScript" SRC="lw_layers.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="lw_menu.js"></SCRIPT>
<link rel="stylesheet" href="jscalendar-WH/theme.css" type="text/css">
</HEAD>
<BODY BGCOLOR=#ffffff vlink=#0000ff>
This popup <div class="div-style">calendar</div> allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
<form name='mainform' method='post'>
<input type=text name='datevalue' size=10 maxlength=10 value='02/02/2002'>
<script language='javascript'>
<!--
if (!document.layers) {
document.write("<input type=button onclick='popUpCalendar(this, mainform.datevalue, \"dd/mm/yyyy\")' value='select' style='font-size:11px'>")
}
//-->
</script>
</form>
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
This popup calendar allows the user to scroll through months and pick any year, which is different from other calendars in the sense that the year range is 'unlimited'.
</body>
</html>
1.2 +25 -10 incubator-myfaces/src/components/org/apache/myfaces/component/html/util/ExtensionsFilter.java
Index: ExtensionsFilter.java
===================================================================
RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/component/html/util/ExtensionsFilter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExtensionsFilter.java 1 Dec 2004 16:32:03 -0000 1.1
+++ ExtensionsFilter.java 1 Dec 2004 20:25:10 -0000 1.2
@@ -95,21 +95,36 @@
HttpServletRequest httpRequest = (HttpServletRequest) request;
- // Process only multipart/form-data requests
- if (FileUpload.isMultipartContent(httpRequest)) {
- MultipartRequestWrapper requestWrapper = new MultipartRequestWrapper(httpRequest, uploadMaxFileSize, uploadThresholdSize, uploadRepositoryPath);
- chain.doFilter(requestWrapper, response);
+ // Serve myFaces internal resources files
+ if( AddResource.isResourceMappedPath( httpRequest ) ){
+ AddResource.serveResource(httpRequest, response);
return;
}
+
+ HttpServletRequest extendedRequest = httpRequest;
+
+ // For multipart/form-data requests
+ if (FileUpload.isMultipartContent(httpRequest)) {
+ extendedRequest = new MultipartRequestWrapper(httpRequest, uploadMaxFileSize, uploadThresholdSize, uploadRepositoryPath);
+ }
- // Serve myFaces internal resources
- if( AddResource.isResourceMappedPath( httpRequest ) ){
- AddResource.serveResource(httpRequest, response);
+ if( !(response instanceof HttpServletResponse)){
+ chain.doFilter(extendedRequest, response);
return;
}
+ ExtensionsResponseWrapper extendedResponse = new ExtensionsResponseWrapper((HttpServletResponse) response);
+
// Standard request
- chain.doFilter(request, response);
+ chain.doFilter(extendedRequest, extendedResponse);
+
+ if( ! AddResource.hasAdditionalHeaderInfoToRender(extendedRequest) ){
+ response.getWriter().write( extendedResponse.toString() );
+ return;
+ }
+
+ // Some headerInfo has to be added
+ AddResource.writeWithFullHeader(extendedRequest, extendedResponse, (HttpServletResponse)response);
}
/**
1.2 +144 -8 incubator-myfaces/src/components/org/apache/myfaces/component/html/util/AddResource.java
Index: AddResource.java
===================================================================
RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/component/html/util/AddResource.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddResource.java 1 Dec 2004 16:32:03 -0000 1.1
+++ AddResource.java 1 Dec 2004 20:25:10 -0000 1.2
@@ -18,11 +18,16 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,6 +41,10 @@
* @author Sylvain Vieujot (latest modification by $Author$)
* @version $Revision$ $Date$
* $Log$
+ * Revision 1.2 2004/12/01 20:25:10 svieujot
+ * Make the Extensions filter support css and image resources.
+ * Convert the popup calendar to use this new filter.
+ *
* Revision 1.1 2004/12/01 16:32:03 svieujot
* Convert the Multipart filter in an ExtensionsFilter that provides an additional facility to include resources in a page.
* Tested only with javascript resources right now, but should work fine with images too.
@@ -51,7 +60,13 @@
private static final String RESOURCE_MAP_PATH = "/myFacesExtensionResource";
+ private static final String ADDITIONAL_HEADER_INFO_REQUEST_ATTRUBITE_NAME = "myFacesHeaderResource2Render";
+
public static void addJavaScript(Class componentClass, String resourceFileName, FacesContext context) throws IOException{
+ addJavaScript(componentClass, resourceFileName, context, null);
+ }
+
+ public static void addJavaScript(Class componentClass, String resourceFileName, FacesContext context, String scriptBody) throws IOException{
ResponseWriter writer = context.getResponseWriter();
writer.startElement(HTML.SCRIPT_ELEM,null);
@@ -59,13 +74,20 @@
writer.writeURIAttribute(HTML.SRC_ATTR,
getResourceMappedPath(componentClass,resourceFileName, context),
null);
+
+ if( scriptBody != null )
+ writer.writeText(scriptBody, null);
writer.endElement(HTML.SCRIPT_ELEM);
}
public static void addJavaScriptOncePerPage(Class componentClass, String resourceFileName, FacesContext context) throws IOException{
+ addJavaScriptOncePerPage(componentClass, resourceFileName, context, null);
+ }
+
+ public static void addJavaScriptOncePerPage(Class componentClass, String resourceFileName, FacesContext context, String scriptBody) throws IOException{
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
- String javascriptRenderedAttributeName = "myFacesResourceRendered"+(componentClass.hashCode()+resourceFileName.hashCode());
+ String javascriptRenderedAttributeName = "myFacesResourceRendered"+(componentClass.hashCode()+(resourceFileName+scriptBody).hashCode());
if( request.getAttribute(javascriptRenderedAttributeName) == null ){
addJavaScript(componentClass, resourceFileName, context);
@@ -73,10 +95,37 @@
}
}
- private static String getResourceMappedPath(Class componentClass, String ressourceFileName, FacesContext context){
- String contextPath = ((HttpServletRequest)context.getExternalContext().getRequest()).getContextPath();
- return contextPath+getAddRessourceMaping()+"?component="+getComponentName(componentClass)
- +"&resource="+ressourceFileName;
+ public static void addStyleSheet(Class componentClass, String resourceFileName, FacesContext context){
+ AdditionalHeaderInfoToRender cssInfo = new AdditionalHeaderInfoToRender(AdditionalHeaderInfoToRender.TYPE_CSS, componentClass, resourceFileName);
+ getAdditionalHeaderInfoToRender(context).add( cssInfo );
+ }
+
+ private static Set getAdditionalHeaderInfoToRender(FacesContext context){
+ HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
+ return getAdditionalHeaderInfoToRender( request );
+ }
+
+ private static Set getAdditionalHeaderInfoToRender(HttpServletRequest request){
+ Set set = (Set) request.getAttribute(ADDITIONAL_HEADER_INFO_REQUEST_ATTRUBITE_NAME);
+ if( set == null ){
+ set = new HashSet();
+ request.setAttribute(ADDITIONAL_HEADER_INFO_REQUEST_ATTRUBITE_NAME, set);
+ }
+
+ return set;
+ }
+
+ public static String getResourceMappedPath(Class componentClass, String resourceFileName, FacesContext context){
+ return getResourceMappedPath(
+ getComponentName(componentClass),
+ resourceFileName,
+ (HttpServletRequest)context.getExternalContext().getRequest());
+ }
+
+ private static String getResourceMappedPath(String componentName, String resourceFileName, HttpServletRequest request){
+ String contextPath = request.getContextPath();
+ return contextPath+getAddRessourceMaping()+"?component="+componentName
+ +"&resource="+resourceFileName;
}
private static String getAddRessourceMaping(){
@@ -129,8 +178,18 @@
String componentName = request.getParameter("component");
String resourceFileName = request.getParameter("resource");
- if( resourceFileName.endsWith(".js") )
+ String lcResourceFileName = resourceFileName.toLowerCase();
+
+ if( lcResourceFileName.endsWith(".js") )
response.setContentType("text/javascript");
+ else if( lcResourceFileName.endsWith(".css") )
+ response.setContentType("text/css");
+ else if( lcResourceFileName.endsWith(".gif") )
+ response.setContentType("image/gif");
+ else if( lcResourceFileName.endsWith(".png") )
+ response.setContentType("image/png");
+ else if( lcResourceFileName.endsWith(".jpg") || lcResourceFileName.endsWith(".jpeg") )
+ response.setContentType("image/jpeg");
InputStream is = getResource(componentName, resourceFileName);
if( is == null ){
@@ -142,5 +201,80 @@
os.write(c);
os.close();
+ }
+
+ static public boolean hasAdditionalHeaderInfoToRender(HttpServletRequest request){
+ return request.getAttribute(ADDITIONAL_HEADER_INFO_REQUEST_ATTRUBITE_NAME) != null;
+ }
+
+ static public void writeWithFullHeader(HttpServletRequest request,
+ ExtensionsResponseWrapper responseWrapper,
+ HttpServletResponse response) throws IOException{
+
+ String initialResponse = responseWrapper.toString();
+ String lcInitialResponse = initialResponse.toLowerCase();
+
+ boolean addHeaderTags = false;
+ int insertPosition = lcInitialResponse.indexOf( "</head>" );
+
+ if( insertPosition < 0 ){
+ insertPosition = lcInitialResponse.indexOf( "<body " );
+ addHeaderTags = true;
+ }
+
+ if( insertPosition < 0 ){
+ log.warn("Response has not <head> or <body> tags.");
+ insertPosition = 0;
+ }
+
+ PrintWriter writer = response.getWriter();
+
+ if( insertPosition > 0 )
+ writer.write( initialResponse.substring(0, insertPosition) );
+ if( addHeaderTags )
+ writer.write("<head>");
+
+ for(Iterator i = getAdditionalHeaderInfoToRender(request).iterator(); i.hasNext() ;){
+ AdditionalHeaderInfoToRender headerInfo = (AdditionalHeaderInfoToRender) i.next();
+ writer.write( headerInfo.getString(request) );
+ }
+
+ if( addHeaderTags )
+ writer.write("</head>");
+
+ writer.write( initialResponse.substring(insertPosition) );
+ }
+
+ private static class AdditionalHeaderInfoToRender{
+ public static final int TYPE_CSS = 0;
+ public String componentName;
+ public String resourceFileName;
+ public int type;
+
+ public AdditionalHeaderInfoToRender(int infoType, String componentName, String resourceFileName) {
+ this.componentName = componentName;
+ this.resourceFileName = resourceFileName;
+ this.type = infoType;
+ }
+
+ public AdditionalHeaderInfoToRender(int infoType, Class componentClass, String resourceFileName) {
+ this.componentName = getComponentName(componentClass);
+ this.resourceFileName = resourceFileName;
+ this.type = infoType;
+ }
+
+ public int hashCode() {
+ return (componentName+((char)7)+resourceFileName+((char)7)+type).hashCode();
+ }
+
+ public String getString(HttpServletRequest request){
+ if( type == TYPE_CSS )
+ return "<link rel=\"stylesheet\" "
+ +"href=\""+getResourceMappedPath(componentName, resourceFileName, request)+"\" "
+ +"type=\"text/css\"/>\n";
+
+ log.warn("Unknown type:"+type);
+ return "<link href=\""+"\"/>\n";
+ }
}
}
1.1 incubator-myfaces/src/components/org/apache/myfaces/component/html/util/ExtensionsResponseWrapper.java
Index: ExtensionsResponseWrapper.java
===================================================================
/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.myfaces.component.html.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import org.xml.sax.InputSource;
/**
* @author Sylvain Vieujot (latest modification by $Author: svieujot $)
* @version $Revision: 1.1 $ $Date: 2004/12/01 20:25:10 $ $Log: ExtensionsResponseWrapper.java,v $
* @version $Revision: 1.1 $ $Date: 2004/12/01 20:25:10 $ Revision 1.1 2004/12/01 20:25:10 svieujot
* @version $Revision: 1.1 $ $Date: 2004/12/01 20:25:10 $ Make the Extensions filter support css and image resources.
* @version $Revision: 1.1 $ $Date: 2004/12/01 20:25:10 $ Convert the popup calendar to use this new filter.
* @version $Revision: 1.1 $ $Date: 2004/12/01 20:25:10 $
*
*/
public class ExtensionsResponseWrapper extends HttpServletResponseWrapper {
private ByteArrayOutputStream output;
public ExtensionsResponseWrapper(HttpServletResponse response){
super( response );
output = new ByteArrayOutputStream();
}
public String toString(){
return output.toString();
//return new String( output.toByteArray() );
/*
try{
return output.toString( "UTF-8" ); // convertion
}catch(UnsupportedEncodingException uee){
uee.printStackTrace();
return output.toString();
} */
}
/** This method is used by Tomcat.
*/
public PrintWriter getWriter(){
return new PrintWriter( output );
}
/** This method is used by Jetty.
*/
public ServletOutputStream getOutputStream(){
return new MyServletOutputStream( output );
}
public InputSource getInputSource(){
ByteArrayInputStream bais = new ByteArrayInputStream( output.toByteArray() );
return new InputSource( bais );
}
/**
* Prevent content-length being set as the page might be modified.
*/
public void setContentLength(int contentLength) {
// noop
}
public void flushBuffer() throws IOException{
output.flush();
}
/** Used in the <code>getOutputStream()</code> method.
*/
private class MyServletOutputStream extends ServletOutputStream {
private ByteArrayOutputStream outputStream;
public MyServletOutputStream(ByteArrayOutputStream outputStream){
this.outputStream = outputStream;
}
public void write(int b){
outputStream.write( b );
}
}
}
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/images/close.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/images/left2.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/images/right2.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/images/right1.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/images/left1.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/images/drop2.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/images/divider.gif
<<Binary file>>
1.1 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/resource/images/drop1.gif
<<Binary file>>
1.9 +0 -5 incubator-myfaces/webapps/examples/web/inc/head.inc
Index: head.inc
===================================================================
RCS file: /home/cvs/incubator-myfaces/webapps/examples/web/inc/head.inc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- head.inc 1 Dec 2004 16:32:03 -0000 1.8
+++ head.inc 1 Dec 2004 20:25:10 -0000 1.9
@@ -14,9 +14,4 @@
<script language="JavaScript" src="jscookmenu/ThemePanel/theme.js"></script>
<link rel="stylesheet" href="jscookmenu/ThemePanel/theme.css" type="text/css">
- <!-- JSCalendar -->
- <script language="JavaScript" src="jscalendar/popcalendar.js" type="text/javascript"></script>
- <link rel="stylesheet" href="jscalendar/jscalendar-WH/theme.css" type="text/css">
- <link rel="stylesheet" href="jscalendar/jscalendar-DB/theme.css" type="text/css">
-
</head>
1.11 +12 -2 incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java
Index: HtmlCalendarRenderer.java
===================================================================
RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/calendar/HtmlCalendarRenderer.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- HtmlCalendarRenderer.java 29 Nov 2004 13:57:56 -0000 1.10
+++ HtmlCalendarRenderer.java 1 Dec 2004 20:25:10 -0000 1.11
@@ -16,6 +16,7 @@
package org.apache.myfaces.custom.calendar;
import org.apache.myfaces.component.html.ext.HtmlInputText;
+import org.apache.myfaces.component.html.util.AddResource;
import org.apache.myfaces.renderkit.JSFAttr;
import org.apache.myfaces.renderkit.RendererUtils;
import org.apache.myfaces.renderkit.html.HTML;
@@ -44,6 +45,10 @@
/**
* $Log$
+ * Revision 1.11 2004/12/01 20:25:10 svieujot
+ * Make the Extensions filter support css and image resources.
+ * Convert the popup calendar to use this new filter.
+ *
* Revision 1.10 2004/11/29 13:57:56 mmarinschek
* changes for input-calendar bugs
*
@@ -107,6 +112,12 @@
if(inputCalendar.isRenderAsPopup())
{
+ // Add the javascript and CSS pages
+ AddResource.addStyleSheet(HtmlCalendarRenderer.class, "WH/theme.css", facesContext);
+ AddResource.addStyleSheet(HtmlCalendarRenderer.class, "DB/theme.css", facesContext);
+ AddResource.addJavaScriptOncePerPage(HtmlCalendarRenderer.class, "popcalendar.js", facesContext,
+ "jscalendarSetImageDirectory("+AddResource.getResourceMappedPath(HtmlCalendarRenderer.class, "DB", facesContext)+")");
+
String dateFormat = CalendarDateTimeConverter.createJSPopupFormat(facesContext,
inputCalendar.getPopupDateFormat());