-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi everybody,
When I call a method from the buttons on the following code, the system dosen´t find the class. Someone can help me ?
<zk> <window title="SIG - APOENA" width="770px" border="normal" use="br.com.apoena.scripts.Usuario" id="usuarioClasse"> <separator/> <groupbox> <listbox id="box" multiple="true" rows="5" onSelect="usuarioClasse.move()"> <listhead> <listheader label="Cod. Usuario" /> <listheader label="Empresa" /> <listheader label="Perfil" /> </listhead> <listitem forEach="${usuarioClasse.todosUsuarios}" value="${each}"> <listcell label="${each.usuario}" /> <listcell label="${each.empresa}" /> <listcell label="${each.perfil}" /> </listitem> </listbox> <caption label="Manut. Usuario" /> <grid fixedLayout="true"> <rows> <row> Cod. Usuario: <textbox id="usuario" cols="10" /> Empresa: <textbox id="empresa" cols="40" /> </row> <row> Senha: <textbox type="password" id="senha" cols="8" /> Perfil: <combobox id="perfil" autodrop="true" > <comboitem label="NIVEL 10" /> <comboitem label="NIVEL 8" /> <comboitem label="NIVEL 6" /> <comboitem label="NIVEL 4" /> <comboitem label="NIVEL 2" /> <comboitem label="NIVEL 0" /> </combobox> </row> <row> <button label="Icluir" width="36px" height="24px" onClick="usuarioClasse.add()" /> <button label="Alterar" width="46px" height="24px" onClick="usuarioClasse.update()" /> <button label="Excluir" width="46px" height="24px" onClick="usuarioClasse.delete()" /> </row> </rows> </grid> </groupbox> <separator/> </window> </zk>
package br.com.apoena.scripts; import java.util.List; import java.util.UUID; import org.zkoss.zul.Combobox; import org.zkoss.zul.Listbox; import org.zkoss.zul.Listcell; import org.zkoss.zul.Listitem; import org.zkoss.zul.Textbox; import org.zkoss.zul.Window; import br.com.apoena.eventos.UsuarioEvento; import br.com.apoena.persistencia.UsuarioDO; @SuppressWarnings("serial") public class Usuario extends Window{ UsuarioDO usuarioDO = new UsuarioDO(); private static final long serialVersionUID = 1L; private Textbox usuarioTela; private Listbox boxTela; private Textbox empresaTela; private Textbox senhaTela; private Combobox perfilTela; public List todosUsuarios ; public List getTodosUsuarios() { return usuarioDO.obterTodos(); } // executa durante criacao da window public void onCreate(){ // pegar referencia dos objetos que manipulam a tela System.out.println(" CHAMOU CREATE "); usuarioTela = ((Textbox) getFellow("usuario")); boxTela = ((Listbox) getFellow("box")); empresaTela = ((Textbox) getFellow("empresa")); senhaTela = ((Textbox) getFellow("senha")); perfilTela = ((Combobox) getFellow("perfil")); todosUsuarios= getTodosUsuarios(); } public void add(){ //insert no banco de dados System.out.println("CHAMOU ADICIONAR"); System.out.println(" > "+UUID.randomUUID().toString()+ " > "+usuarioTela.getValue() + " > "+empresaTela.getValue() + " > "+senhaTela.getValue() + " > "+perfilTela.getId() + " > "+perfilTela.getSelectedItem() + " > "+perfilTela.getName()); UsuarioEvento newEvt = new UsuarioEvento(UUID.randomUUID().toString(), usuarioTela.getValue(), empresaTela.getValue(), senhaTela.getValue(), perfilTela.getSelectedItem().getValue().toString()); usuarioDO.insert(newEvt); //sincroniza a variavel todosUsuarios com os dados do banco todosUsuarios = getTodosUsuarios(); //insere um novo Event na listbox Listitem li = new Listitem(); li.setValue(newEvt); li.appendChild(new Listcell(usuarioTela.getValue())); li.appendChild(new Listcell(empresaTela.getValue())); li.appendChild(new Listcell(perfilTela.getSelectedItem().getValue().toString())); boxTela.appendChild(li); } public void update(){ //atualiza o banco de dados // TODO UsuarioEvento editEvt = (UsuarioEvento)boxTela.getSelectedItem() /* editEvt.setEmpresa(empresaTela.getValue()); editEvt.setPerfil(perfilTela.getSelectedItem().getValue().toString()); //editEvt.setSenha(senha.value); editEvt.setUsuario(usuarioTela.getValue()); usuarioDO.update(editEvt); //atualiza a listbox List children = boxTela.getSelectedItem().getChildren(); ((Listcell)children.get(0)).setLabel(usuarioTela.getValue()); ((Listcell)children.get(1)).setLabel(empresaTela.getValue()); ((Listcell)children.get(2)).setLabel(perfilTela.getSelectedItem().getValue().toString()); */ } public void delete(){ usuarioDO.delete((UsuarioEvento)boxTela.getSelectedItem().getValue()); boxTela.removeItemAt(boxTela.getSelectedIndex()); cleargb(); } public void move(){ usuarioTela.setValue(boxTela.getSelectedItem().getChildren().get(0).toString()); empresaTela.setValue(boxTela.getSelectedItem().getChildren().get(1).toString()); // TODO perfilTela.setsetSelectedItem(new Listitem(boxTela.getSelectedItem().getChildren().get(3).toString())); //senhaTela.getValue() = ((UsuarioEvento)boxTela.selectedItem.value).getSenha(); } public void cleargb(){ usuarioTela.setRawValue(null); empresaTela.setRawValue(null); senhaTela.setRawValue(null); perfilTela.setSelectedIndex(0); } }
package br.com.apoena.eventos; import java.sql.Date; import sun.security.util.BigInt; /** * @author fabio * */ public class UsuarioEvento { private String id; private String usuario; private String empresa; private String senha; private String perfil ; public UsuarioEvento(){} /** * @param id * @param cod_usuario * @param empresa * @param senha * @param perfil */ public UsuarioEvento(String id,String usuario,String empresa,String senha, String perfil){ System.out.println("usuario >"+usuario+" empresa >"+empresa+" senha >"+senha+" perfil >"+perfil); this.id=id; this.usuario=usuario; this.empresa=empresa; this.perfil=perfil; this.senha=senha; } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getUsuario() { return usuario; } public void setUsuario(String usuario) { this.usuario = usuario; } public String getEmpresa() { return empresa; } public void setEmpresa(String empresa) { this.empresa = empresa; } public String getSenha() { return senha; } public void setSenha(String senha) { this.senha = senha; } public String getPerfil() { return perfil; } public void setPerfil(String perfil) { this.perfil = perfil; } }
06/04/2010 11:52:36 org.zkoss.zk.ui.impl.UiEngineImpl handleError:1114 SEVERE: >>org.zkoss.zk.ui.UiException: Sourced file: inline evaluation of: `` usuarioClasse.add();'' : Attempt to resolve method: add() on undefined variable or class name: usuarioClasse : at Line: 54 : in file: inline evaluation of: `` usuarioClasse.add();'' : usuarioClasse .add ( ) >>Sourced file: inline evaluation of: `` usuarioClasse.add();'' : Attempt to resolve method: add() on undefined variable or class name: usuarioClasse : at Line: 54 : in file: inline evaluation of: `` usuarioClasse.add();'' : usuarioClasse .add ( ) >> >> at bsh.UtilEvalError.toEvalError(Unknown Source) >> at bsh.UtilEvalError.toEvalError(Unknown Source) >> at bsh.BSHMethodInvocation.eval(Unknown Source) >> at bsh.BSHPrimaryExpression.eval(Unknown Source) >> at bsh.BSHPrimaryExpression.eval(Unknown Source) >> at bsh.Interpreter.eval(Unknown Source) >> at bsh.Interpreter.eval(Unknown Source) >> at org.zkoss.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:134) >> at org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.java:341) >> at org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:796) >> at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:175) >> at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:140) >>...
try:
<row> <button label="Icluir" width="36px" height="24px" onClick="br.com.apoena.scripts.Usuario.add()" /> . . .
Hi Terry,
For call this static form i have to change somethings on my class. It find the method but appear other problems. Do you know why i can´t use the reference ?
thanks.
See what happens when you change Usuario from
... public void add() { ... }
... public void add(Event evt) { ... }
I know in the event handlers of the GenericForwardComposer subclasses the signature has to include that parameter...
Caclark,
I changed the code, but the error persist.
thanks.
had a solution?
@brunohsimoes, did you experience a similar issue? If so, what is your case? When I simplify portofabio's case down to a runnable code, it works on my system. Here is the test code I have:
zul
<zk> <window use="foo.MyWin" id="win"> <button label="Go" onClick="win.add()"/> </window> </zk>
foo.MyWin
package foo; import org.zkoss.zul.Window; public class MyWin extends Window { public void add(){ System.out.println("triggered!"); } }
Regards,
Simon
Asked: 2010-04-06 22:30:32 +0800
Seen: 1,066 times
Last updated: Jul 21 '10