-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am new comer in ZK.
I have big problem, i can not show my db to Listbox
this is my controller:
public void onClick$searchButton1(Event event) throws InterruptedException {
List<SearchEj> persons = new ArrayList<SearchEj>();
SearchEjServices ejService = new SearchEjServices(null, null);
List<SearchEj> ls = ejService.findAll();
personModelList.addAll(ls);
theList.setModel(personModelList);
}
Zul:
<listbox id="theList" mold="paging"
pageSize="30" vflex="true" >
<listhead sizable="true">
<listheader label="ATM ID" sort="auto" />
<listheader label="Type" sort="auto" />
<listheader label="File Name" sort="auto" />
<listheader label="File Path" sort="auto" />
</listhead>
<listitem >
<listcell label="${each.sATMID}"></listcell>
<listcell label="${each.iTaskType}"></listcell>
<listcell label="${each.sEJFileName}"></listcell>
<listcell label="${each.sEJFilePath}"></listcell>
</listitem>
</listbox>
How can i fix it :( please help me
Please check here
Please Share your Java Class how you implemented getIemrendered() in Java Class?
this is my Controller :
package de.forsthaus.webui.blog; import java.io.Serializable; import java.sql.ResultSet; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import mcrt.config.ConnectODBC_DSN; import mcrt.model.SearchEj; import mcrt.model.SearchEjServices; import org.apache.log4j.Logger; import org.zkoss.util.resource.Labels; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Path; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.util.Clients; import org.zkoss.zkplus.databind.BindingListModelList; import org.zkoss.zul.Borderlayout; import org.zkoss.zul.Iframe; import org.zkoss.zul.Intbox; import org.zkoss.zul.ListModel; import org.zkoss.zul.ListModelList; import org.zkoss.zul.Listbox; import org.zkoss.zul.Listcell; import org.zkoss.zul.Listitem; import org.zkoss.zul.Window; import com.lowagie.text.ListItem; import de.forsthaus.webui.guestbook.model.GuestBookListtemRenderer; import de.forsthaus.webui.util.GFCBaseCtrl; /** * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br> * This is the controller class for the /WEB-INF/blog/blog.zul file. <br> * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br> * * @author bbruhns * @author sgerth */ public class BlogCtrl extends GFCBaseCtrl implements Serializable { private static final long serialVersionUID = 12L; private static final Logger logger = Logger.getLogger(BlogCtrl.class); /* * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * All the components that are defined here and have a corresponding * component with the same 'id' in the zul-file are getting autowired by our * 'extends GFCBaseCtrl' GenericForwardComposer. * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ protected Window windowBlog; // autowired protected Borderlayout borderLayout_blog; // autowired protected Iframe iFrameBlog; // autowired private Listbox theList; private List<SearchEj> pLists; private List<SearchEj> ejfiles = new ArrayList<SearchEj>(); private ListModelList listModel; /** * default constructor.<br> */ public BlogCtrl() { super(); } ListModelList personModelList = new ListModelList(); @Override public void doAfterCompose(Component window) throws Exception { super.doAfterCompose(window); /** * 1. Set an 'alias' for this composer name to access it in the * zul-file.<br> * 2. Set the parameter 'recurse' to 'false' to avoid problems with * managing more than one zul-file in one page. Otherwise it would be * overridden and can ends in curious error messages. */ // SearchEjServices ejService = new SearchEjServices(null, null); // listModel = new ListModelList(ejService.findAll()); // theList.setItemRenderer(new MyItemRenderer()); this.self.setAttribute("controller", this, false); SearchEjServices ejService = new SearchEjServices(null, null); ejfiles = ejService.findAll(); } // +++++++++++++++++++++++++++++++++++++++++++++++++ // // +++++++++++++++ Component Events ++++++++++++++++ // // +++++++++++++++++++++++++++++++++++++++++++++++++ // public void onCreate$windowBlog(Event event) throws Exception { doFitSize(); loadDocument(event); } public void onClick$btnRefresh(Event event) throws InterruptedException { doFitSize(); } public void onClick$searchButton1(Event event) throws InterruptedException { SearchEjServices ejService = new SearchEjServices(null, null); ejfiles = ejService.findAll(); theList.getItems().clear(); theList.setModel(new ListModelList(ejfiles)); //theList.setModel(listModel); //Listitem listitem = new Listitem(); theList.renderAll(); } public List<SearchEj> getEjfiles() { return ejfiles; } // +++++++++++++++++++++++++++++++++++++++++++++++++ // // +++++++++++++++++ Business Logic ++++++++++++++++ // // +++++++++++++++++++++++++++++++++++++++++++++++++ // /** * Loads the document and startet an echo event message. * * @param event * @throws Exception */ public void loadDocument(Event event) { // we load the website in an Echo-event to show a message to the // user if this is a long running operation. Clients.showBusy(Labels .getLabel("message.Information.LongOperationIsRunning")); Events.echoEvent("onLoadDocument", BlogCtrl.this.windowBlog, null); } public void onLoadDocument() { try { iFrameBlog.setSrc("ejm/index.zul"); } finally { Clients.clearBusy(); // close the message } } // +++++++++++++++++++++++++++++++++++++++++++++++++ // // ++++++++++++++++++++ Helpers ++++++++++++++++++++ // // +++++++++++++++++++++++++++++++++++++++++++++++++ // /** * Recalculates the container size for this controller and resize them. * * Calculate how many rows have been place in the listbox. Get the * currentDesktopHeight from a hidden Intbox from the index.zul that are * filled by onClientInfo() in the indexCtroller. */ public void doFitSize() { // normally 0 ! Or we have a i.e. a toolBar on top of the listBox. final int specialSize = 26; final int height = ((Intbox) Path .getComponent("/outerIndexWindow/currentDesktopHeight")) .getValue().intValue(); final int maxListBoxHeight = height - specialSize - 88; this.borderLayout_blog.setHeight(String.valueOf(maxListBoxHeight) + "px"); borderLayout_blog.invalidate(); } }
This is my model
package mcrt.model; import de.forsthaus.backend.model.Entity; public class SearchEj { private String iEJFile; private String sTaskID; private String sATMID; private String sEJFilePath; private String sEJFileName; private String iFileSize; private String dStartDate; private String dEndDate; private String sTaskName; private String tStartTime; private String tEndTime; private String iEJFileType; private String sDescription; private String sATMEJFilePath; private String sATMEJFileName; private String iTaskType; public SearchEj(String iEJFile,String sTaskID,String sATMID,String sEJFilePath, String sEJFileName,String iFileSize,String dStartDate, String dEndDate,String sTaskName,String tStartTime, String tEndTime,String iEJFileType, String sDescription, String sATMEJFilePath,String sATMEJFileName,String iTaskType){ this.iEJFile = iEJFile; this.sTaskID = sTaskID; this.sATMID = sATMID; this.sEJFilePath = sEJFilePath; this.sEJFileName = sEJFileName; this.iFileSize = iFileSize; this.dStartDate = dStartDate; this.dEndDate = dEndDate; this.sTaskName = sTaskName; this.tStartTime = tStartTime; this.tEndTime = tEndTime; this.iEJFileType = iEJFileType; this.sDescription = sDescription; this.sATMEJFilePath = sATMEJFilePath; this.sATMEJFileName = sATMEJFileName; this.iTaskType = iTaskType; } public SearchEj(){} public String getiEJFile() { return this.iEJFile; } public void setiEJFile(String ejfile){ this.iEJFile = ejfile; } public String getTaskID(){ return this.sTaskID; } public void setTaskID(String taskID){ this.sTaskID = taskID; } public String getsATMID(){ return this.sATMID; } public void setsATMID(String sATMID){ this.sATMID = sATMID; } public String getsEJFilePath(){ return this.sEJFilePath; } public void setsEJFilePath(String ejfilepath){ this.sEJFilePath = ejfilepath; } public String getsEJFileName(){ return this.sEJFileName; } public void setsEJFileName(String ejfilename){ this.sEJFileName = ejfilename; } public String getiFileSize(){return this.iFileSize;} public void setiFileSize(String ejfilesize){this.iFileSize = ejfilesize;} public String getdStartDate(){return this.dStartDate;} public void setdStartDate(String startdate){this.dStartDate = startdate;} public String getdEndDate(){return this.dEndDate;} public void setdEndDate(String enddate){this.dEndDate = enddate;} public String getsTaskName(){return this.sTaskName;} public void setsTaskName(String taskname){this.sTaskName = taskname;} public String gettStartTime(){return this.tStartTime;} public void settStartTime(String starttime){this.tStartTime = starttime;} public String gettEndTime(){return this.tEndTime;} public void settEndTime(String endtime){this.tEndTime = endtime;} public String getiEJFileType(){return this.iEJFileType;} public void setiEJFileType(String ejfiletype){this.iEJFileType = ejfiletype;} public String getsDescription(){return this.sDescription;} public void setsDescription(String description){this.sDescription = description;} public String getsATMEJFilePath(){return this.sATMEJFilePath;} public void setsATMEJFilePath(String atmejfilepath){this.sATMEJFilePath = atmejfilepath;} public String getsATMEJFileName(){return this.sATMEJFileName;} public void setsATMEJFileName(String atmejfilename){this.sATMEJFileName = atmejfilename;} public String getiTaskType(){return this.iTaskType;} public void setiTaskType(String tasktype){this.iTaskType = tasktype;} }
this is my view
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?> <div width="100%" height="100%" apply="de.forsthaus.webui.blog.BlogCtrl" id="plstWin"> ATM ID: <textbox id="atmId1" /> Upload type: <listbox id="uploadType" mold="select" tabindex="8"> <listitem label=" " value="0" /> <listitem label="Immediate" value="1" /> <listitem label="Schedule" value="2" /> </listbox> Start from: <datebox id="dateStartFrom" format="dd-MM-yyyy" /> to: <datebox id="dateEndTo" format="dd-MM-yyyy" /> File name: <textbox id="fileName" value="" /> <button id="searchButton1" label="Search" /> <groupbox open="false"> <grid> <rows> <row> ATM ID: <textbox id="atmId2" value="" /> </row> <row></row> <row> <button id="bttsearch" label="Refresh" /> </row> </rows> </grid> </groupbox> <listbox id="theList" emptyMessage="No Ej file found in the result" height="100%" style="margin-top:10px;font-size:10px;" mold="paging" pageSize="30" width="100%"> <listhead> <listheader label="Atm ID" /> <listheader label="Type" /> <listheader label="File Name" /> <listheader label="File Path" /> <listheader width="100px" label="Size" /> <listheader width="150px" label="Start Date" /> <listheader width="150px" label="End Date" /> </listhead> <listitem self="@{each=file}"> <listcell label="${file.sATMID}"></listcell> <listcell label="${file.iTaskType}"></listcell> <listcell label="${file.sEJFileName}"></listcell> <listcell label="${file.sEJFilePath}"></listcell> <listcell> <label value="${file.iFileSize}" /> </listcell> <listcell> <label value="${file.dStartDate}" /> <!-- <label value="@{file.dStartDate, converter='mcrt.ultility.DateCustom'}" />--> <!-- <custom-attributes format="dd-MM-yyyy" />--> </listcell> <listcell> <label value="${file.dEndDate}" /> </listcell> </listitem> </listbox> <div>
please help me :(
i bind data but it blank ( still have record & paging )
As you are using apply and gave your class to this apply then you have to Wire your component in Java Class . As i am looking in your Java Class you did not Wire any component in Java Class.So how you will get the Data in ZUL page? How ZUL page know from where i have to load the data? OtherWise you have to use ViewModel in ZUl page .
See these two example
Wiring Example
ViewModel Example
Please let me know if you still ave any issue
What about this class GFCBaseCtrl.java This is main class which is know about the ZUL page Please post this class also You have to use @Wire in this class as i am assuming. ;So in your afterCompose after add Selector.wireComponent(view,null,null) something like this.
Asked: 2013-01-10 09:43:48 +0800
Seen: 261 times
Last updated: Jan 15 '13