You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Jurgen Lust <Ju...@UGent.be> on 2005/07/27 14:08:17 UTC
more elaborate demo for x:schedule
I've created a little more elaborate demo for the x:schedule component,
adding some more interactivity:
- appointments are stored in the session
- appointments can be added and removed to the schedule, using a form on
the page
- holidays can be set, using a form on the page
See attachment for patches
Cheers,
Jurgen
Re: more elaborate demo for x:schedule
Posted by Martin Marinschek <ma...@gmail.com>.
thanks Jurgen...
it looks even better now ;)
regards,
Martin
On 7/27/05, Mathias Broekelmann <mb...@psi.de> wrote:
>
> I´ve commited your patches.
>
> Thank you.
>
> Best Regards,
> Mathias
>
> Jurgen Lust schrieb:
> > I've created a little more elaborate demo for the x:schedule component,
> > adding some more interactivity:
> >
> > - appointments are stored in the session
> > - appointments can be added and removed to the schedule, using a form on
> > the page
> > - holidays can be set, using a form on the page
> >
> > See attachment for patches
> >
> >
> > Cheers,
> >
> > Jurgen
> >
> >
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > Index: examples/sandbox/WEB-INF/examples-config.xml
> > ===================================================================
> > --- examples/sandbox/WEB-INF/examples-config.xml (revision 225494)
> > +++ examples/sandbox/WEB-INF/examples-config.xml (working copy)
> > @@ -253,6 +253,16 @@
> > <managed-bean-name>simpleSchedule</managed-bean-name>
> > <managed-bean-class>
> org.apache.myfaces.examples.schedule.SimpleScheduleBackingBean
> </managed-bean-class>
> > <managed-bean-scope>session</managed-bean-scope>
> > + </managed-bean>
> > +
> > + <managed-bean>
> > + <managed-bean-name>simpleAppointment</managed-bean-name>
> > + <managed-bean-class>
> org.apache.myfaces.examples.schedule.SimpleAppointmentBackingBean
> </managed-bean-class>
> > + <managed-bean-scope>request</managed-bean-scope>
> > + <managed-property>
> > + <property-name>scheduleBean</property-name>
> > + <value>#{simpleSchedule}</value>
> > + </managed-property>
> > </managed-bean>
> >
> > </faces-config>
> > Index:
> examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
> > ===================================================================
> > ---
> examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
> (revision 225494)
> > +++
> examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
> (working copy)
> > @@ -1,254 +1,246 @@
> > package org.apache.myfaces.examples.schedule;
> >
> > -import org.apache.myfaces.custom.calendar.HtmlInputCalendar;
> > -import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
> > -import org.apache.myfaces.custom.schedule.model.ScheduleModel;
> > -import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> > -
> > import java.util.ArrayList;
> > -import java.util.Calendar;
> > import java.util.Date;
> > -import java.util.GregorianCalendar;
> >
> > -import javax.faces.component.html.HtmlSelectOneRadio;
> > +import javax.faces.component.html.HtmlSelectOneMenu;
> > import javax.faces.event.ActionEvent;
> > import javax.faces.event.ValueChangeEvent;
> > import javax.faces.model.SelectItem;
> >
> > +import org.apache.myfaces.custom.calendar.HtmlInputCalendar;
> > +import org.apache.myfaces.custom.schedule.model.ScheduleModel;
> > +import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> > +import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
> > +
> > /**
> > -* This is an extremely simple demo of the Schedule component. The
> entries are
> > -* actually hardcoded. A real application would typically use a custom
> implementation
> > -* of the SimpleScheduleModel.
> > -*/
> > -public class SimpleScheduleBackingBean {
> > + * This is a simple demo of the Schedule component.
> > + * The entries are stored in the session.
> > + * A real application would typically use a custom implementation
> > + * of the ScheduleModel.
> > + */
> > +public class SimpleScheduleBackingBean
> > +{
> >
> > - //~ Instance fields
> --------------------------------------------------------
> > + //~ Instance fields
> --------------------------------------------------------
> >
> > - private Date date = new Date();
> > - private HtmlInputCalendar dateInput;
> > - private HtmlSelectOneRadio modeInput;
> > - private Integer mode = new Integer(ScheduleModel.WORKWEEK);
> > - private SimpleScheduleModel model;
> > + private Date date = new Date();
> > + private HtmlInputCalendar dateInput;
> > + private HtmlSelectOneMenu modeInput;
> > + private Integer mode = new Integer(ScheduleModel.WORKWEEK);
> > + private SimpleScheduleModel model;
> >
> > - //~ Constructors
> -----------------------------------------------------------
> > + //~ Constructors
> -----------------------------------------------------------
> >
> > - /**
> > - * Creates a new SimpleScheduleBackingBean object.
> > - */
> > - public SimpleScheduleBackingBean() {
> > - super();
> > - initModel();
> > - }
> > + /**
> > + * Creates a new SimpleScheduleBackingBean object.
> > + */
> > + public SimpleScheduleBackingBean()
> > + {
> > + super();
> > + initModel();
> > + }
> >
> > - //~ Methods
> ----------------------------------------------------------------
> > + //~ Methods
> ----------------------------------------------------------------
> >
> > - /**
> > - * @param date The date to set.
> > - */
> > - public void setDate(Date date) {
> > - this.date = date;
> > - }
> > + /**
> > + * @param date The date to set.
> > + */
> > + public void setDate(Date date)
> > + {
> > + this.date = date;
> > + }
> >
> > - /**
> > - * @return Returns the date.
> > - */
> > - public Date getDate() {
> > - return date;
> > - }
> > + /**
> > + * @return Returns the date.
> > + */
> > + public Date getDate()
> > + {
> > + return date;
> > + }
> >
> > - /**
> > - * @param dateInput The dateInput to set.
> > - */
> > - public void setDateInput(HtmlInputCalendar dateInput) {
> > - this.dateInput = dateInput;
> > - }
> > + /**
> > + * @param dateInput The dateInput to set.
> > + */
> > + public void setDateInput(HtmlInputCalendar dateInput)
> > + {
> > + this.dateInput = dateInput;
> > + }
> >
> > - /**
> > - * @return Returns the dateInput.
> > - */
> > - public HtmlInputCalendar getDateInput() {
> > - return dateInput;
> > - }
> > + /**
> > + * @return Returns the dateInput.
> > + */
> > + public HtmlInputCalendar getDateInput()
> > + {
> > + return dateInput;
> > + }
> >
> > - /**
> > - * @param mode The mode to set.
> > - */
> > - public void setMode(Integer mode) {
> > - this.mode = mode;
> > - }
> > + /**
> > + * @param mode The mode to set.
> > + */
> > + public void setMode(Integer mode)
> > + {
> > + this.mode = mode;
> > + }
> >
> > - /**
> > - * @return Returns the mode.
> > - */
> > - public Integer getMode() {
> > - return mode;
> > - }
> > + /**
> > + * @return Returns the mode.
> > + */
> > + public Integer getMode()
> > + {
> > + return mode;
> > + }
> >
> > - /**
> > - * @param modeInput The modeInput to set.
> > - */
> > - public void setModeInput(HtmlSelectOneRadio modeInput) {
> > - this.modeInput = modeInput;
> > - }
> > + /**
> > + * @param modeInput The modeInput to set.
> > + */
> > + public void setModeInput(HtmlSelectOneMenu modeInput)
> > + {
> > + this.modeInput = modeInput;
> > + }
> >
> > - /**
> > - * @return Returns the modeInput.
> > - */
> > - public HtmlSelectOneRadio getModeInput() {
> > - return modeInput;
> > - }
> > + /**
> > + * @return Returns the modeInput.
> > + */
> > + public HtmlSelectOneMenu getModeInput()
> > + {
> > + return modeInput;
> > + }
> >
> > - /**
> > - * <p>
> > - * get the SelectItems for the mode SelectOneRadio
> > - * </p>
> > - *
> > - * @return an ArrayList of SelectItems
> > - */
> > - public ArrayList getModeItems() {
> > - ArrayList items = new ArrayList();
> > - items.add(new SelectItem(new Integer(ScheduleModel.DAY), "day"));
> > - items.add(
> > - new SelectItem(new Integer(ScheduleModel.WORKWEEK), "workweek")
> > - );
> > - items.add(new SelectItem(new Integer(ScheduleModel.WEEK), "week"));
> > - items.add(new SelectItem(new Integer(ScheduleModel.MONTH), "month"));
> > + /**
> > + * <p>
> > + * get the SelectItems for the mode SelectOneRadio
> > + * </p>
> > + *
> > + * @return an ArrayList of SelectItems
> > + */
> > + public ArrayList getModeItems()
> > + {
> > + ArrayList items = new ArrayList();
> > + items.add(new SelectItem(new Integer(ScheduleModel.DAY), "day"));
> > + items.add(new SelectItem(new Integer(ScheduleModel.WORKWEEK),
> > + "workweek"));
> > + items.add(new SelectItem(new Integer(ScheduleModel.WEEK), "week"));
> > + items.add(new SelectItem(new Integer(ScheduleModel.MONTH), "month"));
> >
> > - return items;
> > - }
> > + return items;
> > + }
> >
> > - /**
> > - * @param model The model to set.
> > - */
> > - public void setModel(SimpleScheduleModel model) {
> > - this.model = model;
> > - }
> > + /**
> > + * @param model The model to set.
> > + */
> > + public void setModel(SimpleScheduleModel model)
> > + {
> > + this.model = model;
> > + }
> >
> > - /**
> > - * @return Returns the model.
> > - */
> > - public ScheduleModel getModel() {
> > - return model;
> > - }
> > + /**
> > + * @return Returns the model.
> > + */
> > + public ScheduleModel getModel()
> > + {
> > + return model;
> > + }
> >
> > - /**
> > - * <p>
> > - * a String describing the selected entry on the schedule
> > - * </p>
> > - *
> > - * @return the entry as a string
> > - */
> > - public String getSelectedEntry() {
> > - if ((model == null) || (model.getSelectedEntry() == null)) {
> > - return "no entry selected";
> > - }
> > + /**
> > + * <p>
> > + * a String describing the selected entry on the schedule
> > + * </p>
> > + *
> > + * @return the entry as a string
> > + */
> > + public String getSelectedEntry()
> > + {
> > + if ((model == null) || (model.getSelectedEntry() == null))
> > + {
> > + return "no entry selected";
> > + }
> >
> > - StringBuffer entry = new StringBuffer();
> > - entry.append(model.getSelectedEntry().getTitle());
> > - entry.append(": ");
> > - entry.append(model.getSelectedEntry().getStartTime());
> > - entry.append(" - ");
> > - entry.append(model.getSelectedEntry().getEndTime());
> > + StringBuffer entry = new StringBuffer();
> > + entry.append(model.getSelectedEntry().getTitle());
> > + entry.append(": ");
> > + entry.append(model.getSelectedEntry().getStartTime());
> > + entry.append(" - ");
> > + entry.append(model.getSelectedEntry().getEndTime());
> >
> > - String returnString = entry.toString();
> > + String returnString = entry.toString();
> >
> > - return returnString;
> > - }
> > + return returnString;
> > + }
> >
> > - /**
> > - * <p>
> > - * action listener for the schedule component.
> > - * </p>
> > - *
> > - * @param actionEvent the action event
> > - */
> > - public void actionPerformed(ActionEvent actionEvent) {
> > - }
> > + /**
> > + * Is there an entry currently selected?
> > + *
> > + * @return if an entry is currently selected
> > + */
> > + public boolean isEntrySelected()
> > + {
> > + return model != null && model.getSelectedEntry() != null;
> > + }
> >
> > - /**
> > - * <p>
> > - * When the date of the calendar component changes, navigate to that
> date
> > - * in the schedule component.
> > - * </p>
> > - *
> > - * @param event the change event
> > - */
> > - public void dateChanged(ValueChangeEvent event) {
> > - this.date = (Date) dateInput.getValue();
> > - model.setSelectedDate(date);
> > - model.refresh();
> > - }
> > + /**
> > + * <p>
> > + * action listener for the schedule component.
> > + * </p>
> > + *
> > + * @param actionEvent the action event
> > + */
> > + public void scheduleActionPerformed(ActionEvent actionEvent)
> > + {
> > + }
> >
> > - /**
> > - * <p>
> > - * When a different mode is selected, apply this mode to the schedule
> > - * component.
> > - * </p>
> > - *
> > - * @param event the change event
> > - */
> > - public void modeChanged(ValueChangeEvent event) {
> > - if (mode == null) {
> > - return;
> > - }
> > + /**
> > + * <p>
> > + * When a date is selected in the calendar component, navigate to that
> date
> > + * in the schedule component.
> > + * </p>
> > + *
> > + * @param event the action event
> > + */
> > + public void calendarValueChanged(ValueChangeEvent event)
> > + {
> > + if (date != null
> > + && ScheduleUtil.truncate(date).equals(
> > + ScheduleUtil.truncate((Date) dateInput.getValue())))
> > + return;
> > + this.date = (Date) dateInput.getValue();
> > + model.setSelectedDate(date);
> > + model.refresh();
> > + }
> >
> > - this.mode = (Integer) modeInput.getValue();
> > - model.setMode(mode.intValue());
> > + /**
> > + * <p>
> > + * When a different mode is selected, apply this mode to the schedule
> > + * component.
> > + * </p>
> > + *
> > + * @param event the action event
> > + */
> > + public void modeValueChanged(ValueChangeEvent event)
> > + {
> > + if (mode != null && mode.equals((Integer) modeInput.getValue()))
> > + return;
> > + this.mode = (Integer) modeInput.getValue();
> > + model.setMode(mode.intValue());
> > + model.refresh();
> > + this.date = model.getSelectedDate();
> > + dateInput.setValue(model.getSelectedDate());
> > + }
> >
> > - model.refresh();
> > - }
> > + /**
> > + * Initialize the demo
> > + */
> > + private void initModel()
> > + {
> > + if (model == null)
> > + {
> > + model = new SimpleScheduleModel();
> > + }
> >
> > - /**
> > - * Initialize the demo: We're just adding 3 appointments here, it would
> > - * be easy to do this from a form on the page.
> > - */
> > - private void initModel() {
> > - if (model == null) {
> > - model = new SimpleScheduleModel();
> > - }
> > + this.date = new Date();
> >
> > - Date today = new Date();
> > + model.setMode(mode.intValue());
> >
> > - Calendar cal = GregorianCalendar.getInstance();
> > - cal.setTime(new Date());
> > - cal.set(Calendar.HOUR_OF_DAY, 11);
> > - cal.set(Calendar.MINUTE, 30);
> > - cal.set(Calendar.SECOND, 00);
> > - cal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
> > -
> > - DefaultScheduleEntry entry1 = new DefaultScheduleEntry();
> > - entry1.setStartTime(cal.getTime());
> > - cal.add(Calendar.HOUR_OF_DAY, 2);
> > - entry1.setEndTime(cal.getTime());
> > - entry1.setId("1");
> > - entry1.setTitle("Meeting with portal developers");
> > - entry1.setSubtitle("Meeting room 1");
> > -
> > - DefaultScheduleEntry entry2 = new DefaultScheduleEntry();
> > - cal.add(Calendar.HOUR_OF_DAY, -1);
> > - entry2.setStartTime(cal.getTime());
> > - cal.add(Calendar.HOUR, 4);
> > - entry2.setEndTime(cal.getTime());
> > - entry2.setId("2");
> > - entry2.setTitle("work on MyFaces components");
> > - entry2.setSubtitle("");
> > - entry2.setDescription("I should create a more elaborate demo");
> > -
> > - DefaultScheduleEntry entry3 = new DefaultScheduleEntry();
> > - cal.add(Calendar.HOUR_OF_DAY, -48);
> > - entry3.setStartTime(cal.getTime());
> > - cal.add(Calendar.HOUR_OF_DAY, 48);
> > - entry3.setEndTime(cal.getTime());
> > - entry3.setId("3");
> > - entry3.setTitle("Business trip");
> > - entry3.setSubtitle("Paris");
> > - entry3.setDescription("Better brush up on my French before I
> leave...");
> > - model.addEntry(entry1);
> > - model.addEntry(entry2);
> > - model.addEntry(entry3);
> > -
> > - model.setMode(mode.intValue());
> > -
> > - model.setSelectedDate(today);
> > - }
> > + model.setSelectedDate(this.date);
> > + }
> > }
> > Index: examples/sandbox/schedule.jsp
> > ===================================================================
> > --- examples/sandbox/schedule.jsp (revision 225494)
> > +++ examples/sandbox/schedule.jsp (working copy)
> > @@ -1,53 +1,172 @@
> > -<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> > -<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> > -<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="x"%>
> > -
> > -<!--
> > -/*
> > - * Copyright 2005 The Apache Software Foundation.
> > - *
> > - * Licensed under the Apache License, Version 2.0 (the "License");
> > - * you may not use this file except in compliance with the License.
> > - * You may obtain a copy of the License at
> > - *
> > - * http://www.apache.org/licenses/LICENSE-2.0
> > - *
> > - * Unless required by applicable law or agreed to in writing, software
> > - * distributed under the License is distributed on an "AS IS" BASIS,
> > - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> > - * See the License for the specific language governing permissions and
> > - * limitations under the License.
> > - */
> > -//-->
> > -<html>
> > -
> > - <%@include file="inc/head.inc" %>
> > -
> > - <body>
> > - <f:view>
> > - <h:form>
> > - <br/>
> > - <h:panelGroup>
> > - <h:outputLabel for="modeInput">
> > - <h:outputText value="mode: " />
> > - </h:outputLabel>
> > - <h:selectOneRadio id="modeInput" layout="lineDirection"
> > - binding="#{simpleSchedule.modeInput}" immediate="true"
> > - valueChangeListener="#{simpleSchedule.modeChanged}"
> > - onchange="this.form.submit();" value="#{simpleSchedule.mode}">
> > - <f:selectItems id="modeItems" value="#{simpleSchedule.modeItems}" />
> > - </h:selectOneRadio>
> > -
> > - </h:panelGroup>
> > -
> > - <x:schedule value="#{simpleSchedule.model}" id="schedule1"
> > - rendered="true" visibleEndHour="18" visibleStartHour="8"
> > - workingEndHour="17" workingStartHour="9" readonly="false"
> > - actionListener="#{simpleSchedule.actionPerformed}" tooltip="true"/>
> > - </h:form>
> > - </f:view>
> > - </body>
> > -
> > - <%@include file="inc/page_footer.jsp" %>
> > -
> > -</html>
> > +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> > +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> > +<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
> > +<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
> > +
> > +<!--
> > +/*
> > + * Copyright 2005 The Apache Software Foundation.
> > + *
> > + * Licensed under the Apache License, Version 2.0 (the "License");
> > + * you may not use this file except in compliance with the License.
> > + * You may obtain a copy of the License at
> > + *
> > + * http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing, software
> > + * distributed under the License is distributed on an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> > + * See the License for the specific language governing permissions and
> > + * limitations under the License.
> > + */
> > +//-->
> > +<html>
> > +
> > + <%@include file="inc/head.inc" %>
> > +
> > + <body>
> > + <f:view>
> > + <h:form>
> > + <h:messages
> > + tooltip="true"
> > + id="scheduleMessages"
> > + layout="table"
> > + globalOnly="false"/>
> > +
> > + <table cellpadding="5" border="0">
> > + <tr>
> > + <td valign="top">
> > + <h:panelGrid cellpadding="0" cellspacing="15" columns="1">
> > + <x:inputCalendar
> > + id="scheduleNavigator"
> > + monthYearRowClass="yearMonthHeader"
> > + weekRowClass="weekHeader"
> > + currentDayCellClass="currentDayCell"
> > + value="#{simpleSchedule.date}"
> > + valueChangeListener="#{simpleSchedule.calendarValueChanged}"
> > + binding="#{simpleSchedule.dateInput}"/>
> > + <h:outputLabel
> > + for="modeInput"
> > + id="modeLabel"
> > + value="mode:"/>
> > + <h:selectOneMenu
> > + id="modeInput"
> > + binding="#{simpleSchedule.modeInput}"
> > + immediate="true"
> > + valueChangeListener="#{simpleSchedule.modeValueChanged}"
> > + onchange="this.form.submit();"
> > + value="#{simpleSchedule.mode}">
> > + <f:selectItems
> > + id="modeItems"
> > + value="#{simpleSchedule.modeItems}"/>
> > + </h:selectOneMenu>
> > + </h:panelGrid>
> > + </td>
> > + <td width="100%">
> > + <s:schedule
> > + value="#{simpleSchedule.model}"
> > + id="schedule1"
> > + rendered="true"
> > + visibleEndHour="18"
> > + visibleStartHour="8"
> > + workingEndHour="17"
> > + workingStartHour="9"
> > + readonly="false"
> > + actionListener="#{simpleSchedule.scheduleActionPerformed}"
> > + tooltip="true"/>
> > + </td>
> > + </tr>
> > + <tr>
> > + <td valign="top">
> > + <h3><h:outputText value="add appointment"/></h3>
> > + </td>
> > + <td>
> > + <h:panelGrid cellpadding="0" cellspacing="0" columns="2">
> > + <h:outputLabel
> > + for="appStart"
> > + value="start:"/>
> > + <x:inputDate
> > + id="appStart"
> > + value="#{simpleAppointment.appointmentStart}"
> > + type="both"/>
> > + <h:outputLabel
> > + for="appEnd"
> > + value="end:"/>
> > + <x:inputDate
> > + id="appEnd"
> > + value="#{simpleAppointment.appointmentEnd}"
> > + type="both"/>
> > + <h:outputLabel
> > + for="appTitle"
> > + value="title:"/>
> > + <h:inputText
> > + size="60"
> > + id="appTitle"
> > + value="#{simpleAppointment.appointmentTitle}"/>
> > + <h:outputLabel
> > + for="appLocation"
> > + value="location:"/>
> > + <h:inputText
> > + size="60"
> > + id="appLocation"
> > + value="#{simpleAppointment.appointmentLocation}"/>
> > + <h:outputLabel
> > + for="appComments"
> > + value="comments:"/>
> > + <h:inputTextarea
> > + cols="60"
> > + rows="5"
> > + id="appComments"
> > + value="#{simpleAppointment.appointmentComments}"/>
> > + <h:commandButton
> > + value="Add appointment"
> > + actionListener="#{simpleAppointment.addAppointment}"/>
> > + </h:panelGrid>
> > + </td>
> > + </tr>
> > + <tr>
> > + <td valign="top">
> > + <h3><h:outputText value="remove appointment"/></h3>
> > + </td>
> > + <td>
> > + <h:commandButton
> > + value="Remove selected appointment"
> > + actionListener="#{simpleAppointment.removeAppointment}"
> > + disabled="#{!simpleSchedule.entrySelected}"/>
> > + </td>
> > + </tr>
> > + <tr>
> > + <td valign="top">
> > + <h3><h:outputText value="add holiday"/></h3>
> > + </td>
> > + <td>
> > + <h:panelGrid cellpadding="0" cellspacing="0" columns="2">
> > + <h:outputLabel
> > + for="holidayDate"
> > + value="date:"/>
> > + <x:inputDate
> > + id="holidayDate"
> > + value="#{simpleAppointment.holidayDate}"
> > + type="date"/>
> > + <h:outputLabel
> > + for="holidayName"
> > + value="name:"/>
> > + <h:inputText
> > + size="60"
> > + id="holidayName"
> > + value="#{simpleAppointment.holidayName}"/>
> > + <h:commandButton
> > + value="Add holiday"
> > + actionListener="#{simpleAppointment.addHoliday}"/>
> > + </h:panelGrid>
> > + </td>
> > + </tr>
> > + </table>
> > +
> > + </h:form>
> > + </f:view>
> > + </body>
> > +
> > + <%@include file="inc/page_footer.jsp" %>
> > +
> > +</html>
> >
> >
> > ------------------------------------------------------------------------
> >
> > Index:
> sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java
> > ===================================================================
> > ---
> sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java
> (revision 225494)
> > +++
> sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java
> (working copy)
> > @@ -87,8 +87,6 @@
> > * </p>
> > *
> > * @param entry the entry to add
> > - *
> > - * @return true if successful
> > */
> > public void addEntry(ScheduleEntry entry)
> > {
> > @@ -96,6 +94,18 @@
> > }
> >
> > /**
> > + * <p>
> > + * Remove an entry from the model
> > + * </p>
> > + *
> > + * @param entry the entry to remove
> > + */
> > + public void removeEntry(ScheduleEntry entry)
> > + {
> > + entries.remove(entry);
> > + }
> > +
> > + /**
> > * @see
> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries
> (java.util.Date, java.util.Date)
> > */
> > protected Collection loadEntries(Date startDate, Date endDate)
>
>
Re: more elaborate demo for x:schedule
Posted by Sean Schofield <se...@gmail.com>.
Patch has been applied.
On 7/27/05, Jurgen Lust <Ju...@ugent.be> wrote:
> The examples patch didn't contain an added class, due to a lack of SVN
> experience from my part :-S
> The attached file fixes this.
>
> Sorry about that...
>
> Jurgen
>
>
> Op wo, 27-07-2005 te 14:17 +0200, schreef Mathias Broekelmann:
> > I´ve commited your patches.
> >
> > Thank you.
> >
> > Best Regards,
> > Mathias
> >
> > Jurgen Lust schrieb:
> > > I've created a little more elaborate demo for the x:schedule component,
> > > adding some more interactivity:
> > >
> > > - appointments are stored in the session
> > > - appointments can be added and removed to the schedule, using a form on
> > > the page
> > > - holidays can be set, using a form on the page
> > >
> > > See attachment for patches
> > >
> > >
> > > Cheers,
> > >
> > > Jurgen
> > >
> > >
> > >
> > >
> > >
> > >
> > > ------------------------------------------------------------------------
> > >
> > > Index: examples/sandbox/WEB-INF/examples-config.xml
> > > ===================================================================
> > > --- examples/sandbox/WEB-INF/examples-config.xml (revision 225494)
> > > +++ examples/sandbox/WEB-INF/examples-config.xml (working copy)
> > > @@ -253,6 +253,16 @@
> > > <managed-bean-name>simpleSchedule</managed-bean-name>
> > > <managed-bean-class>org.apache.myfaces.examples.schedule.SimpleScheduleBackingBean</managed-bean-class>
> > > <managed-bean-scope>session</managed-bean-scope>
> > > + </managed-bean>
> > > +
> > > + <managed-bean>
> > > + <managed-bean-name>simpleAppointment</managed-bean-name>
> > > + <managed-bean-class>org.apache.myfaces.examples.schedule.SimpleAppointmentBackingBean</managed-bean-class>
> > > + <managed-bean-scope>request</managed-bean-scope>
> > > + <managed-property>
> > > + <property-name>scheduleBean</property-name>
> > > + <value>#{simpleSchedule}</value>
> > > + </managed-property>
> > > </managed-bean>
> > >
> > > </faces-config>
> > > Index: examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
> > > ===================================================================
> > > --- examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java (revision 225494)
> > > +++ examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java (working copy)
> > > @@ -1,254 +1,246 @@
> > > package org.apache.myfaces.examples.schedule;
> > >
> > > -import org.apache.myfaces.custom.calendar.HtmlInputCalendar;
> > > -import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
> > > -import org.apache.myfaces.custom.schedule.model.ScheduleModel;
> > > -import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> > > -
> > > import java.util.ArrayList;
> > > -import java.util.Calendar;
> > > import java.util.Date;
> > > -import java.util.GregorianCalendar;
> > >
> > > -import javax.faces.component.html.HtmlSelectOneRadio;
> > > +import javax.faces.component.html.HtmlSelectOneMenu;
> > > import javax.faces.event.ActionEvent;
> > > import javax.faces.event.ValueChangeEvent;
> > > import javax.faces.model.SelectItem;
> > >
> > > +import org.apache.myfaces.custom.calendar.HtmlInputCalendar;
> > > +import org.apache.myfaces.custom.schedule.model.ScheduleModel;
> > > +import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> > > +import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
> > > +
> > > /**
> > > -* This is an extremely simple demo of the Schedule component. The entries are
> > > -* actually hardcoded. A real application would typically use a custom implementation
> > > -* of the SimpleScheduleModel.
> > > -*/
> > > -public class SimpleScheduleBackingBean {
> > > + * This is a simple demo of the Schedule component.
> > > + * The entries are stored in the session.
> > > + * A real application would typically use a custom implementation
> > > + * of the ScheduleModel.
> > > + */
> > > +public class SimpleScheduleBackingBean
> > > +{
> > >
> > > - //~ Instance fields --------------------------------------------------------
> > > + //~ Instance fields --------------------------------------------------------
> > >
> > > - private Date date = new Date();
> > > - private HtmlInputCalendar dateInput;
> > > - private HtmlSelectOneRadio modeInput;
> > > - private Integer mode = new Integer(ScheduleModel.WORKWEEK);
> > > - private SimpleScheduleModel model;
> > > + private Date date = new Date();
> > > + private HtmlInputCalendar dateInput;
> > > + private HtmlSelectOneMenu modeInput;
> > > + private Integer mode = new Integer(ScheduleModel.WORKWEEK);
> > > + private SimpleScheduleModel model;
> > >
> > > - //~ Constructors -----------------------------------------------------------
> > > + //~ Constructors -----------------------------------------------------------
> > >
> > > - /**
> > > - * Creates a new SimpleScheduleBackingBean object.
> > > - */
> > > - public SimpleScheduleBackingBean() {
> > > - super();
> > > - initModel();
> > > - }
> > > + /**
> > > + * Creates a new SimpleScheduleBackingBean object.
> > > + */
> > > + public SimpleScheduleBackingBean()
> > > + {
> > > + super();
> > > + initModel();
> > > + }
> > >
> > > - //~ Methods ----------------------------------------------------------------
> > > + //~ Methods ----------------------------------------------------------------
> > >
> > > - /**
> > > - * @param date The date to set.
> > > - */
> > > - public void setDate(Date date) {
> > > - this.date = date;
> > > - }
> > > + /**
> > > + * @param date The date to set.
> > > + */
> > > + public void setDate(Date date)
> > > + {
> > > + this.date = date;
> > > + }
> > >
> > > - /**
> > > - * @return Returns the date.
> > > - */
> > > - public Date getDate() {
> > > - return date;
> > > - }
> > > + /**
> > > + * @return Returns the date.
> > > + */
> > > + public Date getDate()
> > > + {
> > > + return date;
> > > + }
> > >
> > > - /**
> > > - * @param dateInput The dateInput to set.
> > > - */
> > > - public void setDateInput(HtmlInputCalendar dateInput) {
> > > - this.dateInput = dateInput;
> > > - }
> > > + /**
> > > + * @param dateInput The dateInput to set.
> > > + */
> > > + public void setDateInput(HtmlInputCalendar dateInput)
> > > + {
> > > + this.dateInput = dateInput;
> > > + }
> > >
> > > - /**
> > > - * @return Returns the dateInput.
> > > - */
> > > - public HtmlInputCalendar getDateInput() {
> > > - return dateInput;
> > > - }
> > > + /**
> > > + * @return Returns the dateInput.
> > > + */
> > > + public HtmlInputCalendar getDateInput()
> > > + {
> > > + return dateInput;
> > > + }
> > >
> > > - /**
> > > - * @param mode The mode to set.
> > > - */
> > > - public void setMode(Integer mode) {
> > > - this.mode = mode;
> > > - }
> > > + /**
> > > + * @param mode The mode to set.
> > > + */
> > > + public void setMode(Integer mode)
> > > + {
> > > + this.mode = mode;
> > > + }
> > >
> > > - /**
> > > - * @return Returns the mode.
> > > - */
> > > - public Integer getMode() {
> > > - return mode;
> > > - }
> > > + /**
> > > + * @return Returns the mode.
> > > + */
> > > + public Integer getMode()
> > > + {
> > > + return mode;
> > > + }
> > >
> > > - /**
> > > - * @param modeInput The modeInput to set.
> > > - */
> > > - public void setModeInput(HtmlSelectOneRadio modeInput) {
> > > - this.modeInput = modeInput;
> > > - }
> > > + /**
> > > + * @param modeInput The modeInput to set.
> > > + */
> > > + public void setModeInput(HtmlSelectOneMenu modeInput)
> > > + {
> > > + this.modeInput = modeInput;
> > > + }
> > >
> > > - /**
> > > - * @return Returns the modeInput.
> > > - */
> > > - public HtmlSelectOneRadio getModeInput() {
> > > - return modeInput;
> > > - }
> > > + /**
> > > + * @return Returns the modeInput.
> > > + */
> > > + public HtmlSelectOneMenu getModeInput()
> > > + {
> > > + return modeInput;
> > > + }
> > >
> > > - /**
> > > - * <p>
> > > - * get the SelectItems for the mode SelectOneRadio
> > > - * </p>
> > > - *
> > > - * @return an ArrayList of SelectItems
> > > - */
> > > - public ArrayList getModeItems() {
> > > - ArrayList items = new ArrayList();
> > > - items.add(new SelectItem(new Integer(ScheduleModel.DAY), "day"));
> > > - items.add(
> > > - new SelectItem(new Integer(ScheduleModel.WORKWEEK), "workweek")
> > > - );
> > > - items.add(new SelectItem(new Integer(ScheduleModel.WEEK), "week"));
> > > - items.add(new SelectItem(new Integer(ScheduleModel.MONTH), "month"));
> > > + /**
> > > + * <p>
> > > + * get the SelectItems for the mode SelectOneRadio
> > > + * </p>
> > > + *
> > > + * @return an ArrayList of SelectItems
> > > + */
> > > + public ArrayList getModeItems()
> > > + {
> > > + ArrayList items = new ArrayList();
> > > + items.add(new SelectItem(new Integer(ScheduleModel.DAY), "day"));
> > > + items.add(new SelectItem(new Integer(ScheduleModel.WORKWEEK),
> > > + "workweek"));
> > > + items.add(new SelectItem(new Integer(ScheduleModel.WEEK), "week"));
> > > + items.add(new SelectItem(new Integer(ScheduleModel.MONTH), "month"));
> > >
> > > - return items;
> > > - }
> > > + return items;
> > > + }
> > >
> > > - /**
> > > - * @param model The model to set.
> > > - */
> > > - public void setModel(SimpleScheduleModel model) {
> > > - this.model = model;
> > > - }
> > > + /**
> > > + * @param model The model to set.
> > > + */
> > > + public void setModel(SimpleScheduleModel model)
> > > + {
> > > + this.model = model;
> > > + }
> > >
> > > - /**
> > > - * @return Returns the model.
> > > - */
> > > - public ScheduleModel getModel() {
> > > - return model;
> > > - }
> > > + /**
> > > + * @return Returns the model.
> > > + */
> > > + public ScheduleModel getModel()
> > > + {
> > > + return model;
> > > + }
> > >
> > > - /**
> > > - * <p>
> > > - * a String describing the selected entry on the schedule
> > > - * </p>
> > > - *
> > > - * @return the entry as a string
> > > - */
> > > - public String getSelectedEntry() {
> > > - if ((model == null) || (model.getSelectedEntry() == null)) {
> > > - return "no entry selected";
> > > - }
> > > + /**
> > > + * <p>
> > > + * a String describing the selected entry on the schedule
> > > + * </p>
> > > + *
> > > + * @return the entry as a string
> > > + */
> > > + public String getSelectedEntry()
> > > + {
> > > + if ((model == null) || (model.getSelectedEntry() == null))
> > > + {
> > > + return "no entry selected";
> > > + }
> > >
> > > - StringBuffer entry = new StringBuffer();
> > > - entry.append(model.getSelectedEntry().getTitle());
> > > - entry.append(": ");
> > > - entry.append(model.getSelectedEntry().getStartTime());
> > > - entry.append(" - ");
> > > - entry.append(model.getSelectedEntry().getEndTime());
> > > + StringBuffer entry = new StringBuffer();
> > > + entry.append(model.getSelectedEntry().getTitle());
> > > + entry.append(": ");
> > > + entry.append(model.getSelectedEntry().getStartTime());
> > > + entry.append(" - ");
> > > + entry.append(model.getSelectedEntry().getEndTime());
> > >
> > > - String returnString = entry.toString();
> > > + String returnString = entry.toString();
> > >
> > > - return returnString;
> > > - }
> > > + return returnString;
> > > + }
> > >
> > > - /**
> > > - * <p>
> > > - * action listener for the schedule component.
> > > - * </p>
> > > - *
> > > - * @param actionEvent the action event
> > > - */
> > > - public void actionPerformed(ActionEvent actionEvent) {
> > > - }
> > > + /**
> > > + * Is there an entry currently selected?
> > > + *
> > > + * @return if an entry is currently selected
> > > + */
> > > + public boolean isEntrySelected()
> > > + {
> > > + return model != null && model.getSelectedEntry() != null;
> > > + }
> > >
> > > - /**
> > > - * <p>
> > > - * When the date of the calendar component changes, navigate to that date
> > > - * in the schedule component.
> > > - * </p>
> > > - *
> > > - * @param event the change event
> > > - */
> > > - public void dateChanged(ValueChangeEvent event) {
> > > - this.date = (Date) dateInput.getValue();
> > > - model.setSelectedDate(date);
> > > - model.refresh();
> > > - }
> > > + /**
> > > + * <p>
> > > + * action listener for the schedule component.
> > > + * </p>
> > > + *
> > > + * @param actionEvent the action event
> > > + */
> > > + public void scheduleActionPerformed(ActionEvent actionEvent)
> > > + {
> > > + }
> > >
> > > - /**
> > > - * <p>
> > > - * When a different mode is selected, apply this mode to the schedule
> > > - * component.
> > > - * </p>
> > > - *
> > > - * @param event the change event
> > > - */
> > > - public void modeChanged(ValueChangeEvent event) {
> > > - if (mode == null) {
> > > - return;
> > > - }
> > > + /**
> > > + * <p>
> > > + * When a date is selected in the calendar component, navigate to that date
> > > + * in the schedule component.
> > > + * </p>
> > > + *
> > > + * @param event the action event
> > > + */
> > > + public void calendarValueChanged(ValueChangeEvent event)
> > > + {
> > > + if (date != null
> > > + && ScheduleUtil.truncate(date).equals(
> > > + ScheduleUtil.truncate((Date) dateInput.getValue())))
> > > + return;
> > > + this.date = (Date) dateInput.getValue();
> > > + model.setSelectedDate(date);
> > > + model.refresh();
> > > + }
> > >
> > > - this.mode = (Integer) modeInput.getValue();
> > > - model.setMode(mode.intValue());
> > > + /**
> > > + * <p>
> > > + * When a different mode is selected, apply this mode to the schedule
> > > + * component.
> > > + * </p>
> > > + *
> > > + * @param event the action event
> > > + */
> > > + public void modeValueChanged(ValueChangeEvent event)
> > > + {
> > > + if (mode != null && mode.equals((Integer) modeInput.getValue()))
> > > + return;
> > > + this.mode = (Integer) modeInput.getValue();
> > > + model.setMode(mode.intValue());
> > > + model.refresh();
> > > + this.date = model.getSelectedDate();
> > > + dateInput.setValue(model.getSelectedDate());
> > > + }
> > >
> > > - model.refresh();
> > > - }
> > > + /**
> > > + * Initialize the demo
> > > + */
> > > + private void initModel()
> > > + {
> > > + if (model == null)
> > > + {
> > > + model = new SimpleScheduleModel();
> > > + }
> > >
> > > - /**
> > > - * Initialize the demo: We're just adding 3 appointments here, it would
> > > - * be easy to do this from a form on the page.
> > > - */
> > > - private void initModel() {
> > > - if (model == null) {
> > > - model = new SimpleScheduleModel();
> > > - }
> > > + this.date = new Date();
> > >
> > > - Date today = new Date();
> > > + model.setMode(mode.intValue());
> > >
> > > - Calendar cal = GregorianCalendar.getInstance();
> > > - cal.setTime(new Date());
> > > - cal.set(Calendar.HOUR_OF_DAY, 11);
> > > - cal.set(Calendar.MINUTE, 30);
> > > - cal.set(Calendar.SECOND, 00);
> > > - cal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
> > > -
> > > - DefaultScheduleEntry entry1 = new DefaultScheduleEntry();
> > > - entry1.setStartTime(cal.getTime());
> > > - cal.add(Calendar.HOUR_OF_DAY, 2);
> > > - entry1.setEndTime(cal.getTime());
> > > - entry1.setId("1");
> > > - entry1.setTitle("Meeting with portal developers");
> > > - entry1.setSubtitle("Meeting room 1");
> > > -
> > > - DefaultScheduleEntry entry2 = new DefaultScheduleEntry();
> > > - cal.add(Calendar.HOUR_OF_DAY, -1);
> > > - entry2.setStartTime(cal.getTime());
> > > - cal.add(Calendar.HOUR, 4);
> > > - entry2.setEndTime(cal.getTime());
> > > - entry2.setId("2");
> > > - entry2.setTitle("work on MyFaces components");
> > > - entry2.setSubtitle("");
> > > - entry2.setDescription("I should create a more elaborate demo");
> > > -
> > > - DefaultScheduleEntry entry3 = new DefaultScheduleEntry();
> > > - cal.add(Calendar.HOUR_OF_DAY, -48);
> > > - entry3.setStartTime(cal.getTime());
> > > - cal.add(Calendar.HOUR_OF_DAY, 48);
> > > - entry3.setEndTime(cal.getTime());
> > > - entry3.setId("3");
> > > - entry3.setTitle("Business trip");
> > > - entry3.setSubtitle("Paris");
> > > - entry3.setDescription("Better brush up on my French before I leave...");
> > > - model.addEntry(entry1);
> > > - model.addEntry(entry2);
> > > - model.addEntry(entry3);
> > > -
> > > - model.setMode(mode.intValue());
> > > -
> > > - model.setSelectedDate(today);
> > > - }
> > > + model.setSelectedDate(this.date);
> > > + }
> > > }
> > > Index: examples/sandbox/schedule.jsp
> > > ===================================================================
> > > --- examples/sandbox/schedule.jsp (revision 225494)
> > > +++ examples/sandbox/schedule.jsp (working copy)
> > > @@ -1,53 +1,172 @@
> > > -<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> > > -<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> > > -<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="x"%>
> > > -
> > > -<!--
> > > -/*
> > > - * Copyright 2005 The Apache Software Foundation.
> > > - *
> > > - * Licensed under the Apache License, Version 2.0 (the "License");
> > > - * you may not use this file except in compliance with the License.
> > > - * You may obtain a copy of the License at
> > > - *
> > > - * http://www.apache.org/licenses/LICENSE-2.0
> > > - *
> > > - * Unless required by applicable law or agreed to in writing, software
> > > - * distributed under the License is distributed on an "AS IS" BASIS,
> > > - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> > > - * See the License for the specific language governing permissions and
> > > - * limitations under the License.
> > > - */
> > > -//-->
> > > -<html>
> > > -
> > > - <%@include file="inc/head.inc" %>
> > > -
> > > - <body>
> > > - <f:view>
> > > - <h:form>
> > > - <br/>
> > > - <h:panelGroup>
> > > - <h:outputLabel for="modeInput">
> > > - <h:outputText value="mode: " />
> > > - </h:outputLabel>
> > > - <h:selectOneRadio id="modeInput" layout="lineDirection"
> > > - binding="#{simpleSchedule.modeInput}" immediate="true"
> > > - valueChangeListener="#{simpleSchedule.modeChanged}"
> > > - onchange="this.form.submit();" value="#{simpleSchedule.mode}">
> > > - <f:selectItems id="modeItems" value="#{simpleSchedule.modeItems}" />
> > > - </h:selectOneRadio>
> > > -
> > > - </h:panelGroup>
> > > -
> > > - <x:schedule value="#{simpleSchedule.model}" id="schedule1"
> > > - rendered="true" visibleEndHour="18" visibleStartHour="8"
> > > - workingEndHour="17" workingStartHour="9" readonly="false"
> > > - actionListener="#{simpleSchedule.actionPerformed}" tooltip="true"/>
> > > - </h:form>
> > > - </f:view>
> > > - </body>
> > > -
> > > - <%@include file="inc/page_footer.jsp" %>
> > > -
> > > -</html>
> > > +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> > > +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> > > +<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
> > > +<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
> > > +
> > > +<!--
> > > +/*
> > > + * Copyright 2005 The Apache Software Foundation.
> > > + *
> > > + * Licensed under the Apache License, Version 2.0 (the "License");
> > > + * you may not use this file except in compliance with the License.
> > > + * You may obtain a copy of the License at
> > > + *
> > > + * http://www.apache.org/licenses/LICENSE-2.0
> > > + *
> > > + * Unless required by applicable law or agreed to in writing, software
> > > + * distributed under the License is distributed on an "AS IS" BASIS,
> > > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> > > + * See the License for the specific language governing permissions and
> > > + * limitations under the License.
> > > + */
> > > +//-->
> > > +<html>
> > > +
> > > + <%@include file="inc/head.inc" %>
> > > +
> > > + <body>
> > > + <f:view>
> > > + <h:form>
> > > + <h:messages
> > > + tooltip="true"
> > > + id="scheduleMessages"
> > > + layout="table"
> > > + globalOnly="false"/>
> > > +
> > > + <table cellpadding="5" border="0">
> > > + <tr>
> > > + <td valign="top">
> > > + <h:panelGrid cellpadding="0" cellspacing="15" columns="1">
> > > + <x:inputCalendar
> > > + id="scheduleNavigator"
> > > + monthYearRowClass="yearMonthHeader"
> > > + weekRowClass="weekHeader"
> > > + currentDayCellClass="currentDayCell"
> > > + value="#{simpleSchedule.date}"
> > > + valueChangeListener="#{simpleSchedule.calendarValueChanged}"
> > > + binding="#{simpleSchedule.dateInput}"/>
> > > + <h:outputLabel
> > > + for="modeInput"
> > > + id="modeLabel"
> > > + value="mode:"/>
> > > + <h:selectOneMenu
> > > + id="modeInput"
> > > + binding="#{simpleSchedule.modeInput}"
> > > + immediate="true"
> > > + valueChangeListener="#{simpleSchedule.modeValueChanged}"
> > > + onchange="this.form.submit();"
> > > + value="#{simpleSchedule.mode}">
> > > + <f:selectItems
> > > + id="modeItems"
> > > + value="#{simpleSchedule.modeItems}"/>
> > > + </h:selectOneMenu>
> > > + </h:panelGrid>
> > > + </td>
> > > + <td width="100%">
> > > + <s:schedule
> > > + value="#{simpleSchedule.model}"
> > > + id="schedule1"
> > > + rendered="true"
> > > + visibleEndHour="18"
> > > + visibleStartHour="8"
> > > + workingEndHour="17"
> > > + workingStartHour="9"
> > > + readonly="false"
> > > + actionListener="#{simpleSchedule.scheduleActionPerformed}"
> > > + tooltip="true"/>
> > > + </td>
> > > + </tr>
> > > + <tr>
> > > + <td valign="top">
> > > + <h3><h:outputText value="add appointment"/></h3>
> > > + </td>
> > > + <td>
> > > + <h:panelGrid cellpadding="0" cellspacing="0" columns="2">
> > > + <h:outputLabel
> > > + for="appStart"
> > > + value="start:"/>
> > > + <x:inputDate
> > > + id="appStart"
> > > + value="#{simpleAppointment.appointmentStart}"
> > > + type="both"/>
> > > + <h:outputLabel
> > > + for="appEnd"
> > > + value="end:"/>
> > > + <x:inputDate
> > > + id="appEnd"
> > > + value="#{simpleAppointment.appointmentEnd}"
> > > + type="both"/>
> > > + <h:outputLabel
> > > + for="appTitle"
> > > + value="title:"/>
> > > + <h:inputText
> > > + size="60"
> > > + id="appTitle"
> > > + value="#{simpleAppointment.appointmentTitle}"/>
> > > + <h:outputLabel
> > > + for="appLocation"
> > > + value="location:"/>
> > > + <h:inputText
> > > + size="60"
> > > + id="appLocation"
> > > + value="#{simpleAppointment.appointmentLocation}"/>
> > > + <h:outputLabel
> > > + for="appComments"
> > > + value="comments:"/>
> > > + <h:inputTextarea
> > > + cols="60"
> > > + rows="5"
> > > + id="appComments"
> > > + value="#{simpleAppointment.appointmentComments}"/>
> > > + <h:commandButton
> > > + value="Add appointment"
> > > + actionListener="#{simpleAppointment.addAppointment}"/>
> > > + </h:panelGrid>
> > > + </td>
> > > + </tr>
> > > + <tr>
> > > + <td valign="top">
> > > + <h3><h:outputText value="remove appointment"/></h3>
> > > + </td>
> > > + <td>
> > > + <h:commandButton
> > > + value="Remove selected appointment"
> > > + actionListener="#{simpleAppointment.removeAppointment}"
> > > + disabled="#{!simpleSchedule.entrySelected}"/>
> > > + </td>
> > > + </tr>
> > > + <tr>
> > > + <td valign="top">
> > > + <h3><h:outputText value="add holiday"/></h3>
> > > + </td>
> > > + <td>
> > > + <h:panelGrid cellpadding="0" cellspacing="0" columns="2">
> > > + <h:outputLabel
> > > + for="holidayDate"
> > > + value="date:"/>
> > > + <x:inputDate
> > > + id="holidayDate"
> > > + value="#{simpleAppointment.holidayDate}"
> > > + type="date"/>
> > > + <h:outputLabel
> > > + for="holidayName"
> > > + value="name:"/>
> > > + <h:inputText
> > > + size="60"
> > > + id="holidayName"
> > > + value="#{simpleAppointment.holidayName}"/>
> > > + <h:commandButton
> > > + value="Add holiday"
> > > + actionListener="#{simpleAppointment.addHoliday}"/>
> > > + </h:panelGrid>
> > > + </td>
> > > + </tr>
> > > + </table>
> > > +
> > > + </h:form>
> > > + </f:view>
> > > + </body>
> > > +
> > > + <%@include file="inc/page_footer.jsp" %>
> > > +
> > > +</html>
> > >
> > >
> > > ------------------------------------------------------------------------
> > >
> > > Index: sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java
> > > ===================================================================
> > > --- sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java (revision 225494)
> > > +++ sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java (working copy)
> > > @@ -87,8 +87,6 @@
> > > * </p>
> > > *
> > > * @param entry the entry to add
> > > - *
> > > - * @return true if successful
> > > */
> > > public void addEntry(ScheduleEntry entry)
> > > {
> > > @@ -96,6 +94,18 @@
> > > }
> > >
> > > /**
> > > + * <p>
> > > + * Remove an entry from the model
> > > + * </p>
> > > + *
> > > + * @param entry the entry to remove
> > > + */
> > > + public void removeEntry(ScheduleEntry entry)
> > > + {
> > > + entries.remove(entry);
> > > + }
> > > +
> > > + /**
> > > * @see org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date, java.util.Date)
> > > */
> > > protected Collection loadEntries(Date startDate, Date endDate)
> >
>
>
>
Re: more elaborate demo for x:schedule
Posted by Jurgen Lust <Ju...@UGent.be>.
The examples patch didn't contain an added class, due to a lack of SVN
experience from my part :-S
The attached file fixes this.
Sorry about that...
Jurgen
Op wo, 27-07-2005 te 14:17 +0200, schreef Mathias Broekelmann:
> I´ve commited your patches.
>
> Thank you.
>
> Best Regards,
> Mathias
>
> Jurgen Lust schrieb:
> > I've created a little more elaborate demo for the x:schedule component,
> > adding some more interactivity:
> >
> > - appointments are stored in the session
> > - appointments can be added and removed to the schedule, using a form on
> > the page
> > - holidays can be set, using a form on the page
> >
> > See attachment for patches
> >
> >
> > Cheers,
> >
> > Jurgen
> >
> >
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > Index: examples/sandbox/WEB-INF/examples-config.xml
> > ===================================================================
> > --- examples/sandbox/WEB-INF/examples-config.xml (revision 225494)
> > +++ examples/sandbox/WEB-INF/examples-config.xml (working copy)
> > @@ -253,6 +253,16 @@
> > <managed-bean-name>simpleSchedule</managed-bean-name>
> > <managed-bean-class>org.apache.myfaces.examples.schedule.SimpleScheduleBackingBean</managed-bean-class>
> > <managed-bean-scope>session</managed-bean-scope>
> > + </managed-bean>
> > +
> > + <managed-bean>
> > + <managed-bean-name>simpleAppointment</managed-bean-name>
> > + <managed-bean-class>org.apache.myfaces.examples.schedule.SimpleAppointmentBackingBean</managed-bean-class>
> > + <managed-bean-scope>request</managed-bean-scope>
> > + <managed-property>
> > + <property-name>scheduleBean</property-name>
> > + <value>#{simpleSchedule}</value>
> > + </managed-property>
> > </managed-bean>
> >
> > </faces-config>
> > Index: examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
> > ===================================================================
> > --- examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java (revision 225494)
> > +++ examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java (working copy)
> > @@ -1,254 +1,246 @@
> > package org.apache.myfaces.examples.schedule;
> >
> > -import org.apache.myfaces.custom.calendar.HtmlInputCalendar;
> > -import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
> > -import org.apache.myfaces.custom.schedule.model.ScheduleModel;
> > -import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> > -
> > import java.util.ArrayList;
> > -import java.util.Calendar;
> > import java.util.Date;
> > -import java.util.GregorianCalendar;
> >
> > -import javax.faces.component.html.HtmlSelectOneRadio;
> > +import javax.faces.component.html.HtmlSelectOneMenu;
> > import javax.faces.event.ActionEvent;
> > import javax.faces.event.ValueChangeEvent;
> > import javax.faces.model.SelectItem;
> >
> > +import org.apache.myfaces.custom.calendar.HtmlInputCalendar;
> > +import org.apache.myfaces.custom.schedule.model.ScheduleModel;
> > +import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> > +import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
> > +
> > /**
> > -* This is an extremely simple demo of the Schedule component. The entries are
> > -* actually hardcoded. A real application would typically use a custom implementation
> > -* of the SimpleScheduleModel.
> > -*/
> > -public class SimpleScheduleBackingBean {
> > + * This is a simple demo of the Schedule component.
> > + * The entries are stored in the session.
> > + * A real application would typically use a custom implementation
> > + * of the ScheduleModel.
> > + */
> > +public class SimpleScheduleBackingBean
> > +{
> >
> > - //~ Instance fields --------------------------------------------------------
> > + //~ Instance fields --------------------------------------------------------
> >
> > - private Date date = new Date();
> > - private HtmlInputCalendar dateInput;
> > - private HtmlSelectOneRadio modeInput;
> > - private Integer mode = new Integer(ScheduleModel.WORKWEEK);
> > - private SimpleScheduleModel model;
> > + private Date date = new Date();
> > + private HtmlInputCalendar dateInput;
> > + private HtmlSelectOneMenu modeInput;
> > + private Integer mode = new Integer(ScheduleModel.WORKWEEK);
> > + private SimpleScheduleModel model;
> >
> > - //~ Constructors -----------------------------------------------------------
> > + //~ Constructors -----------------------------------------------------------
> >
> > - /**
> > - * Creates a new SimpleScheduleBackingBean object.
> > - */
> > - public SimpleScheduleBackingBean() {
> > - super();
> > - initModel();
> > - }
> > + /**
> > + * Creates a new SimpleScheduleBackingBean object.
> > + */
> > + public SimpleScheduleBackingBean()
> > + {
> > + super();
> > + initModel();
> > + }
> >
> > - //~ Methods ----------------------------------------------------------------
> > + //~ Methods ----------------------------------------------------------------
> >
> > - /**
> > - * @param date The date to set.
> > - */
> > - public void setDate(Date date) {
> > - this.date = date;
> > - }
> > + /**
> > + * @param date The date to set.
> > + */
> > + public void setDate(Date date)
> > + {
> > + this.date = date;
> > + }
> >
> > - /**
> > - * @return Returns the date.
> > - */
> > - public Date getDate() {
> > - return date;
> > - }
> > + /**
> > + * @return Returns the date.
> > + */
> > + public Date getDate()
> > + {
> > + return date;
> > + }
> >
> > - /**
> > - * @param dateInput The dateInput to set.
> > - */
> > - public void setDateInput(HtmlInputCalendar dateInput) {
> > - this.dateInput = dateInput;
> > - }
> > + /**
> > + * @param dateInput The dateInput to set.
> > + */
> > + public void setDateInput(HtmlInputCalendar dateInput)
> > + {
> > + this.dateInput = dateInput;
> > + }
> >
> > - /**
> > - * @return Returns the dateInput.
> > - */
> > - public HtmlInputCalendar getDateInput() {
> > - return dateInput;
> > - }
> > + /**
> > + * @return Returns the dateInput.
> > + */
> > + public HtmlInputCalendar getDateInput()
> > + {
> > + return dateInput;
> > + }
> >
> > - /**
> > - * @param mode The mode to set.
> > - */
> > - public void setMode(Integer mode) {
> > - this.mode = mode;
> > - }
> > + /**
> > + * @param mode The mode to set.
> > + */
> > + public void setMode(Integer mode)
> > + {
> > + this.mode = mode;
> > + }
> >
> > - /**
> > - * @return Returns the mode.
> > - */
> > - public Integer getMode() {
> > - return mode;
> > - }
> > + /**
> > + * @return Returns the mode.
> > + */
> > + public Integer getMode()
> > + {
> > + return mode;
> > + }
> >
> > - /**
> > - * @param modeInput The modeInput to set.
> > - */
> > - public void setModeInput(HtmlSelectOneRadio modeInput) {
> > - this.modeInput = modeInput;
> > - }
> > + /**
> > + * @param modeInput The modeInput to set.
> > + */
> > + public void setModeInput(HtmlSelectOneMenu modeInput)
> > + {
> > + this.modeInput = modeInput;
> > + }
> >
> > - /**
> > - * @return Returns the modeInput.
> > - */
> > - public HtmlSelectOneRadio getModeInput() {
> > - return modeInput;
> > - }
> > + /**
> > + * @return Returns the modeInput.
> > + */
> > + public HtmlSelectOneMenu getModeInput()
> > + {
> > + return modeInput;
> > + }
> >
> > - /**
> > - * <p>
> > - * get the SelectItems for the mode SelectOneRadio
> > - * </p>
> > - *
> > - * @return an ArrayList of SelectItems
> > - */
> > - public ArrayList getModeItems() {
> > - ArrayList items = new ArrayList();
> > - items.add(new SelectItem(new Integer(ScheduleModel.DAY), "day"));
> > - items.add(
> > - new SelectItem(new Integer(ScheduleModel.WORKWEEK), "workweek")
> > - );
> > - items.add(new SelectItem(new Integer(ScheduleModel.WEEK), "week"));
> > - items.add(new SelectItem(new Integer(ScheduleModel.MONTH), "month"));
> > + /**
> > + * <p>
> > + * get the SelectItems for the mode SelectOneRadio
> > + * </p>
> > + *
> > + * @return an ArrayList of SelectItems
> > + */
> > + public ArrayList getModeItems()
> > + {
> > + ArrayList items = new ArrayList();
> > + items.add(new SelectItem(new Integer(ScheduleModel.DAY), "day"));
> > + items.add(new SelectItem(new Integer(ScheduleModel.WORKWEEK),
> > + "workweek"));
> > + items.add(new SelectItem(new Integer(ScheduleModel.WEEK), "week"));
> > + items.add(new SelectItem(new Integer(ScheduleModel.MONTH), "month"));
> >
> > - return items;
> > - }
> > + return items;
> > + }
> >
> > - /**
> > - * @param model The model to set.
> > - */
> > - public void setModel(SimpleScheduleModel model) {
> > - this.model = model;
> > - }
> > + /**
> > + * @param model The model to set.
> > + */
> > + public void setModel(SimpleScheduleModel model)
> > + {
> > + this.model = model;
> > + }
> >
> > - /**
> > - * @return Returns the model.
> > - */
> > - public ScheduleModel getModel() {
> > - return model;
> > - }
> > + /**
> > + * @return Returns the model.
> > + */
> > + public ScheduleModel getModel()
> > + {
> > + return model;
> > + }
> >
> > - /**
> > - * <p>
> > - * a String describing the selected entry on the schedule
> > - * </p>
> > - *
> > - * @return the entry as a string
> > - */
> > - public String getSelectedEntry() {
> > - if ((model == null) || (model.getSelectedEntry() == null)) {
> > - return "no entry selected";
> > - }
> > + /**
> > + * <p>
> > + * a String describing the selected entry on the schedule
> > + * </p>
> > + *
> > + * @return the entry as a string
> > + */
> > + public String getSelectedEntry()
> > + {
> > + if ((model == null) || (model.getSelectedEntry() == null))
> > + {
> > + return "no entry selected";
> > + }
> >
> > - StringBuffer entry = new StringBuffer();
> > - entry.append(model.getSelectedEntry().getTitle());
> > - entry.append(": ");
> > - entry.append(model.getSelectedEntry().getStartTime());
> > - entry.append(" - ");
> > - entry.append(model.getSelectedEntry().getEndTime());
> > + StringBuffer entry = new StringBuffer();
> > + entry.append(model.getSelectedEntry().getTitle());
> > + entry.append(": ");
> > + entry.append(model.getSelectedEntry().getStartTime());
> > + entry.append(" - ");
> > + entry.append(model.getSelectedEntry().getEndTime());
> >
> > - String returnString = entry.toString();
> > + String returnString = entry.toString();
> >
> > - return returnString;
> > - }
> > + return returnString;
> > + }
> >
> > - /**
> > - * <p>
> > - * action listener for the schedule component.
> > - * </p>
> > - *
> > - * @param actionEvent the action event
> > - */
> > - public void actionPerformed(ActionEvent actionEvent) {
> > - }
> > + /**
> > + * Is there an entry currently selected?
> > + *
> > + * @return if an entry is currently selected
> > + */
> > + public boolean isEntrySelected()
> > + {
> > + return model != null && model.getSelectedEntry() != null;
> > + }
> >
> > - /**
> > - * <p>
> > - * When the date of the calendar component changes, navigate to that date
> > - * in the schedule component.
> > - * </p>
> > - *
> > - * @param event the change event
> > - */
> > - public void dateChanged(ValueChangeEvent event) {
> > - this.date = (Date) dateInput.getValue();
> > - model.setSelectedDate(date);
> > - model.refresh();
> > - }
> > + /**
> > + * <p>
> > + * action listener for the schedule component.
> > + * </p>
> > + *
> > + * @param actionEvent the action event
> > + */
> > + public void scheduleActionPerformed(ActionEvent actionEvent)
> > + {
> > + }
> >
> > - /**
> > - * <p>
> > - * When a different mode is selected, apply this mode to the schedule
> > - * component.
> > - * </p>
> > - *
> > - * @param event the change event
> > - */
> > - public void modeChanged(ValueChangeEvent event) {
> > - if (mode == null) {
> > - return;
> > - }
> > + /**
> > + * <p>
> > + * When a date is selected in the calendar component, navigate to that date
> > + * in the schedule component.
> > + * </p>
> > + *
> > + * @param event the action event
> > + */
> > + public void calendarValueChanged(ValueChangeEvent event)
> > + {
> > + if (date != null
> > + && ScheduleUtil.truncate(date).equals(
> > + ScheduleUtil.truncate((Date) dateInput.getValue())))
> > + return;
> > + this.date = (Date) dateInput.getValue();
> > + model.setSelectedDate(date);
> > + model.refresh();
> > + }
> >
> > - this.mode = (Integer) modeInput.getValue();
> > - model.setMode(mode.intValue());
> > + /**
> > + * <p>
> > + * When a different mode is selected, apply this mode to the schedule
> > + * component.
> > + * </p>
> > + *
> > + * @param event the action event
> > + */
> > + public void modeValueChanged(ValueChangeEvent event)
> > + {
> > + if (mode != null && mode.equals((Integer) modeInput.getValue()))
> > + return;
> > + this.mode = (Integer) modeInput.getValue();
> > + model.setMode(mode.intValue());
> > + model.refresh();
> > + this.date = model.getSelectedDate();
> > + dateInput.setValue(model.getSelectedDate());
> > + }
> >
> > - model.refresh();
> > - }
> > + /**
> > + * Initialize the demo
> > + */
> > + private void initModel()
> > + {
> > + if (model == null)
> > + {
> > + model = new SimpleScheduleModel();
> > + }
> >
> > - /**
> > - * Initialize the demo: We're just adding 3 appointments here, it would
> > - * be easy to do this from a form on the page.
> > - */
> > - private void initModel() {
> > - if (model == null) {
> > - model = new SimpleScheduleModel();
> > - }
> > + this.date = new Date();
> >
> > - Date today = new Date();
> > + model.setMode(mode.intValue());
> >
> > - Calendar cal = GregorianCalendar.getInstance();
> > - cal.setTime(new Date());
> > - cal.set(Calendar.HOUR_OF_DAY, 11);
> > - cal.set(Calendar.MINUTE, 30);
> > - cal.set(Calendar.SECOND, 00);
> > - cal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
> > -
> > - DefaultScheduleEntry entry1 = new DefaultScheduleEntry();
> > - entry1.setStartTime(cal.getTime());
> > - cal.add(Calendar.HOUR_OF_DAY, 2);
> > - entry1.setEndTime(cal.getTime());
> > - entry1.setId("1");
> > - entry1.setTitle("Meeting with portal developers");
> > - entry1.setSubtitle("Meeting room 1");
> > -
> > - DefaultScheduleEntry entry2 = new DefaultScheduleEntry();
> > - cal.add(Calendar.HOUR_OF_DAY, -1);
> > - entry2.setStartTime(cal.getTime());
> > - cal.add(Calendar.HOUR, 4);
> > - entry2.setEndTime(cal.getTime());
> > - entry2.setId("2");
> > - entry2.setTitle("work on MyFaces components");
> > - entry2.setSubtitle("");
> > - entry2.setDescription("I should create a more elaborate demo");
> > -
> > - DefaultScheduleEntry entry3 = new DefaultScheduleEntry();
> > - cal.add(Calendar.HOUR_OF_DAY, -48);
> > - entry3.setStartTime(cal.getTime());
> > - cal.add(Calendar.HOUR_OF_DAY, 48);
> > - entry3.setEndTime(cal.getTime());
> > - entry3.setId("3");
> > - entry3.setTitle("Business trip");
> > - entry3.setSubtitle("Paris");
> > - entry3.setDescription("Better brush up on my French before I leave...");
> > - model.addEntry(entry1);
> > - model.addEntry(entry2);
> > - model.addEntry(entry3);
> > -
> > - model.setMode(mode.intValue());
> > -
> > - model.setSelectedDate(today);
> > - }
> > + model.setSelectedDate(this.date);
> > + }
> > }
> > Index: examples/sandbox/schedule.jsp
> > ===================================================================
> > --- examples/sandbox/schedule.jsp (revision 225494)
> > +++ examples/sandbox/schedule.jsp (working copy)
> > @@ -1,53 +1,172 @@
> > -<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> > -<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> > -<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="x"%>
> > -
> > -<!--
> > -/*
> > - * Copyright 2005 The Apache Software Foundation.
> > - *
> > - * Licensed under the Apache License, Version 2.0 (the "License");
> > - * you may not use this file except in compliance with the License.
> > - * You may obtain a copy of the License at
> > - *
> > - * http://www.apache.org/licenses/LICENSE-2.0
> > - *
> > - * Unless required by applicable law or agreed to in writing, software
> > - * distributed under the License is distributed on an "AS IS" BASIS,
> > - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> > - * See the License for the specific language governing permissions and
> > - * limitations under the License.
> > - */
> > -//-->
> > -<html>
> > -
> > - <%@include file="inc/head.inc" %>
> > -
> > - <body>
> > - <f:view>
> > - <h:form>
> > - <br/>
> > - <h:panelGroup>
> > - <h:outputLabel for="modeInput">
> > - <h:outputText value="mode: " />
> > - </h:outputLabel>
> > - <h:selectOneRadio id="modeInput" layout="lineDirection"
> > - binding="#{simpleSchedule.modeInput}" immediate="true"
> > - valueChangeListener="#{simpleSchedule.modeChanged}"
> > - onchange="this.form.submit();" value="#{simpleSchedule.mode}">
> > - <f:selectItems id="modeItems" value="#{simpleSchedule.modeItems}" />
> > - </h:selectOneRadio>
> > -
> > - </h:panelGroup>
> > -
> > - <x:schedule value="#{simpleSchedule.model}" id="schedule1"
> > - rendered="true" visibleEndHour="18" visibleStartHour="8"
> > - workingEndHour="17" workingStartHour="9" readonly="false"
> > - actionListener="#{simpleSchedule.actionPerformed}" tooltip="true"/>
> > - </h:form>
> > - </f:view>
> > - </body>
> > -
> > - <%@include file="inc/page_footer.jsp" %>
> > -
> > -</html>
> > +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> > +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> > +<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
> > +<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
> > +
> > +<!--
> > +/*
> > + * Copyright 2005 The Apache Software Foundation.
> > + *
> > + * Licensed under the Apache License, Version 2.0 (the "License");
> > + * you may not use this file except in compliance with the License.
> > + * You may obtain a copy of the License at
> > + *
> > + * http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing, software
> > + * distributed under the License is distributed on an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> > + * See the License for the specific language governing permissions and
> > + * limitations under the License.
> > + */
> > +//-->
> > +<html>
> > +
> > + <%@include file="inc/head.inc" %>
> > +
> > + <body>
> > + <f:view>
> > + <h:form>
> > + <h:messages
> > + tooltip="true"
> > + id="scheduleMessages"
> > + layout="table"
> > + globalOnly="false"/>
> > +
> > + <table cellpadding="5" border="0">
> > + <tr>
> > + <td valign="top">
> > + <h:panelGrid cellpadding="0" cellspacing="15" columns="1">
> > + <x:inputCalendar
> > + id="scheduleNavigator"
> > + monthYearRowClass="yearMonthHeader"
> > + weekRowClass="weekHeader"
> > + currentDayCellClass="currentDayCell"
> > + value="#{simpleSchedule.date}"
> > + valueChangeListener="#{simpleSchedule.calendarValueChanged}"
> > + binding="#{simpleSchedule.dateInput}"/>
> > + <h:outputLabel
> > + for="modeInput"
> > + id="modeLabel"
> > + value="mode:"/>
> > + <h:selectOneMenu
> > + id="modeInput"
> > + binding="#{simpleSchedule.modeInput}"
> > + immediate="true"
> > + valueChangeListener="#{simpleSchedule.modeValueChanged}"
> > + onchange="this.form.submit();"
> > + value="#{simpleSchedule.mode}">
> > + <f:selectItems
> > + id="modeItems"
> > + value="#{simpleSchedule.modeItems}"/>
> > + </h:selectOneMenu>
> > + </h:panelGrid>
> > + </td>
> > + <td width="100%">
> > + <s:schedule
> > + value="#{simpleSchedule.model}"
> > + id="schedule1"
> > + rendered="true"
> > + visibleEndHour="18"
> > + visibleStartHour="8"
> > + workingEndHour="17"
> > + workingStartHour="9"
> > + readonly="false"
> > + actionListener="#{simpleSchedule.scheduleActionPerformed}"
> > + tooltip="true"/>
> > + </td>
> > + </tr>
> > + <tr>
> > + <td valign="top">
> > + <h3><h:outputText value="add appointment"/></h3>
> > + </td>
> > + <td>
> > + <h:panelGrid cellpadding="0" cellspacing="0" columns="2">
> > + <h:outputLabel
> > + for="appStart"
> > + value="start:"/>
> > + <x:inputDate
> > + id="appStart"
> > + value="#{simpleAppointment.appointmentStart}"
> > + type="both"/>
> > + <h:outputLabel
> > + for="appEnd"
> > + value="end:"/>
> > + <x:inputDate
> > + id="appEnd"
> > + value="#{simpleAppointment.appointmentEnd}"
> > + type="both"/>
> > + <h:outputLabel
> > + for="appTitle"
> > + value="title:"/>
> > + <h:inputText
> > + size="60"
> > + id="appTitle"
> > + value="#{simpleAppointment.appointmentTitle}"/>
> > + <h:outputLabel
> > + for="appLocation"
> > + value="location:"/>
> > + <h:inputText
> > + size="60"
> > + id="appLocation"
> > + value="#{simpleAppointment.appointmentLocation}"/>
> > + <h:outputLabel
> > + for="appComments"
> > + value="comments:"/>
> > + <h:inputTextarea
> > + cols="60"
> > + rows="5"
> > + id="appComments"
> > + value="#{simpleAppointment.appointmentComments}"/>
> > + <h:commandButton
> > + value="Add appointment"
> > + actionListener="#{simpleAppointment.addAppointment}"/>
> > + </h:panelGrid>
> > + </td>
> > + </tr>
> > + <tr>
> > + <td valign="top">
> > + <h3><h:outputText value="remove appointment"/></h3>
> > + </td>
> > + <td>
> > + <h:commandButton
> > + value="Remove selected appointment"
> > + actionListener="#{simpleAppointment.removeAppointment}"
> > + disabled="#{!simpleSchedule.entrySelected}"/>
> > + </td>
> > + </tr>
> > + <tr>
> > + <td valign="top">
> > + <h3><h:outputText value="add holiday"/></h3>
> > + </td>
> > + <td>
> > + <h:panelGrid cellpadding="0" cellspacing="0" columns="2">
> > + <h:outputLabel
> > + for="holidayDate"
> > + value="date:"/>
> > + <x:inputDate
> > + id="holidayDate"
> > + value="#{simpleAppointment.holidayDate}"
> > + type="date"/>
> > + <h:outputLabel
> > + for="holidayName"
> > + value="name:"/>
> > + <h:inputText
> > + size="60"
> > + id="holidayName"
> > + value="#{simpleAppointment.holidayName}"/>
> > + <h:commandButton
> > + value="Add holiday"
> > + actionListener="#{simpleAppointment.addHoliday}"/>
> > + </h:panelGrid>
> > + </td>
> > + </tr>
> > + </table>
> > +
> > + </h:form>
> > + </f:view>
> > + </body>
> > +
> > + <%@include file="inc/page_footer.jsp" %>
> > +
> > +</html>
> >
> >
> > ------------------------------------------------------------------------
> >
> > Index: sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java
> > ===================================================================
> > --- sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java (revision 225494)
> > +++ sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java (working copy)
> > @@ -87,8 +87,6 @@
> > * </p>
> > *
> > * @param entry the entry to add
> > - *
> > - * @return true if successful
> > */
> > public void addEntry(ScheduleEntry entry)
> > {
> > @@ -96,6 +94,18 @@
> > }
> >
> > /**
> > + * <p>
> > + * Remove an entry from the model
> > + * </p>
> > + *
> > + * @param entry the entry to remove
> > + */
> > + public void removeEntry(ScheduleEntry entry)
> > + {
> > + entries.remove(entry);
> > + }
> > +
> > + /**
> > * @see org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date, java.util.Date)
> > */
> > protected Collection loadEntries(Date startDate, Date endDate)
>
Re: more elaborate demo for x:schedule
Posted by Mathias Broekelmann <mb...@PSI.DE>.
I´ve commited your patches.
Thank you.
Best Regards,
Mathias
Jurgen Lust schrieb:
> I've created a little more elaborate demo for the x:schedule component,
> adding some more interactivity:
>
> - appointments are stored in the session
> - appointments can be added and removed to the schedule, using a form on
> the page
> - holidays can be set, using a form on the page
>
> See attachment for patches
>
>
> Cheers,
>
> Jurgen
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> Index: examples/sandbox/WEB-INF/examples-config.xml
> ===================================================================
> --- examples/sandbox/WEB-INF/examples-config.xml (revision 225494)
> +++ examples/sandbox/WEB-INF/examples-config.xml (working copy)
> @@ -253,6 +253,16 @@
> <managed-bean-name>simpleSchedule</managed-bean-name>
> <managed-bean-class>org.apache.myfaces.examples.schedule.SimpleScheduleBackingBean</managed-bean-class>
> <managed-bean-scope>session</managed-bean-scope>
> + </managed-bean>
> +
> + <managed-bean>
> + <managed-bean-name>simpleAppointment</managed-bean-name>
> + <managed-bean-class>org.apache.myfaces.examples.schedule.SimpleAppointmentBackingBean</managed-bean-class>
> + <managed-bean-scope>request</managed-bean-scope>
> + <managed-property>
> + <property-name>scheduleBean</property-name>
> + <value>#{simpleSchedule}</value>
> + </managed-property>
> </managed-bean>
>
> </faces-config>
> Index: examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
> ===================================================================
> --- examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java (revision 225494)
> +++ examples/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java (working copy)
> @@ -1,254 +1,246 @@
> package org.apache.myfaces.examples.schedule;
>
> -import org.apache.myfaces.custom.calendar.HtmlInputCalendar;
> -import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
> -import org.apache.myfaces.custom.schedule.model.ScheduleModel;
> -import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> -
> import java.util.ArrayList;
> -import java.util.Calendar;
> import java.util.Date;
> -import java.util.GregorianCalendar;
>
> -import javax.faces.component.html.HtmlSelectOneRadio;
> +import javax.faces.component.html.HtmlSelectOneMenu;
> import javax.faces.event.ActionEvent;
> import javax.faces.event.ValueChangeEvent;
> import javax.faces.model.SelectItem;
>
> +import org.apache.myfaces.custom.calendar.HtmlInputCalendar;
> +import org.apache.myfaces.custom.schedule.model.ScheduleModel;
> +import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> +import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
> +
> /**
> -* This is an extremely simple demo of the Schedule component. The entries are
> -* actually hardcoded. A real application would typically use a custom implementation
> -* of the SimpleScheduleModel.
> -*/
> -public class SimpleScheduleBackingBean {
> + * This is a simple demo of the Schedule component.
> + * The entries are stored in the session.
> + * A real application would typically use a custom implementation
> + * of the ScheduleModel.
> + */
> +public class SimpleScheduleBackingBean
> +{
>
> - //~ Instance fields --------------------------------------------------------
> + //~ Instance fields --------------------------------------------------------
>
> - private Date date = new Date();
> - private HtmlInputCalendar dateInput;
> - private HtmlSelectOneRadio modeInput;
> - private Integer mode = new Integer(ScheduleModel.WORKWEEK);
> - private SimpleScheduleModel model;
> + private Date date = new Date();
> + private HtmlInputCalendar dateInput;
> + private HtmlSelectOneMenu modeInput;
> + private Integer mode = new Integer(ScheduleModel.WORKWEEK);
> + private SimpleScheduleModel model;
>
> - //~ Constructors -----------------------------------------------------------
> + //~ Constructors -----------------------------------------------------------
>
> - /**
> - * Creates a new SimpleScheduleBackingBean object.
> - */
> - public SimpleScheduleBackingBean() {
> - super();
> - initModel();
> - }
> + /**
> + * Creates a new SimpleScheduleBackingBean object.
> + */
> + public SimpleScheduleBackingBean()
> + {
> + super();
> + initModel();
> + }
>
> - //~ Methods ----------------------------------------------------------------
> + //~ Methods ----------------------------------------------------------------
>
> - /**
> - * @param date The date to set.
> - */
> - public void setDate(Date date) {
> - this.date = date;
> - }
> + /**
> + * @param date The date to set.
> + */
> + public void setDate(Date date)
> + {
> + this.date = date;
> + }
>
> - /**
> - * @return Returns the date.
> - */
> - public Date getDate() {
> - return date;
> - }
> + /**
> + * @return Returns the date.
> + */
> + public Date getDate()
> + {
> + return date;
> + }
>
> - /**
> - * @param dateInput The dateInput to set.
> - */
> - public void setDateInput(HtmlInputCalendar dateInput) {
> - this.dateInput = dateInput;
> - }
> + /**
> + * @param dateInput The dateInput to set.
> + */
> + public void setDateInput(HtmlInputCalendar dateInput)
> + {
> + this.dateInput = dateInput;
> + }
>
> - /**
> - * @return Returns the dateInput.
> - */
> - public HtmlInputCalendar getDateInput() {
> - return dateInput;
> - }
> + /**
> + * @return Returns the dateInput.
> + */
> + public HtmlInputCalendar getDateInput()
> + {
> + return dateInput;
> + }
>
> - /**
> - * @param mode The mode to set.
> - */
> - public void setMode(Integer mode) {
> - this.mode = mode;
> - }
> + /**
> + * @param mode The mode to set.
> + */
> + public void setMode(Integer mode)
> + {
> + this.mode = mode;
> + }
>
> - /**
> - * @return Returns the mode.
> - */
> - public Integer getMode() {
> - return mode;
> - }
> + /**
> + * @return Returns the mode.
> + */
> + public Integer getMode()
> + {
> + return mode;
> + }
>
> - /**
> - * @param modeInput The modeInput to set.
> - */
> - public void setModeInput(HtmlSelectOneRadio modeInput) {
> - this.modeInput = modeInput;
> - }
> + /**
> + * @param modeInput The modeInput to set.
> + */
> + public void setModeInput(HtmlSelectOneMenu modeInput)
> + {
> + this.modeInput = modeInput;
> + }
>
> - /**
> - * @return Returns the modeInput.
> - */
> - public HtmlSelectOneRadio getModeInput() {
> - return modeInput;
> - }
> + /**
> + * @return Returns the modeInput.
> + */
> + public HtmlSelectOneMenu getModeInput()
> + {
> + return modeInput;
> + }
>
> - /**
> - * <p>
> - * get the SelectItems for the mode SelectOneRadio
> - * </p>
> - *
> - * @return an ArrayList of SelectItems
> - */
> - public ArrayList getModeItems() {
> - ArrayList items = new ArrayList();
> - items.add(new SelectItem(new Integer(ScheduleModel.DAY), "day"));
> - items.add(
> - new SelectItem(new Integer(ScheduleModel.WORKWEEK), "workweek")
> - );
> - items.add(new SelectItem(new Integer(ScheduleModel.WEEK), "week"));
> - items.add(new SelectItem(new Integer(ScheduleModel.MONTH), "month"));
> + /**
> + * <p>
> + * get the SelectItems for the mode SelectOneRadio
> + * </p>
> + *
> + * @return an ArrayList of SelectItems
> + */
> + public ArrayList getModeItems()
> + {
> + ArrayList items = new ArrayList();
> + items.add(new SelectItem(new Integer(ScheduleModel.DAY), "day"));
> + items.add(new SelectItem(new Integer(ScheduleModel.WORKWEEK),
> + "workweek"));
> + items.add(new SelectItem(new Integer(ScheduleModel.WEEK), "week"));
> + items.add(new SelectItem(new Integer(ScheduleModel.MONTH), "month"));
>
> - return items;
> - }
> + return items;
> + }
>
> - /**
> - * @param model The model to set.
> - */
> - public void setModel(SimpleScheduleModel model) {
> - this.model = model;
> - }
> + /**
> + * @param model The model to set.
> + */
> + public void setModel(SimpleScheduleModel model)
> + {
> + this.model = model;
> + }
>
> - /**
> - * @return Returns the model.
> - */
> - public ScheduleModel getModel() {
> - return model;
> - }
> + /**
> + * @return Returns the model.
> + */
> + public ScheduleModel getModel()
> + {
> + return model;
> + }
>
> - /**
> - * <p>
> - * a String describing the selected entry on the schedule
> - * </p>
> - *
> - * @return the entry as a string
> - */
> - public String getSelectedEntry() {
> - if ((model == null) || (model.getSelectedEntry() == null)) {
> - return "no entry selected";
> - }
> + /**
> + * <p>
> + * a String describing the selected entry on the schedule
> + * </p>
> + *
> + * @return the entry as a string
> + */
> + public String getSelectedEntry()
> + {
> + if ((model == null) || (model.getSelectedEntry() == null))
> + {
> + return "no entry selected";
> + }
>
> - StringBuffer entry = new StringBuffer();
> - entry.append(model.getSelectedEntry().getTitle());
> - entry.append(": ");
> - entry.append(model.getSelectedEntry().getStartTime());
> - entry.append(" - ");
> - entry.append(model.getSelectedEntry().getEndTime());
> + StringBuffer entry = new StringBuffer();
> + entry.append(model.getSelectedEntry().getTitle());
> + entry.append(": ");
> + entry.append(model.getSelectedEntry().getStartTime());
> + entry.append(" - ");
> + entry.append(model.getSelectedEntry().getEndTime());
>
> - String returnString = entry.toString();
> + String returnString = entry.toString();
>
> - return returnString;
> - }
> + return returnString;
> + }
>
> - /**
> - * <p>
> - * action listener for the schedule component.
> - * </p>
> - *
> - * @param actionEvent the action event
> - */
> - public void actionPerformed(ActionEvent actionEvent) {
> - }
> + /**
> + * Is there an entry currently selected?
> + *
> + * @return if an entry is currently selected
> + */
> + public boolean isEntrySelected()
> + {
> + return model != null && model.getSelectedEntry() != null;
> + }
>
> - /**
> - * <p>
> - * When the date of the calendar component changes, navigate to that date
> - * in the schedule component.
> - * </p>
> - *
> - * @param event the change event
> - */
> - public void dateChanged(ValueChangeEvent event) {
> - this.date = (Date) dateInput.getValue();
> - model.setSelectedDate(date);
> - model.refresh();
> - }
> + /**
> + * <p>
> + * action listener for the schedule component.
> + * </p>
> + *
> + * @param actionEvent the action event
> + */
> + public void scheduleActionPerformed(ActionEvent actionEvent)
> + {
> + }
>
> - /**
> - * <p>
> - * When a different mode is selected, apply this mode to the schedule
> - * component.
> - * </p>
> - *
> - * @param event the change event
> - */
> - public void modeChanged(ValueChangeEvent event) {
> - if (mode == null) {
> - return;
> - }
> + /**
> + * <p>
> + * When a date is selected in the calendar component, navigate to that date
> + * in the schedule component.
> + * </p>
> + *
> + * @param event the action event
> + */
> + public void calendarValueChanged(ValueChangeEvent event)
> + {
> + if (date != null
> + && ScheduleUtil.truncate(date).equals(
> + ScheduleUtil.truncate((Date) dateInput.getValue())))
> + return;
> + this.date = (Date) dateInput.getValue();
> + model.setSelectedDate(date);
> + model.refresh();
> + }
>
> - this.mode = (Integer) modeInput.getValue();
> - model.setMode(mode.intValue());
> + /**
> + * <p>
> + * When a different mode is selected, apply this mode to the schedule
> + * component.
> + * </p>
> + *
> + * @param event the action event
> + */
> + public void modeValueChanged(ValueChangeEvent event)
> + {
> + if (mode != null && mode.equals((Integer) modeInput.getValue()))
> + return;
> + this.mode = (Integer) modeInput.getValue();
> + model.setMode(mode.intValue());
> + model.refresh();
> + this.date = model.getSelectedDate();
> + dateInput.setValue(model.getSelectedDate());
> + }
>
> - model.refresh();
> - }
> + /**
> + * Initialize the demo
> + */
> + private void initModel()
> + {
> + if (model == null)
> + {
> + model = new SimpleScheduleModel();
> + }
>
> - /**
> - * Initialize the demo: We're just adding 3 appointments here, it would
> - * be easy to do this from a form on the page.
> - */
> - private void initModel() {
> - if (model == null) {
> - model = new SimpleScheduleModel();
> - }
> + this.date = new Date();
>
> - Date today = new Date();
> + model.setMode(mode.intValue());
>
> - Calendar cal = GregorianCalendar.getInstance();
> - cal.setTime(new Date());
> - cal.set(Calendar.HOUR_OF_DAY, 11);
> - cal.set(Calendar.MINUTE, 30);
> - cal.set(Calendar.SECOND, 00);
> - cal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
> -
> - DefaultScheduleEntry entry1 = new DefaultScheduleEntry();
> - entry1.setStartTime(cal.getTime());
> - cal.add(Calendar.HOUR_OF_DAY, 2);
> - entry1.setEndTime(cal.getTime());
> - entry1.setId("1");
> - entry1.setTitle("Meeting with portal developers");
> - entry1.setSubtitle("Meeting room 1");
> -
> - DefaultScheduleEntry entry2 = new DefaultScheduleEntry();
> - cal.add(Calendar.HOUR_OF_DAY, -1);
> - entry2.setStartTime(cal.getTime());
> - cal.add(Calendar.HOUR, 4);
> - entry2.setEndTime(cal.getTime());
> - entry2.setId("2");
> - entry2.setTitle("work on MyFaces components");
> - entry2.setSubtitle("");
> - entry2.setDescription("I should create a more elaborate demo");
> -
> - DefaultScheduleEntry entry3 = new DefaultScheduleEntry();
> - cal.add(Calendar.HOUR_OF_DAY, -48);
> - entry3.setStartTime(cal.getTime());
> - cal.add(Calendar.HOUR_OF_DAY, 48);
> - entry3.setEndTime(cal.getTime());
> - entry3.setId("3");
> - entry3.setTitle("Business trip");
> - entry3.setSubtitle("Paris");
> - entry3.setDescription("Better brush up on my French before I leave...");
> - model.addEntry(entry1);
> - model.addEntry(entry2);
> - model.addEntry(entry3);
> -
> - model.setMode(mode.intValue());
> -
> - model.setSelectedDate(today);
> - }
> + model.setSelectedDate(this.date);
> + }
> }
> Index: examples/sandbox/schedule.jsp
> ===================================================================
> --- examples/sandbox/schedule.jsp (revision 225494)
> +++ examples/sandbox/schedule.jsp (working copy)
> @@ -1,53 +1,172 @@
> -<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> -<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> -<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="x"%>
> -
> -<!--
> -/*
> - * Copyright 2005 The Apache Software Foundation.
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - * http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing, software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> - * See the License for the specific language governing permissions and
> - * limitations under the License.
> - */
> -//-->
> -<html>
> -
> - <%@include file="inc/head.inc" %>
> -
> - <body>
> - <f:view>
> - <h:form>
> - <br/>
> - <h:panelGroup>
> - <h:outputLabel for="modeInput">
> - <h:outputText value="mode: " />
> - </h:outputLabel>
> - <h:selectOneRadio id="modeInput" layout="lineDirection"
> - binding="#{simpleSchedule.modeInput}" immediate="true"
> - valueChangeListener="#{simpleSchedule.modeChanged}"
> - onchange="this.form.submit();" value="#{simpleSchedule.mode}">
> - <f:selectItems id="modeItems" value="#{simpleSchedule.modeItems}" />
> - </h:selectOneRadio>
> -
> - </h:panelGroup>
> -
> - <x:schedule value="#{simpleSchedule.model}" id="schedule1"
> - rendered="true" visibleEndHour="18" visibleStartHour="8"
> - workingEndHour="17" workingStartHour="9" readonly="false"
> - actionListener="#{simpleSchedule.actionPerformed}" tooltip="true"/>
> - </h:form>
> - </f:view>
> - </body>
> -
> - <%@include file="inc/page_footer.jsp" %>
> -
> -</html>
> +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> +<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
> +<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
> +
> +<!--
> +/*
> + * Copyright 2005 The Apache Software Foundation.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +//-->
> +<html>
> +
> + <%@include file="inc/head.inc" %>
> +
> + <body>
> + <f:view>
> + <h:form>
> + <h:messages
> + tooltip="true"
> + id="scheduleMessages"
> + layout="table"
> + globalOnly="false"/>
> +
> + <table cellpadding="5" border="0">
> + <tr>
> + <td valign="top">
> + <h:panelGrid cellpadding="0" cellspacing="15" columns="1">
> + <x:inputCalendar
> + id="scheduleNavigator"
> + monthYearRowClass="yearMonthHeader"
> + weekRowClass="weekHeader"
> + currentDayCellClass="currentDayCell"
> + value="#{simpleSchedule.date}"
> + valueChangeListener="#{simpleSchedule.calendarValueChanged}"
> + binding="#{simpleSchedule.dateInput}"/>
> + <h:outputLabel
> + for="modeInput"
> + id="modeLabel"
> + value="mode:"/>
> + <h:selectOneMenu
> + id="modeInput"
> + binding="#{simpleSchedule.modeInput}"
> + immediate="true"
> + valueChangeListener="#{simpleSchedule.modeValueChanged}"
> + onchange="this.form.submit();"
> + value="#{simpleSchedule.mode}">
> + <f:selectItems
> + id="modeItems"
> + value="#{simpleSchedule.modeItems}"/>
> + </h:selectOneMenu>
> + </h:panelGrid>
> + </td>
> + <td width="100%">
> + <s:schedule
> + value="#{simpleSchedule.model}"
> + id="schedule1"
> + rendered="true"
> + visibleEndHour="18"
> + visibleStartHour="8"
> + workingEndHour="17"
> + workingStartHour="9"
> + readonly="false"
> + actionListener="#{simpleSchedule.scheduleActionPerformed}"
> + tooltip="true"/>
> + </td>
> + </tr>
> + <tr>
> + <td valign="top">
> + <h3><h:outputText value="add appointment"/></h3>
> + </td>
> + <td>
> + <h:panelGrid cellpadding="0" cellspacing="0" columns="2">
> + <h:outputLabel
> + for="appStart"
> + value="start:"/>
> + <x:inputDate
> + id="appStart"
> + value="#{simpleAppointment.appointmentStart}"
> + type="both"/>
> + <h:outputLabel
> + for="appEnd"
> + value="end:"/>
> + <x:inputDate
> + id="appEnd"
> + value="#{simpleAppointment.appointmentEnd}"
> + type="both"/>
> + <h:outputLabel
> + for="appTitle"
> + value="title:"/>
> + <h:inputText
> + size="60"
> + id="appTitle"
> + value="#{simpleAppointment.appointmentTitle}"/>
> + <h:outputLabel
> + for="appLocation"
> + value="location:"/>
> + <h:inputText
> + size="60"
> + id="appLocation"
> + value="#{simpleAppointment.appointmentLocation}"/>
> + <h:outputLabel
> + for="appComments"
> + value="comments:"/>
> + <h:inputTextarea
> + cols="60"
> + rows="5"
> + id="appComments"
> + value="#{simpleAppointment.appointmentComments}"/>
> + <h:commandButton
> + value="Add appointment"
> + actionListener="#{simpleAppointment.addAppointment}"/>
> + </h:panelGrid>
> + </td>
> + </tr>
> + <tr>
> + <td valign="top">
> + <h3><h:outputText value="remove appointment"/></h3>
> + </td>
> + <td>
> + <h:commandButton
> + value="Remove selected appointment"
> + actionListener="#{simpleAppointment.removeAppointment}"
> + disabled="#{!simpleSchedule.entrySelected}"/>
> + </td>
> + </tr>
> + <tr>
> + <td valign="top">
> + <h3><h:outputText value="add holiday"/></h3>
> + </td>
> + <td>
> + <h:panelGrid cellpadding="0" cellspacing="0" columns="2">
> + <h:outputLabel
> + for="holidayDate"
> + value="date:"/>
> + <x:inputDate
> + id="holidayDate"
> + value="#{simpleAppointment.holidayDate}"
> + type="date"/>
> + <h:outputLabel
> + for="holidayName"
> + value="name:"/>
> + <h:inputText
> + size="60"
> + id="holidayName"
> + value="#{simpleAppointment.holidayName}"/>
> + <h:commandButton
> + value="Add holiday"
> + actionListener="#{simpleAppointment.addHoliday}"/>
> + </h:panelGrid>
> + </td>
> + </tr>
> + </table>
> +
> + </h:form>
> + </f:view>
> + </body>
> +
> + <%@include file="inc/page_footer.jsp" %>
> +
> +</html>
>
>
> ------------------------------------------------------------------------
>
> Index: sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java
> ===================================================================
> --- sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java (revision 225494)
> +++ sandbox/src/java/org/apache/myfaces/custom/schedule/model/SimpleScheduleModel.java (working copy)
> @@ -87,8 +87,6 @@
> * </p>
> *
> * @param entry the entry to add
> - *
> - * @return true if successful
> */
> public void addEntry(ScheduleEntry entry)
> {
> @@ -96,6 +94,18 @@
> }
>
> /**
> + * <p>
> + * Remove an entry from the model
> + * </p>
> + *
> + * @param entry the entry to remove
> + */
> + public void removeEntry(ScheduleEntry entry)
> + {
> + entries.remove(entry);
> + }
> +
> + /**
> * @see org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date, java.util.Date)
> */
> protected Collection loadEntries(Date startDate, Date endDate)