views:

134

answers:

1

Hi. I have a button in a .xhtml file which calls a javascript function which calls a java function remotely (in jboss seam environment). That java function has an entityManager.persist(object). Do you know why this line of code doesn't commit to the DB? It says something that a transaction hasn't started. I supose in a remote context i don't have a transaction began because if i put an action on that button which calls the same java function instead of using javascript is above, it works fine; entityManager persists the object and i can see it in the DB.

Does anyone has any ideas how could i make to actually persist the object using javascript to call the java function? (i have to use javascript because i need the callback function )

A: 

To ensure a transaction You could extend org.jboss.seam.util.Work:

new Work()
{
    @Override
    protected Object work() throws Exception {
        // do your stuff
        return null;  
    }
}.workInTransaction()
Daan van Yperen