A Problem on removing a ActionListener

In my program, due to the structure constraint, I have one action listener attached to a button in one place. And in somewhere else of my code I have to attach another action listener to this button, in this listener's actionPerformed method, I need to prevent the actionListener which I attached earlier being triggered. but I always fail to do so, here is a simplied code which can describe my situation.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
public class ListenerTest {
public ListenerTest(){
     final JButton button=new JButton();
     final Listener l=new Listener();
     button.addActionListener(l);
     button.addActionListener(new ActionListener(){;
     public void actionPerformed(ActionEvent e){
          System.out.println("listener 2");
          button.removeActionListener(l);
     button.doClick();
private class Listener implements ActionListener{
     public void actionPerformed(ActionEvent e){
          System.out.println("listenr 1");
public static void main(String[] args){
     ListenerTest test=new ListenerTest();
}while run into the listener 2, I want prevent the trigger of listener 1, by using removeActionListener here, I can not get my expected effect, don't know how to do? Thanks in advance

for example:
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class ListenerTest2 {
   private static void createAndShowUI() {
      JPanel panel = new JPanel(new BorderLayout());
      final LTPanel ltPanel = new LTPanel();
      final ActionListener newListener = new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            System.out.println("Now the *new* action listener is active");
      JToggleButton listenerToggle = new JToggleButton("Listener Toggle");
      listenerToggle.addActionListener(new ActionListener() {
         private ActionListener[] allAListeners;
         public void actionPerformed(ActionEvent e) {
            JToggleButton toggleBtn = (JToggleButton)e.getSource();
            JButton button = ltPanel.getButton();
            if (toggleBtn.isSelected()) {
               allAListeners = button.getActionListeners();
               for (ActionListener aListener : allAListeners) {
                  button.removeActionListener(aListener);
               button.addActionListener(newListener);
            else {
               button.removeActionListener(newListener);
               for (ActionListener aListener : allAListeners) {
                  button.addActionListener(aListener);
      panel.add(ltPanel, BorderLayout.CENTER);
      panel.add(listenerToggle, BorderLayout.SOUTH);
      JFrame frame = new JFrame("ListenerTest2");
      frame.getContentPane().add(panel);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.pack();
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);
   public static void main(String[] args) {
      java.awt.EventQueue.invokeLater(new Runnable() {
         public void run() {
            createAndShowUI();
class LTPanel extends JPanel {
   private JButton button = new JButton("Button");
   public LTPanel() {
      button.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            System.out.println("The original action listener is active");
      add(button);
   public JButton getButton() {
      return button;
}

Similar Messages

  • Problem with remove task from schedule in PWA

    In our environment problem with remove task from schedule by PWA.
    Problem is only when I want to remove few task in the same time, but the operation one by one is correct.
    In my opinion problem is with calculation schedule after remove tasks, column ID include wrong value it means that Number ID does not generate in the correct order same of numer
    disappear. Click Calculate button on ribbon causes problem with finshed operation and save project.
    Problem occurs only machine with IE 11.0 browser without compability mode, on other machine for example on the same project with IE 8,9,10 everything is correct.
    Problem appeared recently, earlier everything was OK.
    Txn, Dariusz Moczyński

    Hi Darius,
    I'm a bit confused. You are now talking about 2 issues.
    For the first one, you cannot edit anymore tasks in PWA, with any browser versions? Is it happenonog for any users on any projects? Try the following solutions publish the project from Project Pro and see if it helps. Press CTRL F5 to delete IE cache. Ensure
    that your PWA URL is added to the trusted site and/or compatibility sites. Check for the ULS logs or javascript errors.
    For the second issue, please refer to my previous reply, this obviously cannot be considered as a bug since it is happening with a non supported browser version and working properly on supported versions of IE.
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • HP G56 System Recovery Problem after removing disk 4 black screen

    hi everyone
    this is my first time, im helping my nextdoor neighbours laptop hp g56,
    the hard drive has been fried and i have intalled my old playstation 3 40 gb hard drive into it.
    after the recovery system finished and told me to remove disk 4 it restarts and now have a black screen, does this mean its still installing because i turned it off and then on and now say no bootbale device.
    windows 7
    40 gb hard drive (ps3 40gb)

    pepe999 wrote:
    selinacartwrigh wrote:
    my system comes on and then stop before it opens the key board   and say disk boot failure insert system  disk   how could find  a disk  I  cant even get in
    The message means that your internal hard has been damaged. This message always comes up when the file system is corrupted. I suggest to remove it, connect the hard drive into a different computer as an external drive (use usb caddy), perform a backup if possible and the format the hard drive and restore the factory settings. I'm afraid that you have to reformat the hard drive, a checkdisk scan won't help..
    The error message means that the Boot Sector is corrupt or has been damaged. It does not mean that the hard disk is damaged.
    This is a fixable issue. There are a few command line tools that can be used.
    You will  need to make an appropriate version (32-bit / 64-bit) of the Windows 7 repair disc from a working Windows 7 installation. You will need either a USB or CD to create your rapair CD/USB. Follow the instructions on this video to create the repair installation of your choice..You will will be using the manual boot sector repair that is described in this video to repair your Windows 7 Boot sector.  Use the Windows 7 repair disc or repair USB thumb drive that you created earlier to accomplish the repair.
    Best regards,
    erico
    ****Please click on Accept As Solution if a suggestion solves your problem. It helps others facing the same problem to find a solution easily****
    2015 Microsoft MVP - Windows Experience Consumer

  • Problem With Removal of Validation/Substitution

    Hi all,
    We are currently adding a validation for Vendor Invoice Creation (FB60), however we are experiencing a runtime error.
    When we investigated the cause of the runtime error, it seems that there is a previous validation/substitution that was deleted using transaction OBBH, but the corresponding ABAP code was not removed.  Now, since the program and include where this code is located is standard, how can we remove that particular code please?
    We tried re-generating the substitution/validation code using program RGUGBR00 and RGUGBR01, but it seems it is not working.
    Thanks again in advance.

    Hi,
    Even I have the same problem.
    Even after deleting the substitution code is still exits .
    system generated code in Include GBTAKAMB have an syntax error which is giving short dumps.
    Any help is appreciated.
    Anyone used any SAP NOTE on this.
    TIA
    Rhea.
    Edited by: rhea on Jul 25, 2008 12:11 PM

  • Problem with removing items from a linked list

    Hello,
    I have something weird going with my code. Below is the snippet
    if (ParserDataList.isEmpty())
    try {
    Thread.sleep(10)
    catch (InterruptedException e) {
    else
    data = ParserDataList.remove();
    ParserDataList is declared as a LinkedList. Occasionally I receive the error on NoSuchElement on the remove. I put a try/catch around the remove and print out the value of ParserDataList.isEmpty which is always false. I am very confused on why if the linked list isn't empty I can't remove a data item. There are no other threads that remove data. Thank you in advance for any assistance on this problem.

    I am changing it from linked list to blocking queue however I do have a question about what I should use to poll the data? Instead of a remove should I use take which seemed to remove the first element and if there wasn't one wait until there was. I was trying to not have the threads blocked because I do need to stop them when a disconnect is sent from the main thread.

  • Problem with "Remove find my iphone"

    Somone stole my iphone 4s and I used the remote procedure "find my iphone" but the device appeared offline. In any case, if it were connected to the internet I would come back a signal. The problem is that then I accidentally clicked "remove find my iphone" and therefore there aren't any more device, so I think that the thieves could use the device with no problem. There is no way to undo this?
    Ilaria

    ylaryna11 wrote:
    Somone stole my iphone 4s and I used the remote procedure "find my iphone" but the device appeared offline. In any case, if it were connected to the internet I would come back a signal. The problem is that then I accidentally clicked "remove find my iphone" and therefore there aren't any more device, so I think that the thieves could use the device with no problem. There is no way to undo this?
    No, you cannot undo it.

  • Problem with removing spaces

    Hi,
    I have a problem with spaces. There are constantly two spaces open named Safari. I cannot remove them. See enclosed image. Any ideas how to do it?

    Further research shows that the spaces are indeed there when I view the page source; however, the spaces are not being rendered.
    I removed the css style sheet that was being applied to the shuttle and it made no difference.

  • Problem disabling JButton in ActionListener after setText of JLabel

    What i want is when i click View to see the label say "Viewing ..." and in the same time the btnView (View Button) to be disabled.
    I want the same with the other 2 buttons.
    My problem is in ActionListener of the button. It only half works.
    I cannot disable (setEnabled(false)) the button after it is pressed and showing the JLabel.
    The code i cannot run is the 3 buttons setEnabled (2 in comments).
    Any light?
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    class BTester extends JFrame implements ActionListener { 
         JButton btnView, btnBook, btnSearch;
         BTester(){     //Constructor
              JPanel p = new JPanel();
         JButton btnView = new JButton( "View" );
         btnView.setActionCommand( "View" );
         btnView.addActionListener(this);
         JButton btnBook = new JButton( "Book" );
         btnBook.setActionCommand( "Book" );
         btnBook.addActionListener(this);
         JButton btnSearch = new JButton( "Search" );
         btnSearch.setActionCommand( "Search" );
         btnSearch.addActionListener(this);
         p.add(btnView);
         p.add(btnBook);
         p.add(btnSearch);
         getContentPane().add(show, "North"); //put text up
    getContentPane().add(p, "South"); //put panel of buttons down
    setSize(400,200);
    setVisible(true);
    setTitle("INITIAL BUTTON TESTER");
    show.setFont(new Font("Tahoma",Font.BOLD,20));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     
         //actionPerformed implemented (overrided)
         public void actionPerformed( ActionEvent ae) {
    String actionName = ae.getActionCommand().trim();
    if( actionName.equals( "View" ) ) {
    show.setText("Viewing ...");
         btnView.setEnabled(false); // The line of problem
    //btnBook.setEnabled(true);
    //btnSearch.setEnabled(true);
    else if( actionName.equals( "Book" ) ) {
    show.setText("Booking ...");
    //btnView.setEnabled(true);
    //btnBook.setEnabled(false);
    //btnSearch.setEnabled(true);
    else if( actionName.equals( "Search" ) ) {
    show.setText("Searching ...");
    //btnView.setEnabled(true);
    //btnBook.setEnabled(true);
    //btnSearch.setEnabled(false);
    } //end actionPerformed
         private JLabel show = new JLabel( "Press a button ... " );
    public static void main(String[] args) { 
         new BTester();
    } // End BTester class

    1. Use code formatting when posting code.
    2. You have a Null Pointer Exception since in your constructor you create the JButtons and assign them to a local variable instead of the class member.
    Change this
    JButton btnView = new JButton( "View" );to:
    btnView = new JButton( "View" );

  • Problem in subclass with ActionListener

    Hello,
    I need to program two forms which are identical except for the actions their buttons should do and some other minor differences, therefore I made a superclass for one of the forms and then extended it to build the other form. I messed up and wrote the ActionListener's as inner classes inside the superclass. Now, the buttons in the subclass react exactly the same as the buttons in the superclass. A solution I can think of is to forget about extending the class and making a different class for each form, but this would mean having two different classes with very similar code, therefore I'm sure there is a more elegant solution. Any ideas?
    Thank you,
    Alfredo

    I believe that writing the ActionListeners as separate classes won't fix the problem, since the same ActionListeners would be called for each of the forms. The problem is how do I make the buttons in the subclass call different ActionListeners from the ones in the superclass.

  • Problem with remove a node from a list

    ArrayList<My_node> list = new ArrayList<My_node>(size_of_list);
    My_node is :
    public class My_node {
    public int key;
    public String value;
    public My_node(int x,String y) {
    key = x;
    value = y;
    public void del_(int num,String name) {
    for(j = 0;j<list.size();j++) {
         if(list.get(j).key == num && list.get(j).value == name ) {
    list.remove(j);
    return;
    But unfotrtunately the node is not deleted!!!
    Could you plz tell me where is the problem?
    Thanks in advance!

    The problem might be that you are using == to compare strings. Try to use the .equals method.
    if(list.get(j).key == num && list.get(j).value.equals(name))

  • Problem with removing Search and Advanced Search functionalities in Portal

    Hi,
          As per our client requirement, we have removed search and advanced search functionalities in Masthead and those are working fine. But when ever we restarted the portal server, these search options are reappearing in portal.
              I am not getting why it is happening and every time we restarted the server, we are removing these search functionalities from masthead.
              If anyone knows why it is happening, kindly share with us
    Thanks & Regards
    Pavan

    Hi Santosh,
                         Problem is not solved. Where can i find the Standard tool area iview used in Default frame work page ?
    At present, we disabeled the search and it's working fine. But when we restart the portal, search is again reappearing and we need to disable that once again.
               Is there any sollution for this problem?? Kindly let me know..
    Thanks & Regards
    Pavan
    Edited by: pavanakrishna reddy on Mar 24, 2010 9:44 AM

  • Problem when removing elements from table after apply sort

    Hi,
    I have big problem with <af:table> and sorting.
    When I removed objects from a table without sorting, there is no problem but when I removed
    items from the table after sorting, the remain items are not correct.
    For example, i have in my table these items :
    Item AA
    Item CC
    Item ZZ
    Item BB
    Item AA
    Item BB
    Item CC
    Item ZZ
    I sort the table and i select the following Items : Item BB a Item CC
    The remains item is only Item AA, Item ZZ disappear.
    If i resort the table, the missing Item zz appear again in the table.
    Here is my jspx :
    <af:table var="row" rowBandingInterval="1" width="1050" rows="5"
    rowSelection="multiple"
    value="#{pageFlowScope.editNotificationBackingBean.ingredients}"
    binding="#{pageFlowScope.editNotificationBackingBean.ingredientsTable}"
    autoHeightRows="10" id="t2">
    <af:clientListener method="goEditRow" type="dblClick"/>
    <af:serverListener type="doubleClickOnRow" method="#{pageFlowScope.editNotificationBackingBean.handleRequestIngredientsSelectBtn_action}"/>
    <af:column headerText="#{bundle.col_fr_name}" width="240"
    sortable="true" sortProperty="name.FR_Description" id="c1">
    <af:outputText value="#{row.name.texts['fr'].value}" id="ot1"/>
    </af:column>
    In my backing bean i call this method to remove selected elements :
    public void unselectBtn_action(ActionEvent actionEvent) {
    RowKeySet rowKeySet = selectIngredientsTable.getSelectedRowKeys();
    int i = 0;
    Iterator it = rowKeySet.iterator();
    while (it.hasNext()) {
         Integer index = (Integer)it.next() - i;
    selectIngredientsTable.setRowKey(index);
    CompositionIngredient compositionIngredient =
    (CompositionIngredient)selectIngredientsTable.getRowData();
    notification.getProductDetail().getCompositionIngredients().remove(compositionIngredient);
    i++;
    selectIngredientsTable.getSelectedRowKeys().clear();
    AdfFacesContext.getCurrentInstance().addPartialTarget(selectIngredientsTable);
    Thanks in advance.

    I have made a mistake, i don't paste the right <af:table> from my jspx.
    Here is the correct one :
    <af:table var="row" rowBandingInterval="1" width="1050"
    rowSelection="multiple" id="tableSelectedIngredients"
    value="#{pageFlowScope.editNotificationBackingBean.notification.productDetail.compositionIngredients}"
    binding="#{pageFlowScope.editNotificationBackingBean.selectIngredientsTable}"
    partialTriggers="::tab_ingredients_list_expressed_per">
    <af:column sortable="true" headerText="#{bundle.col_name}" id="c5" width="180"
    sortProperty="ingredient.name.FR_Description">
    <af:outputText value="#{row.ingredient.name.texts['fr'].value}"
    id="ot18"/>
    </af:column>
    ...

  • Sync Space Problems as removed apps being added back

    I had a problem with the original laptop in which I had itunes on so I haven't backed up or sync'd my phone for over 6 months. I finally got around to moving the itunes file to another computer.  Now when I try to sync my phone it is trying to add the apps back that were deleted off the phone but were still on the last time on itunes backed up of the phone.  So now the Apps are being added back and before it can complete the sync it runs out of space and cannot complete the process.  Help how can I get around this, thanks.

    You'd think that deleting an app from your iPhone and then syncing the iPhone would tell iTunes that you don't want that application on your iPhone any longer - but that isn't what happens. iTunes is your home base for applications and media. You have to tell iTunes what you want added to your iOS device or removed from your iOS device.
    My habit is to connect my iOS device and immediately select the option to sync newly purchased items from the device to iTunes. Once that's done I select my device in iTunes and look over the applications and media to see that everything I want/don't want is correctly indicated. Then I sync again.
    Step 1 gets all the updated and newly purchased stuff into iTunes. Step 2 makes sure I get only what I want (and exactly what I want) on my device.

  • TL11g & EJB3: One-to-Many problems with removing entity from list

    Hi,
    I posted this problem on JDev11g forum, but I hope I will get some information here as well.
    I have two entities based on tables in HR schema (Departments and Employees). Department has a list of employees. These are the annotations:
    @Entity
    public class Departments implements Serializable {
        @OneToMany(mappedBy = "departments", cascade = {CascadeType.ALL})
        private List<Employees> employeesList;
    @Entity
    public class Employees implements Serializable {
        @ManyToOne
        @JoinColumn(name = "DEPARTMENT_ID")
        private Departments departments;
    }On a test page, I have a master-detail tables that show all departments and employees in the selected department (drag&drop from data control), a button that removes selected employee from employeeList iterator, and a button that calls em.merge(department).
    The problem is that when I remove some employees from employeeList, on merge, the incoming entity, as well as the return result of the 'merge', are OK (the list doesn't contain the removed entities), but nothing is updated in the database, and no error is shown.
    Can anyone help me with this? I can send the test case if anyone is interested.
    Thanks,
    Pedja

    The transaction is Container Managed, but I did try with flushing the changes, but without success. Here is the log:
    [TopLink Finest]: 2008.08.06 04:31:25.431--ServerSession(27620915)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Execute query ReadAllQuery(model.Employees)
    [TopLink Finest]: 2008.08.06 04:31:25.431--ServerSession(27620915)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--reconnecting to external connection pool
    [TopLink Fine]: 2008.08.06 04:31:25.431--ServerSession(27620915)--Connection(21332891)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--SELECT EMPLOYEE_ID, LAST_NAME, COMMISSION_PCT, PHONE_NUMBER, SALARY, HIRE_DATE, FIRST_NAME, EMAIL, JOB_ID, MANAGER_ID, DEPARTMENT_ID FROM EMPLOYEES WHERE (DEPARTMENT_ID = ?)
         bind => [20]
    [TopLink Finest]: 2008.08.06 04:31:25.431--ServerSession(27620915)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Execute query ReadObjectQuery(model.Employees)
    [TopLink Finest]: 2008.08.06 04:31:25.431--ServerSession(27620915)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Execute query ReadObjectQuery(model.Departments)
    [TopLink Finest]: 2008.08.06 04:31:25.431--UnitOfWork(14721024)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Employees@3001c6
    [TopLink Finest]: 2008.08.06 04:31:25.431--UnitOfWork(14721024)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Employees@1f7d08a
    [TopLink Finest]: 2008.08.06 04:31:25.431--UnitOfWork(14721024)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Employees@3001c6
    [TopLink Finest]: 2008.08.06 04:31:25.431--UnitOfWork(14721024)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Departments@1b21b91
    [TopLink Finer]: 2008.08.06 04:31:36.836--ServerSession(27620915)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--client acquired
    [TopLink Finer]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--TX binding to tx mgr, status=STATUS_ACTIVE
    [TopLink Finest]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Merge clone with references model.Departments@1c49e79
    [TopLink Finest]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Employees@3001c6
    [TopLink Finest]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Employees@aa10a9
    [TopLink Finest]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Departments@12c0836
    [TopLink Finest]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Employees@aa10a9
    [TopLink Finest]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Departments@1b21b91
    [TopLink Finest]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Employees@3001c6
    [TopLink Finest]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Employees@1f7d08a
    [TopLink Finest]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Employees@3001c6
    [TopLink Finest]: 2008.08.06 04:31:36.836--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Register the existing object model.Departments@1b21b91
    [TopLink Finer]: 2008.08.06 04:31:38.711--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--TX beforeCompletion callback, status=STATUS_ACTIVE
    [TopLink Finer]: 2008.08.06 04:31:38.711--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--begin unit of work commit
    [TopLink Finer]: 2008.08.06 04:31:38.711--ClientSession(2685953)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--TX beginTransaction, status=STATUS_ACTIVE
    [TopLink Finest]: 2008.08.06 04:31:38.711--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--Execute query UpdateObjectQuery(model.Departments@776fc0)
    [TopLink Finer]: 2008.08.06 04:31:38.711--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--TX afterCompletion callback, status=COMMITTED
    [TopLink Finer]: 2008.08.06 04:31:38.805--UnitOfWork(631279)--Thread(Thread[HTTPThreadGroup-1,9,HTTPThreadGroup])--end unit of work commitThanks,
    Pedja

  • EJB3: One-to-Many problems with removing entity from list

    Hi,
    I have two entities based on tables in HR schema (Departments and Employees). Department has a list of employees. These are the annotations:
    @Entity
    public class Departments implements Serializable {
        @OneToMany(mappedBy = "departments", cascade = {CascadeType.ALL})
        private List<Employees> employeesList;
    @Entity
    public class Employees implements Serializable {
        @ManyToOne
        @JoinColumn(name = "DEPARTMENT_ID")
        private Departments departments;
    }On a test page, I have a master-detail tables that show all departments and employees in the selected department (drag&drop from data control), a button that removes selected employee from employeeList iterator, and a button that calls em.merge(department).
    The problem is that when I remove some employees from employeeList, on merge, the incoming entity, as well as the return result of the 'merge', are OK (the list doesn't contain the removed entities), but nothing is updated in the database, and no error is shown.
    Can anyone help me with this? I can send the test case if anyone is interested.
    Thanks,
    Pedja

    Hi,
    I have two entities based on tables in HR schema (Departments and Employees). Department has a list of employees. These are the annotations:
    @Entity
    public class Departments implements Serializable {
        @OneToMany(mappedBy = "departments", cascade = {CascadeType.ALL})
        private List<Employees> employeesList;
    @Entity
    public class Employees implements Serializable {
        @ManyToOne
        @JoinColumn(name = "DEPARTMENT_ID")
        private Departments departments;
    }On a test page, I have a master-detail tables that show all departments and employees in the selected department (drag&drop from data control), a button that removes selected employee from employeeList iterator, and a button that calls em.merge(department).
    The problem is that when I remove some employees from employeeList, on merge, the incoming entity, as well as the return result of the 'merge', are OK (the list doesn't contain the removed entities), but nothing is updated in the database, and no error is shown.
    Can anyone help me with this? I can send the test case if anyone is interested.
    Thanks,
    Pedja

Maybe you are looking for

  • Iphone 4 not recognized by Itunes after uninstallation, installation... Anyone help pls ?

    I'd like to synchronise my phone because of a pbm with an app. But it is not recognized at all by ITunes... I uninstalled, repaired, installed ITunes, Quicktime, turned off several time the phone... and the pbm still be... Anyone knows what to do pls

  • HT5312 I can't send a backup email because I didn't put my real date of birth and now I can't buy anything with my 25.00$

    I forgot one of my security questions and I tried to send a email to my backup email so I can reset my security question but I put the wrong date of birth when I started my account and it won't let me change anything or buy anything until I get it ri

  • How to get something in return?

    I'm passing values to my component for an insert into db. Since this is an insert, my function doesn't return anything, so I wrote <cfreturn true> without putting cfreturn I would get an error. This is fine except that I need my function to return so

  • WM Storage Unit Type Capacity

    Hi, I have the following situation: In our warehouse, materials are received in kilograms and stored and transferred in barrels or containers. For this reason we are using storage unit types "barrel" and "container". For the barrels, we have a define

  • Forms 10g Crash in Windows 7

    Hi, Forms builder crashed during opening a file from a network location. Version: Forms= [32 Bit] Version 10.1.2.0.2 DB = Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 Event Id in Event Viewer is 1000 Error in Event Viewer: Faulting appli