0

I'm running mad trying to handle rss request error using the RSSReader component. I create my RssReader like this:

    RSSReader r = new RSSReader();
    r.setTargetContainer(c.getParent());
    r.setUIID("RSSReader");
    r.setURL("some feed url");
    r.setProgressTitle("Fetching News Feed");
    r.setHint("RSS Data Will Show Here");
    r.setLimit(10);
    NetworkManager.getInstance().start();
    r.sendRequest();
    myL x = new myL();
    NetworkManager.getInstance().addErrorListener(x);
    findRssContainer(c.getComponentForm()).removeComponent(findBtnLoadRss(c.getComponentForm()));    

and myL class is written as follows:

class myL implements ActionListener
{
    public void actionPerformed(ActionEvent ae) {
        Container c = (Container)ae.getComponent(); //returns null pointer exception
        findRssContainer(c).addComponent(findBtnLoadRss(c));
    }
}

The problem is that ae.getComponent is null so I get errors trying to call findContainer. I have tried all sorts of properties of the ActionEvent without success. Does anyone know a workaround for this issue?

Thanks!!!

Chibueze Opata
  • 9,856
  • 7
  • 42
  • 65

1 Answers1

0

Seemed the problem was simpler than I thought, I finally cracked it by doing:

class myL implements ActionListener
{
    public Form f;

    public myL(Form frm)
    {
        f = frm;
    }

    public void actionPerformed(ActionEvent ae) {
        if(findBtnLoadRss(f).getParent() != null)
        {
            findRssContainer(f).addComponent(findBtnLoadRss(f));
        }
    }
}

and constructing myL with c.GetComponentForm() as parameter.

Chibueze Opata
  • 9,856
  • 7
  • 42
  • 65