You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Jurgen Lust <Ju...@gmail.com> on 2007/08/16 21:38:32 UTC

Re: Remove Entry from schedule Tomahawk

The ScheduleModel.removeEntry() method expects a ScheduleEntry as
parameter. I suppose you use Hibernate for database access, so what you
should do is retrieve the ScheduleEntry from the database, using the id,
and feed the result to the removeEntry method. In that removeEntry
method, you just delete it with your Hibernate DAO.
You could of course add a method removeEntry(String/Long/Whatever id)
that does all of this.

Jurgen



Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
ignicolist:
> Hi to all, i want to eliminate a especific entry in a model of schedule
> tomahawk. the example in remove a selected entry work fine, but how to
> eliminate a determinated entry?
> 
> 
> i try with this code:
> 
>                               
> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> 
>  entry.setId(select);  
>  entry.setStartTime(start);
>  entry.setEndTime(end);
>  entry.setTitle(select7);	     	      
>  entry.setDescription(select2);
> 	     	
>  model.removeEntry(entry);
>  model.refresh();
> 
> i defined every value for the entry, and then i want to remove that entry!
> Any help please! 
> 
> Tks for all.
-- 
Jurgen Lust <Ju...@gmail.com>


Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
Any help please?

Tks! 

ignicolist wrote:
> 
> Its what i am doing but don´t work!
> 
> an example: 
> 
> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>  
>   entry.setId("1");  
>  model.removeEntry(entry);
> 
> this code is supose to remove the entry from de model with id 1 no? i just
> want remove de entry from the model, but a entry specify by me. 
> 
> 
> 
> 
> 
> Jurgen Lust-2 wrote:
>> 
>> The ScheduleModel.removeEntry() method expects a ScheduleEntry as
>> parameter. I suppose you use Hibernate for database access, so what you
>> should do is retrieve the ScheduleEntry from the database, using the id,
>> and feed the result to the removeEntry method. In that removeEntry
>> method, you just delete it with your Hibernate DAO.
>> You could of course add a method removeEntry(String/Long/Whatever id)
>> that does all of this.
>> 
>> Jurgen
>> 
>> 
>> 
>> Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
>> ignicolist:
>>> Hi to all, i want to eliminate a especific entry in a model of schedule
>>> tomahawk. the example in remove a selected entry work fine, but how to
>>> eliminate a determinated entry?
>>> 
>>> 
>>> i try with this code:
>>> 
>>>                               
>>> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>>> 
>>>  entry.setId(select);  
>>>  entry.setStartTime(start);
>>>  entry.setEndTime(end);
>>>  entry.setTitle(select7);	     	      
>>>  entry.setDescription(select2);
>>> 	     	
>>>  model.removeEntry(entry);
>>>  model.refresh();
>>> 
>>> i defined every value for the entry, and then i want to remove that
>>> entry!
>>> Any help please! 
>>> 
>>> Tks for all.
>> -- 
>> Jurgen Lust <Ju...@gmail.com>
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198136
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
Yes you have right, i try do that when a add a entry and remove it after
enter it, and its actualy remove. But, how do i get the reference of a entry
that i want eliminate in other part of the program ? for example i know the
id of the entry and i want remove that entry. how i get the reference to
that entry?

I hope i explain well! 

Tks for all your help and patience. 




Michał 'Gandalf' Stawicki wrote:
> 
> I believe you have to pass exact reference to object that was added to
> schedule, not some other object containing same data, example:
> 
> ScheduleEntry foo = new MyScheduleEntry("bar");
> ScheduleEntry foo2 = new MyScheduleEntry("bar");
> 
> model.addEntry(foo);
> 
> model.removeEntry(foo2); // wrong
> mode.removeEntry(foo); //ok
> 
> 
> 
> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>>
>> Yes, because the entry when i select it remove with
>> model.removeSelectedEntry(); but if i specify his id:  entry.setId("1");
>> model.removeEntry(entry); dont eliminate. And ids are the same in the two
>> situacions.
>>
>>
>>
>>
>> Jurgen Lust-2 wrote:
>> >
>> > In your model implementation, do you load the persistent entry from the
>> > database, using the supplied id, before you delete it?
>> >
>> > Jurgen
>> >
>> > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
>> > ignicolist:
>> >> Its what i am doing but don´t work!
>> >>
>> >> an example:
>> >>
>> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> >>
>> >>   entry.setId("1");
>> >>  model.removeEntry(entry);
>> >>
>> >> this code is supose to remove the entry from de model with id 1 no? i
>> >> just
>> >> want remove de entry from the model, but a entry specify by me.
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Jurgen Lust-2 wrote:
>> >> >
>> >> > The ScheduleModel.removeEntry() method expects a ScheduleEntry as
>> >> > parameter. I suppose you use Hibernate for database access, so what
>> you
>> >> > should do is retrieve the ScheduleEntry from the database, using the
>> >> id,
>> >> > and feed the result to the removeEntry method. In that removeEntry
>> >> > method, you just delete it with your Hibernate DAO.
>> >> > You could of course add a method removeEntry(String/Long/Whatever
>> id)
>> >> > that does all of this.
>> >> >
>> >> > Jurgen
>> >> >
>> >> >
>> >> >
>> >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
>> >> > ignicolist:
>> >> >> Hi to all, i want to eliminate a especific entry in a model of
>> >> schedule
>> >> >> tomahawk. the example in remove a selected entry work fine, but how
>> to
>> >> >> eliminate a determinated entry?
>> >> >>
>> >> >>
>> >> >> i try with this code:
>> >> >>
>> >> >>
>> >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> >> >>
>> >> >>  entry.setId(select);
>> >> >>  entry.setStartTime(start);
>> >> >>  entry.setEndTime(end);
>> >> >>  entry.setTitle(select7);
>> >> >>  entry.setDescription(select2);
>> >> >>
>> >> >>  model.removeEntry(entry);
>> >> >>  model.refresh();
>> >> >>
>> >> >> i defined every value for the entry, and then i want to remove that
>> >> >> entry!
>> >> >> Any help please!
>> >> >>
>> >> >> Tks for all.
>> >> > --
>> >> > Jurgen Lust <Ju...@gmail.com>
>> >> >
>> >> >
>> >> >
>> >>
>> > --
>> > Jurgen Lust <Ju...@gmail.com>
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Michał Stawicki
> 
> stawicki@gmail.com
> http://stawicki.jasliska.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198995
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
its like in the examples in my faces.


conf.xml->

 <managed-bean>
    	<managed-bean-name>scheduleModel2</managed-bean-name>
    	<managed-bean-class>
    		org.apache.myfaces.custom.schedule.model.ExtendedScheduleModel
    	</managed-bean-class>
    	<managed-bean-scope>session</managed-bean-scope>
    	<managed-property>
    		<property-name>mode</property-name>
    		<value>3</value>
    	</managed-property>
    	<managed-property>
    		<property-name>selectedDate</property-name>
    		<value>#{today}</value>
    	</managed-property>
    </managed-bean>

    <managed-bean>
    	<managed-bean-name>scheduleHandler2</managed-bean-name>
    	<managed-bean-class>
    		org.apache.myfaces.examples.schedule.ScheduleExampleHandler
    	</managed-bean-class>
    	<managed-bean-scope>session</managed-bean-scope>
    	<managed-property>
    		<property-name>model</property-name>
    		<value>#{scheduleModel2}</value>
    	</managed-property>
    </managed-bean>

    <managed-bean>
    	<managed-bean-name>bindingScheduleHandler</managed-bean-name>
    	<managed-bean-class>
    		org.apache.myfaces.examples.schedule.BindingScheduleExampleHandler
    	</managed-bean-class>

    	<managed-bean-scope>session</managed-bean-scope>
    	<managed-property>
    		<property-name>model</property-name>
    		<value>#{scheduleModel2}</value>
    	</managed-property>
    </managed-bean>

  <managed-bean>
    	<managed-bean-name>scheduleSettings2</managed-bean-name>
    	<managed-bean-class>
    		org.apache.myfaces.examples.schedule.ScheduleSettings
    	</managed-bean-class>
    	<managed-bean-scope>session</managed-bean-scope>
    	<managed-property>
    		<property-name>model</property-name>
    		<value>#{scheduleModel2}</value>
    	</managed-property>
    </managed-bean>



the schedule.jsp:


			<s:schedule value="#{scheduleHandler2.model}" id="schedule1"
			binding="#{bindingScheduleHandler.schedule}"
				rendered="true" visibleEndHour="#{scheduleSettings2.visibleEndHour}"
				visibleStartHour="#{scheduleSettings2.visibleStartHour}"
				workingEndHour="#{scheduleSettings2.workingEndHour}"
				workingStartHour="#{scheduleSettings2.workingStartHour}"
				readonly="#{scheduleSettings2.readonly}"
				theme="#{scheduleSettings2.theme}"
				tooltip="#{scheduleSettings2.tooltip}"
				renderZeroLengthEntries="#{scheduleSettings2.renderZeroLength}"
				expandToFitEntries="#{scheduleSettings2.expandToFitEntries}"
				headerDateFormat="#{scheduleSettings2.headerDateFormat}"
				compactWeekRowHeight="#{scheduleSettings2.compactWeekRowHeight}"
				compactMonthRowHeight="#{scheduleSettings2.compactMonthRowHeight}"
				detailedRowHeight="#{scheduleSettings2.detailedRowHeight}"
				submitOnClick="true"
				mouseListener="#{bindingScheduleHandler.scheduleClicked}"
				action="#{bindingScheduleHandler.scheduleAction}"/>
				<h:outputText
value="#{bindingScheduleHandler.mouseActionText}"></h:outputText>
	






