You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sc...@apache.org on 2005/07/27 16:27:38 UTC
svn commit: r225526 - in
/myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule:
SimpleAppointmentBackingBean.java SimpleScheduleBackingBean.java
Author: schof
Date: Wed Jul 27 07:27:34 2005
New Revision: 225526
URL: http://svn.apache.org/viewcvs?rev=225526&view=rev
Log:
Applied Jurgen's schedule patch
Added:
myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleAppointmentBackingBean.java
Modified:
myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
Added: myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleAppointmentBackingBean.java
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleAppointmentBackingBean.java?rev=225526&view=auto
==============================================================================
--- myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleAppointmentBackingBean.java (added)
+++ myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleAppointmentBackingBean.java Wed Jul 27 07:27:34 2005
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2004 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.
+ */
+
+package org.apache.myfaces.examples.schedule;
+
+import java.util.Date;
+
+import javax.faces.event.ActionEvent;
+
+import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
+import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
+
+/**
+ * Backing bean for the add appointment, remove appointment and add holiday
+ * forms in the schedule demo.
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @version $Revision$
+ */
+public class SimpleAppointmentBackingBean
+{
+ private Date appointmentStart;
+ private Date appointmentEnd;
+ private Date holidayDate;
+ private String holidayName;
+ private String appointmentTitle;
+ private String appointmentLocation;
+ private String appointmentComments;
+ private SimpleScheduleBackingBean scheduleBean;
+
+ /**
+ * @return Returns the appointmentComments.
+ */
+ public String getAppointmentComments()
+ {
+ return appointmentComments;
+ }
+
+ /**
+ * @param appointmentComments The appointmentComments to set.
+ */
+ public void setAppointmentComments(String appointmentComments)
+ {
+ this.appointmentComments = appointmentComments;
+ }
+
+ /**
+ * @return Returns the appointmentEnd.
+ */
+ public Date getAppointmentEnd()
+ {
+ return appointmentEnd;
+ }
+
+ /**
+ * @param appointmentEnd The appointmentEnd to set.
+ */
+ public void setAppointmentEnd(Date appointmentEnd)
+ {
+ this.appointmentEnd = appointmentEnd;
+ }
+
+ /**
+ * @return Returns the appointmentLocation.
+ */
+ public String getAppointmentLocation()
+ {
+ return appointmentLocation;
+ }
+
+ /**
+ * @param appointmentLocation The appointmentLocation to set.
+ */
+ public void setAppointmentLocation(String appointmentLocation)
+ {
+ this.appointmentLocation = appointmentLocation;
+ }
+
+ /**
+ * @return Returns the appointmentStart.
+ */
+ public Date getAppointmentStart()
+ {
+ return appointmentStart;
+ }
+
+ /**
+ * @param appointmentStart The appointmentStart to set.
+ */
+ public void setAppointmentStart(Date appointmentStart)
+ {
+ this.appointmentStart = appointmentStart;
+ }
+
+ /**
+ * @return Returns the appointmentTitle.
+ */
+ public String getAppointmentTitle()
+ {
+ return appointmentTitle;
+ }
+
+ /**
+ * @param appointmentTitle The appointmentTitle to set.
+ */
+ public void setAppointmentTitle(String appointmentTitle)
+ {
+ this.appointmentTitle = appointmentTitle;
+ }
+
+ /**
+ * @return Returns the holidayDate.
+ */
+ public Date getHolidayDate()
+ {
+ return holidayDate;
+ }
+
+ /**
+ * @param holidayDate The holidayDate to set.
+ */
+ public void setHolidayDate(Date holidayDate)
+ {
+ this.holidayDate = holidayDate;
+ }
+
+ /**
+ * @return Returns the holidayName.
+ */
+ public String getHolidayName()
+ {
+ return holidayName;
+ }
+
+ /**
+ * @param holidayName The holidayName to set.
+ */
+ public void setHolidayName(String holidayName)
+ {
+ this.holidayName = holidayName;
+ }
+
+ /**
+ * @return Returns the scheduleBean.
+ */
+ public SimpleScheduleBackingBean getScheduleBean()
+ {
+ return scheduleBean;
+ }
+
+ /**
+ * @param scheduleBean The scheduleBean to set.
+ */
+ public void setScheduleBean(SimpleScheduleBackingBean scheduleBean)
+ {
+ this.scheduleBean = scheduleBean;
+ }
+
+ /**
+ * This method is called when the 'add appointment' button is pressed.
+ *
+ * @param event the actionEvent
+ */
+ public void addAppointment(ActionEvent event)
+ {
+ if (scheduleBean == null)
+ return;
+ if (!appointmentStart.before(appointmentEnd))
+ return;
+ if (appointmentTitle == null || appointmentTitle.length() < 1)
+ return;
+ SimpleScheduleModel model = (SimpleScheduleModel) scheduleBean
+ .getModel();
+ DefaultScheduleEntry appointment = new DefaultScheduleEntry();
+ //we need a unique id, let's take the current time in milliseconds
+ appointment.setId(String.valueOf(System.currentTimeMillis()));
+ appointment.setStartTime(appointmentStart);
+ appointment.setEndTime(appointmentEnd);
+ appointment.setTitle(appointmentTitle);
+ appointment.setSubtitle(appointmentLocation == null ? ""
+ : appointmentLocation);
+ appointment.setDescription(appointmentComments == null ? ""
+ : appointmentComments);
+ model.addEntry(appointment);
+ model.refresh();
+ appointmentStart = new Date();
+ appointmentEnd = new Date();
+ appointmentTitle = "";
+ appointmentLocation = "";
+ appointmentComments = "";
+ }
+
+ /**
+ * This method is called when the 'remove appointment' button is pressed.
+ *
+ * @param event the actionEvent
+ */
+ public void removeAppointment(ActionEvent event)
+ {
+ if (scheduleBean == null)
+ return;
+ SimpleScheduleModel model = (SimpleScheduleModel) scheduleBean
+ .getModel();
+ model.removeEntry(model.getSelectedEntry());
+ model.setSelectedEntry(null);
+ model.refresh();
+ }
+
+ /**
+ * This method is called when the 'add holiday' button is pressed.
+ *
+ * @param event the actionEvent
+ */
+ public void addHoliday(ActionEvent event)
+ {
+ if (scheduleBean == null)
+ return;
+ if (holidayDate == null)
+ return;
+ SimpleScheduleModel model = (SimpleScheduleModel) scheduleBean
+ .getModel();
+ if (holidayName != null && holidayName.length() < 1)
+ holidayName = null;
+ model.setHoliday(holidayDate, holidayName);
+ model.refresh();
+ holidayDate = new Date();
+ holidayName = "";
+ }
+}
Modified: myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java
URL: http://svn.apache.org/viewcvs/myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java?rev=225526&r1=225525&r2=225526&view=diff
==============================================================================
--- myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java (original)
+++ myfaces/examples/trunk/sandbox/src/java/org/apache/myfaces/examples/schedule/SimpleScheduleBackingBean.java Wed Jul 27 07:27:34 2005
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2004 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.
+ */
+
package org.apache.myfaces.examples.schedule;
import java.util.ArrayList;
@@ -18,6 +34,9 @@
* The entries are stored in the session.
* A real application would typically use a custom implementation
* of the ScheduleModel.
+ *
+ * @author Jurgen Lust (latest modification by $Author$)
+ * @version $Revision$
*/
public class SimpleScheduleBackingBean
{