Ewerton Queiroga
Ewerton Queiroga

Reputation: 1

How to implement "del" function in struts2-jquery-grid?

I´m try to implement a system using struts2-jquery-grid. It´s almost working. The grid is loaded with "add" and "edit" functions, but "del" does not work. I tried a lot of codes but didn´t get it.

Here is the action´s snippet where i try to del some register of database:

    else if (oper.equalsIgnoreCase("del")){
        concurso = new Concurso();
        String sql = "delete from dpp.concurso where idconcurso=?";

        try {
            ConcursoDAO.encontrarIdconcurso(idconcurso);
            concurso.setIdconcurso(idconcurso);

            PreparedStatement stmt = this.connection.prepareStatement(sql);
        stmt.setLong(1, concurso.getIdconcurso());
        stmt.execute();
        stmt.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
    }

It´s obvious, idconcurso is null. but, how can I pass a parameter to use it for delete???

Thank´s

Upvotes: 0

Views: 502

Answers (1)

Shanta Chauhan
Shanta Chauhan

Reputation: 11

I had also faced similar issue and solve the problem by setting key attribute true for id field. So you could use attribute key="true" for column "idconcurso" at jquery gridview in your jsp page. Like:

<sjg:gridColumn name="progId" key="true" index="progId" editable="true" hidden="true" title="Project ID" />

Since your id column is non-editable so you could make it as hidden.

One more thing you need to define property id and it's getter and setter method in struts action class and from id property you could get the "idconcurso" value.

Upvotes: 1

Related Questions