Thursday, April 26, 2012

Phase Listener Not Running

This is another one of those times when becoming complacent with IDE tools will turn around and bite you.

Hard.

The environment:

IDE: Eclipse Helios SR2
Portal: Liferay 6.0.6
Development: JSF 2.0 (Mojarra)/ICEfaces 2.0

The Phase Listener I included in my portlet absolutely did nothing.  No errors... No crashes... But it simply didn't respond in any way, shape or form.

Yes, it was configured in the faces-config.xml.

Yes, it implemented PhaseListener.

The problem turned out to be that I had allowed Eclipse to automatically add the unimplemented methods to the class when I was creating my PhaseListener.  The problem was in this method:


@Override
public PhaseId getPhaseId() {
// TODO Auto-generated method stub
return null;
}


See the problem?

It should have said


@Override
public PhaseId getPhaseId() {
// TODO Auto-generated method stub
return PhaseId.ANY_PHASE;
}

I hadn't paid any attention to the method after it was auto-generated because I didn't need to modify it, so I didn't notice the problem.

It's a nice feature in Eclipse, but always verify that when it does things to save you some time, that it does them correctly.


No comments:

Post a Comment