ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

zk e comboBox

Welder
18 Dec 2011 17:54:35 GMT
18 Dec 2011 17:54:35 GMT


Submited.zul
<zk xmlns:n="native">

<zscript>
Map m = Executions.getCurrent().getParameterMap();
Iterator ir = m.keySet().iterator();
StringBuffer sb = new StringBuffer();
while(ir.hasNext()){
String key = (String) ir.next();
sb.append(key+":"+m.get(key)[0] +"\n");
}
String ret = sb.toString();
</zscript>
<n:pre>
${ret};

${userName};
${password};
</n:pre>
</zk>

TestComposer.java
package j7v01um$v10;

import org.zkoss.zk.ui.*;
import org.zkoss.zk.ui.event.*;
import org.zkoss.zk.ui.util.*;
import org.zkoss.zul.*;
import org.zkoss.zhtml.Form;

public class TestComposer extends GenericForwardComposer{

private Textbox userName;
private Textbox password;
private Form form;

public void onSubmit$form(Event e){
if(validate()){
Clients.evalJavaScript("jq('#"+form.getUuid()+"')[0].submit();");
}else{
try {
Messagebox.show("Wrong input ");
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}

public boolean validate(){
if(!userName.getValue().matches("\\w{4,15}")){
return false;
}
if(!password.getValue().matches("\\w{4,15}")){
return false;
}
return true;
}
}


index.zul
<zk xmlns:h="xhtml" xmlns:w="client">

<h:form id="form" apply="j7v01um$v10.TestComposer" action="Submited.zul" method="POST" >
<h:table>
<h:tr>
<h:tb> User Name </h:tb>
<h:tb>
<textbox id="userName" name="j_username"></textbox>
</h:tb>
</h:tr>
<h:tr>
<h:tb> Password </h:tb>
<h:tb>
<textbox id="password" type="password" name="j_password"></textbox>
</h:tb>
</h:tr>
<h:tr>
<h:tb>
<h:input type="submit" value="Login"></h:input>
</h:tb>
<h:tb>
<h:input type="button" value="Reset" h:onclick="cleanErr();" forward="onClick=onClean"></h:input>
</h:tb>
</h:tr>
</h:table>
</h:form>
<script>
zk.afterMount(function(){
jq("$form").submit(function(){
zAu.send(new zk.Event(zk.Widget.$(this), 'onSubmit'));
return false;
});
});
</script>

</zk>
How do I fill in a comoBox zk?
If I used the OnCreate, I am looking into it a list, but I could not make up a complete dynamically.

example:

public void onCreate (Event event) throws InterruptedException, IOException, SQLException, ClassNotFoundException {

EditoraPersistencia editoraPersistencia DAOFactory.getiEditoraDAO = ();

Collection <Editora> editoraPersistencia.pesquisar editor = (null);


if (editor! = null) {
for (ed Publisher: publisher) {

/ / i.setLabel (ed.getNome ());
/ / i.setMold (ed.getNome ());
/ / lbxEditora.setName (ed.getNome ());
/ / setModel ((ListModel) ed.getNome ());

}

}

}

I've tried everything to fill out this combo, but I can not. seeking the combo is populated from the DB.
I tried using a <zcript> for that purpose and nadabr

I am using the bandbox, he works as follows where le, $ {languages​​} and receive my list that reads: $ {each} the list data
PS.: This list is of type ListModel, listGroup etc. ...???

How to populate a comboBox in the model Citati

File. zul.

<bandbox id="bd" mold="rounded" autodrop="true">
<bandpopup>
<listbox height = "250px" width = "300px" mold = "paging" autopaging = "true"
onSelect = "= bd.value self.selectedItem.label; bd.close ();">
<listhead>
<listheader label="Programming Languages" ></listheader>
</ listhead>
<listitem> label="${each}" forEach="${languages}" />
</ listbox>
</ bandpopup>
</ bandbox>


In short, how do I fill out a comboBox in zk, fetching data from a database?