public class TimetableRenderer extends TimetableRendererBase {
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
ResponseWriter writer = context.getResponseWriter();
Timetable timetable = (Timetable) component;
if (!component.isRendered())
return;
Rendering.registerDateTimeFormatObject(timetable.getLocale());
AjaxUtil.prepareComponentForAjax(context, timetable);
timetable.setEvent(null);
String clientId = timetable.getClientId(context);
writer.startElement("table", timetable);
writer.writeAttribute("id", clientId, "id");
writer.writeAttribute("cellspacing", "0", null);
writer.writeAttribute("cellpadding", "0", null);
writer.writeAttribute("border", "0", null);
writer.writeAttribute("class", Styles.getCSSClass(context,
timetable, timetable.getStyle(), "o_timetableView", timetable.getStyleClass()), null);
Rendering.writeStandardEvents(writer, timetable);
writer.startElement("tbody", timetable);
renderHeader(context, timetable);
writer.startElement("tr", timetable);
writer.writeAttribute("class", "o_timetableView_tableRow", null);
writer.startElement("td", timetable);
writer.writeAttribute("style", "height: 100%", null);
LayeredPane layeredPane = getLayeredPane(timetable);
layeredPane.encodeAll(context);
List<String> viewIds = new ArrayList<String>();
for (UIComponent c : layeredPane.getChildren()) {
SubPanel subPanel = (SubPanel) c;
if (subPanel.getChildCount() != 1) throw new IllegalStateException();
VirtualContainer container = (VirtualContainer) subPanel.getChildren().get(0);
TimetableView timetableView = (TimetableView) container.getVirtualChild();
String viewId = timetableView.getClientId(context);
viewIds.add(viewId);
}
Rendering.renderInitScript(context, new ScriptBuilder().initScript(context, timetable, "O$.Timetable._init",
layeredPane,
viewIds,
timetable.getViewType(),
Rendering.getEventsParam(timetable, "onviewtypechange")
), getTimetableJsURL(context));
writer.endElement("td");