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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> wrote: > >>> Simply casting it should be fine: > >>> > >>> for(ScheduleEntry e : (TreeSet<ScheduleEntry>)entries) > >>> > >>> > >>> On 17/08/07, ignicolist <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> > >>> > >> > >> > > >>> > >> > >> > > >>> > >> > >> > > >>> > >> > >> > >>> > >> > > -- > >>> > >> > > Jurgen Lust <[EMAIL PROTECTED]> > >>> > >> > > > >>> > >> > > > >>> > >> > > > >>> > >> > > >>> > >> > -- > >>> > >> > 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 > >>> > >> > >>> > >> [EMAIL PROTECTED] > >>> > >> http://stawicki.jasliska.pl > >>> > >> > >>> > > > >>> > > > >>> > > -- > >>> > > Michał Stawicki > >>> > > > >>> > > [EMAIL PROTECTED] > >>> > > 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 > >>> > >>> [EMAIL PROTECTED] > >>> http://stawicki.jasliska.pl > >>> > >> > >> > >> -- > >> Michał Stawicki > >> > >> [EMAIL PROTECTED] > >> 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 [EMAIL PROTECTED] http://stawicki.jasliska.pl