You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by "Seith, Jason D." <Se...@hiram.edu> on 2004/08/10 15:18:12 UTC
XSP help for a newbie
Hello All,
I'm afraid I'm new to Lenya, and need a little help (hrm, I think I've
heard that once or twice before).
At any rate, the issue I'm running into is:
I've written a java-esque xsp to produce a calendar. Using the
precedents I've seen, I've used the < and > instead of the angle
brackets for the HTML, but, when I request the page, I am presented with
the literals I added the page (in otherwords, the actual HTML says <
and >).
But the problem isn't that simple. The only way I'm able to get the
program to run (and it runs, except for the above mentioned problem) is
if I encase the <xsp:logic></xsp:logic> with a <page></page> tag.
If I do not, then I get ' ... Line 260, column 0: Syntax error on token
"(", "Identifier" expected '.
Any help is greatly appreciated...
jason
I have included the pipeline, and code.
--------------pipe line-----------------
<map:pipeline>
<map:match pattern="**/main.xsp">
<map:generate type="serverpages"
src="content/authoring/calendar/main.xsp"/>
<map:transform type="xslt" src="xslt/db.xsl"/>
<map:serialize type="html"/>
</map:match>
</map:pipeline>
--------------/pipe line------------------
-------------------xsp--------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:esql="http://apache.org/cocoon/SQL/v2"
xmlns:xsp-session="http://apache.org/xsp/session/2.0"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
>
<xsp:structure>
<xsp:include> java.util.Calendar</xsp:include>
<xsp:include> java.text.Date</xsp:include>
<xsp:include> java.util.DateFormat</xsp:include>
</xsp:structure>
\\where <page> would be to produce a "working" page
<xsp:logic>
String[] month_of_year =
{"January","February","March","April","May","June","July","August","Sept
ember","October","November","December"};
String[] day_of_week = {"Sun", "Mon", "Tues", "Wed", "Thurs",
"Fri", "Sat"};
Date Calendar = new Date();
String cal = "";
int year = Calendar.getYear();
int month = Calendar.getMonth();
int today = Calendar.getDate();
int weekday = Calendar.getDay();
int DAYS_OF_WEEK = 7;
int DAYS_OF_MONTH = 31;
Calendar.setDate(1);
Calendar.setMonth(month);
String TR_start = "<TR>";
String TR_end = "</TR>";
String highlight_start =
"<TD><TABLE><TR><TD><B><CENTER>";
String highlight_end =
"</CENTER></TD></TR></TABLE></B>";
String TD_start = "<TD><CENTER>";
String TD_end = "</CENTER></TD>";
cal = "<TABLE><TR><TD>";
cal += "<TABLE>" + TR_start;
cal += "<TD COLSPAN #61;\""+ DAYS_OF_WEEK + "\"
><CENTER><B>";
cal += month_of_year[month] + " " + (year+1900) +
"</B>" + TD_end + TR_end;
cal += TR_start;
// LOOPS FOR EACH DAY OF WEEK
for(int index=0; index < DAYS_OF_WEEK; index++)
{
// BOLD TODAY'S DAY OF WEEK
if(weekday == index){
cal += TD_start + "</B>" + day_of_week[index] +
"</B>" + TD_end;
// PRINTS DAY
}else{
cal += TD_start + day_of_week[index] + TD_end;
}}
cal += TD_end + TR_end;
cal += TR_start;
// FILL IN BLANK GAPS UNTIL TODAY'S DAY
for(int index1=0; index1 < Calendar.getDay(); index1++){
cal += TD_start + " " + TD_end;
}
// LOOPS FOR EACH DAY IN CALENDAR
for(int index2=0; index2 < DAYS_OF_MONTH; index2++)
{
if( Calendar.getDate() > index2 )
{
// RETURNS THE NEXT DAY TO PRINT
int week_day =Calendar.getDay();
// START NEW ROW FOR FIRST DAY OF WEEK
if(week_day == 0){
cal += TR_start;
}
if(week_day != DAYS_OF_WEEK)
{
// SET VARIABLE INSIDE LOOP FOR
INCREMENTING PURPOSES
int day = Calendar.getDate();
// HIGHLIGHT TODAY'S DATE
if( today==Calendar.getDate()
){
cal += highlight_start + day +
highlight_end + TD_end;
// PRINTS DAY
}else{
cal += TD_start + "<a
href=\"test.xsp?month=" + month + "&day=" + day + "&year=" +
(year+1900) + "\">" + day + "</a>" + TD_end;
}
}
// END ROW FOR LAST DAY OF WEEK
if(week_day == DAYS_OF_WEEK){
cal += TR_end;
}
}
// INCREMENTS UNTIL END OF THE MONTH
Calendar.setDate(Calendar.getDate()+1);
}// end for loop
cal += "</TD></TR></TABLE></TABLE>";
</xsp:logic>
\\where <page> would be to produce a "non-working" page.
<xsp:expr>cal</xsp:expr>
</page>
</xsp:page>
------------------/xsp--------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-user-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-user-help@cocoon.apache.org
Re: XSP help for a newbie
Posted by "Gregor J. Rothfuss" <gr...@apache.org>.
Seith, Jason D. wrote:
> I've written a java-esque xsp to produce a calendar. Using the
> precedents I've seen, I've used the < and > instead of the angle
> brackets for the HTML, but, when I request the page, I am presented with
> the literals I added the page (in otherwords, the actual HTML says <
> and >).
it might be easier to use the calendar generator
http://cocoon.apache.org/2.1/userdocs/generators/calendar-generator.html
and write an xsl to style it as appropriate
> But the problem isn't that simple. The only way I'm able to get the
> program to run (and it runs, except for the above mentioned problem) is
> if I encase the <xsp:logic></xsp:logic> with a <page></page> tag.
have you studied http://cocoon.apache.org/2.1/userdocs/xsp/index.html ?
--
Gregor J. Rothfuss
Wyona Inc. - Open Source Content Management - Apache Lenya
http://wyona.com http://cocoon.apache.org/lenya
gregor.rothfuss@wyona.com gregor@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-user-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-user-help@cocoon.apache.org