users@glassfish.java.net

VWJSF-CRUD, deleting rows from two related tables

From: <glassfish_at_javadesktop.org>
Date: Fri, 01 May 2009 01:43:13 PDT

Hi,

I am developing a web app about a store and I have related tables on ManyToMany relationship.
The problem is how can I delete a row from a table and the corresponding row in the related table. The related table is a table with th corresponding PKs as FKs

This is my code,

public String borrar_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        form1.discardSubmittedValues("salvar");
        try {
            RowKey rk = tableRowGroup1.getRowKey();
            if (rk != null) {
                subcategoriaDataProvider.removeRow(rk);
                subcategoriaDataProvider.commitChanges();
                subcategoriaDataProvider.refresh();}

// Until here everything is ok, but from here to the end of the block the code is mine
// and of course, it does not work

            rk = categoria_subcategoriaDataProvider.getRowKey(rk.getRowId());
            if (rk != null){
                categoria_subcategoriaDataProvider.removeRow(rk);
                categoria_subcategoriaDataProvider.commitChanges();
                categoria_subcategoriaDataProvider.refresh();}
        } catch (Exception ex) {
            log("ErrorDescription", ex);
            error(ex.getMessage());
        }

        return null;
    }

I am sure it does not work. Please, how is it?

Thanks in advance,
Jose Alvarez de Lara
[Message sent by forum member 'josealvarezdelara' (josealvarezdelara)]

http://forums.java.net/jive/thread.jspa?messageID=344634