Aqui el codigo del jqgrid
Código:
Y aqui el action<sjg:grid id="gridtable" caption="Usuarios" dataType="json" href="%{urlMostrarUsu}" pager="true" navigator="true" navigatorAddOptions="{ closeAfterAdd: true, reloadAfterSubmit:true, }" navigatorEdit="true" navigatorEditOptions="{ closeAfterEdit: true, reloadAfterSubmit:true, }" navigatorDelete="true" navigatorView="true" navigatorSearch="false" navigatorExtraButtons="true" gridModel="gridModel" rowList="10,15,20" rowNum="15" editurl="%{urlEditarUsu}" editinline="false" multiselect="false" viewrecords="true" viewsortcols="[true, 'horizontal', true]" > <sjg:gridColumn name="usuario" index="usuario" title="Nombre Usuario" sortable="true" editable="true" edittype="text" /> <sjg:gridColumn name="pass" index="pass" title="Password" sortable="false" editable="true" edittype="password" /> <sjg:gridColumn name="rol" index="rol" title="Rol" sortable="false" editable="true" edittype="select" editoptions="{value:'10:Admin;9:Usuario'}" /> </sjg:grid>
Código:
Gracias ^^ public class AccionEditarGridUsuarios extends ActionSupport { private static final long serialVersionUID = 1L; private String oper; private String usuario; private String pass; private int rol; public String execute() throws Exception { String url = "jdbc:mysql://localhost:3306/"; String dbName = "clinigest"; String driverName = "com.mysql.jdbc.Driver"; String userName = "root"; String password = "CRSM"; Connection con = null; Statement stmt = null; int val; try{ Class.forName(driverName).newInstance(); con=DriverManager.getConnection(url+dbName, userName, password); stmt=con.createStatement(); } catch(Exception e){ System.out.println(e.getMessage()); } if (oper.equalsIgnoreCase("add")){ val = stmt.executeUpdate("INSERT INTO usuarios (Username, Password, Rol) VALUES ('"+usuario+"', '"+pass+"', '"+rol+"')"); } else if (oper.equalsIgnoreCase("edit")){ val = stmt.executeUpdate("UPDATE usuarios SET Password= '"+pass+"', Rol = '"+rol+"' WHERE Username = '"+usuario+"'"); } else if (oper.equalsIgnoreCase("del")){ val = stmt.executeUpdate("DELETE FROM usuarios WHERE Username = '"+usuario+"'"); } return SUCCESS; } public String getOper() { return oper; } public void setOper(String oper) { this.oper = oper; } public String getUsuario() { return usuario; } public void setUsuario(String usuario) { this.usuario = usuario; } public String getPass() { return pass; } public void setPass(String pass) { this.pass = pass; } public int getRol() { return rol; } public void setRol(int rol) { this.rol = rol; } }