-
FEATURED COMPONENTS
First time here? Check out the FAQ!
as you see. I still bind data, but in ZUL it got error :(
i dont know why i failed . please help me :(
this is my DummyRole.. :
package de.forsthaus.webui.blog; import java.util.ArrayList; import mcrt.model.UserRole; import mcrt.model.UserRoleServices; /* * Created by SonPham - [email protected] */ public class DummyUserRole { private static ArrayList<UserRole> personList = new ArrayList<UserRole>(); static { setPersonList(); } public static ArrayList<UserRole> getPersonList() { return personList; } private static void setPersonList() { UserRoleServices uservices = new UserRoleServices(); for (int i = 0; i < uservices.findAll().size(); i++) { UserRole personx = new UserRole(); //personx.setsDescription(uservices.findAll().get(i).getsDescription()); personList.add(new UserRole(uservices.findAll().get(i).getID(), uservices.findAll().get(i).getFunctionID(),uservices.findAll().get(i).getUserName(),uservices.findAll().get(i).getviewRole(), uservices.findAll().get(i).geteditRole(), uservices.findAll().get(i).getdeleteRole(), uservices.findAll().get(i).getUserID() ,uservices.findAll().get(i).getFunctionName())); } } }
this is my Render:
package de.forsthaus.webui.blog; import mcrt.model.UserRole; import org.zkoss.zul.Listcell; import org.zkoss.zul.Listitem; import org.zkoss.zul.ListitemRenderer; public class UserRoleRender implements ListitemRenderer { public void render(Listitem item, Object data) throws Exception { UserRole person = (UserRole) data; item.setValue(person); Listcell lc; lc = new Listcell(String.valueOf(person.getFunctionName())); lc.setParent(item); lc = new Listcell(String.valueOf(person.getUserName()));lc.setParent(item); lc = new Listcell(String.valueOf(person.getviewRole()));lc.setParent(item); lc = new Listcell(String.valueOf(person.geteditRole()));lc.setParent(item); lc = new Listcell(String.valueOf(person.getdeleteRole()));lc.setParent(item); } }
this is my services controll:
package mcrt.model; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; import java.util.LinkedList; import org.zkoss.zk.ui.Executions; import mcrt.config.ConnectODBC_DSN; public class UserRoleServices implements UserRoleInterface { // data model private List<UserRole> userRole = new LinkedList<UserRole>(); public UserRoleServices() { try { try { ConnectODBC_DSN conDSN = new ConnectODBC_DSN(); ResultSet rs = conDSN.GetResultSet("tblUserFunctionRole"); while (rs.next()) { String ID = rs.getString("ID"); String UserID = rs.getString("userID"); String FunctionID = rs.getString("functionID"); String viewRole = rs.getString("viewRole"); String editRole = rs.getString("editRole"); String deleteRole = rs.getString("deleteRole"); String UserName = rs.getString("userName"); String FunctionName = rs.getString("functionName"); System.out.println("Access: "+ ID + "-" + UserID + "-" + FunctionID + "-" + viewRole + "-" + editRole + "-" + deleteRole + "-" + UserName + "-" + FunctionName ); userRole.add(new UserRole(ID, UserID,FunctionID, viewRole, editRole,deleteRole, UserName,FunctionName) ); } } catch (SQLException s) { System.out.println("ERROR SQL: " + s); } } catch (Exception a) { a.printStackTrace(); } } @Override public List<UserRole> findAll() { // TODO Auto-generated method stub return userRole; } public void checkRole(String username){ try { try { ConnectODBC_DSN conDSN = new ConnectODBC_DSN(); ResultSet rs = conDSN.processSQL("select * from tblUserFunctionRole where FunctionID=" + username); while (rs.next()) { String ID = rs.getString("ID"); String UserID = rs.getString("userID"); String FunctionID = rs.getString("functionID"); String viewRole = rs.getString("viewRole"); String editRole = rs.getString("editRole"); String deleteRole = rs.getString("deleteRole"); String UserName = rs.getString("userName"); String FunctionName = rs.getString("functionName"); userRole.add(new UserRole(ID, UserID,FunctionID, viewRole, editRole,deleteRole, UserName,FunctionName) ); } } catch (SQLException s) { System.out.println("SQL statement is not executed!"); } } catch (Exception a) { a.printStackTrace(); } } @Override public String insertRole(String Username,int FunctionID,int viewRole,int editRole,int deleteRole){ System.out.println(Username); try { try { ConnectODBC_DSN conDSN = new ConnectODBC_DSN(); System.out.println(conDSN.returnID("select iUserID from tblUser where sUserName='" + Username.toUpperCase() +"'")); conDSN.executeSQL("INSERT INTO tblUserFunctionRole" + "(userID, functionID, viewRole, editRole, deleteRole) " + "VALUES(" + conDSN.returnID("select iUserID from tblUsers where sUserName='" + Username.toUpperCase() +"'") + "," + FunctionID + "," + viewRole + "," + editRole + "," + deleteRole + ")"); return "success"; } catch (SQLException s) { System.out.println("SQL statement is not executed!"); return "error"; } } catch (Exception a) { a.printStackTrace(); return "error"; } } //Search with function ID @Override public List<UserRole> search(int keyword) { try { try { ConnectODBC_DSN conDSN = new ConnectODBC_DSN(); ResultSet rs = conDSN.processSQL("select * from tblUserFunctionRole where FunctionID=" + keyword); while (rs.next()) { String ID = rs.getString("ID"); String UserID = rs.getString("userID"); String FunctionID = rs.getString("functionID"); String viewRole = rs.getString("viewRole"); String editRole = rs.getString("editRole"); String deleteRole = rs.getString("deleteRole"); String UserName = rs.getString("userName"); String FunctionName = rs.getString("functionName"); userRole.add(new UserRole(ID, UserID,FunctionID, viewRole, editRole,deleteRole, UserName,FunctionName) ); } } catch (SQLException s) { System.out.println("SQL statement is not executed!"); } } catch (Exception a) { a.printStackTrace(); } return userRole; } @Override public List<UserRole> getDetails(String keyword) { try { try { ConnectODBC_DSN conDSN = new ConnectODBC_DSN(); ResultSet rs = conDSN.processSQL("select * from tblUserFunctionRole where UserID=" + keyword); while (rs.next()) { String ID = rs.getString("ID"); String UserID = rs.getString("userID"); String FunctionID = rs.getString("functionID"); String viewRole = rs.getString("viewRole"); String editRole = rs.getString("editRole"); String deleteRole = rs.getString("deleteRole"); String UserName = rs.getString("userName"); String FunctionName = rs.getString("functionName"); userRole.add(new UserRole(ID, UserID,FunctionID, viewRole, editRole,deleteRole, UserName,FunctionName)); } } catch (SQLException s) { System.out.println("SQL statement is not executed!"); } } catch (Exception a) { a.printStackTrace(); } return userRole; } @Override public List<UserRole> getUser(int UserID) { // TODO Auto-generated method stub return null; } }
PLease help me :((( thank u so much
This is not the original flow.
I'm sure you have a NullPointerException on your listbox.
Move the code in a onCreate$myWindow(Event event) method or better in a doFillListbox() method which is called in the onCreate event for initial filling.
best
Stephan
PS: Hmmm, why is the doAfterCompose called after the onCreate$window method???
Asked: 2013-01-18 07:34:38 +0800
Seen: 47 times
Last updated: Jan 19 '13