Skip to content

Instantly share code, notes, and snippets.

@senthilmuthiah
Created January 16, 2013 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save senthilmuthiah/4545051 to your computer and use it in GitHub Desktop.
Save senthilmuthiah/4545051 to your computer and use it in GitHub Desktop.
package demo;
import java.util.List;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.*;
import org.zkoss.zul.*;
public class SearchController extends SelectorComposer<Component> {
private static final long serialVersionUID = 1L;
@Wire
private Textbox keywordBox;
@Wire
private Listbox carListbox;
@Wire
private Label modelLabel;
@Wire
private Label makeLabel;
@Wire
private Label priceLabel;
@Wire
private Label descriptionLabel;
@Wire
private Image previewImage;
private CarService carService = new CarServiceImpl();
@Listen("onClick = #searchButton")
public void search(){
String keyword = keywordBox.getValue();
List<Car> result = carService.search(keyword);
carListbox.setModel(new ListModelList<Car>(result));
}
@Listen("onSelect = #carListbox")
public void showDetail(){
Car selected = carListbox.getSelectedItem().getValue();
previewImage.setSrc(selected.getPreview());
modelLabel.setValue(selected.getModel());
makeLabel.setValue(selected.getMake());
priceLabel.setValue(selected.getPrice().toString());
descriptionLabel.setValue(selected.getDescription());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment