|
Processing... Click on the column headers to sort each column.
Description & Source Code
demo.zul
<zk> <style src="/widgets/getting_started/grid/style.css"/> <window id="win" title="Car List" width="650px" border="normal" apply="demo.getting_started.grid.CarListController"> <grid model="${win$composer.carsModel}" mold="paging" pageSize="5"> <auxhead> <auxheader /> <auxheader label="General Specification" align="center" colspan="3" /> <auxheader label="Tech Specification" align="center" colspan="2" /> </auxhead> <columns> <column width="40px" /> <column label="Model" align="center" sort="auto(model)" /> <column label="Make" align="center" sort="auto(make)" /> <column label="Cost" align="center" sort="auto(cost)" image="/widgets/getting_started/img/dollar.png" /> <column label="Displacement" align="center" sort="auto(engineDisplacement)" /> <column label="Transmission" align="center" sort="auto(autoTransmission)" /> </columns> <template name="model"> <row> <detail> <hlayout sclass="detail"> <image width="128px" style="margin: 8px" src="/widgets/getting_started/img/${each.picture}.png" /> <vlayout> <hlayout sclass="detail-row"> <label value="Type :" sclass="title" /> <label value="${each.type}" /> </hlayout> <hlayout sclass="detail-row"> <label value="Accessories :" sclass="title" /> <label value="${each.accessories}" /> </hlayout> <hlayout sclass="detail-row"> <label value="Country :" sclass="title" /> <hlayout> <label value="${each.country}" /> <image src="/widgets/getting_started/img/${each.country}.png" /> </hlayout> </hlayout> <hlayout sclass="detail-row"> <label value="Salesmen :" sclass="title" /> <label value="${each.salesmen}" /> </hlayout> </vlayout> </hlayout> </detail> <label value="${each.model}" /> <label value="${each.make}" /> <label value="${each.cost}" /> <label value="${each.engineDisplacement} c.c." /> <hlayout> <image src="/widgets/getting_started/img/${each.autoTransmission ? 'at' : 'mt' }.png" /> <label value="${each.autoTransmission ? 'AT' : 'MT'}" /> </hlayout> </row> </template> </grid> </window> </zk> CarListController.java
package demo.getting_started.grid; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.select.SelectorComposer; import org.zkoss.zul.ListModel; import org.zkoss.zul.ListModelList; import demo.getting_started.Car; import demo.getting_started.CarService; import demo.getting_started.CarServiceImpl; public class CarListController extends SelectorComposer<Component> { private static final long serialVersionUID = 1L; private ListModel<Car> carsModel; public CarListController() { CarService carService = new CarServiceImpl(); carsModel = new ListModelList<Car>(carService.findAll()); } public ListModel<Car> getCarsModel() { return carsModel; } } Car.java
package demo.getting_started; import java.util.Set; public class Car { private String carId; private String model; private String picture; private String make; private String country; private String type; private double cost; private int engineDisplacement; private boolean autoTransmission; private Accessories accessories; private Set<String> salesmen; public Car() { } public String getCarId() { return carId; } public void setCarId(String carId) { this.carId = carId; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } public String getPicture() { return picture; } public void setPicture(String picture) { this.picture = picture; } public String getMake() { return make; } public void setMake(String make) { this.make = make; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } public String getType() { return type; } public void setType(String type) { this.type = type; } public double getCost() { return cost; } public void setCost(double cost) { this.cost = cost; } public int getEngineDisplacement() { return engineDisplacement; } public void setEngineDisplacement(int engineDisplacement) { this.engineDisplacement = engineDisplacement; } public boolean isAutoTransmission() { return autoTransmission; } public void setAutoTransmission(boolean autoTransmission) { this.autoTransmission = autoTransmission; } public Accessories getAccessories() { return accessories; } public void setAccessories(Accessories accessories) { this.accessories = accessories; } public Set<String> getSalesmen() { return salesmen; } public void setSalesmen(Set<String> salesmen) { this.salesmen = salesmen; } public String toString() { return model; } } CarService.java
package demo.getting_started; import java.util.List; public interface CarService { /** * Retrieve all cars in the car store. * @return all cars. */ public List<Car> findAll(); /** * Store or modify a car in car store. */ void store(Car car); /** * Store or modify a inventory item in car store. */ void store(InventoryItem inventoryItem); /** * Order cars. */ void order(List<OrderItem> orderItems); /** * Retrieve the root of car categories. */ Category getCarCategoriesRoot(); /** * Count cars by filter. */ int countByFilter(String filter); /** * Query cars by filter. */ List<Car> queryByFilter(String filter); }
Copyright © 2005-2024 Potix Corporation All rights reserved.
|
Processing... |