How to run listeners?

  5 posts   Feedicon  
Replies: 4 - Last Post: May 20, 2009 04:24
by: Jason Lee
showing 1 - 5 of 5
 
Posted: May 04, 2009 12:12 by IngoHofmann
Hey guys,

First of all, keep the great work!

However, I have some issues with our environment. E.g. the weblets resources can't be found. I found out that the FacesTester ignores the <listener> entries in web.xml. The following has no effect:

<listener>
<listener-class>net.java.dev.weblets.WebletsContextListener</listener-class>
</listener>


This is also the reason of other side effects with other required listeners.

My first and only idea is to change the FacesTester API to get this:

@BeforeClass
public static void setUp() throws Exception {

tester = new FacesTester();

// WebletsContextListener
ServletContextListener wcl = new WebletsContextListenerImpl();
wcl.contextInitialized(new ServletContextEvent(tester.getFacesContextBuilder().getServletContext()));
}


So I added a getFacesContextBuilder()-Method to be able to initialize the listeners "manually". Of course my own API change has been only for testing purposes.

Do you have another ideas to manage this issue?

Greetings from Switzerland,
Ingo
 
Posted: May 06, 2009 23:29 by rcoffin
Hi Ingo,

Thanks for trying out FacesTester and for providing us feedback. I think what you've done is a decent approach. It makes sense to me to have your unit test demarcate the "lifetime" of the servlet context by using a @BeforeClass annotation as you did. It seems to me that the ServletContext makes more sense hanging off of the FacesTester object though instead of the builder. I've made this change and checked it into trunk. Does this approach satisfy what you're trying to do?

Cheers,

Rod
 
Posted: May 07, 2009 08:41 by IngoHofmann
Hot stuff, Rod, thanks!

The next step would be to readout and initialize all listeners that are registered in web.xml. Or is it a to unrealistic dream?
 
Posted: May 08, 2009 14:05 by IngoHofmann
Hey Rod, I just programmed a "generic" method for initializing listeners and it seems to work.

What I would love:

1) Another attribute in FacesConfig:
protected List<ListenerMetaData> listeners = new ArrayList<ListenerMetaData>();

2) Same with filters.

3) Getters for the FacesConfig's attributes.

So we could also check the correct configuration.

And how could we bind listeners? This is now my only one problem...
 
Posted: May 20, 2009 04:24 by Jason Lee
I don't think this is unrealistic. Could you file an RFE on that? We'll try to get this in for 0.3.
Replies: 4 - Last Post: May 20, 2009 04:24
by: Jason Lee
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close