-
FEATURED COMPONENTS
First time here? Check out the FAQ!
hi,
I have a combobox and I want to fill it with images, it has been filled by icons names but the images will not be displayed
knowing that I get these images from a local folder.
public void appendList(){
File f = new File(System.getProperty("folderDirectory")+"/"+folderName);
if(f.exists()){
String[] files = f.list();
for (String fil:files) {
Comboitem item = new Comboitem(fil);
item.setImage(fil);
list.appendChild(item);
}
}
}
can you help me?
Thanks in advance.
Maybe you have to create a RowRenderer
See these links :
- http://www.zkoss.org/smalltalks/livedata/livedataforgrid.dsp
- http://www.zkoss.org/forum/listComment/5351
- http://www.zkoss.org/javadoc/5.0/zk/org/zkoss/zul/RowRenderer.html
If you get the image/icon than it must work like Yamil said!
Bellow are codes as a sample from such an ItemRenderer for a listbox. In one ListCell are an ICON + Label.
You can modify it for working as RowRenderer for a Grid if needed:
/** * Copyright 2010 the original author or authors. * * This file is part of Zksample2. http://zksample2.sourceforge.net/ * * Zksample2 is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Zksample2 is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Zksample2. If not, see <http://www.gnu.org/licenses/gpl.html>. */ . . . /** * Item renderer for listitems in the listbox. * * @author bbruhns * @author sgerth * */ public class SecLoginlogStatisticTotalListModelItemRenderer implements ListitemRenderer, Serializable { private static final long serialVersionUID = 1L; private transient static final Logger logger = Logger.getLogger(SecLoginlogStatisticTotalListModelItemRenderer.class); @Override public void render(Listitem item, Object data) throws Exception { DummyBean dummyBean = (DummyBean) data; if (logger.isDebugEnabled()) { // logger.debug("--> " + dummyBean.getCountry()); } Listcell lc; lc = new Listcell(); Hbox hbox = new Hbox(); hbox.setParent(lc); /* Flag-image */ ---> Image img = new Image(); String path = "/images/countrycode_flags/"; String flag = StringUtils.lowerCase(dummyBean.getCountry()) + ".gif"; img.setSrc(path + flag); hbox.appendChild(img); Separator sep = new Separator(); hbox.appendChild(sep); /* Country */ Label label = new Label(); label.setValue(dummyBean.getCountry()); hbox.appendChild(label); lc.setParent(item); lc = new Listcell(dummyBean.getCountryName()); lc.setParent(item); lc = new Listcell(dummyBean.getTotalCount().toString()); lc.setStyle("text-align: right"); lc.setParent(item); item.setAttribute("data", data); // ComponentsCtrl.applyForward(img, "onClick=onImageClicked"); // ComponentsCtrl.applyForward(item, "onClick=onClicked"); // ComponentsCtrl.applyForward(item, "onDoubleClick=onDoubleClicked"); } }
best
Stephan
I want to use the configuration in:
D:\jboss\jboss-4.2.3.GA\server\default\deploy\jboss-web.deployer/server.xml
<Context path="/image"
docBase="D:/folder/image"
reloadable="true">
</Context>
public void appendList(){
File f = new File(System.getProperty("image");
if(f.exists()){
String[] files = f.list();
for (String fil:files) {
Comboitem item = new Comboitem(fil);
item.setImage(fil);
list.appendChild(item);
}
}
}
Asked: 2010-05-04 09:37:53 +0800
Seen: 481 times
Last updated: May 06 '10