-
FEATURED COMPONENTS
First time here? Check out the FAQ!
The Timeline/BandInfo removeOccurEvent cannot remove the selected event. In what basis removeOccurEvent is finding the equal or relevant OccurEvent? Should we override .equals?
Here is a sample to remove the selected occur event.
sample.zul
<div apply="pkg$.TimelineController">
<timeline id="timeline" height="300px" width="100%">
<bandinfo id="bandinfoMonth" width="70%" intervalUnit="month"
intervalPixels="100" bubbleVisible="false" />
<bandinfo id="bandinfoYear" width="30%" intervalUnit="year"
intervalPixels="200" syncWith="bandinfoMonth" />
</timeline>
</div>
TimelineController.java
package pkg$;
...
@SuppressWarnings("serial")
public class TimelineController extends SelectorComposer<Component> {
private final static DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
@Wire
Timeline timeline;
@Wire
private Bandinfo bandinfoMonth, bandinfoYear;
private ListModelList<OccurEvent> model = null;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
Date currentDate = DATE_FORMAT.parse("2014-01-08");
bandinfoMonth.setDate(currentDate);
bandinfoYear.setDate(currentDate);
List<OccurEvent> listEvents = new ArrayList<OccurEvent>();
OccurEvent oe = null;
oe = new OccurEvent();
oe.setStart(DATE_FORMAT.parse("2013-10-01"));
oe.setDescription("I'm not sure precisely when my friend's wedding is.");
oe.setText("Friend's wedding");
listEvents.add(oe);
oe = new OccurEvent();
oe.setStart(DATE_FORMAT.parse("2013-10-15"));
oe.setEnd(DATE_FORMAT.parse("2013-11-01"));
oe.setDescription("A few days to write some documentation for <a href=\"http://www.zkoss.org/doc/styleguide\">Timeline</a>.");
oe.setText("Writing Style Guide");
oe.setDuration(true);
oe.setImageUrl("http://simile.mit.edu/images/csail-logo.gif");
listEvents.add(oe);
model = new ListModelList<OccurEvent>(listEvents, true);
bandinfoMonth.setModel(model);
bandinfoYear.setModel(model);
}
@Listen("onOccurEventSelect=#bandinfoMonth")
public void doSelect(OccurEventSelectEvent event) {
OccurEvent oe = event.getOccurEvent();
OccurEvent ev = null;
ListIterator<OccurEvent> li = model.listIterator();
while (li.hasNext()) {
ev = li.next();
if (ev.getStart().equals(oe.getStart()))
break;
}
model.remove(ev);
}
}
Asked: 2013-12-24 09:54:25 +0800
Seen: 9 times
Last updated: Jan 08 '14
Are you using an XML or a ListModel as the event source? Can you post the sample code?
neillee ( 2013-12-25 11:10:17 +0800 )edit