Tiago Borghi:
Era pra reconhecer Fabio. Poste o seu código para dar para ter alguma idéia.
Poste também o erro que ele gera.
Abraço
Tiago segue abaixo o meu código e o erro. Obrigado.
login.zul
<window title="SIG - APOENA" width="770px" border="normal" >
<zscript>
import br.com.apoena.eventos.UsuarioEvento;
import br.com.apoena.persistencia.UsuarioDO;
import java.util.ArrayList;
import java.util.UUID;
//fetch all events from database
UsuarioDO usuarioDO = new UsuarioDO();
List todosUsuarios = usuarioDO.obterTodos();
void add(){
//insert no banco de dados
System.out.println("CHAMOU ADICIONAR");
System.out.println(" > "+UUID.randomUUID().toString()+
" > "+usuario.value +
" > "+empresa.value +
" > "+senha.value +
" > "+perfil.value);
UsuarioEvento newEvt =
new UsuarioEvento(UUID.randomUUID().toString(),
usuario.value,
empresa.value,
senha.value,
perfil.value);
usuarioDO.insert(newEvt);
//sincroniza a variavel todosUsuarios com os dados do banco
todosUsuarios = usuarioDO.obterTodos();
//insere um novo Event na listbox
Listitem li = new Listitem();
li.setValue(newEvt);
li.appendChild(new Listcell(usuario.value));
li.appendChild(new Listcell(empresa.value));
li.appendChild(new Listcell(perfil.value));
box.appendChild(li);
}
void update(){
//atualiza o banco de dados
UsuarioEvento editEvt = (UsuarioEvento)box.selectedItem.value;
editEvt.setEmpresa(empresa.value);
editEvt.setPerfil(perfil.value);
//editEvt.setSenha(senha.value);
editEvt.setUsuario(usuario.value);
usuarioDO.update(editEvt);
//atualiza a listbox
List children = box.selectedItem.children;
((Listcell)children.get(0)).label = usuario.value;
((Listcell)children.get(1)).label = empresa.value;
((Listcell)children.get(2)).label = perfil.value;
}
void delete(){
usuarioDO.delete((UsuarioEvento)box.selectedItem.value);
box.removeItemAt(box.getSelectedIndex());
cleargb();
}
void move(){
usuario.value = ((UsuarioEvento)box.selectedItem.value).getUsuario();
empresa.value = ((UsuarioEvento)box.selectedItem.value).getEmpresa();
perfil.value = ((UsuarioEvento)box.selectedItem.value).getPerfil();
senha.value = ((UsuarioEvento)box.selectedItem.value).getSenha();
}
void cleargb(){
usuario.value = null;
empresa.value = null;
senha.value = null;
perfil.value = null;
}
</zscript>
<listbox id="box" multiple="true" rows="4" onSelect="move()">
<listhead>
<listheader label="Cod. Usuario" />
<listheader label="Empresa" />
<listheader label="Perfil" />
</listhead>
<listitem forEach="${todosUsuarios}" value="${each}">
<listcell label="${each.usuario}" />
<listcell label="${each.empresa}" />
<listcell label="${each.perfil}" />
</listitem>
</listbox>
<groupbox>
<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="add()" />
<button label="Alterar" width="46px" height="24px"
onClick="update()" />
<button label="Excluir" width="46px" height="24px"
onClick="delete()" />
</row>
</rows>
</grid>
</groupbox>
</window>
##################################
############# UsuarioEvento.java ##############
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;
}
}
########################################
############### UsuarioDO.java ############################
package br.com.apoena.persistencia;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.beanutils.RowSetDynaClass;
import br.com.apoena.eventos.UsuarioEvento;
import br.com.apoena.utils.bd.ComandoBDFactory;
import br.com.apoena.utils.bd.IComandoBD;
import br.com.apoena.utils.seg.Criptografia;
public class UsuarioDO {
public UsuarioDO() {}
public List obterTodos(){
IComandoBD iBD = null;
try {
List retorno = new ArrayList();
iBD = ComandoBDFactory.getComando();
java.sql.ResultSet rs = iBD.executarSelect("SELECT ID_USUARIO AS ID, " +
"COD_USUARIO AS usuario, " +
"NOME_FANTASIA AS EMPRESA, " +
"NOME_PERFIL AS PERFIL FROM V_USUARIOS ORDER BY COD_USUARIO");
while(rs.next()){
retorno.add(new UsuarioEvento(rs.getString("ID"),
rs.getString("usuario"),
rs.getString("EMPRESA"),
null,
rs.getString("PERFIL")));
}
// return rsdc.getRows();
return retorno;
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public boolean delete(UsuarioEvento evt){
return false;
}
public boolean insert(UsuarioEvento evt){
IComandoBD iBD = null;
try {
iBD = ComandoBDFactory.getComando();
System.out.println("INSERT INTO USUARIO VALUES (" +
"(SELECT MAX(ID_USUARIO) FROM USUARIO) + 1,"
+evt.getUsuario().toUpperCase()+","
+Criptografia.criptografar(evt.getSenha()).toUpperCase()+","
+"(select id_perfil from perfil where nome_perfil='"+evt.getPerfil().toUpperCase()+"'),"
+"(select id_empresa from empresa where nome_fantasia='"+evt.getEmpresa().toUpperCase()+"')");
iBD.executarInsert("INSERT INTO USUARIO VALUES (" +
"(SELECT MAX(ID_USUARIO) FROM USUARIO) + 1,"
+evt.getUsuario().toUpperCase()+","
+Criptografia.criptografar(evt.getSenha()).toUpperCase()+","
+"(select id_perfil from perfil where nome_perfil='"+evt.getPerfil().toUpperCase()+"'),"
+"(select id_empresa from empresa where nome_fantasia='"+evt.getEmpresa().toUpperCase()+"')");
return true;
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
public boolean update(UsuarioEvento evt){
return false;
}
}
########################################
########### Erro #############
26/03/2010 12:33:23 org.zkoss.zk.ui.impl.UiEngineImpl handleError:1114
SEVERE: >>org.zkoss.zk.ui.UiException: Sourced file: inline evaluation
of: . . . '' : Class or variable not found: box.selectedItem.value : at Line: 66 : in file: inline evaluation of: import br.com.apoena.eventos.UsuarioEvento; import
br.com.apoena.pers . . . ‘’ : box .selectedItem .value
Called from method: move : at Line: 81 : in file: inline evaluation
of: ``
. . . ‘’ : move ( )
Sourced file: inline evaluation of: . . . '' : Class or variable not found: box.selectedItem.value : at Line: 66 : in file: inline evaluation of: import br.com.apoena.eventos.UsuarioEvento; import br.com.apoena.pers . . . ‘’ : box .selectedItem .value
Called from method: move : at Line: 81 : in file: inline evaluation of: `` . . . ‘’ : move ( )
at bsh.UtilEvalError.toEvalError(Unknown Source)
at bsh.UtilEvalError.toEvalError(Unknown Source)
at bsh.BSHAmbiguousName.toObject(Unknown Source)
at bsh.BSHAmbiguousName.toObject(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHCastExpression.eval(Unknown Source)
at bsh.BSHPrimarySuffix.doSuffix(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHAssignment.eval(Unknown Source)
at bsh.BSHBlock.evalBlock(Unknown Source)
at bsh.BSHBlock.eval(Unknown Source)
at bsh.BshMethod.invokeImpl(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.Name.invokeLocalMethod(Unknown Source)
at bsh.Name.invokeMethod(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)
…
########################