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"; };
组件实现取决于想象力