WebObjects/Web 應用程式/開發/示例/日曆元件
外觀
以下是一個編寫“日曆”元件的小示例
因此,您有一個具體的月份,某些日期是連結(具體取決於日曆的用處),另外還有某些基本的導航(下一個 / 上一個月、年份)。
html 程式碼應類似於此
<webobject name = "Table">
<tr>
<td align = "left" valign = "top" colspan = "7">
<webobject name = "Month"></webobject>
<webobject name = "HasNavigation">
<webobject name = "YearLink"><webobject name = "Year"></webobject></webobject>
</webobject>
</td>
</tr>
<webobject name = "Rows">
<tr>
<webobject name = "Columns">
<td align = "right" valign = "top">
<webobject name = "HasLink">
<webobject name = "IsCurrentDay"></webobject><webobject name = "Link"><webobject name = "Day"></webobject></webobject><webobject name = "IsCurrentDay"></webobject>
</webobject>
<webobject name = "HasNoLink">
<webobject name = "Day"></webobject>
</webobject>
</td>
</webobject>
</tr>
</webobject>
<webobject name = "HasNavigation">
<tr>
<td align = "left" valign = "top" colspan ="3">
<webobject name = "HasPreviousMonth">
<small><webobject name = "PreviousMonthLink"><webobject name = "PreviousMonth"></webobject></webobject></small>
</webobject>
</td>
<td align = "left" valign = "top">
</td>
<td align = "right" valign = "top" colspan ="3">
<webobject name = "HasNextMonth">
<small><webobject name = "NextMonthLink"><webobject name = "NextMonth"></webobject></webobject></small>
</webobject>
</td>
</tr>
</webobject>
</webobject>
以下便是 wod
Table: WOGenericContainer{
elementName = "table";
border = "0";
cellSpacing = "0";
cellPadding = "0";
};
HasNavigation: WOConditional
{
condition = hasNavigation;
};
YearLink: WOHyperlink{
action = displayYear;
};
Year: SpanString{
value = month.year;
isBold = true;
isSmall = true;
class = "Label";
};
Rows: WORepetition{
count = rowCount;
index = rowIndex;
};
Columns: WORepetition{
count = columnCount;
index = columnIndex;
};
Month: SpanString{
value = month.monthName.toUpperCase;
isBold = true;
isSmall = true;
class = "Label";
};
DayName: SpanString{
value = dayName;
isSmall = true;
class = "Label";
};
HasLink: WOConditional{
condition = hasLink;
};
HasNoLink: WOConditional{
condition = hasLink;
negate = true;
};
IsCurrentDay: WOConditional{
condition = isCurrentDay;
};
Link: WOHyperlink{
action = displayDay;
};
Day: SpanString{
value = day.day;
isSmall = true;
isBold = isCurrentDay;
isItalic = isCurrentDay;
class = "Label";
};
HasNextMonth: WOConditional{
condition = hasNextMonth;
};
NextMonthLink: WOHyperlink{
action = displayNextMonth;
};
NextMonth: SpanString
{
value = nextMonthName;
isSmall = true;
class = "Label";
};
HasPreviousMonth: WOConditional{
condition = hasPreviousMonth;
};
PreviousMonthLink: WOHyperlink{
action = displayPreviousMonth;
};
PreviousMonth: SpanString{
value = previousMonthName;
isSmall = true;
class = "Label";
};
元件實現取決於想象力