Michał 'Gandalf' Stawicki wrote:
> 
>> private ScheduleModel model;
> 
> where do you init model?
> 
> 
>> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>>
>> entry.setId(cod_cal);
>>                 entry.setStartTime(startTime);
>>                 entry.setEndTime(endTime);
>>                 entry.setTitle(title);
>>                 entry.setDescription(description);
>>
>> model.addEntry(entry);
>>            model.refresh();
>>
>> If i try insert like that:
>>
>>
>>  private  ExtendedScheduleModel sss ;
> where do you init sss?
> 
>> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>>
>>  entry.setId(cod_cal);
>>                 entry.setStartTime(startTime);
>>                 entry.setEndTime(endTime);
>>                 entry.setTitle(title);
>>                 entry.setDescription(description);
>>
>>            sss.addEntry(entry);
>>
>> Dont work, blank page.
>>
>>
>> try to delete:
>>
>>  DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> ExtendedScheduleModel foo = new ExtendedScheduleModel();
>>
>>  entry.setId("10");
>> foo.removeEntry(entry);
>>
>> the entries have size 0 in the methot remove.
>>
>> try to remove like that:
>>
>> private ScheduleModel model;
>> ExtendedScheduleModel foo = new ExtendedScheduleModel();
>>
>>  entry.setId("10");
>>  model.removeEntry(entry);
>>
>> blank page!!  i dont know what could be rong here!!
>>
>>
>>
>>
>>
>> Michał 'Gandalf' Stawicki wrote:
>> >
>> > http://www.mail-archive.com/users@myfaces.apache.org/msg41756.html
>> >
>> > You copied whole class from this post and it still doesn't work? Worked
>> > for me.
>> >
>> > On 18/08/07, ignicolist <ig...@gmail.com> wrote:
>> >>
>> >> Your last mail have the same thing! :confused:
>> >> Dont have nathing changed!!
>> >>
>> >>
>> >>
>> >> Michał 'Gandalf' Stawicki wrote:
>> >> >
>> >> > Yes, it was wrong. I have posted correct one, working. see my
>> previous
>> >> > mail.
>> >> >
>> >> > On 18/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >>
>> >> >> Hi again, Tks for your great example, i do every thing, and i found
>> a
>> >> >> problem, in the function remove:
>> >> >>
>> >> >>  protected boolean removeEntry(String id)
>> >> >>         {
>> >> >>
>> >> >>                 ScheduleEntry entry = null;
>> >> >>                 String currentId = null;
>> >> >>
>> >> >>
>> >> >> System.out.println("++++++++++++++++"+entries.size());//*1
>> >> >>
>> >> >>                 for(ScheduleEntry se :
>> >> (TreeSet<ScheduleEntry>)entries)
>> >> >>                 {
>> >> >>
>> >> >>                         if((currentId = se.getId()) != null &&
>> >> >> currentId.equals(id))
>> >> >>                         {
>> >> >>
>> >> >>                                 entry = se;
>> >> >>                                 break;
>> >> >>                         }
>> >> >>                 }
>> >> >>
>> >> >>                 if(entry != null)
>> >> >>                 {
>> >> >>
>> >> >>                         entries.remove(entry);
>> >> >>                         entry = null;
>> >> >>
>> >> >>                         return true;
>> >> >>                 }
>> >> >>
>> >> >>                 return false;
>> >> >>         }
>> >> >>
>> >> >> the id that i select its correct in the funcion, the problem is the
>> >> >> entries
>> >> >> dont have values! i println the entries.size() and its 0.
>> >> >>
>> >> >>
>> >> >> i add the entries like that:
>> >> >>
>> >> >>
>> >> >> private ScheduleModel model;
>> >> >>
>> >> >> entry.setId(cod_cal);
>> >> >>                 entry.setStartTime(startTime);
>> >> >>                 entry.setEndTime(endTime);
>> >> >>                 entry.setTitle(title);
>> >> >>                 entry.setDescription(description);
>> >> >>
>> >> >>            model.addEntry(entry);
>> >> >>              model.refresh();
>> >> >>
>> >> >> i try delete like that:
>> >> >>
>> >> >> ExtendedScheduleModel foo = new ExtendedScheduleModel();
>> >> >>  DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> >> >> entry.setId("10");
>> >> >>
>> >> >> foo.removeEntry(entry);
>> >> >>
>> >> >> if i add the entries like that:
>> >> >>
>> >> >>
>> >> >>  private  ExtendedScheduleModel sss ;
>> >> >>
>> >> >>                entry.setId(cod_cal);
>> >> >>                 entry.setStartTime(startTime);
>> >> >>                 entry.setEndTime(endTime);
>> >> >>                 entry.setTitle(title);
>> >> >>                 entry.setDescription(description);
>> >> >>
>> >> >>              sss.addEntry(entry);
>> >> >>              sss.refresh();
>> >> >>
>> >> >> blank page...
>> >> >>
>> >> >>
>> >> >> Any sujection? Tks for all you are doing!
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> Michał 'Gandalf' Stawicki wrote:
>> >> >> >
>> >> >> > Right, it was fubar'ed, SimpleScheduleModel wasn't meant for
>> >> extending
>> >> >> > :) This works - you use like you tried at the beginning - create
>> >> >> > entry, set id and you can remove it. BTW: I think your bean
>> should
>> >> be
>> >> >> > session, not request, unless you intended so.
>> >> >> >
>> >> >> > /*
>> >> >> >  * Licensed to the Apache Software Foundation (ASF) under one
>> >> >> >  * or more contributor license agreements.  See the NOTICE file
>> >> >> >  * distributed with this work for additional information
>> >> >> >  * regarding copyright ownership.  The ASF licenses this file
>> >> >> >  * to you 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 ###########
>> >> >> >
>> >> >> > import java.io.Serializable;
>> >> >> >
>> >> >> > import java.text.DateFormat;
>> >> >> > import java.text.SimpleDateFormat;
>> >> >> > import java.util.ArrayList;
>> >> >> > import java.util.Collection;
>> >> >> > import java.util.Date;
>> >> >> > import java.util.HashMap;
>> >> >> > import java.util.Iterator;
>> >> >> > import java.util.TreeSet;
>> >> >> > import
>> >> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel;
>> >> >> > import org.apache.myfaces.custom.schedule.model.Day;
>> >> >> > import
>> >> org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
>> >> >> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
>> >> >> >
>> >> >> > import
>> >> org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
>> >> >> >
>> >> >> > /**
>> >> >> >  * <p>
>> >> >> >  * A simple implementation of the ScheduleModel, not backed by
>> any
>> >> kind
>> >> >> of
>> >> >> >  * datasource: entries have to be added manually.
>> >> >> >  * </p>
>> >> >> >  *
>> >> >> >  * @author Jurgen Lust (latest modification by $Author: werpu $)
>> >> >> >  * @version $Revision: 371736 $
>> >> >> >  */
>> >> >> > public class ExtendedScheduleModel extends AbstractScheduleModel
>> >> >> > implements Serializable
>> >> >> > {
>> >> >> >
>> >> >> >
>> >> >> > // TEST
>> >> >> > //    public static void main(String [] args)
>> >> >> > //    {
>> >> >> > //            ExtendedScheduleModel foo = new
>> >> ExtendedScheduleModel();
>> >> >> > //            DefaultScheduleEntry bar = new
>> DefaultScheduleEntry();
>> >> >> > //            bar.setId("1");
>> >> >> > //            foo.addEntry(bar);
>> >> >> > //            DefaultScheduleEntry bar2 = new
>> >> DefaultScheduleEntry();
>> >> >> > //            bar2.setId("1");
>> >> >> > //
>> >> >> > //            foo.removeEntry(bar2);
>> >> >> > //    }
>> >> >> >
>> >> >> >
>> >> >> >       private static final long serialVersionUID = 1L;
>> >> >> >       protected final TreeSet entries;
>> >> >> >       protected final HashMap holidays;
>> >> >> >       protected final DateFormat holidayFormat = new
>> >> >> > SimpleDateFormat("yyyyMMdd");
>> >> >> >
>> >> >> >       public ExtendedScheduleModel()
>> >> >> >       {
>> >> >> >               this.entries = new TreeSet(new
>> >> >> ScheduleEntryComparator());
>> >> >> >               this.holidays = new HashMap();
>> >> >> >       }
>> >> >> >
>> >> >> >       /**
>> >> >> >        * Set the name of a holiday.
>> >> >> >        *
>> >> >> >        * @param date
>> >> >> >        *            the date
>> >> >> >        * @param holidayName
>> >> >> >        *            the name of the holiday
>> >> >> >        */
>> >> >> >       public void setHoliday(Date date, String holidayName)
>> >> >> >       {
>> >> >> >               if (date == null)
>> >> >> >               {
>> >> >> >                       return;
>> >> >> >               }
>> >> >> >
>> >> >> >               String key = holidayFormat.format(date);
>> >> >> >               holidays.put(key, holidayName);
>> >> >> >       }
>> >> >> >
>> >> >> >       /**
>> >> >> >        * Add an entry to the model.
>> >> >> >        *
>> >> >> >        * @param entry
>> >> >> >        *            the entry to add
>> >> >> >        */
>> >> >> >       public void addEntry(ScheduleEntry entry)
>> >> >> >       {
>> >> >> >               entries.add(entry);
>> >> >> >       }
>> >> >> >
>> >> >> >       /**
>> >> >> >        * Remove an entry from the model.
>> >> >> >        *
>> >> >> >        * @param entry
>> >> >> >        *            the entry to remove
>> >> >> >        */
>> >> >> >       public void removeEntry(ScheduleEntry entry)
>> >> >> >       {
>> >> >> >               if(entries.remove(entry))
>> >> >> >                       return;
>> >> >> >
>> >> >> >               if(entry != null && entry.getId() != null)
>> >> >> >                       removeEntry(entry.getId());
>> >> >> >       }
>> >> >> >
>> >> >> >       /**
>> >> >> >        * @see
>> >> >> >
>> >> >>
>> >>
>> org.apache.myfaces.custom.schedule.model.ScheduleModel#removeSelectedEntry()
>> >> >> >        */
>> >> >> >       public void removeSelectedEntry()
>> >> >> >       {
>> >> >> >               if (!isEntrySelected())
>> >> >> >                       return;
>> >> >> >               removeEntry(getSelectedEntry());
>> >> >> >               setSelectedEntry(null);
>> >> >> >               refresh();
>> >> >> >       }
>> >> >> >
>> >> >> >       /**
>> >> >> >        * @see
>> >> >> >
>> >> >>
>> >>
>> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date,
>> >> >> >        *      java.util.Date)
>> >> >> >        */
>> >> >> >       protected Collection loadEntries(Date startDate, Date
>> endDate)
>> >> >> >       {
>> >> >> >               ArrayList selection = new ArrayList();
>> >> >> >
>> >> >> >               for (Iterator entryIterator = entries.iterator();
>> >> >> entryIterator
>> >> >> >                               .hasNext();)
>> >> >> >               {
>> >> >> >                       ScheduleEntry entry = (ScheduleEntry)
>> >> >> entryIterator.next();
>> >> >> >
>> >> >> >                       if (entry.getEndTime().before(startDate)
>> >> >> >                       || entry.getStartTime().after(endDate))
>> >> >> >                       {
>> >> >> >                               continue;
>> >> >> >                       }
>> >> >> >
>> >> >> >                       selection.add(entry);
>> >> >> >               }
>> >> >> >
>> >> >> >               return selection;
>> >> >> >       }
>> >> >> >
>> >> >> >       /**
>> >> >> >        * @see
>> >> >> >
>> >> >>
>> >>
>> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadDayAttributes(org.apache.myfaces.custom.schedule.model.Day)
>> >> >> >        */
>> >> >> >       protected void loadDayAttributes(Day day)
>> >> >> >       {
>> >> >> >               if (day == null)
>> >> >> >                       return;
>> >> >> >               String key = holidayFormat.format(day.getDate());
>> >> >> >               String holiday = (String) holidays.get(key);
>> >> >> >               if (holiday != null)
>> >> >> >               {
>> >> >> >                       day.setSpecialDayName(holiday);
>> >> >> >                       day.setWorkingDay(false);
>> >> >> >               }
>> >> >> >               else
>> >> >> >               {
>> >> >> >                       day.setSpecialDayName(null);
>> >> >> >                       day.setWorkingDay(true);
>> >> >> >               }
>> >> >> >       }
>> >> >> >
>> >> >> >       /**
>> >> >> >        * Remove entry from model
>> >> >> >        * <br /><br />
>> >> >> >        * @param id identifier of entry to be removed
>> >> >> >        * <br /><br />
>> >> >> >        * @return true on success and false on failure (in case
>> entry
>> >> >> with
>> >> >> > specified id wasn't found)
>> >> >> >        *
>> >> >> >        */
>> >> >> >       protected boolean removeEntry(String id)
>> >> >> >       {
>> >> >> >               ScheduleEntry entry = null;
>> >> >> >               String currentId = null;
>> >> >> >
>> >> >> >               for(ScheduleEntry se :
>> >> (TreeSet<ScheduleEntry>)entries)
>> >> >> >               {
>> >> >> >                       if((currentId = se.getId()) != null &&
>> >> >> currentId.equals(id))
>> >> >> >                       {
>> >> >> >                               entry = se;
>> >> >> >                               break;
>> >> >> >                       }
>> >> >> >               }
>> >> >> >
>> >> >> >               if(entry != null)
>> >> >> >               {
>> >> >> >                       entries.remove(entry);
>> >> >> >                       entry = null;
>> >> >> >
>> >> >> >                       return true;
>> >> >> >               }
>> >> >> >
>> >> >> >               return false;
>> >> >> >       }
>> >> >> > }
>> >> >> >
>> >> >> >
>> >> >> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >> >>
>> >> >> >> i have the class correct without errors. But when i call it 
>> show a
>> >> >> blank
>> >> >> >> page!
>> >> >> >>
>> >> >> >> ExtendedScheduleModel x = new ExtendedScheduleModel();
>> >> >> >> x.Remove2("8");
>> >> >> >>
>> >> >> >> I call the class like that. I think its correct! so why the
>> blank
>> >> >> page?
>> >> >> >> if i
>> >> >> >> put thouse two code lines in comments dont have the blank page,
>> so
>> >> the
>> >> >> >> problem is the class! :-((
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> Michał 'Gandalf' Stawicki wrote:
>> >> >> >> >
>> >> >> >> > Try this, remember to set valid package:
>> >> >> >> >
>> >> >> >> >  #####SET ME package #####SET ME
>> >> >> >> >
>> >> >> >> > import java.util.TreeSet;
>> >> >> >> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
>> >> >> >> > import
>> >> org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
>> >> >> >> >
>> >> >> >> > /**
>> >> >> >> >  * @author mstawick
>> >> >> >> >  */
>> >> >> >> > public class ExtendedScheduleModel extends SimpleScheduleModel
>> >> >> >> > {
>> >> >> >> >
>> >> >> >> >       /** Creates a new instance of ExtendedScheduleModel */
>> >> >> >> >       public ExtendedScheduleModel()
>> >> >> >> >       {
>> >> >> >> >               super();
>> >> >> >> >       }
>> >> >> >> >
>> >> >> >> >       /**
>> >> >> >> >        * Remove entry from model
>> >> >> >> >        * <br /><br />
>> >> >> >> >        * @param id identifier of entry to be removed
>> >> >> >> >        * <br /><br />
>> >> >> >> >        * @return true on success and false on failure (in case
>> >> entry
>> >> >> >> with
>> >> >> >> > specified id wasn't found)
>> >> >> >> >        *
>> >> >> >> >        */
>> >> >> >> >       public boolean removeEntry(String id)
>> >> >> >> >       {
>> >> >> >> >               ScheduleEntry entry = null;
>> >> >> >> >               String currentId = null;
>> >> >> >> >
>> >> >> >> >               for(ScheduleEntry se : entries)
>> >> >> >> >               {
>> >> >> >> >                       if((currentId = se.getId()) != null &&
>> >> >> >> currentId.equals(id))
>> >> >> >> >                       {
>> >> >> >> >                               entry = se;
>> >> >> >> >                               break;
>> >> >> >> >                       }
>> >> >> >> >               }
>> >> >> >> >
>> >> >> >> >               if(entry != null)
>> >> >> >> >               {
>> >> >> >> >                       entries.remove(entry);
>> >> >> >> >                       entry = null;
>> >> >> >> >
>> >> >> >> >                       return true;
>> >> >> >> >               }
>> >> >> >> >
>> >> >> >> >               return false;
>> >> >> >> >       }
>> >> >> >> >
>> >> >> >> >       private TreeSet<ScheduleEntry> entries;
>> >> >> >> > }
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >> >> >>
>> >> >> >> >> Sorry to bee so boring and noob, but i realy need to do this,
>> i
>> >> >> need a
>> >> >> >> >> funcionality to show and occult calendars, and i have a entry
>> >> >> >> associate
>> >> >> >> >> to a
>> >> >> >> >> calendar, so when i need occult  the calendar i need to
>> remove
>> >> the
>> >> >> >> >> entries
>> >> >> >> >> of that calendar from the model. everything working, just
>> need
>> >> >> remove
>> >> >> >> the
>> >> >> >> >> entries.
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> ignicolist wrote:
>> >> >> >> >> >
>> >> >> >> >> > Well i am a litle noob to all these, so i cant put your
>> ideas
>> >> to
>> >> >> >> work!
>> >> >> >> >> > :-((
>> >> >> >> >> >
>> >> >> >> >> > So i am using SimpleScheduleModel, so you say to create
>> that
>> >> >> class
>> >> >> >> in
>> >> >> >> >> the
>> >> >> >> >> > component Schedule or in my aplication?
>> >> >> >> >> > Because i create the class in my aplication and don´t work.
>> >> Dam
>> >> >> this
>> >> >> >> is
>> >> >> >> >> so
>> >> >> >> >> > complicated...
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> > Michał 'Gandalf' Stawicki wrote:
>> >> >> >> >> >>
>> >> >> >> >> >> I wrote the code in 'on the fly' just to give you idea how
>> >> >> should
>> >> >> >> it
>> >> >> >> >> >> look, I didn't try it
>> >> >> >> >> >>
>> >> >> >> >> >> On 17/08/07, Michał 'Gandalf' Stawicki
>> <st...@gmail.com>
>> >> >> wrote:
>> >> >> >> >> >>> Simply casting it should be fine:
>> >> >> >> >> >>>
>> >> >> >> >> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
>> >> >> >> >> >>>
>> >> >> >> >> >>>
>> >> >> >> >> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >> >> >> >>> >
>> >> >> >> >> >>> > I try what you say but give me a error in:
>> >> for(ScheduleEntry
>> >> >> e :
>> >> >> >> >> >>> entries)
>> >> >> >> >> >>> > The Error: Type mismatch: cannot convert from element
>> type
>> >> >> >> Object
>> >> >> >> >> to
>> >> >> >> >> >>> > ScheduleEntry
>> >> >> >> >> >>> >
>> >> >> >> >> >>> > Any idea?
>> >> >> >> >> >>> >
>> >> >> >> >> >>> >
>> >> >> >> >> >>> >
>> >> >> >> >> >>> > Michał 'Gandalf' Stawicki wrote:
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > > From SimpleScheduleModel.java
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > >     /**
>> >> >> >> >> >>> > >      * Remove an entry from the model.
>> >> >> >> >> >>> > >      *
>> >> >> >> >> >>> > >      * @param entry
>> >> >> >> >> >>> > >      *            the entry to remove
>> >> >> >> >> >>> > >      */
>> >> >> >> >> >>> > >     public void removeEntry(ScheduleEntry entry)
>> >> >> >> >> >>> > >     {
>> >> >> >> >> >>> > >         entries.remove(entry);
>> >> >> >> >> >>> > >     }
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > > ...
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > >     private final TreeSet entries;
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > > I don't know which model your using, but if it is
>> >> >> >> >> >>> SimpleScheduleModel
>> >> >> >> >> >>> > > than you should extend it and implement your own
>> method,
>> >> >> ex;
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > > public boolean removeEntry(String id)
>> >> >> >> >> >>> > > {
>> >> >> >> >> >>> > > ScheduleEntry entry = null;
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > > if(entries != null && id != null)
>> >> >> >> >> >>> > > for(ScheduleEntry e : entries)
>> >> >> >> >> >>> > > {
>> >> >> >> >> >>> > > if(e.getId() != null && e.getId().equals(id))
>> >> >> >> >> >>> > > {
>> >> >> >> >> >>> > > entry = e;
>> >> >> >> >> >>> > > break;
>> >> >> >> >> >>> > > }
>> >> >> >> >> >>> > > }
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > > if(entry != null)
>> >> >> >> >> >>> > > {
>> >> >> >> >> >>> > > entries.remove(entry);
>> >> >> >> >> >>> > > return true;
>> >> >> >> >> >>> > > }
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > > return false;
>> >> >> >> >> >>> > > }
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki
>> >> <st...@gmail.com>
>> >> >> >> >> wrote:
>> >> >> >> >> >>> > >> I believe you have to pass exact reference to object
>> >> that
>> >> >> was
>> >> >> >> >> added
>> >> >> >> >> >>> to
>> >> >> >> >> >>> > >> schedule, not some other object containing same
>> data,
>> >> >> >> example:
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
>> >> >> >> >> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>> > >> model.addEntry(foo);
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>> > >> model.removeEntry(foo2); // wrong
>> >> >> >> >> >>> > >> mode.removeEntry(foo); //ok
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com>
>> wrote:
>> >> >> >> >> >>> > >> >
>> >> >> >> >> >>> > >> > Yes, because the entry when i select it remove
>> with
>> >> >> >> >> >>> > >> > model.removeSelectedEntry(); but if i specify his
>> id:
>> >> >> >> >> >>> > >> entry.setId("1");
>> >> >> >> >> >>> > >> > model.removeEntry(entry); dont eliminate. And ids
>> are
>> >> >> the
>> >> >> >> same
>> >> >> >> >> in
>> >> >> >> >> >>> the
>> >> >> >> >> >>> > >> two
>> >> >> >> >> >>> > >> > situacions.
>> >> >> >> >> >>> > >> >
>> >> >> >> >> >>> > >> >
>> >> >> >> >> >>> > >> >
>> >> >> >> >> >>> > >> >
>> >> >> >> >> >>> > >> > Jurgen Lust-2 wrote:
>> >> >> >> >> >>> > >> > >
>> >> >> >> >> >>> > >> > > In your model implementation, do you load the
>> >> >> persistent
>> >> >> >> >> entry
>> >> >> >> >> >>> from
>> >> >> >> >> >>> > >> the
>> >> >> >> >> >>> > >> > > database, using the supplied id, before you
>> delete
>> >> it?
>> >> >> >> >> >>> > >> > >
>> >> >> >> >> >>> > >> > > Jurgen
>> >> >> >> >> >>> > >> > >
>> >> >> >> >> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone
>> >> -0700],
>> >> >> >> >> schreef
>> >> >> >> >> >>> > >> > > ignicolist:
>> >> >> >> >> >>> > >> > >> Its what i am doing but don´t work!
>> >> >> >> >> >>> > >> > >>
>> >> >> >> >> >>> > >> > >> an example:
>> >> >> >> >> >>> > >> > >>
>> >> >> >> >> >>> > >> > >> DefaultScheduleEntry entry = new
>> >> >> DefaultScheduleEntry();
>> >> >> >> >> >>> > >> > >>
>> >> >> >> >> >>> > >> > >>   entry.setId("1");
>> >> >> >> >> >>> > >> > >>  model.removeEntry(entry);
>> >> >> >> >> >>> > >> > >>
>> >> >> >> >> >>> > >> > >> this code is supose to remove the entry from de
>> >> model
>> >> >> >> with
>> >> >> >> >> id
>> >> >> >> >> >>> 1 no?
>> >> >> >> >> >>> > >> i
>> >> >> >> >> >>> > >> > >> just
>> >> >> >> >> >>> > >> > >> want remove de entry from the model, but a
>> entry
>> >> >> specify
>> >> >> >> by
>> >> >> >> >> >>> me.
>> >> >> >> >> >>> > >> > >>
>> >> >> >> >> >>> > >> > >>
>> >> >> >> >> >>> > >> > >>
>> >> >> >> >> >>> > >> > >>
>> >> >> >> >> >>> > >> > >>
>> >> >> >> >> >>> > >> > >> Jurgen Lust-2 wrote:
>> >> >> >> >> >>> > >> > >> >
>> >> >> >> >> >>> > >> > >> > The ScheduleModel.removeEntry() method
>> expects a
>> >> >> >> >> >>> ScheduleEntry as
>> >> >> >> >> >>> > >> > >> > parameter. I suppose you use Hibernate for
>> >> database
>> >> >> >> >> access,
>> >> >> >> >> >>> so
>> >> >> >> >> >>> > >> what you
>> >> >> >> >> >>> > >> > >> > should do is retrieve the ScheduleEntry from
>> the
>> >> >> >> >> database,
>> >> >> >> >> >>> using
>> >> >> >> >> >>> > >> the
>> >> >> >> >> >>> > >> > >> id,
>> >> >> >> >> >>> > >> > >> > and feed the result to the removeEntry
>> method.
>> >> In
>> >> >> that
>> >> >> >> >> >>> removeEntry
>> >> >> >> >> >>> > >> > >> > method, you just delete it with your
>> Hibernate
>> >> DAO.
>> >> >> >> >> >>> > >> > >> > You could of course add a method
>> >> >> >> >> >>> removeEntry(String/Long/Whatever
>> >> >> >> >> >>> > >> id)
>> >> >> >> >> >>> > >> > >> > that does all of this.
>> >> >> >> >> >>> > >> > >> >
>> >> >> >> >> >>> > >> > >> > Jurgen
>> >> >> >> >> >>> > >> > >> >
>> >> >> >> >> >>> > >> > >> >
>> >> >> >> >> >>> > >> > >> >
>> >> >> >> >> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur
>> [tijdzone
>> >> >> -0700],
>> >> >> >> >> >>> schreef
>> >> >> >> >> >>> > >> > >> > ignicolist:
>> >> >> >> >> >>> > >> > >> >> Hi to all, i want to eliminate a especific
>> >> entry
>> >> >> in a
>> >> >> >> >> model
>> >> >> >> >> >>> of
>> >> >> >> >> >>> > >> > >> schedule
>> >> >> >> >> >>> > >> > >> >> tomahawk. the example in remove a selected
>> >> entry
>> >> >> work
>> >> >> >> >> fine,
>> >> >> >> >> >>> but
>> >> >> >> >> >>> > >> how to
>> >> >> >> >> >>> > >> > >> >> eliminate a determinated entry?
>> >> >> >> >> >>> > >> > >> >>
>> >> >> >> >> >>> > >> > >> >>
>> >> >> >> >> >>> > >> > >> >> i try with this code:
>> >> >> >> >> >>> > >> > >> >>
>> >> >> >> >> >>> > >> > >> >>
>> >> >> >> >> >>> > >> > >> >> DefaultScheduleEntry entry = new
>> >> >> >> DefaultScheduleEntry();
>> >> >> >> >> >>> > >> > >> >>
>> >> >> >> >> >>> > >> > >> >>  entry.setId(select);
>> >> >> >> >> >>> > >> > >> >>  entry.setStartTime(start);
>> >> >> >> >> >>> > >> > >> >>  entry.setEndTime(end);
>> >> >> >> >> >>> > >> > >> >>  entry.setTitle(select7);
>> >> >> >> >> >>> > >> > >> >>  entry.setDescription(select2);
>> >> >> >> >> >>> > >> > >> >>
>> >> >> >> >> >>> > >> > >> >>  model.removeEntry(entry);
>> >> >> >> >> >>> > >> > >> >>  model.refresh();
>> >> >> >> >> >>> > >> > >> >>
>> >> >> >> >> >>> > >> > >> >> i defined every value for the entry, and
>> then i
>> >> >> want
>> >> >> >> to
>> >> >> >> >> >>> remove
>> >> >> >> >> >>> > >> that
>> >> >> >> >> >>> > >> > >> >> entry!
>> >> >> >> >> >>> > >> > >> >> Any help please!
>> >> >> >> >> >>> > >> > >> >>
>> >> >> >> >> >>> > >> > >> >> Tks for all.
>> >> >> >> >> >>> > >> > >> > --
>> >> >> >> >> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
>> >> >> >> >> >>> > >> > >> >
>> >> >> >> >> >>> > >> > >> >
>> >> >> >> >> >>> > >> > >> >
>> >> >> >> >> >>> > >> > >>
>> >> >> >> >> >>> > >> > > --
>> >> >> >> >> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
>> >> >> >> >> >>> > >> > >
>> >> >> >> >> >>> > >> > >
>> >> >> >> >> >>> > >> > >
>> >> >> >> >> >>> > >> >
>> >> >> >> >> >>> > >> > --
>> >> >> >> >> >>> > >> > View this message in context:
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>>
>> >> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
>> >> >> >> >> >>> > >> > Sent from the MyFaces - Users mailing list archive
>> at
>> >> >> >> >> Nabble.com.
>> >> >> >> >> >>> > >> >
>> >> >> >> >> >>> > >> >
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>> > >> --
>> >> >> >> >> >>> > >> Michał Stawicki
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>> > >> stawicki@gmail.com
>> >> >> >> >> >>> > >> http://stawicki.jasliska.pl
>> >> >> >> >> >>> > >>
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > > --
>> >> >> >> >> >>> > > Michał Stawicki
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > > stawicki@gmail.com
>> >> >> >> >> >>> > > http://stawicki.jasliska.pl
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> > >
>> >> >> >> >> >>> >
>> >> >> >> >> >>> > --
>> >> >> >> >> >>> > View this message in context:
>> >> >> >> >> >>>
>> >> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
>> >> >> >> >> >>> > Sent from the MyFaces - Users mailing list archive at
>> >> >> >> Nabble.com.
>> >> >> >> >> >>> >
>> >> >> >> >> >>> >
>> >> >> >> >> >>>
>> >> >> >> >> >>>
>> >> >> >> >> >>> --
>> >> >> >> >> >>> Michał Stawicki
>> >> >> >> >> >>>
>> >> >> >> >> >>> stawicki@gmail.com
>> >> >> >> >> >>> http://stawicki.jasliska.pl
>> >> >> >> >> >>>
>> >> >> >> >> >>
>> >> >> >> >> >>
>> >> >> >> >> >> --
>> >> >> >> >> >> Michał Stawicki
>> >> >> >> >> >>
>> >> >> >> >> >> stawicki@gmail.com
>> >> >> >> >> >> http://stawicki.jasliska.pl
>> >> >> >> >> >>
>> >> >> >> >> >>
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >>
>> >> >> >> >> --
>> >> >> >> >> View this message in context:
>> >> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
>> >> >> >> >> Sent from the MyFaces - Users mailing list archive at
>> >> Nabble.com.
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > --
>> >> >> >> > Michał Stawicki
>> >> >> >> >
>> >> >> >> > stawicki@gmail.com
>> >> >> >> > http://stawicki.jasliska.pl
>> >> >> >> >
>> >> >> >> >
>> >> >> >>
>> >> >> >> --
>> >> >> >> View this message in context:
>> >> >> >>
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12206017
>> >> >> >> Sent from the MyFaces - Users mailing list archive at
>> Nabble.com.
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> > Michał Stawicki
>> >> >> >
>> >> >> > stawicki@gmail.com
>> >> >> > http://stawicki.jasliska.pl
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12209467
>> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Michał Stawicki
>> >> >
>> >> > stawicki@gmail.com
>> >> > http://stawicki.jasliska.pl
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12212569
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Michał Stawicki
>> >
>> > stawicki@gmail.com
>> > http://stawicki.jasliska.pl
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12213620
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Michał Stawicki
> 
> stawicki@gmail.com
> http://stawicki.jasliska.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12213715
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by Michał 'Gandalf' Stawicki <st...@gmail.com>.
> private ScheduleModel model;

where do you init model?


> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>
> entry.setId(cod_cal);
>                 entry.setStartTime(startTime);
>                 entry.setEndTime(endTime);
>                 entry.setTitle(title);
>                 entry.setDescription(description);
>
> model.addEntry(entry);
>            model.refresh();
>
> If i try insert like that:
>
>
>  private  ExtendedScheduleModel sss ;
where do you init sss?

> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>
>  entry.setId(cod_cal);
>                 entry.setStartTime(startTime);
>                 entry.setEndTime(endTime);
>                 entry.setTitle(title);
>                 entry.setDescription(description);
>
>            sss.addEntry(entry);
>
> Dont work, blank page.
>
>
> try to delete:
>
>  DefaultScheduleEntry entry = new DefaultScheduleEntry();
> ExtendedScheduleModel foo = new ExtendedScheduleModel();
>
>  entry.setId("10");
> foo.removeEntry(entry);
>
> the entries have size 0 in the methot remove.
>
> try to remove like that:
>
> private ScheduleModel model;
> ExtendedScheduleModel foo = new ExtendedScheduleModel();
>
>  entry.setId("10");
>  model.removeEntry(entry);
>
> blank page!!  i dont know what could be rong here!!
>
>
>
>
>
> Michał 'Gandalf' Stawicki wrote:
> >
> > http://www.mail-archive.com/users@myfaces.apache.org/msg41756.html
> >
> > You copied whole class from this post and it still doesn't work? Worked
> > for me.
> >
> > On 18/08/07, ignicolist <ig...@gmail.com> wrote:
> >>
> >> Your last mail have the same thing! :confused:
> >> Dont have nathing changed!!
> >>
> >>
> >>
> >> Michał 'Gandalf' Stawicki wrote:
> >> >
> >> > Yes, it was wrong. I have posted correct one, working. see my previous
> >> > mail.
> >> >
> >> > On 18/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >>
> >> >> Hi again, Tks for your great example, i do every thing, and i found a
> >> >> problem, in the function remove:
> >> >>
> >> >>  protected boolean removeEntry(String id)
> >> >>         {
> >> >>
> >> >>                 ScheduleEntry entry = null;
> >> >>                 String currentId = null;
> >> >>
> >> >>
> >> >> System.out.println("++++++++++++++++"+entries.size());//*1
> >> >>
> >> >>                 for(ScheduleEntry se :
> >> (TreeSet<ScheduleEntry>)entries)
> >> >>                 {
> >> >>
> >> >>                         if((currentId = se.getId()) != null &&
> >> >> currentId.equals(id))
> >> >>                         {
> >> >>
> >> >>                                 entry = se;
> >> >>                                 break;
> >> >>                         }
> >> >>                 }
> >> >>
> >> >>                 if(entry != null)
> >> >>                 {
> >> >>
> >> >>                         entries.remove(entry);
> >> >>                         entry = null;
> >> >>
> >> >>                         return true;
> >> >>                 }
> >> >>
> >> >>                 return false;
> >> >>         }
> >> >>
> >> >> the id that i select its correct in the funcion, the problem is the
> >> >> entries
> >> >> dont have values! i println the entries.size() and its 0.
> >> >>
> >> >>
> >> >> i add the entries like that:
> >> >>
> >> >>
> >> >> private ScheduleModel model;
> >> >>
> >> >> entry.setId(cod_cal);
> >> >>                 entry.setStartTime(startTime);
> >> >>                 entry.setEndTime(endTime);
> >> >>                 entry.setTitle(title);
> >> >>                 entry.setDescription(description);
> >> >>
> >> >>            model.addEntry(entry);
> >> >>              model.refresh();
> >> >>
> >> >> i try delete like that:
> >> >>
> >> >> ExtendedScheduleModel foo = new ExtendedScheduleModel();
> >> >>  DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >> >> entry.setId("10");
> >> >>
> >> >> foo.removeEntry(entry);
> >> >>
> >> >> if i add the entries like that:
> >> >>
> >> >>
> >> >>  private  ExtendedScheduleModel sss ;
> >> >>
> >> >>                entry.setId(cod_cal);
> >> >>                 entry.setStartTime(startTime);
> >> >>                 entry.setEndTime(endTime);
> >> >>                 entry.setTitle(title);
> >> >>                 entry.setDescription(description);
> >> >>
> >> >>              sss.addEntry(entry);
> >> >>              sss.refresh();
> >> >>
> >> >> blank page...
> >> >>
> >> >>
> >> >> Any sujection? Tks for all you are doing!
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> Michał 'Gandalf' Stawicki wrote:
> >> >> >
> >> >> > Right, it was fubar'ed, SimpleScheduleModel wasn't meant for
> >> extending
> >> >> > :) This works - you use like you tried at the beginning - create
> >> >> > entry, set id and you can remove it. BTW: I think your bean should
> >> be
> >> >> > session, not request, unless you intended so.
> >> >> >
> >> >> > /*
> >> >> >  * Licensed to the Apache Software Foundation (ASF) under one
> >> >> >  * or more contributor license agreements.  See the NOTICE file
> >> >> >  * distributed with this work for additional information
> >> >> >  * regarding copyright ownership.  The ASF licenses this file
> >> >> >  * to you 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 ###########
> >> >> >
> >> >> > import java.io.Serializable;
> >> >> >
> >> >> > import java.text.DateFormat;
> >> >> > import java.text.SimpleDateFormat;
> >> >> > import java.util.ArrayList;
> >> >> > import java.util.Collection;
> >> >> > import java.util.Date;
> >> >> > import java.util.HashMap;
> >> >> > import java.util.Iterator;
> >> >> > import java.util.TreeSet;
> >> >> > import
> >> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel;
> >> >> > import org.apache.myfaces.custom.schedule.model.Day;
> >> >> > import
> >> org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
> >> >> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
> >> >> >
> >> >> > import
> >> org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
> >> >> >
> >> >> > /**
> >> >> >  * <p>
> >> >> >  * A simple implementation of the ScheduleModel, not backed by any
> >> kind
> >> >> of
> >> >> >  * datasource: entries have to be added manually.
> >> >> >  * </p>
> >> >> >  *
> >> >> >  * @author Jurgen Lust (latest modification by $Author: werpu $)
> >> >> >  * @version $Revision: 371736 $
> >> >> >  */
> >> >> > public class ExtendedScheduleModel extends AbstractScheduleModel
> >> >> > implements Serializable
> >> >> > {
> >> >> >
> >> >> >
> >> >> > // TEST
> >> >> > //    public static void main(String [] args)
> >> >> > //    {
> >> >> > //            ExtendedScheduleModel foo = new
> >> ExtendedScheduleModel();
> >> >> > //            DefaultScheduleEntry bar = new DefaultScheduleEntry();
> >> >> > //            bar.setId("1");
> >> >> > //            foo.addEntry(bar);
> >> >> > //            DefaultScheduleEntry bar2 = new
> >> DefaultScheduleEntry();
> >> >> > //            bar2.setId("1");
> >> >> > //
> >> >> > //            foo.removeEntry(bar2);
> >> >> > //    }
> >> >> >
> >> >> >
> >> >> >       private static final long serialVersionUID = 1L;
> >> >> >       protected final TreeSet entries;
> >> >> >       protected final HashMap holidays;
> >> >> >       protected final DateFormat holidayFormat = new
> >> >> > SimpleDateFormat("yyyyMMdd");
> >> >> >
> >> >> >       public ExtendedScheduleModel()
> >> >> >       {
> >> >> >               this.entries = new TreeSet(new
> >> >> ScheduleEntryComparator());
> >> >> >               this.holidays = new HashMap();
> >> >> >       }
> >> >> >
> >> >> >       /**
> >> >> >        * Set the name of a holiday.
> >> >> >        *
> >> >> >        * @param date
> >> >> >        *            the date
> >> >> >        * @param holidayName
> >> >> >        *            the name of the holiday
> >> >> >        */
> >> >> >       public void setHoliday(Date date, String holidayName)
> >> >> >       {
> >> >> >               if (date == null)
> >> >> >               {
> >> >> >                       return;
> >> >> >               }
> >> >> >
> >> >> >               String key = holidayFormat.format(date);
> >> >> >               holidays.put(key, holidayName);
> >> >> >       }
> >> >> >
> >> >> >       /**
> >> >> >        * Add an entry to the model.
> >> >> >        *
> >> >> >        * @param entry
> >> >> >        *            the entry to add
> >> >> >        */
> >> >> >       public void addEntry(ScheduleEntry entry)
> >> >> >       {
> >> >> >               entries.add(entry);
> >> >> >       }
> >> >> >
> >> >> >       /**
> >> >> >        * Remove an entry from the model.
> >> >> >        *
> >> >> >        * @param entry
> >> >> >        *            the entry to remove
> >> >> >        */
> >> >> >       public void removeEntry(ScheduleEntry entry)
> >> >> >       {
> >> >> >               if(entries.remove(entry))
> >> >> >                       return;
> >> >> >
> >> >> >               if(entry != null && entry.getId() != null)
> >> >> >                       removeEntry(entry.getId());
> >> >> >       }
> >> >> >
> >> >> >       /**
> >> >> >        * @see
> >> >> >
> >> >>
> >> org.apache.myfaces.custom.schedule.model.ScheduleModel#removeSelectedEntry()
> >> >> >        */
> >> >> >       public void removeSelectedEntry()
> >> >> >       {
> >> >> >               if (!isEntrySelected())
> >> >> >                       return;
> >> >> >               removeEntry(getSelectedEntry());
> >> >> >               setSelectedEntry(null);
> >> >> >               refresh();
> >> >> >       }
> >> >> >
> >> >> >       /**
> >> >> >        * @see
> >> >> >
> >> >>
> >> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date,
> >> >> >        *      java.util.Date)
> >> >> >        */
> >> >> >       protected Collection loadEntries(Date startDate, Date endDate)
> >> >> >       {
> >> >> >               ArrayList selection = new ArrayList();
> >> >> >
> >> >> >               for (Iterator entryIterator = entries.iterator();
> >> >> entryIterator
> >> >> >                               .hasNext();)
> >> >> >               {
> >> >> >                       ScheduleEntry entry = (ScheduleEntry)
> >> >> entryIterator.next();
> >> >> >
> >> >> >                       if (entry.getEndTime().before(startDate)
> >> >> >                       || entry.getStartTime().after(endDate))
> >> >> >                       {
> >> >> >                               continue;
> >> >> >                       }
> >> >> >
> >> >> >                       selection.add(entry);
> >> >> >               }
> >> >> >
> >> >> >               return selection;
> >> >> >       }
> >> >> >
> >> >> >       /**
> >> >> >        * @see
> >> >> >
> >> >>
> >> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadDayAttributes(org.apache.myfaces.custom.schedule.model.Day)
> >> >> >        */
> >> >> >       protected void loadDayAttributes(Day day)
> >> >> >       {
> >> >> >               if (day == null)
> >> >> >                       return;
> >> >> >               String key = holidayFormat.format(day.getDate());
> >> >> >               String holiday = (String) holidays.get(key);
> >> >> >               if (holiday != null)
> >> >> >               {
> >> >> >                       day.setSpecialDayName(holiday);
> >> >> >                       day.setWorkingDay(false);
> >> >> >               }
> >> >> >               else
> >> >> >               {
> >> >> >                       day.setSpecialDayName(null);
> >> >> >                       day.setWorkingDay(true);
> >> >> >               }
> >> >> >       }
> >> >> >
> >> >> >       /**
> >> >> >        * Remove entry from model
> >> >> >        * <br /><br />
> >> >> >        * @param id identifier of entry to be removed
> >> >> >        * <br /><br />
> >> >> >        * @return true on success and false on failure (in case entry
> >> >> with
> >> >> > specified id wasn't found)
> >> >> >        *
> >> >> >        */
> >> >> >       protected boolean removeEntry(String id)
> >> >> >       {
> >> >> >               ScheduleEntry entry = null;
> >> >> >               String currentId = null;
> >> >> >
> >> >> >               for(ScheduleEntry se :
> >> (TreeSet<ScheduleEntry>)entries)
> >> >> >               {
> >> >> >                       if((currentId = se.getId()) != null &&
> >> >> currentId.equals(id))
> >> >> >                       {
> >> >> >                               entry = se;
> >> >> >                               break;
> >> >> >                       }
> >> >> >               }
> >> >> >
> >> >> >               if(entry != null)
> >> >> >               {
> >> >> >                       entries.remove(entry);
> >> >> >                       entry = null;
> >> >> >
> >> >> >                       return true;
> >> >> >               }
> >> >> >
> >> >> >               return false;
> >> >> >       }
> >> >> > }
> >> >> >
> >> >> >
> >> >> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >> >>
> >> >> >> i have the class correct without errors. But when i call it  show a
> >> >> blank
> >> >> >> page!
> >> >> >>
> >> >> >> ExtendedScheduleModel x = new ExtendedScheduleModel();
> >> >> >> x.Remove2("8");
> >> >> >>
> >> >> >> I call the class like that. I think its correct! so why the blank
> >> >> page?
> >> >> >> if i
> >> >> >> put thouse two code lines in comments dont have the blank page, so
> >> the
> >> >> >> problem is the class! :-((
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> Michał 'Gandalf' Stawicki wrote:
> >> >> >> >
> >> >> >> > Try this, remember to set valid package:
> >> >> >> >
> >> >> >> >  #####SET ME package #####SET ME
> >> >> >> >
> >> >> >> > import java.util.TreeSet;
> >> >> >> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
> >> >> >> > import
> >> org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> >> >> >> >
> >> >> >> > /**
> >> >> >> >  * @author mstawick
> >> >> >> >  */
> >> >> >> > public class ExtendedScheduleModel extends SimpleScheduleModel
> >> >> >> > {
> >> >> >> >
> >> >> >> >       /** Creates a new instance of ExtendedScheduleModel */
> >> >> >> >       public ExtendedScheduleModel()
> >> >> >> >       {
> >> >> >> >               super();
> >> >> >> >       }
> >> >> >> >
> >> >> >> >       /**
> >> >> >> >        * Remove entry from model
> >> >> >> >        * <br /><br />
> >> >> >> >        * @param id identifier of entry to be removed
> >> >> >> >        * <br /><br />
> >> >> >> >        * @return true on success and false on failure (in case
> >> entry
> >> >> >> with
> >> >> >> > specified id wasn't found)
> >> >> >> >        *
> >> >> >> >        */
> >> >> >> >       public boolean removeEntry(String id)
> >> >> >> >       {
> >> >> >> >               ScheduleEntry entry = null;
> >> >> >> >               String currentId = null;
> >> >> >> >
> >> >> >> >               for(ScheduleEntry se : entries)
> >> >> >> >               {
> >> >> >> >                       if((currentId = se.getId()) != null &&
> >> >> >> currentId.equals(id))
> >> >> >> >                       {
> >> >> >> >                               entry = se;
> >> >> >> >                               break;
> >> >> >> >                       }
> >> >> >> >               }
> >> >> >> >
> >> >> >> >               if(entry != null)
> >> >> >> >               {
> >> >> >> >                       entries.remove(entry);
> >> >> >> >                       entry = null;
> >> >> >> >
> >> >> >> >                       return true;
> >> >> >> >               }
> >> >> >> >
> >> >> >> >               return false;
> >> >> >> >       }
> >> >> >> >
> >> >> >> >       private TreeSet<ScheduleEntry> entries;
> >> >> >> > }
> >> >> >> >
> >> >> >> >
> >> >> >> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >> >> >>
> >> >> >> >> Sorry to bee so boring and noob, but i realy need to do this, i
> >> >> need a
> >> >> >> >> funcionality to show and occult calendars, and i have a entry
> >> >> >> associate
> >> >> >> >> to a
> >> >> >> >> calendar, so when i need occult  the calendar i need to remove
> >> the
> >> >> >> >> entries
> >> >> >> >> of that calendar from the model. everything working, just need
> >> >> remove
> >> >> >> the
> >> >> >> >> entries.
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> ignicolist wrote:
> >> >> >> >> >
> >> >> >> >> > Well i am a litle noob to all these, so i cant put your ideas
> >> to
> >> >> >> work!
> >> >> >> >> > :-((
> >> >> >> >> >
> >> >> >> >> > So i am using SimpleScheduleModel, so you say to create that
> >> >> class
> >> >> >> in
> >> >> >> >> the
> >> >> >> >> > component Schedule or in my aplication?
> >> >> >> >> > Because i create the class in my aplication and don´t work.
> >> Dam
> >> >> this
> >> >> >> is
> >> >> >> >> so
> >> >> >> >> > complicated...
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> > Michał 'Gandalf' Stawicki wrote:
> >> >> >> >> >>
> >> >> >> >> >> I wrote the code in 'on the fly' just to give you idea how
> >> >> should
> >> >> >> it
> >> >> >> >> >> look, I didn't try it
> >> >> >> >> >>
> >> >> >> >> >> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
> >> >> wrote:
> >> >> >> >> >>> Simply casting it should be fine:
> >> >> >> >> >>>
> >> >> >> >> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
> >> >> >> >> >>>
> >> >> >> >> >>>
> >> >> >> >> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >> >> >> >>> >
> >> >> >> >> >>> > I try what you say but give me a error in:
> >> for(ScheduleEntry
> >> >> e :
> >> >> >> >> >>> entries)
> >> >> >> >> >>> > The Error: Type mismatch: cannot convert from element type
> >> >> >> Object
> >> >> >> >> to
> >> >> >> >> >>> > ScheduleEntry
> >> >> >> >> >>> >
> >> >> >> >> >>> > Any idea?
> >> >> >> >> >>> >
> >> >> >> >> >>> >
> >> >> >> >> >>> >
> >> >> >> >> >>> > Michał 'Gandalf' Stawicki wrote:
> >> >> >> >> >>> > >
> >> >> >> >> >>> > > From SimpleScheduleModel.java
> >> >> >> >> >>> > >
> >> >> >> >> >>> > >     /**
> >> >> >> >> >>> > >      * Remove an entry from the model.
> >> >> >> >> >>> > >      *
> >> >> >> >> >>> > >      * @param entry
> >> >> >> >> >>> > >      *            the entry to remove
> >> >> >> >> >>> > >      */
> >> >> >> >> >>> > >     public void removeEntry(ScheduleEntry entry)
> >> >> >> >> >>> > >     {
> >> >> >> >> >>> > >         entries.remove(entry);
> >> >> >> >> >>> > >     }
> >> >> >> >> >>> > >
> >> >> >> >> >>> > > ...
> >> >> >> >> >>> > >
> >> >> >> >> >>> > >     private final TreeSet entries;
> >> >> >> >> >>> > >
> >> >> >> >> >>> > > I don't know which model your using, but if it is
> >> >> >> >> >>> SimpleScheduleModel
> >> >> >> >> >>> > > than you should extend it and implement your own method,
> >> >> ex;
> >> >> >> >> >>> > >
> >> >> >> >> >>> > > public boolean removeEntry(String id)
> >> >> >> >> >>> > > {
> >> >> >> >> >>> > > ScheduleEntry entry = null;
> >> >> >> >> >>> > >
> >> >> >> >> >>> > > if(entries != null && id != null)
> >> >> >> >> >>> > > for(ScheduleEntry e : entries)
> >> >> >> >> >>> > > {
> >> >> >> >> >>> > > if(e.getId() != null && e.getId().equals(id))
> >> >> >> >> >>> > > {
> >> >> >> >> >>> > > entry = e;
> >> >> >> >> >>> > > break;
> >> >> >> >> >>> > > }
> >> >> >> >> >>> > > }
> >> >> >> >> >>> > >
> >> >> >> >> >>> > > if(entry != null)
> >> >> >> >> >>> > > {
> >> >> >> >> >>> > > entries.remove(entry);
> >> >> >> >> >>> > > return true;
> >> >> >> >> >>> > > }
> >> >> >> >> >>> > >
> >> >> >> >> >>> > > return false;
> >> >> >> >> >>> > > }
> >> >> >> >> >>> > >
> >> >> >> >> >>> > >
> >> >> >> >> >>> > >
> >> >> >> >> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki
> >> <st...@gmail.com>
> >> >> >> >> wrote:
> >> >> >> >> >>> > >> I believe you have to pass exact reference to object
> >> that
> >> >> was
> >> >> >> >> added
> >> >> >> >> >>> to
> >> >> >> >> >>> > >> schedule, not some other object containing same data,
> >> >> >> example:
> >> >> >> >> >>> > >>
> >> >> >> >> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
> >> >> >> >> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
> >> >> >> >> >>> > >>
> >> >> >> >> >>> > >> model.addEntry(foo);
> >> >> >> >> >>> > >>
> >> >> >> >> >>> > >> model.removeEntry(foo2); // wrong
> >> >> >> >> >>> > >> mode.removeEntry(foo); //ok
> >> >> >> >> >>> > >>
> >> >> >> >> >>> > >>
> >> >> >> >> >>> > >>
> >> >> >> >> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >> >> >> >>> > >> >
> >> >> >> >> >>> > >> > Yes, because the entry when i select it remove with
> >> >> >> >> >>> > >> > model.removeSelectedEntry(); but if i specify his id:
> >> >> >> >> >>> > >> entry.setId("1");
> >> >> >> >> >>> > >> > model.removeEntry(entry); dont eliminate. And ids are
> >> >> the
> >> >> >> same
> >> >> >> >> in
> >> >> >> >> >>> the
> >> >> >> >> >>> > >> two
> >> >> >> >> >>> > >> > situacions.
> >> >> >> >> >>> > >> >
> >> >> >> >> >>> > >> >
> >> >> >> >> >>> > >> >
> >> >> >> >> >>> > >> >
> >> >> >> >> >>> > >> > Jurgen Lust-2 wrote:
> >> >> >> >> >>> > >> > >
> >> >> >> >> >>> > >> > > In your model implementation, do you load the
> >> >> persistent
> >> >> >> >> entry
> >> >> >> >> >>> from
> >> >> >> >> >>> > >> the
> >> >> >> >> >>> > >> > > database, using the supplied id, before you delete
> >> it?
> >> >> >> >> >>> > >> > >
> >> >> >> >> >>> > >> > > Jurgen
> >> >> >> >> >>> > >> > >
> >> >> >> >> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone
> >> -0700],
> >> >> >> >> schreef
> >> >> >> >> >>> > >> > > ignicolist:
> >> >> >> >> >>> > >> > >> Its what i am doing but don´t work!
> >> >> >> >> >>> > >> > >>
> >> >> >> >> >>> > >> > >> an example:
> >> >> >> >> >>> > >> > >>
> >> >> >> >> >>> > >> > >> DefaultScheduleEntry entry = new
> >> >> DefaultScheduleEntry();
> >> >> >> >> >>> > >> > >>
> >> >> >> >> >>> > >> > >>   entry.setId("1");
> >> >> >> >> >>> > >> > >>  model.removeEntry(entry);
> >> >> >> >> >>> > >> > >>
> >> >> >> >> >>> > >> > >> this code is supose to remove the entry from de
> >> model
> >> >> >> with
> >> >> >> >> id
> >> >> >> >> >>> 1 no?
> >> >> >> >> >>> > >> i
> >> >> >> >> >>> > >> > >> just
> >> >> >> >> >>> > >> > >> want remove de entry from the model, but a entry
> >> >> specify
> >> >> >> by
> >> >> >> >> >>> me.
> >> >> >> >> >>> > >> > >>
> >> >> >> >> >>> > >> > >>
> >> >> >> >> >>> > >> > >>
> >> >> >> >> >>> > >> > >>
> >> >> >> >> >>> > >> > >>
> >> >> >> >> >>> > >> > >> Jurgen Lust-2 wrote:
> >> >> >> >> >>> > >> > >> >
> >> >> >> >> >>> > >> > >> > The ScheduleModel.removeEntry() method expects a
> >> >> >> >> >>> ScheduleEntry as
> >> >> >> >> >>> > >> > >> > parameter. I suppose you use Hibernate for
> >> database
> >> >> >> >> access,
> >> >> >> >> >>> so
> >> >> >> >> >>> > >> what you
> >> >> >> >> >>> > >> > >> > should do is retrieve the ScheduleEntry from the
> >> >> >> >> database,
> >> >> >> >> >>> using
> >> >> >> >> >>> > >> the
> >> >> >> >> >>> > >> > >> id,
> >> >> >> >> >>> > >> > >> > and feed the result to the removeEntry method.
> >> In
> >> >> that
> >> >> >> >> >>> removeEntry
> >> >> >> >> >>> > >> > >> > method, you just delete it with your Hibernate
> >> DAO.
> >> >> >> >> >>> > >> > >> > You could of course add a method
> >> >> >> >> >>> removeEntry(String/Long/Whatever
> >> >> >> >> >>> > >> id)
> >> >> >> >> >>> > >> > >> > that does all of this.
> >> >> >> >> >>> > >> > >> >
> >> >> >> >> >>> > >> > >> > Jurgen
> >> >> >> >> >>> > >> > >> >
> >> >> >> >> >>> > >> > >> >
> >> >> >> >> >>> > >> > >> >
> >> >> >> >> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone
> >> >> -0700],
> >> >> >> >> >>> schreef
> >> >> >> >> >>> > >> > >> > ignicolist:
> >> >> >> >> >>> > >> > >> >> Hi to all, i want to eliminate a especific
> >> entry
> >> >> in a
> >> >> >> >> model
> >> >> >> >> >>> of
> >> >> >> >> >>> > >> > >> schedule
> >> >> >> >> >>> > >> > >> >> tomahawk. the example in remove a selected
> >> entry
> >> >> work
> >> >> >> >> fine,
> >> >> >> >> >>> but
> >> >> >> >> >>> > >> how to
> >> >> >> >> >>> > >> > >> >> eliminate a determinated entry?
> >> >> >> >> >>> > >> > >> >>
> >> >> >> >> >>> > >> > >> >>
> >> >> >> >> >>> > >> > >> >> i try with this code:
> >> >> >> >> >>> > >> > >> >>
> >> >> >> >> >>> > >> > >> >>
> >> >> >> >> >>> > >> > >> >> DefaultScheduleEntry entry = new
> >> >> >> DefaultScheduleEntry();
> >> >> >> >> >>> > >> > >> >>
> >> >> >> >> >>> > >> > >> >>  entry.setId(select);
> >> >> >> >> >>> > >> > >> >>  entry.setStartTime(start);
> >> >> >> >> >>> > >> > >> >>  entry.setEndTime(end);
> >> >> >> >> >>> > >> > >> >>  entry.setTitle(select7);
> >> >> >> >> >>> > >> > >> >>  entry.setDescription(select2);
> >> >> >> >> >>> > >> > >> >>
> >> >> >> >> >>> > >> > >> >>  model.removeEntry(entry);
> >> >> >> >> >>> > >> > >> >>  model.refresh();
> >> >> >> >> >>> > >> > >> >>
> >> >> >> >> >>> > >> > >> >> i defined every value for the entry, and then i
> >> >> want
> >> >> >> to
> >> >> >> >> >>> remove
> >> >> >> >> >>> > >> that
> >> >> >> >> >>> > >> > >> >> entry!
> >> >> >> >> >>> > >> > >> >> Any help please!
> >> >> >> >> >>> > >> > >> >>
> >> >> >> >> >>> > >> > >> >> Tks for all.
> >> >> >> >> >>> > >> > >> > --
> >> >> >> >> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
> >> >> >> >> >>> > >> > >> >
> >> >> >> >> >>> > >> > >> >
> >> >> >> >> >>> > >> > >> >
> >> >> >> >> >>> > >> > >>
> >> >> >> >> >>> > >> > > --
> >> >> >> >> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
> >> >> >> >> >>> > >> > >
> >> >> >> >> >>> > >> > >
> >> >> >> >> >>> > >> > >
> >> >> >> >> >>> > >> >
> >> >> >> >> >>> > >> > --
> >> >> >> >> >>> > >> > View this message in context:
> >> >> >> >> >>> > >>
> >> >> >> >> >>>
> >> >> >> >>
> >> >> >>
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
> >> >> >> >> >>> > >> > Sent from the MyFaces - Users mailing list archive at
> >> >> >> >> Nabble.com.
> >> >> >> >> >>> > >> >
> >> >> >> >> >>> > >> >
> >> >> >> >> >>> > >>
> >> >> >> >> >>> > >>
> >> >> >> >> >>> > >> --
> >> >> >> >> >>> > >> Michał Stawicki
> >> >> >> >> >>> > >>
> >> >> >> >> >>> > >> stawicki@gmail.com
> >> >> >> >> >>> > >> http://stawicki.jasliska.pl
> >> >> >> >> >>> > >>
> >> >> >> >> >>> > >
> >> >> >> >> >>> > >
> >> >> >> >> >>> > > --
> >> >> >> >> >>> > > Michał Stawicki
> >> >> >> >> >>> > >
> >> >> >> >> >>> > > stawicki@gmail.com
> >> >> >> >> >>> > > http://stawicki.jasliska.pl
> >> >> >> >> >>> > >
> >> >> >> >> >>> > >
> >> >> >> >> >>> >
> >> >> >> >> >>> > --
> >> >> >> >> >>> > View this message in context:
> >> >> >> >> >>>
> >> >> >> >>
> >> >> >>
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
> >> >> >> >> >>> > Sent from the MyFaces - Users mailing list archive at
> >> >> >> Nabble.com.
> >> >> >> >> >>> >
> >> >> >> >> >>> >
> >> >> >> >> >>>
> >> >> >> >> >>>
> >> >> >> >> >>> --
> >> >> >> >> >>> Michał Stawicki
> >> >> >> >> >>>
> >> >> >> >> >>> stawicki@gmail.com
> >> >> >> >> >>> http://stawicki.jasliska.pl
> >> >> >> >> >>>
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >> --
> >> >> >> >> >> Michał Stawicki
> >> >> >> >> >>
> >> >> >> >> >> stawicki@gmail.com
> >> >> >> >> >> http://stawicki.jasliska.pl
> >> >> >> >> >>
> >> >> >> >> >>
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >>
> >> >> >> >> --
> >> >> >> >> View this message in context:
> >> >> >> >>
> >> >> >>
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
> >> >> >> >> Sent from the MyFaces - Users mailing list archive at
> >> Nabble.com.
> >> >> >> >>
> >> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> >> > --
> >> >> >> > Michał Stawicki
> >> >> >> >
> >> >> >> > stawicki@gmail.com
> >> >> >> > http://stawicki.jasliska.pl
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >> >> --
> >> >> >> View this message in context:
> >> >> >>
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12206017
> >> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Michał Stawicki
> >> >> >
> >> >> > stawicki@gmail.com
> >> >> > http://stawicki.jasliska.pl
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12209467
> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Michał Stawicki
> >> >
> >> > stawicki@gmail.com
> >> > http://stawicki.jasliska.pl
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12212569
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Michał Stawicki
> >
> > stawicki@gmail.com
> > http://stawicki.jasliska.pl
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12213620
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
Michał Stawicki

stawicki@gmail.com
http://stawicki.jasliska.pl

Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
No use !! How you test the example? I eliminate now the simpleScheduleModel
to dont interfer.

look i insert entries like that :

private ScheduleModel model;

DefaultScheduleEntry entry = new DefaultScheduleEntry();

entry.setId(cod_cal);
	        entry.setStartTime(startTime);
	        entry.setEndTime(endTime);
	        entry.setTitle(title);
	        entry.setDescription(description);

model.addEntry(entry);     
	   model.refresh();

If i try insert like that:


 private  ExtendedScheduleModel sss ;
DefaultScheduleEntry entry = new DefaultScheduleEntry();

 entry.setId(cod_cal);
	        entry.setStartTime(startTime);
	        entry.setEndTime(endTime);
	        entry.setTitle(title);
	        entry.setDescription(description);
	        
	   sss.addEntry(entry);

Dont work, blank page.


try to delete:

 DefaultScheduleEntry entry = new DefaultScheduleEntry();
ExtendedScheduleModel foo = new ExtendedScheduleModel();

 entry.setId("10");
foo.removeEntry(entry);

the entries have size 0 in the methot remove.

try to remove like that:

private ScheduleModel model;
ExtendedScheduleModel foo = new ExtendedScheduleModel();

 entry.setId("10");
 model.removeEntry(entry);

blank page!!  i dont know what could be rong here!! 





Michał 'Gandalf' Stawicki wrote:
> 
> http://www.mail-archive.com/users@myfaces.apache.org/msg41756.html
> 
> You copied whole class from this post and it still doesn't work? Worked
> for me.
> 
> On 18/08/07, ignicolist <ig...@gmail.com> wrote:
>>
>> Your last mail have the same thing! :confused:
>> Dont have nathing changed!!
>>
>>
>>
>> Michał 'Gandalf' Stawicki wrote:
>> >
>> > Yes, it was wrong. I have posted correct one, working. see my previous
>> > mail.
>> >
>> > On 18/08/07, ignicolist <ig...@gmail.com> wrote:
>> >>
>> >> Hi again, Tks for your great example, i do every thing, and i found a
>> >> problem, in the function remove:
>> >>
>> >>  protected boolean removeEntry(String id)
>> >>         {
>> >>
>> >>                 ScheduleEntry entry = null;
>> >>                 String currentId = null;
>> >>
>> >>
>> >> System.out.println("++++++++++++++++"+entries.size());//*1
>> >>
>> >>                 for(ScheduleEntry se :
>> (TreeSet<ScheduleEntry>)entries)
>> >>                 {
>> >>
>> >>                         if((currentId = se.getId()) != null &&
>> >> currentId.equals(id))
>> >>                         {
>> >>
>> >>                                 entry = se;
>> >>                                 break;
>> >>                         }
>> >>                 }
>> >>
>> >>                 if(entry != null)
>> >>                 {
>> >>
>> >>                         entries.remove(entry);
>> >>                         entry = null;
>> >>
>> >>                         return true;
>> >>                 }
>> >>
>> >>                 return false;
>> >>         }
>> >>
>> >> the id that i select its correct in the funcion, the problem is the
>> >> entries
>> >> dont have values! i println the entries.size() and its 0.
>> >>
>> >>
>> >> i add the entries like that:
>> >>
>> >>
>> >> private ScheduleModel model;
>> >>
>> >> entry.setId(cod_cal);
>> >>                 entry.setStartTime(startTime);
>> >>                 entry.setEndTime(endTime);
>> >>                 entry.setTitle(title);
>> >>                 entry.setDescription(description);
>> >>
>> >>            model.addEntry(entry);
>> >>              model.refresh();
>> >>
>> >> i try delete like that:
>> >>
>> >> ExtendedScheduleModel foo = new ExtendedScheduleModel();
>> >>  DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> >> entry.setId("10");
>> >>
>> >> foo.removeEntry(entry);
>> >>
>> >> if i add the entries like that:
>> >>
>> >>
>> >>  private  ExtendedScheduleModel sss ;
>> >>
>> >>                entry.setId(cod_cal);
>> >>                 entry.setStartTime(startTime);
>> >>                 entry.setEndTime(endTime);
>> >>                 entry.setTitle(title);
>> >>                 entry.setDescription(description);
>> >>
>> >>              sss.addEntry(entry);
>> >>              sss.refresh();
>> >>
>> >> blank page...
>> >>
>> >>
>> >> Any sujection? Tks for all you are doing!
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Michał 'Gandalf' Stawicki wrote:
>> >> >
>> >> > Right, it was fubar'ed, SimpleScheduleModel wasn't meant for
>> extending
>> >> > :) This works - you use like you tried at the beginning - create
>> >> > entry, set id and you can remove it. BTW: I think your bean should
>> be
>> >> > session, not request, unless you intended so.
>> >> >
>> >> > /*
>> >> >  * Licensed to the Apache Software Foundation (ASF) under one
>> >> >  * or more contributor license agreements.  See the NOTICE file
>> >> >  * distributed with this work for additional information
>> >> >  * regarding copyright ownership.  The ASF licenses this file
>> >> >  * to you 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 ###########
>> >> >
>> >> > import java.io.Serializable;
>> >> >
>> >> > import java.text.DateFormat;
>> >> > import java.text.SimpleDateFormat;
>> >> > import java.util.ArrayList;
>> >> > import java.util.Collection;
>> >> > import java.util.Date;
>> >> > import java.util.HashMap;
>> >> > import java.util.Iterator;
>> >> > import java.util.TreeSet;
>> >> > import
>> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel;
>> >> > import org.apache.myfaces.custom.schedule.model.Day;
>> >> > import
>> org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
>> >> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
>> >> >
>> >> > import
>> org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
>> >> >
>> >> > /**
>> >> >  * <p>
>> >> >  * A simple implementation of the ScheduleModel, not backed by any
>> kind
>> >> of
>> >> >  * datasource: entries have to be added manually.
>> >> >  * </p>
>> >> >  *
>> >> >  * @author Jurgen Lust (latest modification by $Author: werpu $)
>> >> >  * @version $Revision: 371736 $
>> >> >  */
>> >> > public class ExtendedScheduleModel extends AbstractScheduleModel
>> >> > implements Serializable
>> >> > {
>> >> >
>> >> >
>> >> > // TEST
>> >> > //    public static void main(String [] args)
>> >> > //    {
>> >> > //            ExtendedScheduleModel foo = new
>> ExtendedScheduleModel();
>> >> > //            DefaultScheduleEntry bar = new DefaultScheduleEntry();
>> >> > //            bar.setId("1");
>> >> > //            foo.addEntry(bar);
>> >> > //            DefaultScheduleEntry bar2 = new
>> DefaultScheduleEntry();
>> >> > //            bar2.setId("1");
>> >> > //
>> >> > //            foo.removeEntry(bar2);
>> >> > //    }
>> >> >
>> >> >
>> >> >       private static final long serialVersionUID = 1L;
>> >> >       protected final TreeSet entries;
>> >> >       protected final HashMap holidays;
>> >> >       protected final DateFormat holidayFormat = new
>> >> > SimpleDateFormat("yyyyMMdd");
>> >> >
>> >> >       public ExtendedScheduleModel()
>> >> >       {
>> >> >               this.entries = new TreeSet(new
>> >> ScheduleEntryComparator());
>> >> >               this.holidays = new HashMap();
>> >> >       }
>> >> >
>> >> >       /**
>> >> >        * Set the name of a holiday.
>> >> >        *
>> >> >        * @param date
>> >> >        *            the date
>> >> >        * @param holidayName
>> >> >        *            the name of the holiday
>> >> >        */
>> >> >       public void setHoliday(Date date, String holidayName)
>> >> >       {
>> >> >               if (date == null)
>> >> >               {
>> >> >                       return;
>> >> >               }
>> >> >
>> >> >               String key = holidayFormat.format(date);
>> >> >               holidays.put(key, holidayName);
>> >> >       }
>> >> >
>> >> >       /**
>> >> >        * Add an entry to the model.
>> >> >        *
>> >> >        * @param entry
>> >> >        *            the entry to add
>> >> >        */
>> >> >       public void addEntry(ScheduleEntry entry)
>> >> >       {
>> >> >               entries.add(entry);
>> >> >       }
>> >> >
>> >> >       /**
>> >> >        * Remove an entry from the model.
>> >> >        *
>> >> >        * @param entry
>> >> >        *            the entry to remove
>> >> >        */
>> >> >       public void removeEntry(ScheduleEntry entry)
>> >> >       {
>> >> >               if(entries.remove(entry))
>> >> >                       return;
>> >> >
>> >> >               if(entry != null && entry.getId() != null)
>> >> >                       removeEntry(entry.getId());
>> >> >       }
>> >> >
>> >> >       /**
>> >> >        * @see
>> >> >
>> >>
>> org.apache.myfaces.custom.schedule.model.ScheduleModel#removeSelectedEntry()
>> >> >        */
>> >> >       public void removeSelectedEntry()
>> >> >       {
>> >> >               if (!isEntrySelected())
>> >> >                       return;
>> >> >               removeEntry(getSelectedEntry());
>> >> >               setSelectedEntry(null);
>> >> >               refresh();
>> >> >       }
>> >> >
>> >> >       /**
>> >> >        * @see
>> >> >
>> >>
>> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date,
>> >> >        *      java.util.Date)
>> >> >        */
>> >> >       protected Collection loadEntries(Date startDate, Date endDate)
>> >> >       {
>> >> >               ArrayList selection = new ArrayList();
>> >> >
>> >> >               for (Iterator entryIterator = entries.iterator();
>> >> entryIterator
>> >> >                               .hasNext();)
>> >> >               {
>> >> >                       ScheduleEntry entry = (ScheduleEntry)
>> >> entryIterator.next();
>> >> >
>> >> >                       if (entry.getEndTime().before(startDate)
>> >> >                       || entry.getStartTime().after(endDate))
>> >> >                       {
>> >> >                               continue;
>> >> >                       }
>> >> >
>> >> >                       selection.add(entry);
>> >> >               }
>> >> >
>> >> >               return selection;
>> >> >       }
>> >> >
>> >> >       /**
>> >> >        * @see
>> >> >
>> >>
>> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadDayAttributes(org.apache.myfaces.custom.schedule.model.Day)
>> >> >        */
>> >> >       protected void loadDayAttributes(Day day)
>> >> >       {
>> >> >               if (day == null)
>> >> >                       return;
>> >> >               String key = holidayFormat.format(day.getDate());
>> >> >               String holiday = (String) holidays.get(key);
>> >> >               if (holiday != null)
>> >> >               {
>> >> >                       day.setSpecialDayName(holiday);
>> >> >                       day.setWorkingDay(false);
>> >> >               }
>> >> >               else
>> >> >               {
>> >> >                       day.setSpecialDayName(null);
>> >> >                       day.setWorkingDay(true);
>> >> >               }
>> >> >       }
>> >> >
>> >> >       /**
>> >> >        * Remove entry from model
>> >> >        * <br /><br />
>> >> >        * @param id identifier of entry to be removed
>> >> >        * <br /><br />
>> >> >        * @return true on success and false on failure (in case entry
>> >> with
>> >> > specified id wasn't found)
>> >> >        *
>> >> >        */
>> >> >       protected boolean removeEntry(String id)
>> >> >       {
>> >> >               ScheduleEntry entry = null;
>> >> >               String currentId = null;
>> >> >
>> >> >               for(ScheduleEntry se :
>> (TreeSet<ScheduleEntry>)entries)
>> >> >               {
>> >> >                       if((currentId = se.getId()) != null &&
>> >> currentId.equals(id))
>> >> >                       {
>> >> >                               entry = se;
>> >> >                               break;
>> >> >                       }
>> >> >               }
>> >> >
>> >> >               if(entry != null)
>> >> >               {
>> >> >                       entries.remove(entry);
>> >> >                       entry = null;
>> >> >
>> >> >                       return true;
>> >> >               }
>> >> >
>> >> >               return false;
>> >> >       }
>> >> > }
>> >> >
>> >> >
>> >> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >>
>> >> >> i have the class correct without errors. But when i call it  show a
>> >> blank
>> >> >> page!
>> >> >>
>> >> >> ExtendedScheduleModel x = new ExtendedScheduleModel();
>> >> >> x.Remove2("8");
>> >> >>
>> >> >> I call the class like that. I think its correct! so why the blank
>> >> page?
>> >> >> if i
>> >> >> put thouse two code lines in comments dont have the blank page, so
>> the
>> >> >> problem is the class! :-((
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> Michał 'Gandalf' Stawicki wrote:
>> >> >> >
>> >> >> > Try this, remember to set valid package:
>> >> >> >
>> >> >> >  #####SET ME package #####SET ME
>> >> >> >
>> >> >> > import java.util.TreeSet;
>> >> >> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
>> >> >> > import
>> org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
>> >> >> >
>> >> >> > /**
>> >> >> >  * @author mstawick
>> >> >> >  */
>> >> >> > public class ExtendedScheduleModel extends SimpleScheduleModel
>> >> >> > {
>> >> >> >
>> >> >> >       /** Creates a new instance of ExtendedScheduleModel */
>> >> >> >       public ExtendedScheduleModel()
>> >> >> >       {
>> >> >> >               super();
>> >> >> >       }
>> >> >> >
>> >> >> >       /**
>> >> >> >        * Remove entry from model
>> >> >> >        * <br /><br />
>> >> >> >        * @param id identifier of entry to be removed
>> >> >> >        * <br /><br />
>> >> >> >        * @return true on success and false on failure (in case
>> entry
>> >> >> with
>> >> >> > specified id wasn't found)
>> >> >> >        *
>> >> >> >        */
>> >> >> >       public boolean removeEntry(String id)
>> >> >> >       {
>> >> >> >               ScheduleEntry entry = null;
>> >> >> >               String currentId = null;
>> >> >> >
>> >> >> >               for(ScheduleEntry se : entries)
>> >> >> >               {
>> >> >> >                       if((currentId = se.getId()) != null &&
>> >> >> currentId.equals(id))
>> >> >> >                       {
>> >> >> >                               entry = se;
>> >> >> >                               break;
>> >> >> >                       }
>> >> >> >               }
>> >> >> >
>> >> >> >               if(entry != null)
>> >> >> >               {
>> >> >> >                       entries.remove(entry);
>> >> >> >                       entry = null;
>> >> >> >
>> >> >> >                       return true;
>> >> >> >               }
>> >> >> >
>> >> >> >               return false;
>> >> >> >       }
>> >> >> >
>> >> >> >       private TreeSet<ScheduleEntry> entries;
>> >> >> > }
>> >> >> >
>> >> >> >
>> >> >> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >> >>
>> >> >> >> Sorry to bee so boring and noob, but i realy need to do this, i
>> >> need a
>> >> >> >> funcionality to show and occult calendars, and i have a entry
>> >> >> associate
>> >> >> >> to a
>> >> >> >> calendar, so when i need occult  the calendar i need to remove
>> the
>> >> >> >> entries
>> >> >> >> of that calendar from the model. everything working, just need
>> >> remove
>> >> >> the
>> >> >> >> entries.
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> ignicolist wrote:
>> >> >> >> >
>> >> >> >> > Well i am a litle noob to all these, so i cant put your ideas
>> to
>> >> >> work!
>> >> >> >> > :-((
>> >> >> >> >
>> >> >> >> > So i am using SimpleScheduleModel, so you say to create that
>> >> class
>> >> >> in
>> >> >> >> the
>> >> >> >> > component Schedule or in my aplication?
>> >> >> >> > Because i create the class in my aplication and don´t work.
>> Dam
>> >> this
>> >> >> is
>> >> >> >> so
>> >> >> >> > complicated...
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > Michał 'Gandalf' Stawicki wrote:
>> >> >> >> >>
>> >> >> >> >> I wrote the code in 'on the fly' just to give you idea how
>> >> should
>> >> >> it
>> >> >> >> >> look, I didn't try it
>> >> >> >> >>
>> >> >> >> >> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
>> >> wrote:
>> >> >> >> >>> Simply casting it should be fine:
>> >> >> >> >>>
>> >> >> >> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
>> >> >> >> >>>
>> >> >> >> >>>
>> >> >> >> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >> >> >>> >
>> >> >> >> >>> > I try what you say but give me a error in:
>> for(ScheduleEntry
>> >> e :
>> >> >> >> >>> entries)
>> >> >> >> >>> > The Error: Type mismatch: cannot convert from element type
>> >> >> Object
>> >> >> >> to
>> >> >> >> >>> > ScheduleEntry
>> >> >> >> >>> >
>> >> >> >> >>> > Any idea?
>> >> >> >> >>> >
>> >> >> >> >>> >
>> >> >> >> >>> >
>> >> >> >> >>> > Michał 'Gandalf' Stawicki wrote:
>> >> >> >> >>> > >
>> >> >> >> >>> > > From SimpleScheduleModel.java
>> >> >> >> >>> > >
>> >> >> >> >>> > >     /**
>> >> >> >> >>> > >      * Remove an entry from the model.
>> >> >> >> >>> > >      *
>> >> >> >> >>> > >      * @param entry
>> >> >> >> >>> > >      *            the entry to remove
>> >> >> >> >>> > >      */
>> >> >> >> >>> > >     public void removeEntry(ScheduleEntry entry)
>> >> >> >> >>> > >     {
>> >> >> >> >>> > >         entries.remove(entry);
>> >> >> >> >>> > >     }
>> >> >> >> >>> > >
>> >> >> >> >>> > > ...
>> >> >> >> >>> > >
>> >> >> >> >>> > >     private final TreeSet entries;
>> >> >> >> >>> > >
>> >> >> >> >>> > > I don't know which model your using, but if it is
>> >> >> >> >>> SimpleScheduleModel
>> >> >> >> >>> > > than you should extend it and implement your own method,
>> >> ex;
>> >> >> >> >>> > >
>> >> >> >> >>> > > public boolean removeEntry(String id)
>> >> >> >> >>> > > {
>> >> >> >> >>> > > ScheduleEntry entry = null;
>> >> >> >> >>> > >
>> >> >> >> >>> > > if(entries != null && id != null)
>> >> >> >> >>> > > for(ScheduleEntry e : entries)
>> >> >> >> >>> > > {
>> >> >> >> >>> > > if(e.getId() != null && e.getId().equals(id))
>> >> >> >> >>> > > {
>> >> >> >> >>> > > entry = e;
>> >> >> >> >>> > > break;
>> >> >> >> >>> > > }
>> >> >> >> >>> > > }
>> >> >> >> >>> > >
>> >> >> >> >>> > > if(entry != null)
>> >> >> >> >>> > > {
>> >> >> >> >>> > > entries.remove(entry);
>> >> >> >> >>> > > return true;
>> >> >> >> >>> > > }
>> >> >> >> >>> > >
>> >> >> >> >>> > > return false;
>> >> >> >> >>> > > }
>> >> >> >> >>> > >
>> >> >> >> >>> > >
>> >> >> >> >>> > >
>> >> >> >> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki
>> <st...@gmail.com>
>> >> >> >> wrote:
>> >> >> >> >>> > >> I believe you have to pass exact reference to object
>> that
>> >> was
>> >> >> >> added
>> >> >> >> >>> to
>> >> >> >> >>> > >> schedule, not some other object containing same data,
>> >> >> example:
>> >> >> >> >>> > >>
>> >> >> >> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
>> >> >> >> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
>> >> >> >> >>> > >>
>> >> >> >> >>> > >> model.addEntry(foo);
>> >> >> >> >>> > >>
>> >> >> >> >>> > >> model.removeEntry(foo2); // wrong
>> >> >> >> >>> > >> mode.removeEntry(foo); //ok
>> >> >> >> >>> > >>
>> >> >> >> >>> > >>
>> >> >> >> >>> > >>
>> >> >> >> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >> >> >>> > >> >
>> >> >> >> >>> > >> > Yes, because the entry when i select it remove with
>> >> >> >> >>> > >> > model.removeSelectedEntry(); but if i specify his id:
>> >> >> >> >>> > >> entry.setId("1");
>> >> >> >> >>> > >> > model.removeEntry(entry); dont eliminate. And ids are
>> >> the
>> >> >> same
>> >> >> >> in
>> >> >> >> >>> the
>> >> >> >> >>> > >> two
>> >> >> >> >>> > >> > situacions.
>> >> >> >> >>> > >> >
>> >> >> >> >>> > >> >
>> >> >> >> >>> > >> >
>> >> >> >> >>> > >> >
>> >> >> >> >>> > >> > Jurgen Lust-2 wrote:
>> >> >> >> >>> > >> > >
>> >> >> >> >>> > >> > > In your model implementation, do you load the
>> >> persistent
>> >> >> >> entry
>> >> >> >> >>> from
>> >> >> >> >>> > >> the
>> >> >> >> >>> > >> > > database, using the supplied id, before you delete
>> it?
>> >> >> >> >>> > >> > >
>> >> >> >> >>> > >> > > Jurgen
>> >> >> >> >>> > >> > >
>> >> >> >> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone
>> -0700],
>> >> >> >> schreef
>> >> >> >> >>> > >> > > ignicolist:
>> >> >> >> >>> > >> > >> Its what i am doing but don´t work!
>> >> >> >> >>> > >> > >>
>> >> >> >> >>> > >> > >> an example:
>> >> >> >> >>> > >> > >>
>> >> >> >> >>> > >> > >> DefaultScheduleEntry entry = new
>> >> DefaultScheduleEntry();
>> >> >> >> >>> > >> > >>
>> >> >> >> >>> > >> > >>   entry.setId("1");
>> >> >> >> >>> > >> > >>  model.removeEntry(entry);
>> >> >> >> >>> > >> > >>
>> >> >> >> >>> > >> > >> this code is supose to remove the entry from de
>> model
>> >> >> with
>> >> >> >> id
>> >> >> >> >>> 1 no?
>> >> >> >> >>> > >> i
>> >> >> >> >>> > >> > >> just
>> >> >> >> >>> > >> > >> want remove de entry from the model, but a entry
>> >> specify
>> >> >> by
>> >> >> >> >>> me.
>> >> >> >> >>> > >> > >>
>> >> >> >> >>> > >> > >>
>> >> >> >> >>> > >> > >>
>> >> >> >> >>> > >> > >>
>> >> >> >> >>> > >> > >>
>> >> >> >> >>> > >> > >> Jurgen Lust-2 wrote:
>> >> >> >> >>> > >> > >> >
>> >> >> >> >>> > >> > >> > The ScheduleModel.removeEntry() method expects a
>> >> >> >> >>> ScheduleEntry as
>> >> >> >> >>> > >> > >> > parameter. I suppose you use Hibernate for
>> database
>> >> >> >> access,
>> >> >> >> >>> so
>> >> >> >> >>> > >> what you
>> >> >> >> >>> > >> > >> > should do is retrieve the ScheduleEntry from the
>> >> >> >> database,
>> >> >> >> >>> using
>> >> >> >> >>> > >> the
>> >> >> >> >>> > >> > >> id,
>> >> >> >> >>> > >> > >> > and feed the result to the removeEntry method.
>> In
>> >> that
>> >> >> >> >>> removeEntry
>> >> >> >> >>> > >> > >> > method, you just delete it with your Hibernate
>> DAO.
>> >> >> >> >>> > >> > >> > You could of course add a method
>> >> >> >> >>> removeEntry(String/Long/Whatever
>> >> >> >> >>> > >> id)
>> >> >> >> >>> > >> > >> > that does all of this.
>> >> >> >> >>> > >> > >> >
>> >> >> >> >>> > >> > >> > Jurgen
>> >> >> >> >>> > >> > >> >
>> >> >> >> >>> > >> > >> >
>> >> >> >> >>> > >> > >> >
>> >> >> >> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone
>> >> -0700],
>> >> >> >> >>> schreef
>> >> >> >> >>> > >> > >> > ignicolist:
>> >> >> >> >>> > >> > >> >> Hi to all, i want to eliminate a especific
>> entry
>> >> in a
>> >> >> >> model
>> >> >> >> >>> of
>> >> >> >> >>> > >> > >> schedule
>> >> >> >> >>> > >> > >> >> tomahawk. the example in remove a selected
>> entry
>> >> work
>> >> >> >> fine,
>> >> >> >> >>> but
>> >> >> >> >>> > >> how to
>> >> >> >> >>> > >> > >> >> eliminate a determinated entry?
>> >> >> >> >>> > >> > >> >>
>> >> >> >> >>> > >> > >> >>
>> >> >> >> >>> > >> > >> >> i try with this code:
>> >> >> >> >>> > >> > >> >>
>> >> >> >> >>> > >> > >> >>
>> >> >> >> >>> > >> > >> >> DefaultScheduleEntry entry = new
>> >> >> DefaultScheduleEntry();
>> >> >> >> >>> > >> > >> >>
>> >> >> >> >>> > >> > >> >>  entry.setId(select);
>> >> >> >> >>> > >> > >> >>  entry.setStartTime(start);
>> >> >> >> >>> > >> > >> >>  entry.setEndTime(end);
>> >> >> >> >>> > >> > >> >>  entry.setTitle(select7);
>> >> >> >> >>> > >> > >> >>  entry.setDescription(select2);
>> >> >> >> >>> > >> > >> >>
>> >> >> >> >>> > >> > >> >>  model.removeEntry(entry);
>> >> >> >> >>> > >> > >> >>  model.refresh();
>> >> >> >> >>> > >> > >> >>
>> >> >> >> >>> > >> > >> >> i defined every value for the entry, and then i
>> >> want
>> >> >> to
>> >> >> >> >>> remove
>> >> >> >> >>> > >> that
>> >> >> >> >>> > >> > >> >> entry!
>> >> >> >> >>> > >> > >> >> Any help please!
>> >> >> >> >>> > >> > >> >>
>> >> >> >> >>> > >> > >> >> Tks for all.
>> >> >> >> >>> > >> > >> > --
>> >> >> >> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
>> >> >> >> >>> > >> > >> >
>> >> >> >> >>> > >> > >> >
>> >> >> >> >>> > >> > >> >
>> >> >> >> >>> > >> > >>
>> >> >> >> >>> > >> > > --
>> >> >> >> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
>> >> >> >> >>> > >> > >
>> >> >> >> >>> > >> > >
>> >> >> >> >>> > >> > >
>> >> >> >> >>> > >> >
>> >> >> >> >>> > >> > --
>> >> >> >> >>> > >> > View this message in context:
>> >> >> >> >>> > >>
>> >> >> >> >>>
>> >> >> >>
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
>> >> >> >> >>> > >> > Sent from the MyFaces - Users mailing list archive at
>> >> >> >> Nabble.com.
>> >> >> >> >>> > >> >
>> >> >> >> >>> > >> >
>> >> >> >> >>> > >>
>> >> >> >> >>> > >>
>> >> >> >> >>> > >> --
>> >> >> >> >>> > >> Michał Stawicki
>> >> >> >> >>> > >>
>> >> >> >> >>> > >> stawicki@gmail.com
>> >> >> >> >>> > >> http://stawicki.jasliska.pl
>> >> >> >> >>> > >>
>> >> >> >> >>> > >
>> >> >> >> >>> > >
>> >> >> >> >>> > > --
>> >> >> >> >>> > > Michał Stawicki
>> >> >> >> >>> > >
>> >> >> >> >>> > > stawicki@gmail.com
>> >> >> >> >>> > > http://stawicki.jasliska.pl
>> >> >> >> >>> > >
>> >> >> >> >>> > >
>> >> >> >> >>> >
>> >> >> >> >>> > --
>> >> >> >> >>> > View this message in context:
>> >> >> >> >>>
>> >> >> >>
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
>> >> >> >> >>> > Sent from the MyFaces - Users mailing list archive at
>> >> >> Nabble.com.
>> >> >> >> >>> >
>> >> >> >> >>> >
>> >> >> >> >>>
>> >> >> >> >>>
>> >> >> >> >>> --
>> >> >> >> >>> Michał Stawicki
>> >> >> >> >>>
>> >> >> >> >>> stawicki@gmail.com
>> >> >> >> >>> http://stawicki.jasliska.pl
>> >> >> >> >>>
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >> --
>> >> >> >> >> Michał Stawicki
>> >> >> >> >>
>> >> >> >> >> stawicki@gmail.com
>> >> >> >> >> http://stawicki.jasliska.pl
>> >> >> >> >>
>> >> >> >> >>
>> >> >> >> >
>> >> >> >> >
>> >> >> >>
>> >> >> >> --
>> >> >> >> View this message in context:
>> >> >> >>
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
>> >> >> >> Sent from the MyFaces - Users mailing list archive at
>> Nabble.com.
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> > Michał Stawicki
>> >> >> >
>> >> >> > stawicki@gmail.com
>> >> >> > http://stawicki.jasliska.pl
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12206017
>> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Michał Stawicki
>> >> >
>> >> > stawicki@gmail.com
>> >> > http://stawicki.jasliska.pl
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12209467
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Michał Stawicki
>> >
>> > stawicki@gmail.com
>> > http://stawicki.jasliska.pl
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12212569
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Michał Stawicki
> 
> stawicki@gmail.com
> http://stawicki.jasliska.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12213620
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by Michał 'Gandalf' Stawicki <st...@gmail.com>.
http://www.mail-archive.com/users@myfaces.apache.org/msg41756.html

You copied whole class from this post and it still doesn't work? Worked for me.

On 18/08/07, ignicolist <ig...@gmail.com> wrote:
>
> Your last mail have the same thing! :confused:
> Dont have nathing changed!!
>
>
>
> Michał 'Gandalf' Stawicki wrote:
> >
> > Yes, it was wrong. I have posted correct one, working. see my previous
> > mail.
> >
> > On 18/08/07, ignicolist <ig...@gmail.com> wrote:
> >>
> >> Hi again, Tks for your great example, i do every thing, and i found a
> >> problem, in the function remove:
> >>
> >>  protected boolean removeEntry(String id)
> >>         {
> >>
> >>                 ScheduleEntry entry = null;
> >>                 String currentId = null;
> >>
> >>
> >> System.out.println("++++++++++++++++"+entries.size());//*1
> >>
> >>                 for(ScheduleEntry se : (TreeSet<ScheduleEntry>)entries)
> >>                 {
> >>
> >>                         if((currentId = se.getId()) != null &&
> >> currentId.equals(id))
> >>                         {
> >>
> >>                                 entry = se;
> >>                                 break;
> >>                         }
> >>                 }
> >>
> >>                 if(entry != null)
> >>                 {
> >>
> >>                         entries.remove(entry);
> >>                         entry = null;
> >>
> >>                         return true;
> >>                 }
> >>
> >>                 return false;
> >>         }
> >>
> >> the id that i select its correct in the funcion, the problem is the
> >> entries
> >> dont have values! i println the entries.size() and its 0.
> >>
> >>
> >> i add the entries like that:
> >>
> >>
> >> private ScheduleModel model;
> >>
> >> entry.setId(cod_cal);
> >>                 entry.setStartTime(startTime);
> >>                 entry.setEndTime(endTime);
> >>                 entry.setTitle(title);
> >>                 entry.setDescription(description);
> >>
> >>            model.addEntry(entry);
> >>              model.refresh();
> >>
> >> i try delete like that:
> >>
> >> ExtendedScheduleModel foo = new ExtendedScheduleModel();
> >>  DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >> entry.setId("10");
> >>
> >> foo.removeEntry(entry);
> >>
> >> if i add the entries like that:
> >>
> >>
> >>  private  ExtendedScheduleModel sss ;
> >>
> >>                entry.setId(cod_cal);
> >>                 entry.setStartTime(startTime);
> >>                 entry.setEndTime(endTime);
> >>                 entry.setTitle(title);
> >>                 entry.setDescription(description);
> >>
> >>              sss.addEntry(entry);
> >>              sss.refresh();
> >>
> >> blank page...
> >>
> >>
> >> Any sujection? Tks for all you are doing!
> >>
> >>
> >>
> >>
> >>
> >>
> >> Michał 'Gandalf' Stawicki wrote:
> >> >
> >> > Right, it was fubar'ed, SimpleScheduleModel wasn't meant for extending
> >> > :) This works - you use like you tried at the beginning - create
> >> > entry, set id and you can remove it. BTW: I think your bean should be
> >> > session, not request, unless you intended so.
> >> >
> >> > /*
> >> >  * Licensed to the Apache Software Foundation (ASF) under one
> >> >  * or more contributor license agreements.  See the NOTICE file
> >> >  * distributed with this work for additional information
> >> >  * regarding copyright ownership.  The ASF licenses this file
> >> >  * to you 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 ###########
> >> >
> >> > import java.io.Serializable;
> >> >
> >> > import java.text.DateFormat;
> >> > import java.text.SimpleDateFormat;
> >> > import java.util.ArrayList;
> >> > import java.util.Collection;
> >> > import java.util.Date;
> >> > import java.util.HashMap;
> >> > import java.util.Iterator;
> >> > import java.util.TreeSet;
> >> > import org.apache.myfaces.custom.schedule.model.AbstractScheduleModel;
> >> > import org.apache.myfaces.custom.schedule.model.Day;
> >> > import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
> >> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
> >> >
> >> > import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
> >> >
> >> > /**
> >> >  * <p>
> >> >  * A simple implementation of the ScheduleModel, not backed by any kind
> >> of
> >> >  * datasource: entries have to be added manually.
> >> >  * </p>
> >> >  *
> >> >  * @author Jurgen Lust (latest modification by $Author: werpu $)
> >> >  * @version $Revision: 371736 $
> >> >  */
> >> > public class ExtendedScheduleModel extends AbstractScheduleModel
> >> > implements Serializable
> >> > {
> >> >
> >> >
> >> > // TEST
> >> > //    public static void main(String [] args)
> >> > //    {
> >> > //            ExtendedScheduleModel foo = new ExtendedScheduleModel();
> >> > //            DefaultScheduleEntry bar = new DefaultScheduleEntry();
> >> > //            bar.setId("1");
> >> > //            foo.addEntry(bar);
> >> > //            DefaultScheduleEntry bar2 = new DefaultScheduleEntry();
> >> > //            bar2.setId("1");
> >> > //
> >> > //            foo.removeEntry(bar2);
> >> > //    }
> >> >
> >> >
> >> >       private static final long serialVersionUID = 1L;
> >> >       protected final TreeSet entries;
> >> >       protected final HashMap holidays;
> >> >       protected final DateFormat holidayFormat = new
> >> > SimpleDateFormat("yyyyMMdd");
> >> >
> >> >       public ExtendedScheduleModel()
> >> >       {
> >> >               this.entries = new TreeSet(new
> >> ScheduleEntryComparator());
> >> >               this.holidays = new HashMap();
> >> >       }
> >> >
> >> >       /**
> >> >        * Set the name of a holiday.
> >> >        *
> >> >        * @param date
> >> >        *            the date
> >> >        * @param holidayName
> >> >        *            the name of the holiday
> >> >        */
> >> >       public void setHoliday(Date date, String holidayName)
> >> >       {
> >> >               if (date == null)
> >> >               {
> >> >                       return;
> >> >               }
> >> >
> >> >               String key = holidayFormat.format(date);
> >> >               holidays.put(key, holidayName);
> >> >       }
> >> >
> >> >       /**
> >> >        * Add an entry to the model.
> >> >        *
> >> >        * @param entry
> >> >        *            the entry to add
> >> >        */
> >> >       public void addEntry(ScheduleEntry entry)
> >> >       {
> >> >               entries.add(entry);
> >> >       }
> >> >
> >> >       /**
> >> >        * Remove an entry from the model.
> >> >        *
> >> >        * @param entry
> >> >        *            the entry to remove
> >> >        */
> >> >       public void removeEntry(ScheduleEntry entry)
> >> >       {
> >> >               if(entries.remove(entry))
> >> >                       return;
> >> >
> >> >               if(entry != null && entry.getId() != null)
> >> >                       removeEntry(entry.getId());
> >> >       }
> >> >
> >> >       /**
> >> >        * @see
> >> >
> >> org.apache.myfaces.custom.schedule.model.ScheduleModel#removeSelectedEntry()
> >> >        */
> >> >       public void removeSelectedEntry()
> >> >       {
> >> >               if (!isEntrySelected())
> >> >                       return;
> >> >               removeEntry(getSelectedEntry());
> >> >               setSelectedEntry(null);
> >> >               refresh();
> >> >       }
> >> >
> >> >       /**
> >> >        * @see
> >> >
> >> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date,
> >> >        *      java.util.Date)
> >> >        */
> >> >       protected Collection loadEntries(Date startDate, Date endDate)
> >> >       {
> >> >               ArrayList selection = new ArrayList();
> >> >
> >> >               for (Iterator entryIterator = entries.iterator();
> >> entryIterator
> >> >                               .hasNext();)
> >> >               {
> >> >                       ScheduleEntry entry = (ScheduleEntry)
> >> entryIterator.next();
> >> >
> >> >                       if (entry.getEndTime().before(startDate)
> >> >                       || entry.getStartTime().after(endDate))
> >> >                       {
> >> >                               continue;
> >> >                       }
> >> >
> >> >                       selection.add(entry);
> >> >               }
> >> >
> >> >               return selection;
> >> >       }
> >> >
> >> >       /**
> >> >        * @see
> >> >
> >> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadDayAttributes(org.apache.myfaces.custom.schedule.model.Day)
> >> >        */
> >> >       protected void loadDayAttributes(Day day)
> >> >       {
> >> >               if (day == null)
> >> >                       return;
> >> >               String key = holidayFormat.format(day.getDate());
> >> >               String holiday = (String) holidays.get(key);
> >> >               if (holiday != null)
> >> >               {
> >> >                       day.setSpecialDayName(holiday);
> >> >                       day.setWorkingDay(false);
> >> >               }
> >> >               else
> >> >               {
> >> >                       day.setSpecialDayName(null);
> >> >                       day.setWorkingDay(true);
> >> >               }
> >> >       }
> >> >
> >> >       /**
> >> >        * Remove entry from model
> >> >        * <br /><br />
> >> >        * @param id identifier of entry to be removed
> >> >        * <br /><br />
> >> >        * @return true on success and false on failure (in case entry
> >> with
> >> > specified id wasn't found)
> >> >        *
> >> >        */
> >> >       protected boolean removeEntry(String id)
> >> >       {
> >> >               ScheduleEntry entry = null;
> >> >               String currentId = null;
> >> >
> >> >               for(ScheduleEntry se : (TreeSet<ScheduleEntry>)entries)
> >> >               {
> >> >                       if((currentId = se.getId()) != null &&
> >> currentId.equals(id))
> >> >                       {
> >> >                               entry = se;
> >> >                               break;
> >> >                       }
> >> >               }
> >> >
> >> >               if(entry != null)
> >> >               {
> >> >                       entries.remove(entry);
> >> >                       entry = null;
> >> >
> >> >                       return true;
> >> >               }
> >> >
> >> >               return false;
> >> >       }
> >> > }
> >> >
> >> >
> >> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >>
> >> >> i have the class correct without errors. But when i call it  show a
> >> blank
> >> >> page!
> >> >>
> >> >> ExtendedScheduleModel x = new ExtendedScheduleModel();
> >> >> x.Remove2("8");
> >> >>
> >> >> I call the class like that. I think its correct! so why the blank
> >> page?
> >> >> if i
> >> >> put thouse two code lines in comments dont have the blank page, so the
> >> >> problem is the class! :-((
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> Michał 'Gandalf' Stawicki wrote:
> >> >> >
> >> >> > Try this, remember to set valid package:
> >> >> >
> >> >> >  #####SET ME package #####SET ME
> >> >> >
> >> >> > import java.util.TreeSet;
> >> >> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
> >> >> > import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> >> >> >
> >> >> > /**
> >> >> >  * @author mstawick
> >> >> >  */
> >> >> > public class ExtendedScheduleModel extends SimpleScheduleModel
> >> >> > {
> >> >> >
> >> >> >       /** Creates a new instance of ExtendedScheduleModel */
> >> >> >       public ExtendedScheduleModel()
> >> >> >       {
> >> >> >               super();
> >> >> >       }
> >> >> >
> >> >> >       /**
> >> >> >        * Remove entry from model
> >> >> >        * <br /><br />
> >> >> >        * @param id identifier of entry to be removed
> >> >> >        * <br /><br />
> >> >> >        * @return true on success and false on failure (in case entry
> >> >> with
> >> >> > specified id wasn't found)
> >> >> >        *
> >> >> >        */
> >> >> >       public boolean removeEntry(String id)
> >> >> >       {
> >> >> >               ScheduleEntry entry = null;
> >> >> >               String currentId = null;
> >> >> >
> >> >> >               for(ScheduleEntry se : entries)
> >> >> >               {
> >> >> >                       if((currentId = se.getId()) != null &&
> >> >> currentId.equals(id))
> >> >> >                       {
> >> >> >                               entry = se;
> >> >> >                               break;
> >> >> >                       }
> >> >> >               }
> >> >> >
> >> >> >               if(entry != null)
> >> >> >               {
> >> >> >                       entries.remove(entry);
> >> >> >                       entry = null;
> >> >> >
> >> >> >                       return true;
> >> >> >               }
> >> >> >
> >> >> >               return false;
> >> >> >       }
> >> >> >
> >> >> >       private TreeSet<ScheduleEntry> entries;
> >> >> > }
> >> >> >
> >> >> >
> >> >> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >> >>
> >> >> >> Sorry to bee so boring and noob, but i realy need to do this, i
> >> need a
> >> >> >> funcionality to show and occult calendars, and i have a entry
> >> >> associate
> >> >> >> to a
> >> >> >> calendar, so when i need occult  the calendar i need to remove the
> >> >> >> entries
> >> >> >> of that calendar from the model. everything working, just need
> >> remove
> >> >> the
> >> >> >> entries.
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> ignicolist wrote:
> >> >> >> >
> >> >> >> > Well i am a litle noob to all these, so i cant put your ideas to
> >> >> work!
> >> >> >> > :-((
> >> >> >> >
> >> >> >> > So i am using SimpleScheduleModel, so you say to create that
> >> class
> >> >> in
> >> >> >> the
> >> >> >> > component Schedule or in my aplication?
> >> >> >> > Because i create the class in my aplication and don´t work. Dam
> >> this
> >> >> is
> >> >> >> so
> >> >> >> > complicated...
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > Michał 'Gandalf' Stawicki wrote:
> >> >> >> >>
> >> >> >> >> I wrote the code in 'on the fly' just to give you idea how
> >> should
> >> >> it
> >> >> >> >> look, I didn't try it
> >> >> >> >>
> >> >> >> >> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
> >> wrote:
> >> >> >> >>> Simply casting it should be fine:
> >> >> >> >>>
> >> >> >> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
> >> >> >> >>>
> >> >> >> >>>
> >> >> >> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >> >> >>> >
> >> >> >> >>> > I try what you say but give me a error in: for(ScheduleEntry
> >> e :
> >> >> >> >>> entries)
> >> >> >> >>> > The Error: Type mismatch: cannot convert from element type
> >> >> Object
> >> >> >> to
> >> >> >> >>> > ScheduleEntry
> >> >> >> >>> >
> >> >> >> >>> > Any idea?
> >> >> >> >>> >
> >> >> >> >>> >
> >> >> >> >>> >
> >> >> >> >>> > Michał 'Gandalf' Stawicki wrote:
> >> >> >> >>> > >
> >> >> >> >>> > > From SimpleScheduleModel.java
> >> >> >> >>> > >
> >> >> >> >>> > >     /**
> >> >> >> >>> > >      * Remove an entry from the model.
> >> >> >> >>> > >      *
> >> >> >> >>> > >      * @param entry
> >> >> >> >>> > >      *            the entry to remove
> >> >> >> >>> > >      */
> >> >> >> >>> > >     public void removeEntry(ScheduleEntry entry)
> >> >> >> >>> > >     {
> >> >> >> >>> > >         entries.remove(entry);
> >> >> >> >>> > >     }
> >> >> >> >>> > >
> >> >> >> >>> > > ...
> >> >> >> >>> > >
> >> >> >> >>> > >     private final TreeSet entries;
> >> >> >> >>> > >
> >> >> >> >>> > > I don't know which model your using, but if it is
> >> >> >> >>> SimpleScheduleModel
> >> >> >> >>> > > than you should extend it and implement your own method,
> >> ex;
> >> >> >> >>> > >
> >> >> >> >>> > > public boolean removeEntry(String id)
> >> >> >> >>> > > {
> >> >> >> >>> > > ScheduleEntry entry = null;
> >> >> >> >>> > >
> >> >> >> >>> > > if(entries != null && id != null)
> >> >> >> >>> > > for(ScheduleEntry e : entries)
> >> >> >> >>> > > {
> >> >> >> >>> > > if(e.getId() != null && e.getId().equals(id))
> >> >> >> >>> > > {
> >> >> >> >>> > > entry = e;
> >> >> >> >>> > > break;
> >> >> >> >>> > > }
> >> >> >> >>> > > }
> >> >> >> >>> > >
> >> >> >> >>> > > if(entry != null)
> >> >> >> >>> > > {
> >> >> >> >>> > > entries.remove(entry);
> >> >> >> >>> > > return true;
> >> >> >> >>> > > }
> >> >> >> >>> > >
> >> >> >> >>> > > return false;
> >> >> >> >>> > > }
> >> >> >> >>> > >
> >> >> >> >>> > >
> >> >> >> >>> > >
> >> >> >> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
> >> >> >> wrote:
> >> >> >> >>> > >> I believe you have to pass exact reference to object that
> >> was
> >> >> >> added
> >> >> >> >>> to
> >> >> >> >>> > >> schedule, not some other object containing same data,
> >> >> example:
> >> >> >> >>> > >>
> >> >> >> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
> >> >> >> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
> >> >> >> >>> > >>
> >> >> >> >>> > >> model.addEntry(foo);
> >> >> >> >>> > >>
> >> >> >> >>> > >> model.removeEntry(foo2); // wrong
> >> >> >> >>> > >> mode.removeEntry(foo); //ok
> >> >> >> >>> > >>
> >> >> >> >>> > >>
> >> >> >> >>> > >>
> >> >> >> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >> >> >>> > >> >
> >> >> >> >>> > >> > Yes, because the entry when i select it remove with
> >> >> >> >>> > >> > model.removeSelectedEntry(); but if i specify his id:
> >> >> >> >>> > >> entry.setId("1");
> >> >> >> >>> > >> > model.removeEntry(entry); dont eliminate. And ids are
> >> the
> >> >> same
> >> >> >> in
> >> >> >> >>> the
> >> >> >> >>> > >> two
> >> >> >> >>> > >> > situacions.
> >> >> >> >>> > >> >
> >> >> >> >>> > >> >
> >> >> >> >>> > >> >
> >> >> >> >>> > >> >
> >> >> >> >>> > >> > Jurgen Lust-2 wrote:
> >> >> >> >>> > >> > >
> >> >> >> >>> > >> > > In your model implementation, do you load the
> >> persistent
> >> >> >> entry
> >> >> >> >>> from
> >> >> >> >>> > >> the
> >> >> >> >>> > >> > > database, using the supplied id, before you delete it?
> >> >> >> >>> > >> > >
> >> >> >> >>> > >> > > Jurgen
> >> >> >> >>> > >> > >
> >> >> >> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700],
> >> >> >> schreef
> >> >> >> >>> > >> > > ignicolist:
> >> >> >> >>> > >> > >> Its what i am doing but don´t work!
> >> >> >> >>> > >> > >>
> >> >> >> >>> > >> > >> an example:
> >> >> >> >>> > >> > >>
> >> >> >> >>> > >> > >> DefaultScheduleEntry entry = new
> >> DefaultScheduleEntry();
> >> >> >> >>> > >> > >>
> >> >> >> >>> > >> > >>   entry.setId("1");
> >> >> >> >>> > >> > >>  model.removeEntry(entry);
> >> >> >> >>> > >> > >>
> >> >> >> >>> > >> > >> this code is supose to remove the entry from de model
> >> >> with
> >> >> >> id
> >> >> >> >>> 1 no?
> >> >> >> >>> > >> i
> >> >> >> >>> > >> > >> just
> >> >> >> >>> > >> > >> want remove de entry from the model, but a entry
> >> specify
> >> >> by
> >> >> >> >>> me.
> >> >> >> >>> > >> > >>
> >> >> >> >>> > >> > >>
> >> >> >> >>> > >> > >>
> >> >> >> >>> > >> > >>
> >> >> >> >>> > >> > >>
> >> >> >> >>> > >> > >> Jurgen Lust-2 wrote:
> >> >> >> >>> > >> > >> >
> >> >> >> >>> > >> > >> > The ScheduleModel.removeEntry() method expects a
> >> >> >> >>> ScheduleEntry as
> >> >> >> >>> > >> > >> > parameter. I suppose you use Hibernate for database
> >> >> >> access,
> >> >> >> >>> so
> >> >> >> >>> > >> what you
> >> >> >> >>> > >> > >> > should do is retrieve the ScheduleEntry from the
> >> >> >> database,
> >> >> >> >>> using
> >> >> >> >>> > >> the
> >> >> >> >>> > >> > >> id,
> >> >> >> >>> > >> > >> > and feed the result to the removeEntry method. In
> >> that
> >> >> >> >>> removeEntry
> >> >> >> >>> > >> > >> > method, you just delete it with your Hibernate DAO.
> >> >> >> >>> > >> > >> > You could of course add a method
> >> >> >> >>> removeEntry(String/Long/Whatever
> >> >> >> >>> > >> id)
> >> >> >> >>> > >> > >> > that does all of this.
> >> >> >> >>> > >> > >> >
> >> >> >> >>> > >> > >> > Jurgen
> >> >> >> >>> > >> > >> >
> >> >> >> >>> > >> > >> >
> >> >> >> >>> > >> > >> >
> >> >> >> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone
> >> -0700],
> >> >> >> >>> schreef
> >> >> >> >>> > >> > >> > ignicolist:
> >> >> >> >>> > >> > >> >> Hi to all, i want to eliminate a especific entry
> >> in a
> >> >> >> model
> >> >> >> >>> of
> >> >> >> >>> > >> > >> schedule
> >> >> >> >>> > >> > >> >> tomahawk. the example in remove a selected entry
> >> work
> >> >> >> fine,
> >> >> >> >>> but
> >> >> >> >>> > >> how to
> >> >> >> >>> > >> > >> >> eliminate a determinated entry?
> >> >> >> >>> > >> > >> >>
> >> >> >> >>> > >> > >> >>
> >> >> >> >>> > >> > >> >> i try with this code:
> >> >> >> >>> > >> > >> >>
> >> >> >> >>> > >> > >> >>
> >> >> >> >>> > >> > >> >> DefaultScheduleEntry entry = new
> >> >> DefaultScheduleEntry();
> >> >> >> >>> > >> > >> >>
> >> >> >> >>> > >> > >> >>  entry.setId(select);
> >> >> >> >>> > >> > >> >>  entry.setStartTime(start);
> >> >> >> >>> > >> > >> >>  entry.setEndTime(end);
> >> >> >> >>> > >> > >> >>  entry.setTitle(select7);
> >> >> >> >>> > >> > >> >>  entry.setDescription(select2);
> >> >> >> >>> > >> > >> >>
> >> >> >> >>> > >> > >> >>  model.removeEntry(entry);
> >> >> >> >>> > >> > >> >>  model.refresh();
> >> >> >> >>> > >> > >> >>
> >> >> >> >>> > >> > >> >> i defined every value for the entry, and then i
> >> want
> >> >> to
> >> >> >> >>> remove
> >> >> >> >>> > >> that
> >> >> >> >>> > >> > >> >> entry!
> >> >> >> >>> > >> > >> >> Any help please!
> >> >> >> >>> > >> > >> >>
> >> >> >> >>> > >> > >> >> Tks for all.
> >> >> >> >>> > >> > >> > --
> >> >> >> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
> >> >> >> >>> > >> > >> >
> >> >> >> >>> > >> > >> >
> >> >> >> >>> > >> > >> >
> >> >> >> >>> > >> > >>
> >> >> >> >>> > >> > > --
> >> >> >> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
> >> >> >> >>> > >> > >
> >> >> >> >>> > >> > >
> >> >> >> >>> > >> > >
> >> >> >> >>> > >> >
> >> >> >> >>> > >> > --
> >> >> >> >>> > >> > View this message in context:
> >> >> >> >>> > >>
> >> >> >> >>>
> >> >> >>
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
> >> >> >> >>> > >> > Sent from the MyFaces - Users mailing list archive at
> >> >> >> Nabble.com.
> >> >> >> >>> > >> >
> >> >> >> >>> > >> >
> >> >> >> >>> > >>
> >> >> >> >>> > >>
> >> >> >> >>> > >> --
> >> >> >> >>> > >> Michał Stawicki
> >> >> >> >>> > >>
> >> >> >> >>> > >> stawicki@gmail.com
> >> >> >> >>> > >> http://stawicki.jasliska.pl
> >> >> >> >>> > >>
> >> >> >> >>> > >
> >> >> >> >>> > >
> >> >> >> >>> > > --
> >> >> >> >>> > > Michał Stawicki
> >> >> >> >>> > >
> >> >> >> >>> > > stawicki@gmail.com
> >> >> >> >>> > > http://stawicki.jasliska.pl
> >> >> >> >>> > >
> >> >> >> >>> > >
> >> >> >> >>> >
> >> >> >> >>> > --
> >> >> >> >>> > View this message in context:
> >> >> >> >>>
> >> >> >>
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
> >> >> >> >>> > Sent from the MyFaces - Users mailing list archive at
> >> >> Nabble.com.
> >> >> >> >>> >
> >> >> >> >>> >
> >> >> >> >>>
> >> >> >> >>>
> >> >> >> >>> --
> >> >> >> >>> Michał Stawicki
> >> >> >> >>>
> >> >> >> >>> stawicki@gmail.com
> >> >> >> >>> http://stawicki.jasliska.pl
> >> >> >> >>>
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> --
> >> >> >> >> Michał Stawicki
> >> >> >> >>
> >> >> >> >> stawicki@gmail.com
> >> >> >> >> http://stawicki.jasliska.pl
> >> >> >> >>
> >> >> >> >>
> >> >> >> >
> >> >> >> >
> >> >> >>
> >> >> >> --
> >> >> >> View this message in context:
> >> >> >>
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
> >> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Michał Stawicki
> >> >> >
> >> >> > stawicki@gmail.com
> >> >> > http://stawicki.jasliska.pl
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12206017
> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Michał Stawicki
> >> >
> >> > stawicki@gmail.com
> >> > http://stawicki.jasliska.pl
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12209467
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Michał Stawicki
> >
> > stawicki@gmail.com
> > http://stawicki.jasliska.pl
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12212569
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
Michał Stawicki

stawicki@gmail.com
http://stawicki.jasliska.pl

Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
Your last mail have the same thing! :confused:
Dont have nathing changed!!



Michał 'Gandalf' Stawicki wrote:
> 
> Yes, it was wrong. I have posted correct one, working. see my previous
> mail.
> 
> On 18/08/07, ignicolist <ig...@gmail.com> wrote:
>>
>> Hi again, Tks for your great example, i do every thing, and i found a
>> problem, in the function remove:
>>
>>  protected boolean removeEntry(String id)
>>         {
>>
>>                 ScheduleEntry entry = null;
>>                 String currentId = null;
>>
>>                
>> System.out.println("++++++++++++++++"+entries.size());//*1
>>
>>                 for(ScheduleEntry se : (TreeSet<ScheduleEntry>)entries)
>>                 {
>>
>>                         if((currentId = se.getId()) != null &&
>> currentId.equals(id))
>>                         {
>>
>>                                 entry = se;
>>                                 break;
>>                         }
>>                 }
>>
>>                 if(entry != null)
>>                 {
>>
>>                         entries.remove(entry);
>>                         entry = null;
>>
>>                         return true;
>>                 }
>>
>>                 return false;
>>         }
>>
>> the id that i select its correct in the funcion, the problem is the
>> entries
>> dont have values! i println the entries.size() and its 0.
>>
>>
>> i add the entries like that:
>>
>>
>> private ScheduleModel model;
>>
>> entry.setId(cod_cal);
>>                 entry.setStartTime(startTime);
>>                 entry.setEndTime(endTime);
>>                 entry.setTitle(title);
>>                 entry.setDescription(description);
>>
>>            model.addEntry(entry);
>>              model.refresh();
>>
>> i try delete like that:
>>
>> ExtendedScheduleModel foo = new ExtendedScheduleModel();
>>  DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> entry.setId("10");
>>
>> foo.removeEntry(entry);
>>
>> if i add the entries like that:
>>
>>
>>  private  ExtendedScheduleModel sss ;
>>
>>                entry.setId(cod_cal);
>>                 entry.setStartTime(startTime);
>>                 entry.setEndTime(endTime);
>>                 entry.setTitle(title);
>>                 entry.setDescription(description);
>>
>>              sss.addEntry(entry);
>>              sss.refresh();
>>
>> blank page...
>>
>>
>> Any sujection? Tks for all you are doing!
>>
>>
>>
>>
>>
>>
>> Michał 'Gandalf' Stawicki wrote:
>> >
>> > Right, it was fubar'ed, SimpleScheduleModel wasn't meant for extending
>> > :) This works - you use like you tried at the beginning - create
>> > entry, set id and you can remove it. BTW: I think your bean should be
>> > session, not request, unless you intended so.
>> >
>> > /*
>> >  * Licensed to the Apache Software Foundation (ASF) under one
>> >  * or more contributor license agreements.  See the NOTICE file
>> >  * distributed with this work for additional information
>> >  * regarding copyright ownership.  The ASF licenses this file
>> >  * to you 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 ###########
>> >
>> > import java.io.Serializable;
>> >
>> > import java.text.DateFormat;
>> > import java.text.SimpleDateFormat;
>> > import java.util.ArrayList;
>> > import java.util.Collection;
>> > import java.util.Date;
>> > import java.util.HashMap;
>> > import java.util.Iterator;
>> > import java.util.TreeSet;
>> > import org.apache.myfaces.custom.schedule.model.AbstractScheduleModel;
>> > import org.apache.myfaces.custom.schedule.model.Day;
>> > import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
>> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
>> >
>> > import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
>> >
>> > /**
>> >  * <p>
>> >  * A simple implementation of the ScheduleModel, not backed by any kind
>> of
>> >  * datasource: entries have to be added manually.
>> >  * </p>
>> >  *
>> >  * @author Jurgen Lust (latest modification by $Author: werpu $)
>> >  * @version $Revision: 371736 $
>> >  */
>> > public class ExtendedScheduleModel extends AbstractScheduleModel
>> > implements Serializable
>> > {
>> >
>> >
>> > // TEST
>> > //    public static void main(String [] args)
>> > //    {
>> > //            ExtendedScheduleModel foo = new ExtendedScheduleModel();
>> > //            DefaultScheduleEntry bar = new DefaultScheduleEntry();
>> > //            bar.setId("1");
>> > //            foo.addEntry(bar);
>> > //            DefaultScheduleEntry bar2 = new DefaultScheduleEntry();
>> > //            bar2.setId("1");
>> > //
>> > //            foo.removeEntry(bar2);
>> > //    }
>> >
>> >
>> >       private static final long serialVersionUID = 1L;
>> >       protected final TreeSet entries;
>> >       protected final HashMap holidays;
>> >       protected final DateFormat holidayFormat = new
>> > SimpleDateFormat("yyyyMMdd");
>> >
>> >       public ExtendedScheduleModel()
>> >       {
>> >               this.entries = new TreeSet(new
>> ScheduleEntryComparator());
>> >               this.holidays = new HashMap();
>> >       }
>> >
>> >       /**
>> >        * Set the name of a holiday.
>> >        *
>> >        * @param date
>> >        *            the date
>> >        * @param holidayName
>> >        *            the name of the holiday
>> >        */
>> >       public void setHoliday(Date date, String holidayName)
>> >       {
>> >               if (date == null)
>> >               {
>> >                       return;
>> >               }
>> >
>> >               String key = holidayFormat.format(date);
>> >               holidays.put(key, holidayName);
>> >       }
>> >
>> >       /**
>> >        * Add an entry to the model.
>> >        *
>> >        * @param entry
>> >        *            the entry to add
>> >        */
>> >       public void addEntry(ScheduleEntry entry)
>> >       {
>> >               entries.add(entry);
>> >       }
>> >
>> >       /**
>> >        * Remove an entry from the model.
>> >        *
>> >        * @param entry
>> >        *            the entry to remove
>> >        */
>> >       public void removeEntry(ScheduleEntry entry)
>> >       {
>> >               if(entries.remove(entry))
>> >                       return;
>> >
>> >               if(entry != null && entry.getId() != null)
>> >                       removeEntry(entry.getId());
>> >       }
>> >
>> >       /**
>> >        * @see
>> >
>> org.apache.myfaces.custom.schedule.model.ScheduleModel#removeSelectedEntry()
>> >        */
>> >       public void removeSelectedEntry()
>> >       {
>> >               if (!isEntrySelected())
>> >                       return;
>> >               removeEntry(getSelectedEntry());
>> >               setSelectedEntry(null);
>> >               refresh();
>> >       }
>> >
>> >       /**
>> >        * @see
>> >
>> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date,
>> >        *      java.util.Date)
>> >        */
>> >       protected Collection loadEntries(Date startDate, Date endDate)
>> >       {
>> >               ArrayList selection = new ArrayList();
>> >
>> >               for (Iterator entryIterator = entries.iterator();
>> entryIterator
>> >                               .hasNext();)
>> >               {
>> >                       ScheduleEntry entry = (ScheduleEntry)
>> entryIterator.next();
>> >
>> >                       if (entry.getEndTime().before(startDate)
>> >                       || entry.getStartTime().after(endDate))
>> >                       {
>> >                               continue;
>> >                       }
>> >
>> >                       selection.add(entry);
>> >               }
>> >
>> >               return selection;
>> >       }
>> >
>> >       /**
>> >        * @see
>> >
>> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadDayAttributes(org.apache.myfaces.custom.schedule.model.Day)
>> >        */
>> >       protected void loadDayAttributes(Day day)
>> >       {
>> >               if (day == null)
>> >                       return;
>> >               String key = holidayFormat.format(day.getDate());
>> >               String holiday = (String) holidays.get(key);
>> >               if (holiday != null)
>> >               {
>> >                       day.setSpecialDayName(holiday);
>> >                       day.setWorkingDay(false);
>> >               }
>> >               else
>> >               {
>> >                       day.setSpecialDayName(null);
>> >                       day.setWorkingDay(true);
>> >               }
>> >       }
>> >
>> >       /**
>> >        * Remove entry from model
>> >        * <br /><br />
>> >        * @param id identifier of entry to be removed
>> >        * <br /><br />
>> >        * @return true on success and false on failure (in case entry
>> with
>> > specified id wasn't found)
>> >        *
>> >        */
>> >       protected boolean removeEntry(String id)
>> >       {
>> >               ScheduleEntry entry = null;
>> >               String currentId = null;
>> >
>> >               for(ScheduleEntry se : (TreeSet<ScheduleEntry>)entries)
>> >               {
>> >                       if((currentId = se.getId()) != null &&
>> currentId.equals(id))
>> >                       {
>> >                               entry = se;
>> >                               break;
>> >                       }
>> >               }
>> >
>> >               if(entry != null)
>> >               {
>> >                       entries.remove(entry);
>> >                       entry = null;
>> >
>> >                       return true;
>> >               }
>> >
>> >               return false;
>> >       }
>> > }
>> >
>> >
>> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >>
>> >> i have the class correct without errors. But when i call it  show a
>> blank
>> >> page!
>> >>
>> >> ExtendedScheduleModel x = new ExtendedScheduleModel();
>> >> x.Remove2("8");
>> >>
>> >> I call the class like that. I think its correct! so why the blank
>> page?
>> >> if i
>> >> put thouse two code lines in comments dont have the blank page, so the
>> >> problem is the class! :-((
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Michał 'Gandalf' Stawicki wrote:
>> >> >
>> >> > Try this, remember to set valid package:
>> >> >
>> >> >  #####SET ME package #####SET ME
>> >> >
>> >> > import java.util.TreeSet;
>> >> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
>> >> > import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
>> >> >
>> >> > /**
>> >> >  * @author mstawick
>> >> >  */
>> >> > public class ExtendedScheduleModel extends SimpleScheduleModel
>> >> > {
>> >> >
>> >> >       /** Creates a new instance of ExtendedScheduleModel */
>> >> >       public ExtendedScheduleModel()
>> >> >       {
>> >> >               super();
>> >> >       }
>> >> >
>> >> >       /**
>> >> >        * Remove entry from model
>> >> >        * <br /><br />
>> >> >        * @param id identifier of entry to be removed
>> >> >        * <br /><br />
>> >> >        * @return true on success and false on failure (in case entry
>> >> with
>> >> > specified id wasn't found)
>> >> >        *
>> >> >        */
>> >> >       public boolean removeEntry(String id)
>> >> >       {
>> >> >               ScheduleEntry entry = null;
>> >> >               String currentId = null;
>> >> >
>> >> >               for(ScheduleEntry se : entries)
>> >> >               {
>> >> >                       if((currentId = se.getId()) != null &&
>> >> currentId.equals(id))
>> >> >                       {
>> >> >                               entry = se;
>> >> >                               break;
>> >> >                       }
>> >> >               }
>> >> >
>> >> >               if(entry != null)
>> >> >               {
>> >> >                       entries.remove(entry);
>> >> >                       entry = null;
>> >> >
>> >> >                       return true;
>> >> >               }
>> >> >
>> >> >               return false;
>> >> >       }
>> >> >
>> >> >       private TreeSet<ScheduleEntry> entries;
>> >> > }
>> >> >
>> >> >
>> >> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >>
>> >> >> Sorry to bee so boring and noob, but i realy need to do this, i
>> need a
>> >> >> funcionality to show and occult calendars, and i have a entry
>> >> associate
>> >> >> to a
>> >> >> calendar, so when i need occult  the calendar i need to remove the
>> >> >> entries
>> >> >> of that calendar from the model. everything working, just need
>> remove
>> >> the
>> >> >> entries.
>> >> >>
>> >> >>
>> >> >>
>> >> >> ignicolist wrote:
>> >> >> >
>> >> >> > Well i am a litle noob to all these, so i cant put your ideas to
>> >> work!
>> >> >> > :-((
>> >> >> >
>> >> >> > So i am using SimpleScheduleModel, so you say to create that
>> class
>> >> in
>> >> >> the
>> >> >> > component Schedule or in my aplication?
>> >> >> > Because i create the class in my aplication and don´t work. Dam
>> this
>> >> is
>> >> >> so
>> >> >> > complicated...
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > Michał 'Gandalf' Stawicki wrote:
>> >> >> >>
>> >> >> >> I wrote the code in 'on the fly' just to give you idea how
>> should
>> >> it
>> >> >> >> look, I didn't try it
>> >> >> >>
>> >> >> >> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
>> wrote:
>> >> >> >>> Simply casting it should be fine:
>> >> >> >>>
>> >> >> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
>> >> >> >>>
>> >> >> >>>
>> >> >> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >> >>> >
>> >> >> >>> > I try what you say but give me a error in: for(ScheduleEntry
>> e :
>> >> >> >>> entries)
>> >> >> >>> > The Error: Type mismatch: cannot convert from element type
>> >> Object
>> >> >> to
>> >> >> >>> > ScheduleEntry
>> >> >> >>> >
>> >> >> >>> > Any idea?
>> >> >> >>> >
>> >> >> >>> >
>> >> >> >>> >
>> >> >> >>> > Michał 'Gandalf' Stawicki wrote:
>> >> >> >>> > >
>> >> >> >>> > > From SimpleScheduleModel.java
>> >> >> >>> > >
>> >> >> >>> > >     /**
>> >> >> >>> > >      * Remove an entry from the model.
>> >> >> >>> > >      *
>> >> >> >>> > >      * @param entry
>> >> >> >>> > >      *            the entry to remove
>> >> >> >>> > >      */
>> >> >> >>> > >     public void removeEntry(ScheduleEntry entry)
>> >> >> >>> > >     {
>> >> >> >>> > >         entries.remove(entry);
>> >> >> >>> > >     }
>> >> >> >>> > >
>> >> >> >>> > > ...
>> >> >> >>> > >
>> >> >> >>> > >     private final TreeSet entries;
>> >> >> >>> > >
>> >> >> >>> > > I don't know which model your using, but if it is
>> >> >> >>> SimpleScheduleModel
>> >> >> >>> > > than you should extend it and implement your own method,
>> ex;
>> >> >> >>> > >
>> >> >> >>> > > public boolean removeEntry(String id)
>> >> >> >>> > > {
>> >> >> >>> > > ScheduleEntry entry = null;
>> >> >> >>> > >
>> >> >> >>> > > if(entries != null && id != null)
>> >> >> >>> > > for(ScheduleEntry e : entries)
>> >> >> >>> > > {
>> >> >> >>> > > if(e.getId() != null && e.getId().equals(id))
>> >> >> >>> > > {
>> >> >> >>> > > entry = e;
>> >> >> >>> > > break;
>> >> >> >>> > > }
>> >> >> >>> > > }
>> >> >> >>> > >
>> >> >> >>> > > if(entry != null)
>> >> >> >>> > > {
>> >> >> >>> > > entries.remove(entry);
>> >> >> >>> > > return true;
>> >> >> >>> > > }
>> >> >> >>> > >
>> >> >> >>> > > return false;
>> >> >> >>> > > }
>> >> >> >>> > >
>> >> >> >>> > >
>> >> >> >>> > >
>> >> >> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
>> >> >> wrote:
>> >> >> >>> > >> I believe you have to pass exact reference to object that
>> was
>> >> >> added
>> >> >> >>> to
>> >> >> >>> > >> schedule, not some other object containing same data,
>> >> example:
>> >> >> >>> > >>
>> >> >> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
>> >> >> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
>> >> >> >>> > >>
>> >> >> >>> > >> model.addEntry(foo);
>> >> >> >>> > >>
>> >> >> >>> > >> model.removeEntry(foo2); // wrong
>> >> >> >>> > >> mode.removeEntry(foo); //ok
>> >> >> >>> > >>
>> >> >> >>> > >>
>> >> >> >>> > >>
>> >> >> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >> >>> > >> >
>> >> >> >>> > >> > Yes, because the entry when i select it remove with
>> >> >> >>> > >> > model.removeSelectedEntry(); but if i specify his id:
>> >> >> >>> > >> entry.setId("1");
>> >> >> >>> > >> > model.removeEntry(entry); dont eliminate. And ids are
>> the
>> >> same
>> >> >> in
>> >> >> >>> the
>> >> >> >>> > >> two
>> >> >> >>> > >> > situacions.
>> >> >> >>> > >> >
>> >> >> >>> > >> >
>> >> >> >>> > >> >
>> >> >> >>> > >> >
>> >> >> >>> > >> > Jurgen Lust-2 wrote:
>> >> >> >>> > >> > >
>> >> >> >>> > >> > > In your model implementation, do you load the
>> persistent
>> >> >> entry
>> >> >> >>> from
>> >> >> >>> > >> the
>> >> >> >>> > >> > > database, using the supplied id, before you delete it?
>> >> >> >>> > >> > >
>> >> >> >>> > >> > > Jurgen
>> >> >> >>> > >> > >
>> >> >> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700],
>> >> >> schreef
>> >> >> >>> > >> > > ignicolist:
>> >> >> >>> > >> > >> Its what i am doing but don´t work!
>> >> >> >>> > >> > >>
>> >> >> >>> > >> > >> an example:
>> >> >> >>> > >> > >>
>> >> >> >>> > >> > >> DefaultScheduleEntry entry = new
>> DefaultScheduleEntry();
>> >> >> >>> > >> > >>
>> >> >> >>> > >> > >>   entry.setId("1");
>> >> >> >>> > >> > >>  model.removeEntry(entry);
>> >> >> >>> > >> > >>
>> >> >> >>> > >> > >> this code is supose to remove the entry from de model
>> >> with
>> >> >> id
>> >> >> >>> 1 no?
>> >> >> >>> > >> i
>> >> >> >>> > >> > >> just
>> >> >> >>> > >> > >> want remove de entry from the model, but a entry
>> specify
>> >> by
>> >> >> >>> me.
>> >> >> >>> > >> > >>
>> >> >> >>> > >> > >>
>> >> >> >>> > >> > >>
>> >> >> >>> > >> > >>
>> >> >> >>> > >> > >>
>> >> >> >>> > >> > >> Jurgen Lust-2 wrote:
>> >> >> >>> > >> > >> >
>> >> >> >>> > >> > >> > The ScheduleModel.removeEntry() method expects a
>> >> >> >>> ScheduleEntry as
>> >> >> >>> > >> > >> > parameter. I suppose you use Hibernate for database
>> >> >> access,
>> >> >> >>> so
>> >> >> >>> > >> what you
>> >> >> >>> > >> > >> > should do is retrieve the ScheduleEntry from the
>> >> >> database,
>> >> >> >>> using
>> >> >> >>> > >> the
>> >> >> >>> > >> > >> id,
>> >> >> >>> > >> > >> > and feed the result to the removeEntry method. In
>> that
>> >> >> >>> removeEntry
>> >> >> >>> > >> > >> > method, you just delete it with your Hibernate DAO.
>> >> >> >>> > >> > >> > You could of course add a method
>> >> >> >>> removeEntry(String/Long/Whatever
>> >> >> >>> > >> id)
>> >> >> >>> > >> > >> > that does all of this.
>> >> >> >>> > >> > >> >
>> >> >> >>> > >> > >> > Jurgen
>> >> >> >>> > >> > >> >
>> >> >> >>> > >> > >> >
>> >> >> >>> > >> > >> >
>> >> >> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone
>> -0700],
>> >> >> >>> schreef
>> >> >> >>> > >> > >> > ignicolist:
>> >> >> >>> > >> > >> >> Hi to all, i want to eliminate a especific entry
>> in a
>> >> >> model
>> >> >> >>> of
>> >> >> >>> > >> > >> schedule
>> >> >> >>> > >> > >> >> tomahawk. the example in remove a selected entry
>> work
>> >> >> fine,
>> >> >> >>> but
>> >> >> >>> > >> how to
>> >> >> >>> > >> > >> >> eliminate a determinated entry?
>> >> >> >>> > >> > >> >>
>> >> >> >>> > >> > >> >>
>> >> >> >>> > >> > >> >> i try with this code:
>> >> >> >>> > >> > >> >>
>> >> >> >>> > >> > >> >>
>> >> >> >>> > >> > >> >> DefaultScheduleEntry entry = new
>> >> DefaultScheduleEntry();
>> >> >> >>> > >> > >> >>
>> >> >> >>> > >> > >> >>  entry.setId(select);
>> >> >> >>> > >> > >> >>  entry.setStartTime(start);
>> >> >> >>> > >> > >> >>  entry.setEndTime(end);
>> >> >> >>> > >> > >> >>  entry.setTitle(select7);
>> >> >> >>> > >> > >> >>  entry.setDescription(select2);
>> >> >> >>> > >> > >> >>
>> >> >> >>> > >> > >> >>  model.removeEntry(entry);
>> >> >> >>> > >> > >> >>  model.refresh();
>> >> >> >>> > >> > >> >>
>> >> >> >>> > >> > >> >> i defined every value for the entry, and then i
>> want
>> >> to
>> >> >> >>> remove
>> >> >> >>> > >> that
>> >> >> >>> > >> > >> >> entry!
>> >> >> >>> > >> > >> >> Any help please!
>> >> >> >>> > >> > >> >>
>> >> >> >>> > >> > >> >> Tks for all.
>> >> >> >>> > >> > >> > --
>> >> >> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
>> >> >> >>> > >> > >> >
>> >> >> >>> > >> > >> >
>> >> >> >>> > >> > >> >
>> >> >> >>> > >> > >>
>> >> >> >>> > >> > > --
>> >> >> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
>> >> >> >>> > >> > >
>> >> >> >>> > >> > >
>> >> >> >>> > >> > >
>> >> >> >>> > >> >
>> >> >> >>> > >> > --
>> >> >> >>> > >> > View this message in context:
>> >> >> >>> > >>
>> >> >> >>>
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
>> >> >> >>> > >> > Sent from the MyFaces - Users mailing list archive at
>> >> >> Nabble.com.
>> >> >> >>> > >> >
>> >> >> >>> > >> >
>> >> >> >>> > >>
>> >> >> >>> > >>
>> >> >> >>> > >> --
>> >> >> >>> > >> Michał Stawicki
>> >> >> >>> > >>
>> >> >> >>> > >> stawicki@gmail.com
>> >> >> >>> > >> http://stawicki.jasliska.pl
>> >> >> >>> > >>
>> >> >> >>> > >
>> >> >> >>> > >
>> >> >> >>> > > --
>> >> >> >>> > > Michał Stawicki
>> >> >> >>> > >
>> >> >> >>> > > stawicki@gmail.com
>> >> >> >>> > > http://stawicki.jasliska.pl
>> >> >> >>> > >
>> >> >> >>> > >
>> >> >> >>> >
>> >> >> >>> > --
>> >> >> >>> > View this message in context:
>> >> >> >>>
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
>> >> >> >>> > Sent from the MyFaces - Users mailing list archive at
>> >> Nabble.com.
>> >> >> >>> >
>> >> >> >>> >
>> >> >> >>>
>> >> >> >>>
>> >> >> >>> --
>> >> >> >>> Michał Stawicki
>> >> >> >>>
>> >> >> >>> stawicki@gmail.com
>> >> >> >>> http://stawicki.jasliska.pl
>> >> >> >>>
>> >> >> >>
>> >> >> >>
>> >> >> >> --
>> >> >> >> Michał Stawicki
>> >> >> >>
>> >> >> >> stawicki@gmail.com
>> >> >> >> http://stawicki.jasliska.pl
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
>> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > Michał Stawicki
>> >> >
>> >> > stawicki@gmail.com
>> >> > http://stawicki.jasliska.pl
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12206017
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Michał Stawicki
>> >
>> > stawicki@gmail.com
>> > http://stawicki.jasliska.pl
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12209467
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Michał Stawicki
> 
> stawicki@gmail.com
> http://stawicki.jasliska.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12212569
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by Michał 'Gandalf' Stawicki <st...@gmail.com>.
Yes, it was wrong. I have posted correct one, working. see my previous mail.

On 18/08/07, ignicolist <ig...@gmail.com> wrote:
>
> Hi again, Tks for your great example, i do every thing, and i found a
> problem, in the function remove:
>
>  protected boolean removeEntry(String id)
>         {
>
>                 ScheduleEntry entry = null;
>                 String currentId = null;
>
>                 System.out.println("++++++++++++++++"+entries.size());//*1
>
>                 for(ScheduleEntry se : (TreeSet<ScheduleEntry>)entries)
>                 {
>
>                         if((currentId = se.getId()) != null &&
> currentId.equals(id))
>                         {
>
>                                 entry = se;
>                                 break;
>                         }
>                 }
>
>                 if(entry != null)
>                 {
>
>                         entries.remove(entry);
>                         entry = null;
>
>                         return true;
>                 }
>
>                 return false;
>         }
>
> the id that i select its correct in the funcion, the problem is the entries
> dont have values! i println the entries.size() and its 0.
>
>
> i add the entries like that:
>
>
> private ScheduleModel model;
>
> entry.setId(cod_cal);
>                 entry.setStartTime(startTime);
>                 entry.setEndTime(endTime);
>                 entry.setTitle(title);
>                 entry.setDescription(description);
>
>            model.addEntry(entry);
>              model.refresh();
>
> i try delete like that:
>
> ExtendedScheduleModel foo = new ExtendedScheduleModel();
>  DefaultScheduleEntry entry = new DefaultScheduleEntry();
> entry.setId("10");
>
> foo.removeEntry(entry);
>
> if i add the entries like that:
>
>
>  private  ExtendedScheduleModel sss ;
>
>                entry.setId(cod_cal);
>                 entry.setStartTime(startTime);
>                 entry.setEndTime(endTime);
>                 entry.setTitle(title);
>                 entry.setDescription(description);
>
>              sss.addEntry(entry);
>              sss.refresh();
>
> blank page...
>
>
> Any sujection? Tks for all you are doing!
>
>
>
>
>
>
> Michał 'Gandalf' Stawicki wrote:
> >
> > Right, it was fubar'ed, SimpleScheduleModel wasn't meant for extending
> > :) This works - you use like you tried at the beginning - create
> > entry, set id and you can remove it. BTW: I think your bean should be
> > session, not request, unless you intended so.
> >
> > /*
> >  * Licensed to the Apache Software Foundation (ASF) under one
> >  * or more contributor license agreements.  See the NOTICE file
> >  * distributed with this work for additional information
> >  * regarding copyright ownership.  The ASF licenses this file
> >  * to you 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 ###########
> >
> > import java.io.Serializable;
> >
> > import java.text.DateFormat;
> > import java.text.SimpleDateFormat;
> > import java.util.ArrayList;
> > import java.util.Collection;
> > import java.util.Date;
> > import java.util.HashMap;
> > import java.util.Iterator;
> > import java.util.TreeSet;
> > import org.apache.myfaces.custom.schedule.model.AbstractScheduleModel;
> > import org.apache.myfaces.custom.schedule.model.Day;
> > import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
> >
> > import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
> >
> > /**
> >  * <p>
> >  * A simple implementation of the ScheduleModel, not backed by any kind of
> >  * datasource: entries have to be added manually.
> >  * </p>
> >  *
> >  * @author Jurgen Lust (latest modification by $Author: werpu $)
> >  * @version $Revision: 371736 $
> >  */
> > public class ExtendedScheduleModel extends AbstractScheduleModel
> > implements Serializable
> > {
> >
> >
> > // TEST
> > //    public static void main(String [] args)
> > //    {
> > //            ExtendedScheduleModel foo = new ExtendedScheduleModel();
> > //            DefaultScheduleEntry bar = new DefaultScheduleEntry();
> > //            bar.setId("1");
> > //            foo.addEntry(bar);
> > //            DefaultScheduleEntry bar2 = new DefaultScheduleEntry();
> > //            bar2.setId("1");
> > //
> > //            foo.removeEntry(bar2);
> > //    }
> >
> >
> >       private static final long serialVersionUID = 1L;
> >       protected final TreeSet entries;
> >       protected final HashMap holidays;
> >       protected final DateFormat holidayFormat = new
> > SimpleDateFormat("yyyyMMdd");
> >
> >       public ExtendedScheduleModel()
> >       {
> >               this.entries = new TreeSet(new ScheduleEntryComparator());
> >               this.holidays = new HashMap();
> >       }
> >
> >       /**
> >        * Set the name of a holiday.
> >        *
> >        * @param date
> >        *            the date
> >        * @param holidayName
> >        *            the name of the holiday
> >        */
> >       public void setHoliday(Date date, String holidayName)
> >       {
> >               if (date == null)
> >               {
> >                       return;
> >               }
> >
> >               String key = holidayFormat.format(date);
> >               holidays.put(key, holidayName);
> >       }
> >
> >       /**
> >        * Add an entry to the model.
> >        *
> >        * @param entry
> >        *            the entry to add
> >        */
> >       public void addEntry(ScheduleEntry entry)
> >       {
> >               entries.add(entry);
> >       }
> >
> >       /**
> >        * Remove an entry from the model.
> >        *
> >        * @param entry
> >        *            the entry to remove
> >        */
> >       public void removeEntry(ScheduleEntry entry)
> >       {
> >               if(entries.remove(entry))
> >                       return;
> >
> >               if(entry != null && entry.getId() != null)
> >                       removeEntry(entry.getId());
> >       }
> >
> >       /**
> >        * @see
> > org.apache.myfaces.custom.schedule.model.ScheduleModel#removeSelectedEntry()
> >        */
> >       public void removeSelectedEntry()
> >       {
> >               if (!isEntrySelected())
> >                       return;
> >               removeEntry(getSelectedEntry());
> >               setSelectedEntry(null);
> >               refresh();
> >       }
> >
> >       /**
> >        * @see
> > org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date,
> >        *      java.util.Date)
> >        */
> >       protected Collection loadEntries(Date startDate, Date endDate)
> >       {
> >               ArrayList selection = new ArrayList();
> >
> >               for (Iterator entryIterator = entries.iterator(); entryIterator
> >                               .hasNext();)
> >               {
> >                       ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
> >
> >                       if (entry.getEndTime().before(startDate)
> >                       || entry.getStartTime().after(endDate))
> >                       {
> >                               continue;
> >                       }
> >
> >                       selection.add(entry);
> >               }
> >
> >               return selection;
> >       }
> >
> >       /**
> >        * @see
> > org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadDayAttributes(org.apache.myfaces.custom.schedule.model.Day)
> >        */
> >       protected void loadDayAttributes(Day day)
> >       {
> >               if (day == null)
> >                       return;
> >               String key = holidayFormat.format(day.getDate());
> >               String holiday = (String) holidays.get(key);
> >               if (holiday != null)
> >               {
> >                       day.setSpecialDayName(holiday);
> >                       day.setWorkingDay(false);
> >               }
> >               else
> >               {
> >                       day.setSpecialDayName(null);
> >                       day.setWorkingDay(true);
> >               }
> >       }
> >
> >       /**
> >        * Remove entry from model
> >        * <br /><br />
> >        * @param id identifier of entry to be removed
> >        * <br /><br />
> >        * @return true on success and false on failure (in case entry with
> > specified id wasn't found)
> >        *
> >        */
> >       protected boolean removeEntry(String id)
> >       {
> >               ScheduleEntry entry = null;
> >               String currentId = null;
> >
> >               for(ScheduleEntry se : (TreeSet<ScheduleEntry>)entries)
> >               {
> >                       if((currentId = se.getId()) != null && currentId.equals(id))
> >                       {
> >                               entry = se;
> >                               break;
> >                       }
> >               }
> >
> >               if(entry != null)
> >               {
> >                       entries.remove(entry);
> >                       entry = null;
> >
> >                       return true;
> >               }
> >
> >               return false;
> >       }
> > }
> >
> >
> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >>
> >> i have the class correct without errors. But when i call it  show a blank
> >> page!
> >>
> >> ExtendedScheduleModel x = new ExtendedScheduleModel();
> >> x.Remove2("8");
> >>
> >> I call the class like that. I think its correct! so why the blank page?
> >> if i
> >> put thouse two code lines in comments dont have the blank page, so the
> >> problem is the class! :-((
> >>
> >>
> >>
> >>
> >>
> >>
> >> Michał 'Gandalf' Stawicki wrote:
> >> >
> >> > Try this, remember to set valid package:
> >> >
> >> >  #####SET ME package #####SET ME
> >> >
> >> > import java.util.TreeSet;
> >> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
> >> > import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> >> >
> >> > /**
> >> >  * @author mstawick
> >> >  */
> >> > public class ExtendedScheduleModel extends SimpleScheduleModel
> >> > {
> >> >
> >> >       /** Creates a new instance of ExtendedScheduleModel */
> >> >       public ExtendedScheduleModel()
> >> >       {
> >> >               super();
> >> >       }
> >> >
> >> >       /**
> >> >        * Remove entry from model
> >> >        * <br /><br />
> >> >        * @param id identifier of entry to be removed
> >> >        * <br /><br />
> >> >        * @return true on success and false on failure (in case entry
> >> with
> >> > specified id wasn't found)
> >> >        *
> >> >        */
> >> >       public boolean removeEntry(String id)
> >> >       {
> >> >               ScheduleEntry entry = null;
> >> >               String currentId = null;
> >> >
> >> >               for(ScheduleEntry se : entries)
> >> >               {
> >> >                       if((currentId = se.getId()) != null &&
> >> currentId.equals(id))
> >> >                       {
> >> >                               entry = se;
> >> >                               break;
> >> >                       }
> >> >               }
> >> >
> >> >               if(entry != null)
> >> >               {
> >> >                       entries.remove(entry);
> >> >                       entry = null;
> >> >
> >> >                       return true;
> >> >               }
> >> >
> >> >               return false;
> >> >       }
> >> >
> >> >       private TreeSet<ScheduleEntry> entries;
> >> > }
> >> >
> >> >
> >> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >>
> >> >> Sorry to bee so boring and noob, but i realy need to do this, i need a
> >> >> funcionality to show and occult calendars, and i have a entry
> >> associate
> >> >> to a
> >> >> calendar, so when i need occult  the calendar i need to remove the
> >> >> entries
> >> >> of that calendar from the model. everything working, just need remove
> >> the
> >> >> entries.
> >> >>
> >> >>
> >> >>
> >> >> ignicolist wrote:
> >> >> >
> >> >> > Well i am a litle noob to all these, so i cant put your ideas to
> >> work!
> >> >> > :-((
> >> >> >
> >> >> > So i am using SimpleScheduleModel, so you say to create that class
> >> in
> >> >> the
> >> >> > component Schedule or in my aplication?
> >> >> > Because i create the class in my aplication and don´t work. Dam this
> >> is
> >> >> so
> >> >> > complicated...
> >> >> >
> >> >> >
> >> >> >
> >> >> > Michał 'Gandalf' Stawicki wrote:
> >> >> >>
> >> >> >> I wrote the code in 'on the fly' just to give you idea how should
> >> it
> >> >> >> look, I didn't try it
> >> >> >>
> >> >> >> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
> >> >> >>> Simply casting it should be fine:
> >> >> >>>
> >> >> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
> >> >> >>>
> >> >> >>>
> >> >> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >> >>> >
> >> >> >>> > I try what you say but give me a error in: for(ScheduleEntry e :
> >> >> >>> entries)
> >> >> >>> > The Error: Type mismatch: cannot convert from element type
> >> Object
> >> >> to
> >> >> >>> > ScheduleEntry
> >> >> >>> >
> >> >> >>> > Any idea?
> >> >> >>> >
> >> >> >>> >
> >> >> >>> >
> >> >> >>> > Michał 'Gandalf' Stawicki wrote:
> >> >> >>> > >
> >> >> >>> > > From SimpleScheduleModel.java
> >> >> >>> > >
> >> >> >>> > >     /**
> >> >> >>> > >      * Remove an entry from the model.
> >> >> >>> > >      *
> >> >> >>> > >      * @param entry
> >> >> >>> > >      *            the entry to remove
> >> >> >>> > >      */
> >> >> >>> > >     public void removeEntry(ScheduleEntry entry)
> >> >> >>> > >     {
> >> >> >>> > >         entries.remove(entry);
> >> >> >>> > >     }
> >> >> >>> > >
> >> >> >>> > > ...
> >> >> >>> > >
> >> >> >>> > >     private final TreeSet entries;
> >> >> >>> > >
> >> >> >>> > > I don't know which model your using, but if it is
> >> >> >>> SimpleScheduleModel
> >> >> >>> > > than you should extend it and implement your own method, ex;
> >> >> >>> > >
> >> >> >>> > > public boolean removeEntry(String id)
> >> >> >>> > > {
> >> >> >>> > > ScheduleEntry entry = null;
> >> >> >>> > >
> >> >> >>> > > if(entries != null && id != null)
> >> >> >>> > > for(ScheduleEntry e : entries)
> >> >> >>> > > {
> >> >> >>> > > if(e.getId() != null && e.getId().equals(id))
> >> >> >>> > > {
> >> >> >>> > > entry = e;
> >> >> >>> > > break;
> >> >> >>> > > }
> >> >> >>> > > }
> >> >> >>> > >
> >> >> >>> > > if(entry != null)
> >> >> >>> > > {
> >> >> >>> > > entries.remove(entry);
> >> >> >>> > > return true;
> >> >> >>> > > }
> >> >> >>> > >
> >> >> >>> > > return false;
> >> >> >>> > > }
> >> >> >>> > >
> >> >> >>> > >
> >> >> >>> > >
> >> >> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
> >> >> wrote:
> >> >> >>> > >> I believe you have to pass exact reference to object that was
> >> >> added
> >> >> >>> to
> >> >> >>> > >> schedule, not some other object containing same data,
> >> example:
> >> >> >>> > >>
> >> >> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
> >> >> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
> >> >> >>> > >>
> >> >> >>> > >> model.addEntry(foo);
> >> >> >>> > >>
> >> >> >>> > >> model.removeEntry(foo2); // wrong
> >> >> >>> > >> mode.removeEntry(foo); //ok
> >> >> >>> > >>
> >> >> >>> > >>
> >> >> >>> > >>
> >> >> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >> >>> > >> >
> >> >> >>> > >> > Yes, because the entry when i select it remove with
> >> >> >>> > >> > model.removeSelectedEntry(); but if i specify his id:
> >> >> >>> > >> entry.setId("1");
> >> >> >>> > >> > model.removeEntry(entry); dont eliminate. And ids are the
> >> same
> >> >> in
> >> >> >>> the
> >> >> >>> > >> two
> >> >> >>> > >> > situacions.
> >> >> >>> > >> >
> >> >> >>> > >> >
> >> >> >>> > >> >
> >> >> >>> > >> >
> >> >> >>> > >> > Jurgen Lust-2 wrote:
> >> >> >>> > >> > >
> >> >> >>> > >> > > In your model implementation, do you load the persistent
> >> >> entry
> >> >> >>> from
> >> >> >>> > >> the
> >> >> >>> > >> > > database, using the supplied id, before you delete it?
> >> >> >>> > >> > >
> >> >> >>> > >> > > Jurgen
> >> >> >>> > >> > >
> >> >> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700],
> >> >> schreef
> >> >> >>> > >> > > ignicolist:
> >> >> >>> > >> > >> Its what i am doing but don´t work!
> >> >> >>> > >> > >>
> >> >> >>> > >> > >> an example:
> >> >> >>> > >> > >>
> >> >> >>> > >> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >> >> >>> > >> > >>
> >> >> >>> > >> > >>   entry.setId("1");
> >> >> >>> > >> > >>  model.removeEntry(entry);
> >> >> >>> > >> > >>
> >> >> >>> > >> > >> this code is supose to remove the entry from de model
> >> with
> >> >> id
> >> >> >>> 1 no?
> >> >> >>> > >> i
> >> >> >>> > >> > >> just
> >> >> >>> > >> > >> want remove de entry from the model, but a entry specify
> >> by
> >> >> >>> me.
> >> >> >>> > >> > >>
> >> >> >>> > >> > >>
> >> >> >>> > >> > >>
> >> >> >>> > >> > >>
> >> >> >>> > >> > >>
> >> >> >>> > >> > >> Jurgen Lust-2 wrote:
> >> >> >>> > >> > >> >
> >> >> >>> > >> > >> > The ScheduleModel.removeEntry() method expects a
> >> >> >>> ScheduleEntry as
> >> >> >>> > >> > >> > parameter. I suppose you use Hibernate for database
> >> >> access,
> >> >> >>> so
> >> >> >>> > >> what you
> >> >> >>> > >> > >> > should do is retrieve the ScheduleEntry from the
> >> >> database,
> >> >> >>> using
> >> >> >>> > >> the
> >> >> >>> > >> > >> id,
> >> >> >>> > >> > >> > and feed the result to the removeEntry method. In that
> >> >> >>> removeEntry
> >> >> >>> > >> > >> > method, you just delete it with your Hibernate DAO.
> >> >> >>> > >> > >> > You could of course add a method
> >> >> >>> removeEntry(String/Long/Whatever
> >> >> >>> > >> id)
> >> >> >>> > >> > >> > that does all of this.
> >> >> >>> > >> > >> >
> >> >> >>> > >> > >> > Jurgen
> >> >> >>> > >> > >> >
> >> >> >>> > >> > >> >
> >> >> >>> > >> > >> >
> >> >> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700],
> >> >> >>> schreef
> >> >> >>> > >> > >> > ignicolist:
> >> >> >>> > >> > >> >> Hi to all, i want to eliminate a especific entry in a
> >> >> model
> >> >> >>> of
> >> >> >>> > >> > >> schedule
> >> >> >>> > >> > >> >> tomahawk. the example in remove a selected entry work
> >> >> fine,
> >> >> >>> but
> >> >> >>> > >> how to
> >> >> >>> > >> > >> >> eliminate a determinated entry?
> >> >> >>> > >> > >> >>
> >> >> >>> > >> > >> >>
> >> >> >>> > >> > >> >> i try with this code:
> >> >> >>> > >> > >> >>
> >> >> >>> > >> > >> >>
> >> >> >>> > >> > >> >> DefaultScheduleEntry entry = new
> >> DefaultScheduleEntry();
> >> >> >>> > >> > >> >>
> >> >> >>> > >> > >> >>  entry.setId(select);
> >> >> >>> > >> > >> >>  entry.setStartTime(start);
> >> >> >>> > >> > >> >>  entry.setEndTime(end);
> >> >> >>> > >> > >> >>  entry.setTitle(select7);
> >> >> >>> > >> > >> >>  entry.setDescription(select2);
> >> >> >>> > >> > >> >>
> >> >> >>> > >> > >> >>  model.removeEntry(entry);
> >> >> >>> > >> > >> >>  model.refresh();
> >> >> >>> > >> > >> >>
> >> >> >>> > >> > >> >> i defined every value for the entry, and then i want
> >> to
> >> >> >>> remove
> >> >> >>> > >> that
> >> >> >>> > >> > >> >> entry!
> >> >> >>> > >> > >> >> Any help please!
> >> >> >>> > >> > >> >>
> >> >> >>> > >> > >> >> Tks for all.
> >> >> >>> > >> > >> > --
> >> >> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
> >> >> >>> > >> > >> >
> >> >> >>> > >> > >> >
> >> >> >>> > >> > >> >
> >> >> >>> > >> > >>
> >> >> >>> > >> > > --
> >> >> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
> >> >> >>> > >> > >
> >> >> >>> > >> > >
> >> >> >>> > >> > >
> >> >> >>> > >> >
> >> >> >>> > >> > --
> >> >> >>> > >> > View this message in context:
> >> >> >>> > >>
> >> >> >>>
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
> >> >> >>> > >> > Sent from the MyFaces - Users mailing list archive at
> >> >> Nabble.com.
> >> >> >>> > >> >
> >> >> >>> > >> >
> >> >> >>> > >>
> >> >> >>> > >>
> >> >> >>> > >> --
> >> >> >>> > >> Michał Stawicki
> >> >> >>> > >>
> >> >> >>> > >> stawicki@gmail.com
> >> >> >>> > >> http://stawicki.jasliska.pl
> >> >> >>> > >>
> >> >> >>> > >
> >> >> >>> > >
> >> >> >>> > > --
> >> >> >>> > > Michał Stawicki
> >> >> >>> > >
> >> >> >>> > > stawicki@gmail.com
> >> >> >>> > > http://stawicki.jasliska.pl
> >> >> >>> > >
> >> >> >>> > >
> >> >> >>> >
> >> >> >>> > --
> >> >> >>> > View this message in context:
> >> >> >>>
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
> >> >> >>> > Sent from the MyFaces - Users mailing list archive at
> >> Nabble.com.
> >> >> >>> >
> >> >> >>> >
> >> >> >>>
> >> >> >>>
> >> >> >>> --
> >> >> >>> Michał Stawicki
> >> >> >>>
> >> >> >>> stawicki@gmail.com
> >> >> >>> http://stawicki.jasliska.pl
> >> >> >>>
> >> >> >>
> >> >> >>
> >> >> >> --
> >> >> >> Michał Stawicki
> >> >> >>
> >> >> >> stawicki@gmail.com
> >> >> >> http://stawicki.jasliska.pl
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > Michał Stawicki
> >> >
> >> > stawicki@gmail.com
> >> > http://stawicki.jasliska.pl
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12206017
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Michał Stawicki
> >
> > stawicki@gmail.com
> > http://stawicki.jasliska.pl
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12209467
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
Michał Stawicki

stawicki@gmail.com
http://stawicki.jasliska.pl

Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
Hi again, Tks for your great example, i do every thing, and i found a
problem, in the function remove:

 protected boolean removeEntry(String id)
        {
        	 
                ScheduleEntry entry = null;
                String currentId = null;
               
                System.out.println("++++++++++++++++"+entries.size());//*1
                
                for(ScheduleEntry se : (TreeSet<ScheduleEntry>)entries)
                {
                	
                        if((currentId = se.getId()) != null &&
currentId.equals(id))
                        {
                        	
                                entry = se;
                                break;
                        }
                }
               
                if(entry != null)
                {
                	
                        entries.remove(entry);
                        entry = null;
                       
                        return true;
                }
               
                return false;
        }

the id that i select its correct in the funcion, the problem is the entries
dont have values! i println the entries.size() and its 0. 


i add the entries like that:

 
private ScheduleModel model;

entry.setId(cod_cal);
	        entry.setStartTime(startTime);
	        entry.setEndTime(endTime);
	        entry.setTitle(title);
	        entry.setDescription(description);
	        
	   model.addEntry(entry);     
	     model.refresh();

i try delete like that:

ExtendedScheduleModel foo = new ExtendedScheduleModel();
 DefaultScheduleEntry entry = new DefaultScheduleEntry();
entry.setId("10");
		
foo.removeEntry(entry);

if i add the entries like that:


 private  ExtendedScheduleModel sss ;

               entry.setId(cod_cal);
	        entry.setStartTime(startTime);
	        entry.setEndTime(endTime);
	        entry.setTitle(title);
	        entry.setDescription(description);
	        
	     sss.addEntry(entry);
	     sss.refresh();

blank page...


Any sujection? Tks for all you are doing! 






Michał 'Gandalf' Stawicki wrote:
> 
> Right, it was fubar'ed, SimpleScheduleModel wasn't meant for extending
> :) This works - you use like you tried at the beginning - create
> entry, set id and you can remove it. BTW: I think your bean should be
> session, not request, unless you intended so.
> 
> /*
>  * Licensed to the Apache Software Foundation (ASF) under one
>  * or more contributor license agreements.  See the NOTICE file
>  * distributed with this work for additional information
>  * regarding copyright ownership.  The ASF licenses this file
>  * to you 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 ###########
> 
> import java.io.Serializable;
> 
> import java.text.DateFormat;
> import java.text.SimpleDateFormat;
> import java.util.ArrayList;
> import java.util.Collection;
> import java.util.Date;
> import java.util.HashMap;
> import java.util.Iterator;
> import java.util.TreeSet;
> import org.apache.myfaces.custom.schedule.model.AbstractScheduleModel;
> import org.apache.myfaces.custom.schedule.model.Day;
> import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
> import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
> 
> import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;
> 
> /**
>  * <p>
>  * A simple implementation of the ScheduleModel, not backed by any kind of
>  * datasource: entries have to be added manually.
>  * </p>
>  *
>  * @author Jurgen Lust (latest modification by $Author: werpu $)
>  * @version $Revision: 371736 $
>  */
> public class ExtendedScheduleModel extends AbstractScheduleModel
> implements Serializable
> {
> 	
> 	
> // TEST
> //	public static void main(String [] args)
> //	{
> //		ExtendedScheduleModel foo = new ExtendedScheduleModel();
> //		DefaultScheduleEntry bar = new DefaultScheduleEntry();
> //		bar.setId("1");
> //		foo.addEntry(bar);
> //		DefaultScheduleEntry bar2 = new DefaultScheduleEntry();
> //		bar2.setId("1");
> //
> //		foo.removeEntry(bar2);
> //	}
> 	
> 	
> 	private static final long serialVersionUID = 1L;
> 	protected final TreeSet entries;
> 	protected final HashMap holidays;
> 	protected final DateFormat holidayFormat = new
> SimpleDateFormat("yyyyMMdd");
> 	
> 	public ExtendedScheduleModel()
> 	{
> 		this.entries = new TreeSet(new ScheduleEntryComparator());
> 		this.holidays = new HashMap();
> 	}
> 	
> 	/**
> 	 * Set the name of a holiday.
> 	 *
> 	 * @param date
> 	 *            the date
> 	 * @param holidayName
> 	 *            the name of the holiday
> 	 */
> 	public void setHoliday(Date date, String holidayName)
> 	{
> 		if (date == null)
> 		{
> 			return;
> 		}
> 		
> 		String key = holidayFormat.format(date);
> 		holidays.put(key, holidayName);
> 	}
> 	
> 	/**
> 	 * Add an entry to the model.
> 	 *
> 	 * @param entry
> 	 *            the entry to add
> 	 */
> 	public void addEntry(ScheduleEntry entry)
> 	{
> 		entries.add(entry);
> 	}
> 	
> 	/**
> 	 * Remove an entry from the model.
> 	 *
> 	 * @param entry
> 	 *            the entry to remove
> 	 */
> 	public void removeEntry(ScheduleEntry entry)
> 	{
> 		if(entries.remove(entry))
> 			return;
> 		
> 		if(entry != null && entry.getId() != null)
> 			removeEntry(entry.getId());
> 	}
> 	
> 	/**
> 	 * @see
> org.apache.myfaces.custom.schedule.model.ScheduleModel#removeSelectedEntry()
> 	 */
> 	public void removeSelectedEntry()
> 	{
> 		if (!isEntrySelected())
> 			return;
> 		removeEntry(getSelectedEntry());
> 		setSelectedEntry(null);
> 		refresh();
> 	}
> 	
> 	/**
> 	 * @see
> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date,
> 	 *      java.util.Date)
> 	 */
> 	protected Collection loadEntries(Date startDate, Date endDate)
> 	{
> 		ArrayList selection = new ArrayList();
> 		
> 		for (Iterator entryIterator = entries.iterator(); entryIterator
> 				.hasNext();)
> 		{
> 			ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
> 			
> 			if (entry.getEndTime().before(startDate)
> 			|| entry.getStartTime().after(endDate))
> 			{
> 				continue;
> 			}
> 			
> 			selection.add(entry);
> 		}
> 		
> 		return selection;
> 	}
> 	
> 	/**
> 	 * @see
> org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadDayAttributes(org.apache.myfaces.custom.schedule.model.Day)
> 	 */
> 	protected void loadDayAttributes(Day day)
> 	{
> 		if (day == null)
> 			return;
> 		String key = holidayFormat.format(day.getDate());
> 		String holiday = (String) holidays.get(key);
> 		if (holiday != null)
> 		{
> 			day.setSpecialDayName(holiday);
> 			day.setWorkingDay(false);
> 		}
> 		else
> 		{
> 			day.setSpecialDayName(null);
> 			day.setWorkingDay(true);
> 		}
> 	}
> 	
> 	/**
> 	 * Remove entry from model
> 	 * <br /><br />
> 	 * @param id identifier of entry to be removed
> 	 * <br /><br />
> 	 * @return true on success and false on failure (in case entry with
> specified id wasn't found)
> 	 *
> 	 */
> 	protected boolean removeEntry(String id)
> 	{
> 		ScheduleEntry entry = null;
> 		String currentId = null;
> 		
> 		for(ScheduleEntry se : (TreeSet<ScheduleEntry>)entries)
> 		{
> 			if((currentId = se.getId()) != null && currentId.equals(id))
> 			{
> 				entry = se;
> 				break;
> 			}
> 		}
> 		
> 		if(entry != null)
> 		{
> 			entries.remove(entry);
> 			entry = null;
> 			
> 			return true;
> 		}
> 		
> 		return false;
> 	}
> }
> 
> 
> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>>
>> i have the class correct without errors. But when i call it  show a blank
>> page!
>>
>> ExtendedScheduleModel x = new ExtendedScheduleModel();
>> x.Remove2("8");
>>
>> I call the class like that. I think its correct! so why the blank page?
>> if i
>> put thouse two code lines in comments dont have the blank page, so the
>> problem is the class! :-((
>>
>>
>>
>>
>>
>>
>> Michał 'Gandalf' Stawicki wrote:
>> >
>> > Try this, remember to set valid package:
>> >
>> >  #####SET ME package #####SET ME
>> >
>> > import java.util.TreeSet;
>> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
>> > import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
>> >
>> > /**
>> >  * @author mstawick
>> >  */
>> > public class ExtendedScheduleModel extends SimpleScheduleModel
>> > {
>> >
>> >       /** Creates a new instance of ExtendedScheduleModel */
>> >       public ExtendedScheduleModel()
>> >       {
>> >               super();
>> >       }
>> >
>> >       /**
>> >        * Remove entry from model
>> >        * <br /><br />
>> >        * @param id identifier of entry to be removed
>> >        * <br /><br />
>> >        * @return true on success and false on failure (in case entry
>> with
>> > specified id wasn't found)
>> >        *
>> >        */
>> >       public boolean removeEntry(String id)
>> >       {
>> >               ScheduleEntry entry = null;
>> >               String currentId = null;
>> >
>> >               for(ScheduleEntry se : entries)
>> >               {
>> >                       if((currentId = se.getId()) != null &&
>> currentId.equals(id))
>> >                       {
>> >                               entry = se;
>> >                               break;
>> >                       }
>> >               }
>> >
>> >               if(entry != null)
>> >               {
>> >                       entries.remove(entry);
>> >                       entry = null;
>> >
>> >                       return true;
>> >               }
>> >
>> >               return false;
>> >       }
>> >
>> >       private TreeSet<ScheduleEntry> entries;
>> > }
>> >
>> >
>> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >>
>> >> Sorry to bee so boring and noob, but i realy need to do this, i need a
>> >> funcionality to show and occult calendars, and i have a entry
>> associate
>> >> to a
>> >> calendar, so when i need occult  the calendar i need to remove the
>> >> entries
>> >> of that calendar from the model. everything working, just need remove
>> the
>> >> entries.
>> >>
>> >>
>> >>
>> >> ignicolist wrote:
>> >> >
>> >> > Well i am a litle noob to all these, so i cant put your ideas to
>> work!
>> >> > :-((
>> >> >
>> >> > So i am using SimpleScheduleModel, so you say to create that class
>> in
>> >> the
>> >> > component Schedule or in my aplication?
>> >> > Because i create the class in my aplication and don´t work. Dam this
>> is
>> >> so
>> >> > complicated...
>> >> >
>> >> >
>> >> >
>> >> > Michał 'Gandalf' Stawicki wrote:
>> >> >>
>> >> >> I wrote the code in 'on the fly' just to give you idea how should
>> it
>> >> >> look, I didn't try it
>> >> >>
>> >> >> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
>> >> >>> Simply casting it should be fine:
>> >> >>>
>> >> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
>> >> >>>
>> >> >>>
>> >> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >>> >
>> >> >>> > I try what you say but give me a error in: for(ScheduleEntry e :
>> >> >>> entries)
>> >> >>> > The Error: Type mismatch: cannot convert from element type
>> Object
>> >> to
>> >> >>> > ScheduleEntry
>> >> >>> >
>> >> >>> > Any idea?
>> >> >>> >
>> >> >>> >
>> >> >>> >
>> >> >>> > Michał 'Gandalf' Stawicki wrote:
>> >> >>> > >
>> >> >>> > > From SimpleScheduleModel.java
>> >> >>> > >
>> >> >>> > >     /**
>> >> >>> > >      * Remove an entry from the model.
>> >> >>> > >      *
>> >> >>> > >      * @param entry
>> >> >>> > >      *            the entry to remove
>> >> >>> > >      */
>> >> >>> > >     public void removeEntry(ScheduleEntry entry)
>> >> >>> > >     {
>> >> >>> > >         entries.remove(entry);
>> >> >>> > >     }
>> >> >>> > >
>> >> >>> > > ...
>> >> >>> > >
>> >> >>> > >     private final TreeSet entries;
>> >> >>> > >
>> >> >>> > > I don't know which model your using, but if it is
>> >> >>> SimpleScheduleModel
>> >> >>> > > than you should extend it and implement your own method, ex;
>> >> >>> > >
>> >> >>> > > public boolean removeEntry(String id)
>> >> >>> > > {
>> >> >>> > > ScheduleEntry entry = null;
>> >> >>> > >
>> >> >>> > > if(entries != null && id != null)
>> >> >>> > > for(ScheduleEntry e : entries)
>> >> >>> > > {
>> >> >>> > > if(e.getId() != null && e.getId().equals(id))
>> >> >>> > > {
>> >> >>> > > entry = e;
>> >> >>> > > break;
>> >> >>> > > }
>> >> >>> > > }
>> >> >>> > >
>> >> >>> > > if(entry != null)
>> >> >>> > > {
>> >> >>> > > entries.remove(entry);
>> >> >>> > > return true;
>> >> >>> > > }
>> >> >>> > >
>> >> >>> > > return false;
>> >> >>> > > }
>> >> >>> > >
>> >> >>> > >
>> >> >>> > >
>> >> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
>> >> wrote:
>> >> >>> > >> I believe you have to pass exact reference to object that was
>> >> added
>> >> >>> to
>> >> >>> > >> schedule, not some other object containing same data,
>> example:
>> >> >>> > >>
>> >> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
>> >> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
>> >> >>> > >>
>> >> >>> > >> model.addEntry(foo);
>> >> >>> > >>
>> >> >>> > >> model.removeEntry(foo2); // wrong
>> >> >>> > >> mode.removeEntry(foo); //ok
>> >> >>> > >>
>> >> >>> > >>
>> >> >>> > >>
>> >> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >> >>> > >> >
>> >> >>> > >> > Yes, because the entry when i select it remove with
>> >> >>> > >> > model.removeSelectedEntry(); but if i specify his id:
>> >> >>> > >> entry.setId("1");
>> >> >>> > >> > model.removeEntry(entry); dont eliminate. And ids are the
>> same
>> >> in
>> >> >>> the
>> >> >>> > >> two
>> >> >>> > >> > situacions.
>> >> >>> > >> >
>> >> >>> > >> >
>> >> >>> > >> >
>> >> >>> > >> >
>> >> >>> > >> > Jurgen Lust-2 wrote:
>> >> >>> > >> > >
>> >> >>> > >> > > In your model implementation, do you load the persistent
>> >> entry
>> >> >>> from
>> >> >>> > >> the
>> >> >>> > >> > > database, using the supplied id, before you delete it?
>> >> >>> > >> > >
>> >> >>> > >> > > Jurgen
>> >> >>> > >> > >
>> >> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700],
>> >> schreef
>> >> >>> > >> > > ignicolist:
>> >> >>> > >> > >> Its what i am doing but don´t work!
>> >> >>> > >> > >>
>> >> >>> > >> > >> an example:
>> >> >>> > >> > >>
>> >> >>> > >> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> >> >>> > >> > >>
>> >> >>> > >> > >>   entry.setId("1");
>> >> >>> > >> > >>  model.removeEntry(entry);
>> >> >>> > >> > >>
>> >> >>> > >> > >> this code is supose to remove the entry from de model
>> with
>> >> id
>> >> >>> 1 no?
>> >> >>> > >> i
>> >> >>> > >> > >> just
>> >> >>> > >> > >> want remove de entry from the model, but a entry specify
>> by
>> >> >>> me.
>> >> >>> > >> > >>
>> >> >>> > >> > >>
>> >> >>> > >> > >>
>> >> >>> > >> > >>
>> >> >>> > >> > >>
>> >> >>> > >> > >> Jurgen Lust-2 wrote:
>> >> >>> > >> > >> >
>> >> >>> > >> > >> > The ScheduleModel.removeEntry() method expects a
>> >> >>> ScheduleEntry as
>> >> >>> > >> > >> > parameter. I suppose you use Hibernate for database
>> >> access,
>> >> >>> so
>> >> >>> > >> what you
>> >> >>> > >> > >> > should do is retrieve the ScheduleEntry from the
>> >> database,
>> >> >>> using
>> >> >>> > >> the
>> >> >>> > >> > >> id,
>> >> >>> > >> > >> > and feed the result to the removeEntry method. In that
>> >> >>> removeEntry
>> >> >>> > >> > >> > method, you just delete it with your Hibernate DAO.
>> >> >>> > >> > >> > You could of course add a method
>> >> >>> removeEntry(String/Long/Whatever
>> >> >>> > >> id)
>> >> >>> > >> > >> > that does all of this.
>> >> >>> > >> > >> >
>> >> >>> > >> > >> > Jurgen
>> >> >>> > >> > >> >
>> >> >>> > >> > >> >
>> >> >>> > >> > >> >
>> >> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700],
>> >> >>> schreef
>> >> >>> > >> > >> > ignicolist:
>> >> >>> > >> > >> >> Hi to all, i want to eliminate a especific entry in a
>> >> model
>> >> >>> of
>> >> >>> > >> > >> schedule
>> >> >>> > >> > >> >> tomahawk. the example in remove a selected entry work
>> >> fine,
>> >> >>> but
>> >> >>> > >> how to
>> >> >>> > >> > >> >> eliminate a determinated entry?
>> >> >>> > >> > >> >>
>> >> >>> > >> > >> >>
>> >> >>> > >> > >> >> i try with this code:
>> >> >>> > >> > >> >>
>> >> >>> > >> > >> >>
>> >> >>> > >> > >> >> DefaultScheduleEntry entry = new
>> DefaultScheduleEntry();
>> >> >>> > >> > >> >>
>> >> >>> > >> > >> >>  entry.setId(select);
>> >> >>> > >> > >> >>  entry.setStartTime(start);
>> >> >>> > >> > >> >>  entry.setEndTime(end);
>> >> >>> > >> > >> >>  entry.setTitle(select7);
>> >> >>> > >> > >> >>  entry.setDescription(select2);
>> >> >>> > >> > >> >>
>> >> >>> > >> > >> >>  model.removeEntry(entry);
>> >> >>> > >> > >> >>  model.refresh();
>> >> >>> > >> > >> >>
>> >> >>> > >> > >> >> i defined every value for the entry, and then i want
>> to
>> >> >>> remove
>> >> >>> > >> that
>> >> >>> > >> > >> >> entry!
>> >> >>> > >> > >> >> Any help please!
>> >> >>> > >> > >> >>
>> >> >>> > >> > >> >> Tks for all.
>> >> >>> > >> > >> > --
>> >> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
>> >> >>> > >> > >> >
>> >> >>> > >> > >> >
>> >> >>> > >> > >> >
>> >> >>> > >> > >>
>> >> >>> > >> > > --
>> >> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
>> >> >>> > >> > >
>> >> >>> > >> > >
>> >> >>> > >> > >
>> >> >>> > >> >
>> >> >>> > >> > --
>> >> >>> > >> > View this message in context:
>> >> >>> > >>
>> >> >>>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
>> >> >>> > >> > Sent from the MyFaces - Users mailing list archive at
>> >> Nabble.com.
>> >> >>> > >> >
>> >> >>> > >> >
>> >> >>> > >>
>> >> >>> > >>
>> >> >>> > >> --
>> >> >>> > >> Michał Stawicki
>> >> >>> > >>
>> >> >>> > >> stawicki@gmail.com
>> >> >>> > >> http://stawicki.jasliska.pl
>> >> >>> > >>
>> >> >>> > >
>> >> >>> > >
>> >> >>> > > --
>> >> >>> > > Michał Stawicki
>> >> >>> > >
>> >> >>> > > stawicki@gmail.com
>> >> >>> > > http://stawicki.jasliska.pl
>> >> >>> > >
>> >> >>> > >
>> >> >>> >
>> >> >>> > --
>> >> >>> > View this message in context:
>> >> >>>
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
>> >> >>> > Sent from the MyFaces - Users mailing list archive at
>> Nabble.com.
>> >> >>> >
>> >> >>> >
>> >> >>>
>> >> >>>
>> >> >>> --
>> >> >>> Michał Stawicki
>> >> >>>
>> >> >>> stawicki@gmail.com
>> >> >>> http://stawicki.jasliska.pl
>> >> >>>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> Michał Stawicki
>> >> >>
>> >> >> stawicki@gmail.com
>> >> >> http://stawicki.jasliska.pl
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>> > --
>> > Michał Stawicki
>> >
>> > stawicki@gmail.com
>> > http://stawicki.jasliska.pl
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12206017
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Michał Stawicki
> 
> stawicki@gmail.com
> http://stawicki.jasliska.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12209467
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by Michał 'Gandalf' Stawicki <st...@gmail.com>.
Right, it was fubar'ed, SimpleScheduleModel wasn't meant for extending
:) This works - you use like you tried at the beginning - create
entry, set id and you can remove it. BTW: I think your bean should be
session, not request, unless you intended so.

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 ###########

import java.io.Serializable;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.TreeSet;
import org.apache.myfaces.custom.schedule.model.AbstractScheduleModel;
import org.apache.myfaces.custom.schedule.model.Day;
import org.apache.myfaces.custom.schedule.model.DefaultScheduleEntry;
import org.apache.myfaces.custom.schedule.model.ScheduleEntry;

import org.apache.myfaces.custom.schedule.util.ScheduleEntryComparator;

/**
 * <p>
 * A simple implementation of the ScheduleModel, not backed by any kind of
 * datasource: entries have to be added manually.
 * </p>
 *
 * @author Jurgen Lust (latest modification by $Author: werpu $)
 * @version $Revision: 371736 $
 */
public class ExtendedScheduleModel extends AbstractScheduleModel
implements Serializable
{
	
	
// TEST
//	public static void main(String [] args)
//	{
//		ExtendedScheduleModel foo = new ExtendedScheduleModel();
//		DefaultScheduleEntry bar = new DefaultScheduleEntry();
//		bar.setId("1");
//		foo.addEntry(bar);
//		DefaultScheduleEntry bar2 = new DefaultScheduleEntry();
//		bar2.setId("1");
//
//		foo.removeEntry(bar2);
//	}
	
	
	private static final long serialVersionUID = 1L;
	protected final TreeSet entries;
	protected final HashMap holidays;
	protected final DateFormat holidayFormat = new SimpleDateFormat("yyyyMMdd");
	
	public ExtendedScheduleModel()
	{
		this.entries = new TreeSet(new ScheduleEntryComparator());
		this.holidays = new HashMap();
	}
	
	/**
	 * Set the name of a holiday.
	 *
	 * @param date
	 *            the date
	 * @param holidayName
	 *            the name of the holiday
	 */
	public void setHoliday(Date date, String holidayName)
	{
		if (date == null)
		{
			return;
		}
		
		String key = holidayFormat.format(date);
		holidays.put(key, holidayName);
	}
	
	/**
	 * Add an entry to the model.
	 *
	 * @param entry
	 *            the entry to add
	 */
	public void addEntry(ScheduleEntry entry)
	{
		entries.add(entry);
	}
	
	/**
	 * Remove an entry from the model.
	 *
	 * @param entry
	 *            the entry to remove
	 */
	public void removeEntry(ScheduleEntry entry)
	{
		if(entries.remove(entry))
			return;
		
		if(entry != null && entry.getId() != null)
			removeEntry(entry.getId());
	}
	
	/**
	 * @see org.apache.myfaces.custom.schedule.model.ScheduleModel#removeSelectedEntry()
	 */
	public void removeSelectedEntry()
	{
		if (!isEntrySelected())
			return;
		removeEntry(getSelectedEntry());
		setSelectedEntry(null);
		refresh();
	}
	
	/**
	 * @see org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadEntries(java.util.Date,
	 *      java.util.Date)
	 */
	protected Collection loadEntries(Date startDate, Date endDate)
	{
		ArrayList selection = new ArrayList();
		
		for (Iterator entryIterator = entries.iterator(); entryIterator
				.hasNext();)
		{
			ScheduleEntry entry = (ScheduleEntry) entryIterator.next();
			
			if (entry.getEndTime().before(startDate)
			|| entry.getStartTime().after(endDate))
			{
				continue;
			}
			
			selection.add(entry);
		}
		
		return selection;
	}
	
	/**
	 * @see org.apache.myfaces.custom.schedule.model.AbstractScheduleModel#loadDayAttributes(org.apache.myfaces.custom.schedule.model.Day)
	 */
	protected void loadDayAttributes(Day day)
	{
		if (day == null)
			return;
		String key = holidayFormat.format(day.getDate());
		String holiday = (String) holidays.get(key);
		if (holiday != null)
		{
			day.setSpecialDayName(holiday);
			day.setWorkingDay(false);
		}
		else
		{
			day.setSpecialDayName(null);
			day.setWorkingDay(true);
		}
	}
	
	/**
	 * Remove entry from model
	 * <br /><br />
	 * @param <b>id</b> identifier of entry to be removed
	 * <br /><br />
	 * @return true on success and false on failure (in case entry with
specified id wasn't found)
	 *
	 */
	protected boolean removeEntry(String id)
	{
		ScheduleEntry entry = null;
		String currentId = null;
		
		for(ScheduleEntry se : (TreeSet<ScheduleEntry>)entries)
		{
			if((currentId = se.getId()) != null && currentId.equals(id))
			{
				entry = se;
				break;
			}
		}
		
		if(entry != null)
		{
			entries.remove(entry);
			entry = null;
			
			return true;
		}
		
		return false;
	}
}


On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>
> i have the class correct without errors. But when i call it  show a blank
> page!
>
> ExtendedScheduleModel x = new ExtendedScheduleModel();
> x.Remove2("8");
>
> I call the class like that. I think its correct! so why the blank page? if i
> put thouse two code lines in comments dont have the blank page, so the
> problem is the class! :-((
>
>
>
>
>
>
> Michał 'Gandalf' Stawicki wrote:
> >
> > Try this, remember to set valid package:
> >
> >  #####SET ME package #####SET ME
> >
> > import java.util.TreeSet;
> > import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
> > import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> >
> > /**
> >  * @author mstawick
> >  */
> > public class ExtendedScheduleModel extends SimpleScheduleModel
> > {
> >
> >       /** Creates a new instance of ExtendedScheduleModel */
> >       public ExtendedScheduleModel()
> >       {
> >               super();
> >       }
> >
> >       /**
> >        * Remove entry from model
> >        * <br /><br />
> >        * @param id identifier of entry to be removed
> >        * <br /><br />
> >        * @return true on success and false on failure (in case entry with
> > specified id wasn't found)
> >        *
> >        */
> >       public boolean removeEntry(String id)
> >       {
> >               ScheduleEntry entry = null;
> >               String currentId = null;
> >
> >               for(ScheduleEntry se : entries)
> >               {
> >                       if((currentId = se.getId()) != null && currentId.equals(id))
> >                       {
> >                               entry = se;
> >                               break;
> >                       }
> >               }
> >
> >               if(entry != null)
> >               {
> >                       entries.remove(entry);
> >                       entry = null;
> >
> >                       return true;
> >               }
> >
> >               return false;
> >       }
> >
> >       private TreeSet<ScheduleEntry> entries;
> > }
> >
> >
> > On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >>
> >> Sorry to bee so boring and noob, but i realy need to do this, i need a
> >> funcionality to show and occult calendars, and i have a entry associate
> >> to a
> >> calendar, so when i need occult  the calendar i need to remove the
> >> entries
> >> of that calendar from the model. everything working, just need remove the
> >> entries.
> >>
> >>
> >>
> >> ignicolist wrote:
> >> >
> >> > Well i am a litle noob to all these, so i cant put your ideas to work!
> >> > :-((
> >> >
> >> > So i am using SimpleScheduleModel, so you say to create that class in
> >> the
> >> > component Schedule or in my aplication?
> >> > Because i create the class in my aplication and don´t work. Dam this is
> >> so
> >> > complicated...
> >> >
> >> >
> >> >
> >> > Michał 'Gandalf' Stawicki wrote:
> >> >>
> >> >> I wrote the code in 'on the fly' just to give you idea how should it
> >> >> look, I didn't try it
> >> >>
> >> >> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
> >> >>> Simply casting it should be fine:
> >> >>>
> >> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
> >> >>>
> >> >>>
> >> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >>> >
> >> >>> > I try what you say but give me a error in: for(ScheduleEntry e :
> >> >>> entries)
> >> >>> > The Error: Type mismatch: cannot convert from element type Object
> >> to
> >> >>> > ScheduleEntry
> >> >>> >
> >> >>> > Any idea?
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> > Michał 'Gandalf' Stawicki wrote:
> >> >>> > >
> >> >>> > > From SimpleScheduleModel.java
> >> >>> > >
> >> >>> > >     /**
> >> >>> > >      * Remove an entry from the model.
> >> >>> > >      *
> >> >>> > >      * @param entry
> >> >>> > >      *            the entry to remove
> >> >>> > >      */
> >> >>> > >     public void removeEntry(ScheduleEntry entry)
> >> >>> > >     {
> >> >>> > >         entries.remove(entry);
> >> >>> > >     }
> >> >>> > >
> >> >>> > > ...
> >> >>> > >
> >> >>> > >     private final TreeSet entries;
> >> >>> > >
> >> >>> > > I don't know which model your using, but if it is
> >> >>> SimpleScheduleModel
> >> >>> > > than you should extend it and implement your own method, ex;
> >> >>> > >
> >> >>> > > public boolean removeEntry(String id)
> >> >>> > > {
> >> >>> > > ScheduleEntry entry = null;
> >> >>> > >
> >> >>> > > if(entries != null && id != null)
> >> >>> > > for(ScheduleEntry e : entries)
> >> >>> > > {
> >> >>> > > if(e.getId() != null && e.getId().equals(id))
> >> >>> > > {
> >> >>> > > entry = e;
> >> >>> > > break;
> >> >>> > > }
> >> >>> > > }
> >> >>> > >
> >> >>> > > if(entry != null)
> >> >>> > > {
> >> >>> > > entries.remove(entry);
> >> >>> > > return true;
> >> >>> > > }
> >> >>> > >
> >> >>> > > return false;
> >> >>> > > }
> >> >>> > >
> >> >>> > >
> >> >>> > >
> >> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
> >> wrote:
> >> >>> > >> I believe you have to pass exact reference to object that was
> >> added
> >> >>> to
> >> >>> > >> schedule, not some other object containing same data, example:
> >> >>> > >>
> >> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
> >> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
> >> >>> > >>
> >> >>> > >> model.addEntry(foo);
> >> >>> > >>
> >> >>> > >> model.removeEntry(foo2); // wrong
> >> >>> > >> mode.removeEntry(foo); //ok
> >> >>> > >>
> >> >>> > >>
> >> >>> > >>
> >> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >>> > >> >
> >> >>> > >> > Yes, because the entry when i select it remove with
> >> >>> > >> > model.removeSelectedEntry(); but if i specify his id:
> >> >>> > >> entry.setId("1");
> >> >>> > >> > model.removeEntry(entry); dont eliminate. And ids are the same
> >> in
> >> >>> the
> >> >>> > >> two
> >> >>> > >> > situacions.
> >> >>> > >> >
> >> >>> > >> >
> >> >>> > >> >
> >> >>> > >> >
> >> >>> > >> > Jurgen Lust-2 wrote:
> >> >>> > >> > >
> >> >>> > >> > > In your model implementation, do you load the persistent
> >> entry
> >> >>> from
> >> >>> > >> the
> >> >>> > >> > > database, using the supplied id, before you delete it?
> >> >>> > >> > >
> >> >>> > >> > > Jurgen
> >> >>> > >> > >
> >> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700],
> >> schreef
> >> >>> > >> > > ignicolist:
> >> >>> > >> > >> Its what i am doing but don´t work!
> >> >>> > >> > >>
> >> >>> > >> > >> an example:
> >> >>> > >> > >>
> >> >>> > >> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >> >>> > >> > >>
> >> >>> > >> > >>   entry.setId("1");
> >> >>> > >> > >>  model.removeEntry(entry);
> >> >>> > >> > >>
> >> >>> > >> > >> this code is supose to remove the entry from de model with
> >> id
> >> >>> 1 no?
> >> >>> > >> i
> >> >>> > >> > >> just
> >> >>> > >> > >> want remove de entry from the model, but a entry specify by
> >> >>> me.
> >> >>> > >> > >>
> >> >>> > >> > >>
> >> >>> > >> > >>
> >> >>> > >> > >>
> >> >>> > >> > >>
> >> >>> > >> > >> Jurgen Lust-2 wrote:
> >> >>> > >> > >> >
> >> >>> > >> > >> > The ScheduleModel.removeEntry() method expects a
> >> >>> ScheduleEntry as
> >> >>> > >> > >> > parameter. I suppose you use Hibernate for database
> >> access,
> >> >>> so
> >> >>> > >> what you
> >> >>> > >> > >> > should do is retrieve the ScheduleEntry from the
> >> database,
> >> >>> using
> >> >>> > >> the
> >> >>> > >> > >> id,
> >> >>> > >> > >> > and feed the result to the removeEntry method. In that
> >> >>> removeEntry
> >> >>> > >> > >> > method, you just delete it with your Hibernate DAO.
> >> >>> > >> > >> > You could of course add a method
> >> >>> removeEntry(String/Long/Whatever
> >> >>> > >> id)
> >> >>> > >> > >> > that does all of this.
> >> >>> > >> > >> >
> >> >>> > >> > >> > Jurgen
> >> >>> > >> > >> >
> >> >>> > >> > >> >
> >> >>> > >> > >> >
> >> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700],
> >> >>> schreef
> >> >>> > >> > >> > ignicolist:
> >> >>> > >> > >> >> Hi to all, i want to eliminate a especific entry in a
> >> model
> >> >>> of
> >> >>> > >> > >> schedule
> >> >>> > >> > >> >> tomahawk. the example in remove a selected entry work
> >> fine,
> >> >>> but
> >> >>> > >> how to
> >> >>> > >> > >> >> eliminate a determinated entry?
> >> >>> > >> > >> >>
> >> >>> > >> > >> >>
> >> >>> > >> > >> >> i try with this code:
> >> >>> > >> > >> >>
> >> >>> > >> > >> >>
> >> >>> > >> > >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >> >>> > >> > >> >>
> >> >>> > >> > >> >>  entry.setId(select);
> >> >>> > >> > >> >>  entry.setStartTime(start);
> >> >>> > >> > >> >>  entry.setEndTime(end);
> >> >>> > >> > >> >>  entry.setTitle(select7);
> >> >>> > >> > >> >>  entry.setDescription(select2);
> >> >>> > >> > >> >>
> >> >>> > >> > >> >>  model.removeEntry(entry);
> >> >>> > >> > >> >>  model.refresh();
> >> >>> > >> > >> >>
> >> >>> > >> > >> >> i defined every value for the entry, and then i want to
> >> >>> remove
> >> >>> > >> that
> >> >>> > >> > >> >> entry!
> >> >>> > >> > >> >> Any help please!
> >> >>> > >> > >> >>
> >> >>> > >> > >> >> Tks for all.
> >> >>> > >> > >> > --
> >> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
> >> >>> > >> > >> >
> >> >>> > >> > >> >
> >> >>> > >> > >> >
> >> >>> > >> > >>
> >> >>> > >> > > --
> >> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
> >> >>> > >> > >
> >> >>> > >> > >
> >> >>> > >> > >
> >> >>> > >> >
> >> >>> > >> > --
> >> >>> > >> > View this message in context:
> >> >>> > >>
> >> >>>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
> >> >>> > >> > Sent from the MyFaces - Users mailing list archive at
> >> Nabble.com.
> >> >>> > >> >
> >> >>> > >> >
> >> >>> > >>
> >> >>> > >>
> >> >>> > >> --
> >> >>> > >> Michał Stawicki
> >> >>> > >>
> >> >>> > >> stawicki@gmail.com
> >> >>> > >> http://stawicki.jasliska.pl
> >> >>> > >>
> >> >>> > >
> >> >>> > >
> >> >>> > > --
> >> >>> > > Michał Stawicki
> >> >>> > >
> >> >>> > > stawicki@gmail.com
> >> >>> > > http://stawicki.jasliska.pl
> >> >>> > >
> >> >>> > >
> >> >>> >
> >> >>> > --
> >> >>> > View this message in context:
> >> >>>
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
> >> >>> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >> >>> >
> >> >>> >
> >> >>>
> >> >>>
> >> >>> --
> >> >>> Michał Stawicki
> >> >>>
> >> >>> stawicki@gmail.com
> >> >>> http://stawicki.jasliska.pl
> >> >>>
> >> >>
> >> >>
> >> >> --
> >> >> Michał Stawicki
> >> >>
> >> >> stawicki@gmail.com
> >> >> http://stawicki.jasliska.pl
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Michał Stawicki
> >
> > stawicki@gmail.com
> > http://stawicki.jasliska.pl
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12206017
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
Michał Stawicki

stawicki@gmail.com
http://stawicki.jasliska.pl

Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
i have the class correct without errors. But when i call it  show a blank
page! 

ExtendedScheduleModel x = new ExtendedScheduleModel();
x.Remove2("8");

I call the class like that. I think its correct! so why the blank page? if i
put thouse two code lines in comments dont have the blank page, so the
problem is the class! :-((






Michał 'Gandalf' Stawicki wrote:
> 
> Try this, remember to set valid package:
> 
>  #####SET ME package #####SET ME
> 
> import java.util.TreeSet;
> import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
> import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> 
> /**
>  * @author mstawick
>  */
> public class ExtendedScheduleModel extends SimpleScheduleModel
> {
> 	
> 	/** Creates a new instance of ExtendedScheduleModel */
> 	public ExtendedScheduleModel()
> 	{
> 		super();
> 	}
> 	
> 	/**
> 	 * Remove entry from model
> 	 * <br /><br />
> 	 * @param id identifier of entry to be removed
> 	 * <br /><br />
> 	 * @return true on success and false on failure (in case entry with
> specified id wasn't found)
> 	 *
> 	 */
> 	public boolean removeEntry(String id)
> 	{
> 		ScheduleEntry entry = null;
> 		String currentId = null;
> 		
> 		for(ScheduleEntry se : entries)
> 		{
> 			if((currentId = se.getId()) != null && currentId.equals(id))
> 			{
> 				entry = se;
> 				break;
> 			}
> 		}
> 		
> 		if(entry != null)
> 		{
> 			entries.remove(entry);
> 			entry = null;
> 			
> 			return true;
> 		}
> 		
> 		return false;
> 	}
> 	
> 	private TreeSet<ScheduleEntry> entries;
> }
> 
> 
> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>>
>> Sorry to bee so boring and noob, but i realy need to do this, i need a
>> funcionality to show and occult calendars, and i have a entry associate
>> to a
>> calendar, so when i need occult  the calendar i need to remove the
>> entries
>> of that calendar from the model. everything working, just need remove the
>> entries.
>>
>>
>>
>> ignicolist wrote:
>> >
>> > Well i am a litle noob to all these, so i cant put your ideas to work!
>> > :-((
>> >
>> > So i am using SimpleScheduleModel, so you say to create that class in
>> the
>> > component Schedule or in my aplication?
>> > Because i create the class in my aplication and don´t work. Dam this is
>> so
>> > complicated...
>> >
>> >
>> >
>> > Michał 'Gandalf' Stawicki wrote:
>> >>
>> >> I wrote the code in 'on the fly' just to give you idea how should it
>> >> look, I didn't try it
>> >>
>> >> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
>> >>> Simply casting it should be fine:
>> >>>
>> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
>> >>>
>> >>>
>> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >>> >
>> >>> > I try what you say but give me a error in: for(ScheduleEntry e :
>> >>> entries)
>> >>> > The Error: Type mismatch: cannot convert from element type Object
>> to
>> >>> > ScheduleEntry
>> >>> >
>> >>> > Any idea?
>> >>> >
>> >>> >
>> >>> >
>> >>> > Michał 'Gandalf' Stawicki wrote:
>> >>> > >
>> >>> > > From SimpleScheduleModel.java
>> >>> > >
>> >>> > >     /**
>> >>> > >      * Remove an entry from the model.
>> >>> > >      *
>> >>> > >      * @param entry
>> >>> > >      *            the entry to remove
>> >>> > >      */
>> >>> > >     public void removeEntry(ScheduleEntry entry)
>> >>> > >     {
>> >>> > >         entries.remove(entry);
>> >>> > >     }
>> >>> > >
>> >>> > > ...
>> >>> > >
>> >>> > >     private final TreeSet entries;
>> >>> > >
>> >>> > > I don't know which model your using, but if it is
>> >>> SimpleScheduleModel
>> >>> > > than you should extend it and implement your own method, ex;
>> >>> > >
>> >>> > > public boolean removeEntry(String id)
>> >>> > > {
>> >>> > > ScheduleEntry entry = null;
>> >>> > >
>> >>> > > if(entries != null && id != null)
>> >>> > > for(ScheduleEntry e : entries)
>> >>> > > {
>> >>> > > if(e.getId() != null && e.getId().equals(id))
>> >>> > > {
>> >>> > > entry = e;
>> >>> > > break;
>> >>> > > }
>> >>> > > }
>> >>> > >
>> >>> > > if(entry != null)
>> >>> > > {
>> >>> > > entries.remove(entry);
>> >>> > > return true;
>> >>> > > }
>> >>> > >
>> >>> > > return false;
>> >>> > > }
>> >>> > >
>> >>> > >
>> >>> > >
>> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
>> wrote:
>> >>> > >> I believe you have to pass exact reference to object that was
>> added
>> >>> to
>> >>> > >> schedule, not some other object containing same data, example:
>> >>> > >>
>> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
>> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
>> >>> > >>
>> >>> > >> model.addEntry(foo);
>> >>> > >>
>> >>> > >> model.removeEntry(foo2); // wrong
>> >>> > >> mode.removeEntry(foo); //ok
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >>> > >> >
>> >>> > >> > Yes, because the entry when i select it remove with
>> >>> > >> > model.removeSelectedEntry(); but if i specify his id:
>> >>> > >> entry.setId("1");
>> >>> > >> > model.removeEntry(entry); dont eliminate. And ids are the same
>> in
>> >>> the
>> >>> > >> two
>> >>> > >> > situacions.
>> >>> > >> >
>> >>> > >> >
>> >>> > >> >
>> >>> > >> >
>> >>> > >> > Jurgen Lust-2 wrote:
>> >>> > >> > >
>> >>> > >> > > In your model implementation, do you load the persistent
>> entry
>> >>> from
>> >>> > >> the
>> >>> > >> > > database, using the supplied id, before you delete it?
>> >>> > >> > >
>> >>> > >> > > Jurgen
>> >>> > >> > >
>> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700],
>> schreef
>> >>> > >> > > ignicolist:
>> >>> > >> > >> Its what i am doing but don´t work!
>> >>> > >> > >>
>> >>> > >> > >> an example:
>> >>> > >> > >>
>> >>> > >> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> >>> > >> > >>
>> >>> > >> > >>   entry.setId("1");
>> >>> > >> > >>  model.removeEntry(entry);
>> >>> > >> > >>
>> >>> > >> > >> this code is supose to remove the entry from de model with
>> id
>> >>> 1 no?
>> >>> > >> i
>> >>> > >> > >> just
>> >>> > >> > >> want remove de entry from the model, but a entry specify by
>> >>> me.
>> >>> > >> > >>
>> >>> > >> > >>
>> >>> > >> > >>
>> >>> > >> > >>
>> >>> > >> > >>
>> >>> > >> > >> Jurgen Lust-2 wrote:
>> >>> > >> > >> >
>> >>> > >> > >> > The ScheduleModel.removeEntry() method expects a
>> >>> ScheduleEntry as
>> >>> > >> > >> > parameter. I suppose you use Hibernate for database
>> access,
>> >>> so
>> >>> > >> what you
>> >>> > >> > >> > should do is retrieve the ScheduleEntry from the
>> database,
>> >>> using
>> >>> > >> the
>> >>> > >> > >> id,
>> >>> > >> > >> > and feed the result to the removeEntry method. In that
>> >>> removeEntry
>> >>> > >> > >> > method, you just delete it with your Hibernate DAO.
>> >>> > >> > >> > You could of course add a method
>> >>> removeEntry(String/Long/Whatever
>> >>> > >> id)
>> >>> > >> > >> > that does all of this.
>> >>> > >> > >> >
>> >>> > >> > >> > Jurgen
>> >>> > >> > >> >
>> >>> > >> > >> >
>> >>> > >> > >> >
>> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700],
>> >>> schreef
>> >>> > >> > >> > ignicolist:
>> >>> > >> > >> >> Hi to all, i want to eliminate a especific entry in a
>> model
>> >>> of
>> >>> > >> > >> schedule
>> >>> > >> > >> >> tomahawk. the example in remove a selected entry work
>> fine,
>> >>> but
>> >>> > >> how to
>> >>> > >> > >> >> eliminate a determinated entry?
>> >>> > >> > >> >>
>> >>> > >> > >> >>
>> >>> > >> > >> >> i try with this code:
>> >>> > >> > >> >>
>> >>> > >> > >> >>
>> >>> > >> > >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> >>> > >> > >> >>
>> >>> > >> > >> >>  entry.setId(select);
>> >>> > >> > >> >>  entry.setStartTime(start);
>> >>> > >> > >> >>  entry.setEndTime(end);
>> >>> > >> > >> >>  entry.setTitle(select7);
>> >>> > >> > >> >>  entry.setDescription(select2);
>> >>> > >> > >> >>
>> >>> > >> > >> >>  model.removeEntry(entry);
>> >>> > >> > >> >>  model.refresh();
>> >>> > >> > >> >>
>> >>> > >> > >> >> i defined every value for the entry, and then i want to
>> >>> remove
>> >>> > >> that
>> >>> > >> > >> >> entry!
>> >>> > >> > >> >> Any help please!
>> >>> > >> > >> >>
>> >>> > >> > >> >> Tks for all.
>> >>> > >> > >> > --
>> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
>> >>> > >> > >> >
>> >>> > >> > >> >
>> >>> > >> > >> >
>> >>> > >> > >>
>> >>> > >> > > --
>> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
>> >>> > >> > >
>> >>> > >> > >
>> >>> > >> > >
>> >>> > >> >
>> >>> > >> > --
>> >>> > >> > View this message in context:
>> >>> > >>
>> >>>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
>> >>> > >> > Sent from the MyFaces - Users mailing list archive at
>> Nabble.com.
>> >>> > >> >
>> >>> > >> >
>> >>> > >>
>> >>> > >>
>> >>> > >> --
>> >>> > >> Michał Stawicki
>> >>> > >>
>> >>> > >> stawicki@gmail.com
>> >>> > >> http://stawicki.jasliska.pl
>> >>> > >>
>> >>> > >
>> >>> > >
>> >>> > > --
>> >>> > > Michał Stawicki
>> >>> > >
>> >>> > > stawicki@gmail.com
>> >>> > > http://stawicki.jasliska.pl
>> >>> > >
>> >>> > >
>> >>> >
>> >>> > --
>> >>> > View this message in context:
>> >>>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
>> >>> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>> --
>> >>> Michał Stawicki
>> >>>
>> >>> stawicki@gmail.com
>> >>> http://stawicki.jasliska.pl
>> >>>
>> >>
>> >>
>> >> --
>> >> Michał Stawicki
>> >>
>> >> stawicki@gmail.com
>> >> http://stawicki.jasliska.pl
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Michał Stawicki
> 
> stawicki@gmail.com
> http://stawicki.jasliska.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12206017
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
I do that cllass, and dont give erros, but in the aplication when a call that
class it show me a blank page!

i am calling my class like that :  <h:commandLink 
action="#{remove.Remove2}" >
			                <h:outputText value="Mostrar/Ocultar" />		
			                </h:commandLink>
                                        <h:message for="mostrar" />


and the conf.xml:  <managed-bean>
                         <managed-bean-name>remove</managed-bean-name>
           
<managed-bean-class>org.apache.myfaces.examples.schedule.Remove</managed-bean-class>
                         <managed-bean-scope>request</managed-bean-scope>
                         </managed-bean>  


And the class:

package org.apache.myfaces.examples.schedule;

import java.util.TreeSet;
import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;

public class Remove extends SimpleScheduleModel  {
	
	 public Remove()
	    {
		 super(); 
      
	    }

	 public boolean Remove2(){
		 ScheduleEntry entry = null;
         String currentId = null;
        
         String id="8";
         
         for(ScheduleEntry se : entries)
         {
                 if((currentId = se.getId()) != null &&
currentId.equals(id))
                 {
                         entry = se;
                         break;
                 }
         }
        
         if(entry != null)
         {
                 entries.remove(entry);
                 entry = null;
                
                 return true;
         }
        
         return false; 
         }
	 private TreeSet<ScheduleEntry> entries; 
}





Michał 'Gandalf' Stawicki wrote:
> 
> Try this, remember to set valid package:
> 
>  #####SET ME package #####SET ME
> 
> import java.util.TreeSet;
> import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
> import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;
> 
> /**
>  * @author mstawick
>  */
> public class ExtendedScheduleModel extends SimpleScheduleModel
> {
> 	
> 	/** Creates a new instance of ExtendedScheduleModel */
> 	public ExtendedScheduleModel()
> 	{
> 		super();
> 	}
> 	
> 	/**
> 	 * Remove entry from model
> 	 * <br /><br />
> 	 * @param id identifier of entry to be removed
> 	 * <br /><br />
> 	 * @return true on success and false on failure (in case entry with
> specified id wasn't found)
> 	 *
> 	 */
> 	public boolean removeEntry(String id)
> 	{
> 		ScheduleEntry entry = null;
> 		String currentId = null;
> 		
> 		for(ScheduleEntry se : entries)
> 		{
> 			if((currentId = se.getId()) != null && currentId.equals(id))
> 			{
> 				entry = se;
> 				break;
> 			}
> 		}
> 		
> 		if(entry != null)
> 		{
> 			entries.remove(entry);
> 			entry = null;
> 			
> 			return true;
> 		}
> 		
> 		return false;
> 	}
> 	
> 	private TreeSet<ScheduleEntry> entries;
> }
> 
> 
> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>>
>> Sorry to bee so boring and noob, but i realy need to do this, i need a
>> funcionality to show and occult calendars, and i have a entry associate
>> to a
>> calendar, so when i need occult  the calendar i need to remove the
>> entries
>> of that calendar from the model. everything working, just need remove the
>> entries.
>>
>>
>>
>> ignicolist wrote:
>> >
>> > Well i am a litle noob to all these, so i cant put your ideas to work!
>> > :-((
>> >
>> > So i am using SimpleScheduleModel, so you say to create that class in
>> the
>> > component Schedule or in my aplication?
>> > Because i create the class in my aplication and don´t work. Dam this is
>> so
>> > complicated...
>> >
>> >
>> >
>> > Michał 'Gandalf' Stawicki wrote:
>> >>
>> >> I wrote the code in 'on the fly' just to give you idea how should it
>> >> look, I didn't try it
>> >>
>> >> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
>> >>> Simply casting it should be fine:
>> >>>
>> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
>> >>>
>> >>>
>> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >>> >
>> >>> > I try what you say but give me a error in: for(ScheduleEntry e :
>> >>> entries)
>> >>> > The Error: Type mismatch: cannot convert from element type Object
>> to
>> >>> > ScheduleEntry
>> >>> >
>> >>> > Any idea?
>> >>> >
>> >>> >
>> >>> >
>> >>> > Michał 'Gandalf' Stawicki wrote:
>> >>> > >
>> >>> > > From SimpleScheduleModel.java
>> >>> > >
>> >>> > >     /**
>> >>> > >      * Remove an entry from the model.
>> >>> > >      *
>> >>> > >      * @param entry
>> >>> > >      *            the entry to remove
>> >>> > >      */
>> >>> > >     public void removeEntry(ScheduleEntry entry)
>> >>> > >     {
>> >>> > >         entries.remove(entry);
>> >>> > >     }
>> >>> > >
>> >>> > > ...
>> >>> > >
>> >>> > >     private final TreeSet entries;
>> >>> > >
>> >>> > > I don't know which model your using, but if it is
>> >>> SimpleScheduleModel
>> >>> > > than you should extend it and implement your own method, ex;
>> >>> > >
>> >>> > > public boolean removeEntry(String id)
>> >>> > > {
>> >>> > > ScheduleEntry entry = null;
>> >>> > >
>> >>> > > if(entries != null && id != null)
>> >>> > > for(ScheduleEntry e : entries)
>> >>> > > {
>> >>> > > if(e.getId() != null && e.getId().equals(id))
>> >>> > > {
>> >>> > > entry = e;
>> >>> > > break;
>> >>> > > }
>> >>> > > }
>> >>> > >
>> >>> > > if(entry != null)
>> >>> > > {
>> >>> > > entries.remove(entry);
>> >>> > > return true;
>> >>> > > }
>> >>> > >
>> >>> > > return false;
>> >>> > > }
>> >>> > >
>> >>> > >
>> >>> > >
>> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com>
>> wrote:
>> >>> > >> I believe you have to pass exact reference to object that was
>> added
>> >>> to
>> >>> > >> schedule, not some other object containing same data, example:
>> >>> > >>
>> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
>> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
>> >>> > >>
>> >>> > >> model.addEntry(foo);
>> >>> > >>
>> >>> > >> model.removeEntry(foo2); // wrong
>> >>> > >> mode.removeEntry(foo); //ok
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >>> > >> >
>> >>> > >> > Yes, because the entry when i select it remove with
>> >>> > >> > model.removeSelectedEntry(); but if i specify his id:
>> >>> > >> entry.setId("1");
>> >>> > >> > model.removeEntry(entry); dont eliminate. And ids are the same
>> in
>> >>> the
>> >>> > >> two
>> >>> > >> > situacions.
>> >>> > >> >
>> >>> > >> >
>> >>> > >> >
>> >>> > >> >
>> >>> > >> > Jurgen Lust-2 wrote:
>> >>> > >> > >
>> >>> > >> > > In your model implementation, do you load the persistent
>> entry
>> >>> from
>> >>> > >> the
>> >>> > >> > > database, using the supplied id, before you delete it?
>> >>> > >> > >
>> >>> > >> > > Jurgen
>> >>> > >> > >
>> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700],
>> schreef
>> >>> > >> > > ignicolist:
>> >>> > >> > >> Its what i am doing but don´t work!
>> >>> > >> > >>
>> >>> > >> > >> an example:
>> >>> > >> > >>
>> >>> > >> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> >>> > >> > >>
>> >>> > >> > >>   entry.setId("1");
>> >>> > >> > >>  model.removeEntry(entry);
>> >>> > >> > >>
>> >>> > >> > >> this code is supose to remove the entry from de model with
>> id
>> >>> 1 no?
>> >>> > >> i
>> >>> > >> > >> just
>> >>> > >> > >> want remove de entry from the model, but a entry specify by
>> >>> me.
>> >>> > >> > >>
>> >>> > >> > >>
>> >>> > >> > >>
>> >>> > >> > >>
>> >>> > >> > >>
>> >>> > >> > >> Jurgen Lust-2 wrote:
>> >>> > >> > >> >
>> >>> > >> > >> > The ScheduleModel.removeEntry() method expects a
>> >>> ScheduleEntry as
>> >>> > >> > >> > parameter. I suppose you use Hibernate for database
>> access,
>> >>> so
>> >>> > >> what you
>> >>> > >> > >> > should do is retrieve the ScheduleEntry from the
>> database,
>> >>> using
>> >>> > >> the
>> >>> > >> > >> id,
>> >>> > >> > >> > and feed the result to the removeEntry method. In that
>> >>> removeEntry
>> >>> > >> > >> > method, you just delete it with your Hibernate DAO.
>> >>> > >> > >> > You could of course add a method
>> >>> removeEntry(String/Long/Whatever
>> >>> > >> id)
>> >>> > >> > >> > that does all of this.
>> >>> > >> > >> >
>> >>> > >> > >> > Jurgen
>> >>> > >> > >> >
>> >>> > >> > >> >
>> >>> > >> > >> >
>> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700],
>> >>> schreef
>> >>> > >> > >> > ignicolist:
>> >>> > >> > >> >> Hi to all, i want to eliminate a especific entry in a
>> model
>> >>> of
>> >>> > >> > >> schedule
>> >>> > >> > >> >> tomahawk. the example in remove a selected entry work
>> fine,
>> >>> but
>> >>> > >> how to
>> >>> > >> > >> >> eliminate a determinated entry?
>> >>> > >> > >> >>
>> >>> > >> > >> >>
>> >>> > >> > >> >> i try with this code:
>> >>> > >> > >> >>
>> >>> > >> > >> >>
>> >>> > >> > >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> >>> > >> > >> >>
>> >>> > >> > >> >>  entry.setId(select);
>> >>> > >> > >> >>  entry.setStartTime(start);
>> >>> > >> > >> >>  entry.setEndTime(end);
>> >>> > >> > >> >>  entry.setTitle(select7);
>> >>> > >> > >> >>  entry.setDescription(select2);
>> >>> > >> > >> >>
>> >>> > >> > >> >>  model.removeEntry(entry);
>> >>> > >> > >> >>  model.refresh();
>> >>> > >> > >> >>
>> >>> > >> > >> >> i defined every value for the entry, and then i want to
>> >>> remove
>> >>> > >> that
>> >>> > >> > >> >> entry!
>> >>> > >> > >> >> Any help please!
>> >>> > >> > >> >>
>> >>> > >> > >> >> Tks for all.
>> >>> > >> > >> > --
>> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
>> >>> > >> > >> >
>> >>> > >> > >> >
>> >>> > >> > >> >
>> >>> > >> > >>
>> >>> > >> > > --
>> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
>> >>> > >> > >
>> >>> > >> > >
>> >>> > >> > >
>> >>> > >> >
>> >>> > >> > --
>> >>> > >> > View this message in context:
>> >>> > >>
>> >>>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
>> >>> > >> > Sent from the MyFaces - Users mailing list archive at
>> Nabble.com.
>> >>> > >> >
>> >>> > >> >
>> >>> > >>
>> >>> > >>
>> >>> > >> --
>> >>> > >> Michał Stawicki
>> >>> > >>
>> >>> > >> stawicki@gmail.com
>> >>> > >> http://stawicki.jasliska.pl
>> >>> > >>
>> >>> > >
>> >>> > >
>> >>> > > --
>> >>> > > Michał Stawicki
>> >>> > >
>> >>> > > stawicki@gmail.com
>> >>> > > http://stawicki.jasliska.pl
>> >>> > >
>> >>> > >
>> >>> >
>> >>> > --
>> >>> > View this message in context:
>> >>>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
>> >>> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>> >
>> >>> >
>> >>>
>> >>>
>> >>> --
>> >>> Michał Stawicki
>> >>>
>> >>> stawicki@gmail.com
>> >>> http://stawicki.jasliska.pl
>> >>>
>> >>
>> >>
>> >> --
>> >> Michał Stawicki
>> >>
>> >> stawicki@gmail.com
>> >> http://stawicki.jasliska.pl
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Michał Stawicki
> 
> stawicki@gmail.com
> http://stawicki.jasliska.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12202757
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by Michał 'Gandalf' Stawicki <st...@gmail.com>.
Try this, remember to set valid package:

 #####SET ME package #####SET ME

import java.util.TreeSet;
import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
import org.apache.myfaces.custom.schedule.model.SimpleScheduleModel;

/**
 * @author mstawick
 */
public class ExtendedScheduleModel extends SimpleScheduleModel
{
	
	/** Creates a new instance of ExtendedScheduleModel */
	public ExtendedScheduleModel()
	{
		super();
	}
	
	/**
	 * Remove entry from model
	 * <br /><br />
	 * @param <b>id</b> identifier of entry to be removed
	 * <br /><br />
	 * @return true on success and false on failure (in case entry with
specified id wasn't found)
	 *
	 */
	public boolean removeEntry(String id)
	{
		ScheduleEntry entry = null;
		String currentId = null;
		
		for(ScheduleEntry se : entries)
		{
			if((currentId = se.getId()) != null && currentId.equals(id))
			{
				entry = se;
				break;
			}
		}
		
		if(entry != null)
		{
			entries.remove(entry);
			entry = null;
			
			return true;
		}
		
		return false;
	}
	
	private TreeSet<ScheduleEntry> entries;
}


On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>
> Sorry to bee so boring and noob, but i realy need to do this, i need a
> funcionality to show and occult calendars, and i have a entry associate to a
> calendar, so when i need occult  the calendar i need to remove the entries
> of that calendar from the model. everything working, just need remove the
> entries.
>
>
>
> ignicolist wrote:
> >
> > Well i am a litle noob to all these, so i cant put your ideas to work!
> > :-((
> >
> > So i am using SimpleScheduleModel, so you say to create that class in the
> > component Schedule or in my aplication?
> > Because i create the class in my aplication and don´t work. Dam this is so
> > complicated...
> >
> >
> >
> > Michał 'Gandalf' Stawicki wrote:
> >>
> >> I wrote the code in 'on the fly' just to give you idea how should it
> >> look, I didn't try it
> >>
> >> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
> >>> Simply casting it should be fine:
> >>>
> >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
> >>>
> >>>
> >>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >>> >
> >>> > I try what you say but give me a error in: for(ScheduleEntry e :
> >>> entries)
> >>> > The Error: Type mismatch: cannot convert from element type Object to
> >>> > ScheduleEntry
> >>> >
> >>> > Any idea?
> >>> >
> >>> >
> >>> >
> >>> > Michał 'Gandalf' Stawicki wrote:
> >>> > >
> >>> > > From SimpleScheduleModel.java
> >>> > >
> >>> > >     /**
> >>> > >      * Remove an entry from the model.
> >>> > >      *
> >>> > >      * @param entry
> >>> > >      *            the entry to remove
> >>> > >      */
> >>> > >     public void removeEntry(ScheduleEntry entry)
> >>> > >     {
> >>> > >         entries.remove(entry);
> >>> > >     }
> >>> > >
> >>> > > ...
> >>> > >
> >>> > >     private final TreeSet entries;
> >>> > >
> >>> > > I don't know which model your using, but if it is
> >>> SimpleScheduleModel
> >>> > > than you should extend it and implement your own method, ex;
> >>> > >
> >>> > > public boolean removeEntry(String id)
> >>> > > {
> >>> > > ScheduleEntry entry = null;
> >>> > >
> >>> > > if(entries != null && id != null)
> >>> > > for(ScheduleEntry e : entries)
> >>> > > {
> >>> > > if(e.getId() != null && e.getId().equals(id))
> >>> > > {
> >>> > > entry = e;
> >>> > > break;
> >>> > > }
> >>> > > }
> >>> > >
> >>> > > if(entry != null)
> >>> > > {
> >>> > > entries.remove(entry);
> >>> > > return true;
> >>> > > }
> >>> > >
> >>> > > return false;
> >>> > > }
> >>> > >
> >>> > >
> >>> > >
> >>> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
> >>> > >> I believe you have to pass exact reference to object that was added
> >>> to
> >>> > >> schedule, not some other object containing same data, example:
> >>> > >>
> >>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
> >>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
> >>> > >>
> >>> > >> model.addEntry(foo);
> >>> > >>
> >>> > >> model.removeEntry(foo2); // wrong
> >>> > >> mode.removeEntry(foo); //ok
> >>> > >>
> >>> > >>
> >>> > >>
> >>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >>> > >> >
> >>> > >> > Yes, because the entry when i select it remove with
> >>> > >> > model.removeSelectedEntry(); but if i specify his id:
> >>> > >> entry.setId("1");
> >>> > >> > model.removeEntry(entry); dont eliminate. And ids are the same in
> >>> the
> >>> > >> two
> >>> > >> > situacions.
> >>> > >> >
> >>> > >> >
> >>> > >> >
> >>> > >> >
> >>> > >> > Jurgen Lust-2 wrote:
> >>> > >> > >
> >>> > >> > > In your model implementation, do you load the persistent entry
> >>> from
> >>> > >> the
> >>> > >> > > database, using the supplied id, before you delete it?
> >>> > >> > >
> >>> > >> > > Jurgen
> >>> > >> > >
> >>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
> >>> > >> > > ignicolist:
> >>> > >> > >> Its what i am doing but don´t work!
> >>> > >> > >>
> >>> > >> > >> an example:
> >>> > >> > >>
> >>> > >> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >>> > >> > >>
> >>> > >> > >>   entry.setId("1");
> >>> > >> > >>  model.removeEntry(entry);
> >>> > >> > >>
> >>> > >> > >> this code is supose to remove the entry from de model with id
> >>> 1 no?
> >>> > >> i
> >>> > >> > >> just
> >>> > >> > >> want remove de entry from the model, but a entry specify by
> >>> me.
> >>> > >> > >>
> >>> > >> > >>
> >>> > >> > >>
> >>> > >> > >>
> >>> > >> > >>
> >>> > >> > >> Jurgen Lust-2 wrote:
> >>> > >> > >> >
> >>> > >> > >> > The ScheduleModel.removeEntry() method expects a
> >>> ScheduleEntry as
> >>> > >> > >> > parameter. I suppose you use Hibernate for database access,
> >>> so
> >>> > >> what you
> >>> > >> > >> > should do is retrieve the ScheduleEntry from the database,
> >>> using
> >>> > >> the
> >>> > >> > >> id,
> >>> > >> > >> > and feed the result to the removeEntry method. In that
> >>> removeEntry
> >>> > >> > >> > method, you just delete it with your Hibernate DAO.
> >>> > >> > >> > You could of course add a method
> >>> removeEntry(String/Long/Whatever
> >>> > >> id)
> >>> > >> > >> > that does all of this.
> >>> > >> > >> >
> >>> > >> > >> > Jurgen
> >>> > >> > >> >
> >>> > >> > >> >
> >>> > >> > >> >
> >>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700],
> >>> schreef
> >>> > >> > >> > ignicolist:
> >>> > >> > >> >> Hi to all, i want to eliminate a especific entry in a model
> >>> of
> >>> > >> > >> schedule
> >>> > >> > >> >> tomahawk. the example in remove a selected entry work fine,
> >>> but
> >>> > >> how to
> >>> > >> > >> >> eliminate a determinated entry?
> >>> > >> > >> >>
> >>> > >> > >> >>
> >>> > >> > >> >> i try with this code:
> >>> > >> > >> >>
> >>> > >> > >> >>
> >>> > >> > >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >>> > >> > >> >>
> >>> > >> > >> >>  entry.setId(select);
> >>> > >> > >> >>  entry.setStartTime(start);
> >>> > >> > >> >>  entry.setEndTime(end);
> >>> > >> > >> >>  entry.setTitle(select7);
> >>> > >> > >> >>  entry.setDescription(select2);
> >>> > >> > >> >>
> >>> > >> > >> >>  model.removeEntry(entry);
> >>> > >> > >> >>  model.refresh();
> >>> > >> > >> >>
> >>> > >> > >> >> i defined every value for the entry, and then i want to
> >>> remove
> >>> > >> that
> >>> > >> > >> >> entry!
> >>> > >> > >> >> Any help please!
> >>> > >> > >> >>
> >>> > >> > >> >> Tks for all.
> >>> > >> > >> > --
> >>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
> >>> > >> > >> >
> >>> > >> > >> >
> >>> > >> > >> >
> >>> > >> > >>
> >>> > >> > > --
> >>> > >> > > Jurgen Lust <Ju...@gmail.com>
> >>> > >> > >
> >>> > >> > >
> >>> > >> > >
> >>> > >> >
> >>> > >> > --
> >>> > >> > View this message in context:
> >>> > >>
> >>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
> >>> > >> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>> > >> >
> >>> > >> >
> >>> > >>
> >>> > >>
> >>> > >> --
> >>> > >> Michał Stawicki
> >>> > >>
> >>> > >> stawicki@gmail.com
> >>> > >> http://stawicki.jasliska.pl
> >>> > >>
> >>> > >
> >>> > >
> >>> > > --
> >>> > > Michał Stawicki
> >>> > >
> >>> > > stawicki@gmail.com
> >>> > > http://stawicki.jasliska.pl
> >>> > >
> >>> > >
> >>> >
> >>> > --
> >>> > View this message in context:
> >>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
> >>> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>> >
> >>> >
> >>>
> >>>
> >>> --
> >>> Michał Stawicki
> >>>
> >>> stawicki@gmail.com
> >>> http://stawicki.jasliska.pl
> >>>
> >>
> >>
> >> --
> >> Michał Stawicki
> >>
> >> stawicki@gmail.com
> >> http://stawicki.jasliska.pl
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
Michał Stawicki

stawicki@gmail.com
http://stawicki.jasliska.pl

Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
Sorry to bee so boring and noob, but i realy need to do this, i need a
funcionality to show and occult calendars, and i have a entry associate to a
calendar, so when i need occult  the calendar i need to remove the entries
of that calendar from the model. everything working, just need remove the
entries.



ignicolist wrote:
> 
> Well i am a litle noob to all these, so i cant put your ideas to work!
> :-((
> 
> So i am using SimpleScheduleModel, so you say to create that class in the
> component Schedule or in my aplication?
> Because i create the class in my aplication and don´t work. Dam this is so
> complicated... 
> 
> 
> 
> Michał 'Gandalf' Stawicki wrote:
>> 
>> I wrote the code in 'on the fly' just to give you idea how should it
>> look, I didn't try it
>> 
>> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
>>> Simply casting it should be fine:
>>>
>>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
>>>
>>>
>>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>>> >
>>> > I try what you say but give me a error in: for(ScheduleEntry e :
>>> entries)
>>> > The Error: Type mismatch: cannot convert from element type Object to
>>> > ScheduleEntry
>>> >
>>> > Any idea?
>>> >
>>> >
>>> >
>>> > Michał 'Gandalf' Stawicki wrote:
>>> > >
>>> > > From SimpleScheduleModel.java
>>> > >
>>> > >     /**
>>> > >      * Remove an entry from the model.
>>> > >      *
>>> > >      * @param entry
>>> > >      *            the entry to remove
>>> > >      */
>>> > >     public void removeEntry(ScheduleEntry entry)
>>> > >     {
>>> > >         entries.remove(entry);
>>> > >     }
>>> > >
>>> > > ...
>>> > >
>>> > >     private final TreeSet entries;
>>> > >
>>> > > I don't know which model your using, but if it is
>>> SimpleScheduleModel
>>> > > than you should extend it and implement your own method, ex;
>>> > >
>>> > > public boolean removeEntry(String id)
>>> > > {
>>> > > ScheduleEntry entry = null;
>>> > >
>>> > > if(entries != null && id != null)
>>> > > for(ScheduleEntry e : entries)
>>> > > {
>>> > > if(e.getId() != null && e.getId().equals(id))
>>> > > {
>>> > > entry = e;
>>> > > break;
>>> > > }
>>> > > }
>>> > >
>>> > > if(entry != null)
>>> > > {
>>> > > entries.remove(entry);
>>> > > return true;
>>> > > }
>>> > >
>>> > > return false;
>>> > > }
>>> > >
>>> > >
>>> > >
>>> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
>>> > >> I believe you have to pass exact reference to object that was added
>>> to
>>> > >> schedule, not some other object containing same data, example:
>>> > >>
>>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
>>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
>>> > >>
>>> > >> model.addEntry(foo);
>>> > >>
>>> > >> model.removeEntry(foo2); // wrong
>>> > >> mode.removeEntry(foo); //ok
>>> > >>
>>> > >>
>>> > >>
>>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>>> > >> >
>>> > >> > Yes, because the entry when i select it remove with
>>> > >> > model.removeSelectedEntry(); but if i specify his id:
>>> > >> entry.setId("1");
>>> > >> > model.removeEntry(entry); dont eliminate. And ids are the same in
>>> the
>>> > >> two
>>> > >> > situacions.
>>> > >> >
>>> > >> >
>>> > >> >
>>> > >> >
>>> > >> > Jurgen Lust-2 wrote:
>>> > >> > >
>>> > >> > > In your model implementation, do you load the persistent entry
>>> from
>>> > >> the
>>> > >> > > database, using the supplied id, before you delete it?
>>> > >> > >
>>> > >> > > Jurgen
>>> > >> > >
>>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
>>> > >> > > ignicolist:
>>> > >> > >> Its what i am doing but don´t work!
>>> > >> > >>
>>> > >> > >> an example:
>>> > >> > >>
>>> > >> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>>> > >> > >>
>>> > >> > >>   entry.setId("1");
>>> > >> > >>  model.removeEntry(entry);
>>> > >> > >>
>>> > >> > >> this code is supose to remove the entry from de model with id
>>> 1 no?
>>> > >> i
>>> > >> > >> just
>>> > >> > >> want remove de entry from the model, but a entry specify by
>>> me.
>>> > >> > >>
>>> > >> > >>
>>> > >> > >>
>>> > >> > >>
>>> > >> > >>
>>> > >> > >> Jurgen Lust-2 wrote:
>>> > >> > >> >
>>> > >> > >> > The ScheduleModel.removeEntry() method expects a
>>> ScheduleEntry as
>>> > >> > >> > parameter. I suppose you use Hibernate for database access,
>>> so
>>> > >> what you
>>> > >> > >> > should do is retrieve the ScheduleEntry from the database,
>>> using
>>> > >> the
>>> > >> > >> id,
>>> > >> > >> > and feed the result to the removeEntry method. In that
>>> removeEntry
>>> > >> > >> > method, you just delete it with your Hibernate DAO.
>>> > >> > >> > You could of course add a method
>>> removeEntry(String/Long/Whatever
>>> > >> id)
>>> > >> > >> > that does all of this.
>>> > >> > >> >
>>> > >> > >> > Jurgen
>>> > >> > >> >
>>> > >> > >> >
>>> > >> > >> >
>>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700],
>>> schreef
>>> > >> > >> > ignicolist:
>>> > >> > >> >> Hi to all, i want to eliminate a especific entry in a model
>>> of
>>> > >> > >> schedule
>>> > >> > >> >> tomahawk. the example in remove a selected entry work fine,
>>> but
>>> > >> how to
>>> > >> > >> >> eliminate a determinated entry?
>>> > >> > >> >>
>>> > >> > >> >>
>>> > >> > >> >> i try with this code:
>>> > >> > >> >>
>>> > >> > >> >>
>>> > >> > >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>>> > >> > >> >>
>>> > >> > >> >>  entry.setId(select);
>>> > >> > >> >>  entry.setStartTime(start);
>>> > >> > >> >>  entry.setEndTime(end);
>>> > >> > >> >>  entry.setTitle(select7);
>>> > >> > >> >>  entry.setDescription(select2);
>>> > >> > >> >>
>>> > >> > >> >>  model.removeEntry(entry);
>>> > >> > >> >>  model.refresh();
>>> > >> > >> >>
>>> > >> > >> >> i defined every value for the entry, and then i want to
>>> remove
>>> > >> that
>>> > >> > >> >> entry!
>>> > >> > >> >> Any help please!
>>> > >> > >> >>
>>> > >> > >> >> Tks for all.
>>> > >> > >> > --
>>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
>>> > >> > >> >
>>> > >> > >> >
>>> > >> > >> >
>>> > >> > >>
>>> > >> > > --
>>> > >> > > Jurgen Lust <Ju...@gmail.com>
>>> > >> > >
>>> > >> > >
>>> > >> > >
>>> > >> >
>>> > >> > --
>>> > >> > View this message in context:
>>> > >>
>>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
>>> > >> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>> > >> >
>>> > >> >
>>> > >>
>>> > >>
>>> > >> --
>>> > >> Michał Stawicki
>>> > >>
>>> > >> stawicki@gmail.com
>>> > >> http://stawicki.jasliska.pl
>>> > >>
>>> > >
>>> > >
>>> > > --
>>> > > Michał Stawicki
>>> > >
>>> > > stawicki@gmail.com
>>> > > http://stawicki.jasliska.pl
>>> > >
>>> > >
>>> >
>>> > --
>>> > View this message in context:
>>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
>>> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>> >
>>> >
>>>
>>>
>>> --
>>> Michał Stawicki
>>>
>>> stawicki@gmail.com
>>> http://stawicki.jasliska.pl
>>>
>> 
>> 
>> -- 
>> Michał Stawicki
>> 
>> stawicki@gmail.com
>> http://stawicki.jasliska.pl
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201958
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
Well i am a litle noob to all these, so i cant put your ideas to work! :-((

So i am using SimpleScheduleModel, so you say to create that class in the
component Schedule or in my aplication?
Because i create the class in my aplication and don´t work. Dam this is so
complicated... 



Michał 'Gandalf' Stawicki wrote:
> 
> I wrote the code in 'on the fly' just to give you idea how should it
> look, I didn't try it
> 
> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
>> Simply casting it should be fine:
>>
>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
>>
>>
>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >
>> > I try what you say but give me a error in: for(ScheduleEntry e :
>> entries)
>> > The Error: Type mismatch: cannot convert from element type Object to
>> > ScheduleEntry
>> >
>> > Any idea?
>> >
>> >
>> >
>> > Michał 'Gandalf' Stawicki wrote:
>> > >
>> > > From SimpleScheduleModel.java
>> > >
>> > >     /**
>> > >      * Remove an entry from the model.
>> > >      *
>> > >      * @param entry
>> > >      *            the entry to remove
>> > >      */
>> > >     public void removeEntry(ScheduleEntry entry)
>> > >     {
>> > >         entries.remove(entry);
>> > >     }
>> > >
>> > > ...
>> > >
>> > >     private final TreeSet entries;
>> > >
>> > > I don't know which model your using, but if it is SimpleScheduleModel
>> > > than you should extend it and implement your own method, ex;
>> > >
>> > > public boolean removeEntry(String id)
>> > > {
>> > > ScheduleEntry entry = null;
>> > >
>> > > if(entries != null && id != null)
>> > > for(ScheduleEntry e : entries)
>> > > {
>> > > if(e.getId() != null && e.getId().equals(id))
>> > > {
>> > > entry = e;
>> > > break;
>> > > }
>> > > }
>> > >
>> > > if(entry != null)
>> > > {
>> > > entries.remove(entry);
>> > > return true;
>> > > }
>> > >
>> > > return false;
>> > > }
>> > >
>> > >
>> > >
>> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
>> > >> I believe you have to pass exact reference to object that was added
>> to
>> > >> schedule, not some other object containing same data, example:
>> > >>
>> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
>> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
>> > >>
>> > >> model.addEntry(foo);
>> > >>
>> > >> model.removeEntry(foo2); // wrong
>> > >> mode.removeEntry(foo); //ok
>> > >>
>> > >>
>> > >>
>> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> > >> >
>> > >> > Yes, because the entry when i select it remove with
>> > >> > model.removeSelectedEntry(); but if i specify his id:
>> > >> entry.setId("1");
>> > >> > model.removeEntry(entry); dont eliminate. And ids are the same in
>> the
>> > >> two
>> > >> > situacions.
>> > >> >
>> > >> >
>> > >> >
>> > >> >
>> > >> > Jurgen Lust-2 wrote:
>> > >> > >
>> > >> > > In your model implementation, do you load the persistent entry
>> from
>> > >> the
>> > >> > > database, using the supplied id, before you delete it?
>> > >> > >
>> > >> > > Jurgen
>> > >> > >
>> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
>> > >> > > ignicolist:
>> > >> > >> Its what i am doing but don´t work!
>> > >> > >>
>> > >> > >> an example:
>> > >> > >>
>> > >> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> > >> > >>
>> > >> > >>   entry.setId("1");
>> > >> > >>  model.removeEntry(entry);
>> > >> > >>
>> > >> > >> this code is supose to remove the entry from de model with id 1
>> no?
>> > >> i
>> > >> > >> just
>> > >> > >> want remove de entry from the model, but a entry specify by me.
>> > >> > >>
>> > >> > >>
>> > >> > >>
>> > >> > >>
>> > >> > >>
>> > >> > >> Jurgen Lust-2 wrote:
>> > >> > >> >
>> > >> > >> > The ScheduleModel.removeEntry() method expects a
>> ScheduleEntry as
>> > >> > >> > parameter. I suppose you use Hibernate for database access,
>> so
>> > >> what you
>> > >> > >> > should do is retrieve the ScheduleEntry from the database,
>> using
>> > >> the
>> > >> > >> id,
>> > >> > >> > and feed the result to the removeEntry method. In that
>> removeEntry
>> > >> > >> > method, you just delete it with your Hibernate DAO.
>> > >> > >> > You could of course add a method
>> removeEntry(String/Long/Whatever
>> > >> id)
>> > >> > >> > that does all of this.
>> > >> > >> >
>> > >> > >> > Jurgen
>> > >> > >> >
>> > >> > >> >
>> > >> > >> >
>> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700],
>> schreef
>> > >> > >> > ignicolist:
>> > >> > >> >> Hi to all, i want to eliminate a especific entry in a model
>> of
>> > >> > >> schedule
>> > >> > >> >> tomahawk. the example in remove a selected entry work fine,
>> but
>> > >> how to
>> > >> > >> >> eliminate a determinated entry?
>> > >> > >> >>
>> > >> > >> >>
>> > >> > >> >> i try with this code:
>> > >> > >> >>
>> > >> > >> >>
>> > >> > >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> > >> > >> >>
>> > >> > >> >>  entry.setId(select);
>> > >> > >> >>  entry.setStartTime(start);
>> > >> > >> >>  entry.setEndTime(end);
>> > >> > >> >>  entry.setTitle(select7);
>> > >> > >> >>  entry.setDescription(select2);
>> > >> > >> >>
>> > >> > >> >>  model.removeEntry(entry);
>> > >> > >> >>  model.refresh();
>> > >> > >> >>
>> > >> > >> >> i defined every value for the entry, and then i want to
>> remove
>> > >> that
>> > >> > >> >> entry!
>> > >> > >> >> Any help please!
>> > >> > >> >>
>> > >> > >> >> Tks for all.
>> > >> > >> > --
>> > >> > >> > Jurgen Lust <Ju...@gmail.com>
>> > >> > >> >
>> > >> > >> >
>> > >> > >> >
>> > >> > >>
>> > >> > > --
>> > >> > > Jurgen Lust <Ju...@gmail.com>
>> > >> > >
>> > >> > >
>> > >> > >
>> > >> >
>> > >> > --
>> > >> > View this message in context:
>> > >>
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
>> > >> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> > >> >
>> > >> >
>> > >>
>> > >>
>> > >> --
>> > >> Michał Stawicki
>> > >>
>> > >> stawicki@gmail.com
>> > >> http://stawicki.jasliska.pl
>> > >>
>> > >
>> > >
>> > > --
>> > > Michał Stawicki
>> > >
>> > > stawicki@gmail.com
>> > > http://stawicki.jasliska.pl
>> > >
>> > >
>> >
>> > --
>> > View this message in context:
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
>> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >
>> >
>>
>>
>> --
>> Michał Stawicki
>>
>> stawicki@gmail.com
>> http://stawicki.jasliska.pl
>>
> 
> 
> -- 
> Michał Stawicki
> 
> stawicki@gmail.com
> http://stawicki.jasliska.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12201543
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by Michał 'Gandalf' Stawicki <st...@gmail.com>.
I wrote the code in 'on the fly' just to give you idea how should it
look, I didn't try it

On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
> Simply casting it should be fine:
>
> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)
>
>
> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >
> > I try what you say but give me a error in: for(ScheduleEntry e : entries)
> > The Error: Type mismatch: cannot convert from element type Object to
> > ScheduleEntry
> >
> > Any idea?
> >
> >
> >
> > Michał 'Gandalf' Stawicki wrote:
> > >
> > > From SimpleScheduleModel.java
> > >
> > >     /**
> > >      * Remove an entry from the model.
> > >      *
> > >      * @param entry
> > >      *            the entry to remove
> > >      */
> > >     public void removeEntry(ScheduleEntry entry)
> > >     {
> > >         entries.remove(entry);
> > >     }
> > >
> > > ...
> > >
> > >     private final TreeSet entries;
> > >
> > > I don't know which model your using, but if it is SimpleScheduleModel
> > > than you should extend it and implement your own method, ex;
> > >
> > > public boolean removeEntry(String id)
> > > {
> > > ScheduleEntry entry = null;
> > >
> > > if(entries != null && id != null)
> > > for(ScheduleEntry e : entries)
> > > {
> > > if(e.getId() != null && e.getId().equals(id))
> > > {
> > > entry = e;
> > > break;
> > > }
> > > }
> > >
> > > if(entry != null)
> > > {
> > > entries.remove(entry);
> > > return true;
> > > }
> > >
> > > return false;
> > > }
> > >
> > >
> > >
> > > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
> > >> I believe you have to pass exact reference to object that was added to
> > >> schedule, not some other object containing same data, example:
> > >>
> > >> ScheduleEntry foo = new MyScheduleEntry("bar");
> > >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
> > >>
> > >> model.addEntry(foo);
> > >>
> > >> model.removeEntry(foo2); // wrong
> > >> mode.removeEntry(foo); //ok
> > >>
> > >>
> > >>
> > >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> > >> >
> > >> > Yes, because the entry when i select it remove with
> > >> > model.removeSelectedEntry(); but if i specify his id:
> > >> entry.setId("1");
> > >> > model.removeEntry(entry); dont eliminate. And ids are the same in the
> > >> two
> > >> > situacions.
> > >> >
> > >> >
> > >> >
> > >> >
> > >> > Jurgen Lust-2 wrote:
> > >> > >
> > >> > > In your model implementation, do you load the persistent entry from
> > >> the
> > >> > > database, using the supplied id, before you delete it?
> > >> > >
> > >> > > Jurgen
> > >> > >
> > >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
> > >> > > ignicolist:
> > >> > >> Its what i am doing but don´t work!
> > >> > >>
> > >> > >> an example:
> > >> > >>
> > >> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> > >> > >>
> > >> > >>   entry.setId("1");
> > >> > >>  model.removeEntry(entry);
> > >> > >>
> > >> > >> this code is supose to remove the entry from de model with id 1 no?
> > >> i
> > >> > >> just
> > >> > >> want remove de entry from the model, but a entry specify by me.
> > >> > >>
> > >> > >>
> > >> > >>
> > >> > >>
> > >> > >>
> > >> > >> Jurgen Lust-2 wrote:
> > >> > >> >
> > >> > >> > The ScheduleModel.removeEntry() method expects a ScheduleEntry as
> > >> > >> > parameter. I suppose you use Hibernate for database access, so
> > >> what you
> > >> > >> > should do is retrieve the ScheduleEntry from the database, using
> > >> the
> > >> > >> id,
> > >> > >> > and feed the result to the removeEntry method. In that removeEntry
> > >> > >> > method, you just delete it with your Hibernate DAO.
> > >> > >> > You could of course add a method removeEntry(String/Long/Whatever
> > >> id)
> > >> > >> > that does all of this.
> > >> > >> >
> > >> > >> > Jurgen
> > >> > >> >
> > >> > >> >
> > >> > >> >
> > >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
> > >> > >> > ignicolist:
> > >> > >> >> Hi to all, i want to eliminate a especific entry in a model of
> > >> > >> schedule
> > >> > >> >> tomahawk. the example in remove a selected entry work fine, but
> > >> how to
> > >> > >> >> eliminate a determinated entry?
> > >> > >> >>
> > >> > >> >>
> > >> > >> >> i try with this code:
> > >> > >> >>
> > >> > >> >>
> > >> > >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> > >> > >> >>
> > >> > >> >>  entry.setId(select);
> > >> > >> >>  entry.setStartTime(start);
> > >> > >> >>  entry.setEndTime(end);
> > >> > >> >>  entry.setTitle(select7);
> > >> > >> >>  entry.setDescription(select2);
> > >> > >> >>
> > >> > >> >>  model.removeEntry(entry);
> > >> > >> >>  model.refresh();
> > >> > >> >>
> > >> > >> >> i defined every value for the entry, and then i want to remove
> > >> that
> > >> > >> >> entry!
> > >> > >> >> Any help please!
> > >> > >> >>
> > >> > >> >> Tks for all.
> > >> > >> > --
> > >> > >> > Jurgen Lust <Ju...@gmail.com>
> > >> > >> >
> > >> > >> >
> > >> > >> >
> > >> > >>
> > >> > > --
> > >> > > Jurgen Lust <Ju...@gmail.com>
> > >> > >
> > >> > >
> > >> > >
> > >> >
> > >> > --
> > >> > View this message in context:
> > >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
> > >> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> > >> >
> > >> >
> > >>
> > >>
> > >> --
> > >> Michał Stawicki
> > >>
> > >> stawicki@gmail.com
> > >> http://stawicki.jasliska.pl
> > >>
> > >
> > >
> > > --
> > > Michał Stawicki
> > >
> > > stawicki@gmail.com
> > > http://stawicki.jasliska.pl
> > >
> > >
> >
> > --
> > View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >
> >
>
>
> --
> Michał Stawicki
>
> stawicki@gmail.com
> http://stawicki.jasliska.pl
>


-- 
Michał Stawicki

stawicki@gmail.com
http://stawicki.jasliska.pl

Re: Remove Entry from schedule Tomahawk

Posted by Michał 'Gandalf' Stawicki <st...@gmail.com>.
Simply casting it should be fine:

for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries)


On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>
> I try what you say but give me a error in: for(ScheduleEntry e : entries)
> The Error: Type mismatch: cannot convert from element type Object to
> ScheduleEntry
>
> Any idea?
>
>
>
> Michał 'Gandalf' Stawicki wrote:
> >
> > From SimpleScheduleModel.java
> >
> >     /**
> >      * Remove an entry from the model.
> >      *
> >      * @param entry
> >      *            the entry to remove
> >      */
> >     public void removeEntry(ScheduleEntry entry)
> >     {
> >         entries.remove(entry);
> >     }
> >
> > ...
> >
> >     private final TreeSet entries;
> >
> > I don't know which model your using, but if it is SimpleScheduleModel
> > than you should extend it and implement your own method, ex;
> >
> > public boolean removeEntry(String id)
> > {
> > ScheduleEntry entry = null;
> >
> > if(entries != null && id != null)
> > for(ScheduleEntry e : entries)
> > {
> > if(e.getId() != null && e.getId().equals(id))
> > {
> > entry = e;
> > break;
> > }
> > }
> >
> > if(entry != null)
> > {
> > entries.remove(entry);
> > return true;
> > }
> >
> > return false;
> > }
> >
> >
> >
> > On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
> >> I believe you have to pass exact reference to object that was added to
> >> schedule, not some other object containing same data, example:
> >>
> >> ScheduleEntry foo = new MyScheduleEntry("bar");
> >> ScheduleEntry foo2 = new MyScheduleEntry("bar");
> >>
> >> model.addEntry(foo);
> >>
> >> model.removeEntry(foo2); // wrong
> >> mode.removeEntry(foo); //ok
> >>
> >>
> >>
> >> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >> >
> >> > Yes, because the entry when i select it remove with
> >> > model.removeSelectedEntry(); but if i specify his id:
> >> entry.setId("1");
> >> > model.removeEntry(entry); dont eliminate. And ids are the same in the
> >> two
> >> > situacions.
> >> >
> >> >
> >> >
> >> >
> >> > Jurgen Lust-2 wrote:
> >> > >
> >> > > In your model implementation, do you load the persistent entry from
> >> the
> >> > > database, using the supplied id, before you delete it?
> >> > >
> >> > > Jurgen
> >> > >
> >> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
> >> > > ignicolist:
> >> > >> Its what i am doing but don´t work!
> >> > >>
> >> > >> an example:
> >> > >>
> >> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >> > >>
> >> > >>   entry.setId("1");
> >> > >>  model.removeEntry(entry);
> >> > >>
> >> > >> this code is supose to remove the entry from de model with id 1 no?
> >> i
> >> > >> just
> >> > >> want remove de entry from the model, but a entry specify by me.
> >> > >>
> >> > >>
> >> > >>
> >> > >>
> >> > >>
> >> > >> Jurgen Lust-2 wrote:
> >> > >> >
> >> > >> > The ScheduleModel.removeEntry() method expects a ScheduleEntry as
> >> > >> > parameter. I suppose you use Hibernate for database access, so
> >> what you
> >> > >> > should do is retrieve the ScheduleEntry from the database, using
> >> the
> >> > >> id,
> >> > >> > and feed the result to the removeEntry method. In that removeEntry
> >> > >> > method, you just delete it with your Hibernate DAO.
> >> > >> > You could of course add a method removeEntry(String/Long/Whatever
> >> id)
> >> > >> > that does all of this.
> >> > >> >
> >> > >> > Jurgen
> >> > >> >
> >> > >> >
> >> > >> >
> >> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
> >> > >> > ignicolist:
> >> > >> >> Hi to all, i want to eliminate a especific entry in a model of
> >> > >> schedule
> >> > >> >> tomahawk. the example in remove a selected entry work fine, but
> >> how to
> >> > >> >> eliminate a determinated entry?
> >> > >> >>
> >> > >> >>
> >> > >> >> i try with this code:
> >> > >> >>
> >> > >> >>
> >> > >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >> > >> >>
> >> > >> >>  entry.setId(select);
> >> > >> >>  entry.setStartTime(start);
> >> > >> >>  entry.setEndTime(end);
> >> > >> >>  entry.setTitle(select7);
> >> > >> >>  entry.setDescription(select2);
> >> > >> >>
> >> > >> >>  model.removeEntry(entry);
> >> > >> >>  model.refresh();
> >> > >> >>
> >> > >> >> i defined every value for the entry, and then i want to remove
> >> that
> >> > >> >> entry!
> >> > >> >> Any help please!
> >> > >> >>
> >> > >> >> Tks for all.
> >> > >> > --
> >> > >> > Jurgen Lust <Ju...@gmail.com>
> >> > >> >
> >> > >> >
> >> > >> >
> >> > >>
> >> > > --
> >> > > Jurgen Lust <Ju...@gmail.com>
> >> > >
> >> > >
> >> > >
> >> >
> >> > --
> >> > View this message in context:
> >> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
> >> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >> >
> >> >
> >>
> >>
> >> --
> >> Michał Stawicki
> >>
> >> stawicki@gmail.com
> >> http://stawicki.jasliska.pl
> >>
> >
> >
> > --
> > Michał Stawicki
> >
> > stawicki@gmail.com
> > http://stawicki.jasliska.pl
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
Michał Stawicki

stawicki@gmail.com
http://stawicki.jasliska.pl

Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
I try what you say but give me a error in: for(ScheduleEntry e : entries)  
The Error: Type mismatch: cannot convert from element type Object to
ScheduleEntry

Any idea?



Michał 'Gandalf' Stawicki wrote:
> 
> From SimpleScheduleModel.java
> 
>     /**
>      * Remove an entry from the model.
>      *
>      * @param entry
>      *            the entry to remove
>      */
>     public void removeEntry(ScheduleEntry entry)
>     {
>         entries.remove(entry);
>     }
> 
> ...
> 
>     private final TreeSet entries;
> 
> I don't know which model your using, but if it is SimpleScheduleModel
> than you should extend it and implement your own method, ex;
> 
> public boolean removeEntry(String id)
> {
> ScheduleEntry entry = null;
> 
> if(entries != null && id != null)
> for(ScheduleEntry e : entries)
> {
> if(e.getId() != null && e.getId().equals(id))
> {
> entry = e;
> break;
> }
> }
> 
> if(entry != null)
> {
> entries.remove(entry);
> return true;
> }
> 
> return false;
> }
> 
> 
> 
> On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
>> I believe you have to pass exact reference to object that was added to
>> schedule, not some other object containing same data, example:
>>
>> ScheduleEntry foo = new MyScheduleEntry("bar");
>> ScheduleEntry foo2 = new MyScheduleEntry("bar");
>>
>> model.addEntry(foo);
>>
>> model.removeEntry(foo2); // wrong
>> mode.removeEntry(foo); //ok
>>
>>
>>
>> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>> >
>> > Yes, because the entry when i select it remove with
>> > model.removeSelectedEntry(); but if i specify his id: 
>> entry.setId("1");
>> > model.removeEntry(entry); dont eliminate. And ids are the same in the
>> two
>> > situacions.
>> >
>> >
>> >
>> >
>> > Jurgen Lust-2 wrote:
>> > >
>> > > In your model implementation, do you load the persistent entry from
>> the
>> > > database, using the supplied id, before you delete it?
>> > >
>> > > Jurgen
>> > >
>> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
>> > > ignicolist:
>> > >> Its what i am doing but don´t work!
>> > >>
>> > >> an example:
>> > >>
>> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> > >>
>> > >>   entry.setId("1");
>> > >>  model.removeEntry(entry);
>> > >>
>> > >> this code is supose to remove the entry from de model with id 1 no?
>> i
>> > >> just
>> > >> want remove de entry from the model, but a entry specify by me.
>> > >>
>> > >>
>> > >>
>> > >>
>> > >>
>> > >> Jurgen Lust-2 wrote:
>> > >> >
>> > >> > The ScheduleModel.removeEntry() method expects a ScheduleEntry as
>> > >> > parameter. I suppose you use Hibernate for database access, so
>> what you
>> > >> > should do is retrieve the ScheduleEntry from the database, using
>> the
>> > >> id,
>> > >> > and feed the result to the removeEntry method. In that removeEntry
>> > >> > method, you just delete it with your Hibernate DAO.
>> > >> > You could of course add a method removeEntry(String/Long/Whatever
>> id)
>> > >> > that does all of this.
>> > >> >
>> > >> > Jurgen
>> > >> >
>> > >> >
>> > >> >
>> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
>> > >> > ignicolist:
>> > >> >> Hi to all, i want to eliminate a especific entry in a model of
>> > >> schedule
>> > >> >> tomahawk. the example in remove a selected entry work fine, but
>> how to
>> > >> >> eliminate a determinated entry?
>> > >> >>
>> > >> >>
>> > >> >> i try with this code:
>> > >> >>
>> > >> >>
>> > >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> > >> >>
>> > >> >>  entry.setId(select);
>> > >> >>  entry.setStartTime(start);
>> > >> >>  entry.setEndTime(end);
>> > >> >>  entry.setTitle(select7);
>> > >> >>  entry.setDescription(select2);
>> > >> >>
>> > >> >>  model.removeEntry(entry);
>> > >> >>  model.refresh();
>> > >> >>
>> > >> >> i defined every value for the entry, and then i want to remove
>> that
>> > >> >> entry!
>> > >> >> Any help please!
>> > >> >>
>> > >> >> Tks for all.
>> > >> > --
>> > >> > Jurgen Lust <Ju...@gmail.com>
>> > >> >
>> > >> >
>> > >> >
>> > >>
>> > > --
>> > > Jurgen Lust <Ju...@gmail.com>
>> > >
>> > >
>> > >
>> >
>> > --
>> > View this message in context:
>> http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
>> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >
>> >
>>
>>
>> --
>> Michał Stawicki
>>
>> stawicki@gmail.com
>> http://stawicki.jasliska.pl
>>
> 
> 
> -- 
> Michał Stawicki
> 
> stawicki@gmail.com
> http://stawicki.jasliska.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12200949
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by Michał 'Gandalf' Stawicki <st...@gmail.com>.
From SimpleScheduleModel.java

    /**
     * Remove an entry from the model.
     *
     * @param entry
     *            the entry to remove
     */
    public void removeEntry(ScheduleEntry entry)
    {
        entries.remove(entry);
    }

...

    private final TreeSet entries;

I don't know which model your using, but if it is SimpleScheduleModel
than you should extend it and implement your own method, ex;

public boolean removeEntry(String id)
{
ScheduleEntry entry = null;

if(entries != null && id != null)
for(ScheduleEntry e : entries)
{
if(e.getId() != null && e.getId().equals(id))
{
entry = e;
break;
}
}

if(entry != null)
{
entries.remove(entry);
return true;
}

return false;
}



On 17/08/07, Michał 'Gandalf' Stawicki <st...@gmail.com> wrote:
> I believe you have to pass exact reference to object that was added to
> schedule, not some other object containing same data, example:
>
> ScheduleEntry foo = new MyScheduleEntry("bar");
> ScheduleEntry foo2 = new MyScheduleEntry("bar");
>
> model.addEntry(foo);
>
> model.removeEntry(foo2); // wrong
> mode.removeEntry(foo); //ok
>
>
>
> On 17/08/07, ignicolist <ig...@gmail.com> wrote:
> >
> > Yes, because the entry when i select it remove with
> > model.removeSelectedEntry(); but if i specify his id:  entry.setId("1");
> > model.removeEntry(entry); dont eliminate. And ids are the same in the two
> > situacions.
> >
> >
> >
> >
> > Jurgen Lust-2 wrote:
> > >
> > > In your model implementation, do you load the persistent entry from the
> > > database, using the supplied id, before you delete it?
> > >
> > > Jurgen
> > >
> > > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
> > > ignicolist:
> > >> Its what i am doing but don´t work!
> > >>
> > >> an example:
> > >>
> > >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> > >>
> > >>   entry.setId("1");
> > >>  model.removeEntry(entry);
> > >>
> > >> this code is supose to remove the entry from de model with id 1 no? i
> > >> just
> > >> want remove de entry from the model, but a entry specify by me.
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> Jurgen Lust-2 wrote:
> > >> >
> > >> > The ScheduleModel.removeEntry() method expects a ScheduleEntry as
> > >> > parameter. I suppose you use Hibernate for database access, so what you
> > >> > should do is retrieve the ScheduleEntry from the database, using the
> > >> id,
> > >> > and feed the result to the removeEntry method. In that removeEntry
> > >> > method, you just delete it with your Hibernate DAO.
> > >> > You could of course add a method removeEntry(String/Long/Whatever id)
> > >> > that does all of this.
> > >> >
> > >> > Jurgen
> > >> >
> > >> >
> > >> >
> > >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
> > >> > ignicolist:
> > >> >> Hi to all, i want to eliminate a especific entry in a model of
> > >> schedule
> > >> >> tomahawk. the example in remove a selected entry work fine, but how to
> > >> >> eliminate a determinated entry?
> > >> >>
> > >> >>
> > >> >> i try with this code:
> > >> >>
> > >> >>
> > >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> > >> >>
> > >> >>  entry.setId(select);
> > >> >>  entry.setStartTime(start);
> > >> >>  entry.setEndTime(end);
> > >> >>  entry.setTitle(select7);
> > >> >>  entry.setDescription(select2);
> > >> >>
> > >> >>  model.removeEntry(entry);
> > >> >>  model.refresh();
> > >> >>
> > >> >> i defined every value for the entry, and then i want to remove that
> > >> >> entry!
> > >> >> Any help please!
> > >> >>
> > >> >> Tks for all.
> > >> > --
> > >> > Jurgen Lust <Ju...@gmail.com>
> > >> >
> > >> >
> > >> >
> > >>
> > > --
> > > Jurgen Lust <Ju...@gmail.com>
> > >
> > >
> > >
> >
> > --
> > View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >
> >
>
>
> --
> Michał Stawicki
>
> stawicki@gmail.com
> http://stawicki.jasliska.pl
>


-- 
Michał Stawicki

stawicki@gmail.com
http://stawicki.jasliska.pl

Re: Remove Entry from schedule Tomahawk

Posted by Michał 'Gandalf' Stawicki <st...@gmail.com>.
I believe you have to pass exact reference to object that was added to
schedule, not some other object containing same data, example:

ScheduleEntry foo = new MyScheduleEntry("bar");
ScheduleEntry foo2 = new MyScheduleEntry("bar");

model.addEntry(foo);

model.removeEntry(foo2); // wrong
mode.removeEntry(foo); //ok



On 17/08/07, ignicolist <ig...@gmail.com> wrote:
>
> Yes, because the entry when i select it remove with
> model.removeSelectedEntry(); but if i specify his id:  entry.setId("1");
> model.removeEntry(entry); dont eliminate. And ids are the same in the two
> situacions.
>
>
>
>
> Jurgen Lust-2 wrote:
> >
> > In your model implementation, do you load the persistent entry from the
> > database, using the supplied id, before you delete it?
> >
> > Jurgen
> >
> > Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
> > ignicolist:
> >> Its what i am doing but don´t work!
> >>
> >> an example:
> >>
> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >>
> >>   entry.setId("1");
> >>  model.removeEntry(entry);
> >>
> >> this code is supose to remove the entry from de model with id 1 no? i
> >> just
> >> want remove de entry from the model, but a entry specify by me.
> >>
> >>
> >>
> >>
> >>
> >> Jurgen Lust-2 wrote:
> >> >
> >> > The ScheduleModel.removeEntry() method expects a ScheduleEntry as
> >> > parameter. I suppose you use Hibernate for database access, so what you
> >> > should do is retrieve the ScheduleEntry from the database, using the
> >> id,
> >> > and feed the result to the removeEntry method. In that removeEntry
> >> > method, you just delete it with your Hibernate DAO.
> >> > You could of course add a method removeEntry(String/Long/Whatever id)
> >> > that does all of this.
> >> >
> >> > Jurgen
> >> >
> >> >
> >> >
> >> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
> >> > ignicolist:
> >> >> Hi to all, i want to eliminate a especific entry in a model of
> >> schedule
> >> >> tomahawk. the example in remove a selected entry work fine, but how to
> >> >> eliminate a determinated entry?
> >> >>
> >> >>
> >> >> i try with this code:
> >> >>
> >> >>
> >> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >> >>
> >> >>  entry.setId(select);
> >> >>  entry.setStartTime(start);
> >> >>  entry.setEndTime(end);
> >> >>  entry.setTitle(select7);
> >> >>  entry.setDescription(select2);
> >> >>
> >> >>  model.removeEntry(entry);
> >> >>  model.refresh();
> >> >>
> >> >> i defined every value for the entry, and then i want to remove that
> >> >> entry!
> >> >> Any help please!
> >> >>
> >> >> Tks for all.
> >> > --
> >> > Jurgen Lust <Ju...@gmail.com>
> >> >
> >> >
> >> >
> >>
> > --
> > Jurgen Lust <Ju...@gmail.com>
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>


-- 
Michał Stawicki

stawicki@gmail.com
http://stawicki.jasliska.pl

Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
I try another way:


public void deleteSelectedEntry(ActionEvent event)
    {
        if (model == null)
            return;
       
      String x= model.getSelectedEntry().getId();
    
        DefaultScheduleEntry entry = new DefaultScheduleEntry();

        entry.setId(x);  //*1

        model.removeEntry(entry);//*2
		 
        model.refresh();
       
    }


this is was the method that remove a selected entry from the example in
myfaces, so i change *1 and *2 that was supose to work no? but dont work!
Any sujesction?










ignicolist wrote:
> 
> Yes, because the entry when i select it remove with  
> model.removeSelectedEntry(); but if i specify his id:  entry.setId("1");  
> model.removeEntry(entry); dont eliminate. And ids are the same in the two
> situacions.
> 
> 
> 
> 
> Jurgen Lust-2 wrote:
>> 
>> In your model implementation, do you load the persistent entry from the
>> database, using the supplied id, before you delete it?
>> 
>> Jurgen
>> 
>> Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
>> ignicolist:
>>> Its what i am doing but don´t work!
>>> 
>>> an example: 
>>> 
>>> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>>>  
>>>   entry.setId("1");  
>>>  model.removeEntry(entry);
>>> 
>>> this code is supose to remove the entry from de model with id 1 no? i
>>> just
>>> want remove de entry from the model, but a entry specify by me. 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Jurgen Lust-2 wrote:
>>> > 
>>> > The ScheduleModel.removeEntry() method expects a ScheduleEntry as
>>> > parameter. I suppose you use Hibernate for database access, so what
>>> you
>>> > should do is retrieve the ScheduleEntry from the database, using the
>>> id,
>>> > and feed the result to the removeEntry method. In that removeEntry
>>> > method, you just delete it with your Hibernate DAO.
>>> > You could of course add a method removeEntry(String/Long/Whatever id)
>>> > that does all of this.
>>> > 
>>> > Jurgen
>>> > 
>>> > 
>>> > 
>>> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
>>> > ignicolist:
>>> >> Hi to all, i want to eliminate a especific entry in a model of
>>> schedule
>>> >> tomahawk. the example in remove a selected entry work fine, but how
>>> to
>>> >> eliminate a determinated entry?
>>> >> 
>>> >> 
>>> >> i try with this code:
>>> >> 
>>> >>                               
>>> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>>> >> 
>>> >>  entry.setId(select);  
>>> >>  entry.setStartTime(start);
>>> >>  entry.setEndTime(end);
>>> >>  entry.setTitle(select7);	     	      
>>> >>  entry.setDescription(select2);
>>> >> 	     	
>>> >>  model.removeEntry(entry);
>>> >>  model.refresh();
>>> >> 
>>> >> i defined every value for the entry, and then i want to remove that
>>> >> entry!
>>> >> Any help please! 
>>> >> 
>>> >> Tks for all.
>>> > -- 
>>> > Jurgen Lust <Ju...@gmail.com>
>>> > 
>>> > 
>>> > 
>>> 
>> -- 
>> Jurgen Lust <Ju...@gmail.com>
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198762
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
Yes, because the entry when i select it remove with  
model.removeSelectedEntry(); but if i specify his id:  entry.setId("1");  
model.removeEntry(entry); dont eliminate. And ids are the same in the two
situacions.




Jurgen Lust-2 wrote:
> 
> In your model implementation, do you load the persistent entry from the
> database, using the supplied id, before you delete it?
> 
> Jurgen
> 
> Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
> ignicolist:
>> Its what i am doing but don´t work!
>> 
>> an example: 
>> 
>> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>>  
>>   entry.setId("1");  
>>  model.removeEntry(entry);
>> 
>> this code is supose to remove the entry from de model with id 1 no? i
>> just
>> want remove de entry from the model, but a entry specify by me. 
>> 
>> 
>> 
>> 
>> 
>> Jurgen Lust-2 wrote:
>> > 
>> > The ScheduleModel.removeEntry() method expects a ScheduleEntry as
>> > parameter. I suppose you use Hibernate for database access, so what you
>> > should do is retrieve the ScheduleEntry from the database, using the
>> id,
>> > and feed the result to the removeEntry method. In that removeEntry
>> > method, you just delete it with your Hibernate DAO.
>> > You could of course add a method removeEntry(String/Long/Whatever id)
>> > that does all of this.
>> > 
>> > Jurgen
>> > 
>> > 
>> > 
>> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
>> > ignicolist:
>> >> Hi to all, i want to eliminate a especific entry in a model of
>> schedule
>> >> tomahawk. the example in remove a selected entry work fine, but how to
>> >> eliminate a determinated entry?
>> >> 
>> >> 
>> >> i try with this code:
>> >> 
>> >>                               
>> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> >> 
>> >>  entry.setId(select);  
>> >>  entry.setStartTime(start);
>> >>  entry.setEndTime(end);
>> >>  entry.setTitle(select7);	     	      
>> >>  entry.setDescription(select2);
>> >> 	     	
>> >>  model.removeEntry(entry);
>> >>  model.refresh();
>> >> 
>> >> i defined every value for the entry, and then i want to remove that
>> >> entry!
>> >> Any help please! 
>> >> 
>> >> Tks for all.
>> > -- 
>> > Jurgen Lust <Ju...@gmail.com>
>> > 
>> > 
>> > 
>> 
> -- 
> Jurgen Lust <Ju...@gmail.com>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12198391
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Remove Entry from schedule Tomahawk

Posted by Jurgen Lust <Ju...@gmail.com>.
In your model implementation, do you load the persistent entry from the
database, using the supplied id, before you delete it?

Jurgen

Op donderdag 16-08-2007 om 14:01 uur [tijdzone -0700], schreef
ignicolist:
> Its what i am doing but don´t work!
> 
> an example: 
> 
> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>  
>   entry.setId("1");  
>  model.removeEntry(entry);
> 
> this code is supose to remove the entry from de model with id 1 no? i just
> want remove de entry from the model, but a entry specify by me. 
> 
> 
> 
> 
> 
> Jurgen Lust-2 wrote:
> > 
> > The ScheduleModel.removeEntry() method expects a ScheduleEntry as
> > parameter. I suppose you use Hibernate for database access, so what you
> > should do is retrieve the ScheduleEntry from the database, using the id,
> > and feed the result to the removeEntry method. In that removeEntry
> > method, you just delete it with your Hibernate DAO.
> > You could of course add a method removeEntry(String/Long/Whatever id)
> > that does all of this.
> > 
> > Jurgen
> > 
> > 
> > 
> > Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
> > ignicolist:
> >> Hi to all, i want to eliminate a especific entry in a model of schedule
> >> tomahawk. the example in remove a selected entry work fine, but how to
> >> eliminate a determinated entry?
> >> 
> >> 
> >> i try with this code:
> >> 
> >>                               
> >> DefaultScheduleEntry entry = new DefaultScheduleEntry();
> >> 
> >>  entry.setId(select);  
> >>  entry.setStartTime(start);
> >>  entry.setEndTime(end);
> >>  entry.setTitle(select7);	     	      
> >>  entry.setDescription(select2);
> >> 	     	
> >>  model.removeEntry(entry);
> >>  model.refresh();
> >> 
> >> i defined every value for the entry, and then i want to remove that
> >> entry!
> >> Any help please! 
> >> 
> >> Tks for all.
> > -- 
> > Jurgen Lust <Ju...@gmail.com>
> > 
> > 
> > 
> 
-- 
Jurgen Lust <Ju...@gmail.com>


Re: Remove Entry from schedule Tomahawk

Posted by ignicolist <ig...@gmail.com>.
Its what i am doing but don´t work!

an example: 

DefaultScheduleEntry entry = new DefaultScheduleEntry();
 
  entry.setId("1");  
 model.removeEntry(entry);

this code is supose to remove the entry from de model with id 1 no? i just
want remove de entry from the model, but a entry specify by me. 





Jurgen Lust-2 wrote:
> 
> The ScheduleModel.removeEntry() method expects a ScheduleEntry as
> parameter. I suppose you use Hibernate for database access, so what you
> should do is retrieve the ScheduleEntry from the database, using the id,
> and feed the result to the removeEntry method. In that removeEntry
> method, you just delete it with your Hibernate DAO.
> You could of course add a method removeEntry(String/Long/Whatever id)
> that does all of this.
> 
> Jurgen
> 
> 
> 
> Op donderdag 16-08-2007 om 11:20 uur [tijdzone -0700], schreef
> ignicolist:
>> Hi to all, i want to eliminate a especific entry in a model of schedule
>> tomahawk. the example in remove a selected entry work fine, but how to
>> eliminate a determinated entry?
>> 
>> 
>> i try with this code:
>> 
>>                               
>> DefaultScheduleEntry entry = new DefaultScheduleEntry();
>> 
>>  entry.setId(select);  
>>  entry.setStartTime(start);
>>  entry.setEndTime(end);
>>  entry.setTitle(select7);	     	      
>>  entry.setDescription(select2);
>> 	     	
>>  model.removeEntry(entry);
>>  model.refresh();
>> 
>> i defined every value for the entry, and then i want to remove that
>> entry!
>> Any help please! 
>> 
>> Tks for all.
> -- 
> Jurgen Lust <Ju...@gmail.com>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-Remove-Entry-from-schedule-Tomahawk-tf4281655.html#a12189456
Sent from the MyFaces - Users mailing list archive at Nabble.com.