import java.util.List;
public class TimetableViewSwitcherRenderer extends TabSetRenderer {
@Override
public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
TimetableViewSwitcher switcher = (TimetableViewSwitcher) component;
Timetable timetable = switcher.getTimetable();
List<UIComponent> children = switcher.getChildren();
children.clear();
children.add(createTabSetItem("Month", switcher, "monthItem"));
children.add(createTabSetItem("Week", switcher, "weekItem"));
children.add(createTabSetItem("Day", switcher, "dayItem"));
switcher.setOnchange(
new ScriptBuilder().O$(timetable).dot().functionCall("setViewType",
new RawScript("['month','week','day'][O$('" + switcher.getClientId(context) + "').getSelectedIndex()]")
).toString()
);
super.encodeBegin(context, component);