cancel a process using cancel button

Hi,

Can somebody plz tell me how to cancel a process that I have started using the cancel button.

I use this code,
apiAccessor.getProcessAPI().cancelProcessInstance(processInstanceId);
in th conncetor of the cancel button,but it does not work.Can somebosy Plz help.

Thank,
Charulatha