Wicket and JEE6
Hi, I'm building a new java project using all JEE6 technologies. That means I'm using JPA, CDI, and JSF2 for example. Each layer came together great with fully annotated classes until I got to the JSF2 layer which drove me crazy because JSF wants to mess with HTML element ids and names. In looking for alternative view layers I came across Wicket. The technology seems great in terms of its philosophy to keep presentation code separate, except I'm not finding much information about its support for JEE6 technologies. In particular searches for support for CDI (aka WebBeans, aka Weld) only got me to an old example in the Seam project. I cannot find any current references to using Weld within a Wicket project where I can use annotations such as @Inject, @Named, @ApplicationScoped, etc. So my very first question for this list of experts is this: Is there currently any support for Weld in Wicket? Downloading the Weld project from JBoss, I included the weld-wicket.jar into my project and my application is subclassed from WeldApplication. No such luck. Any class injected using @Inject is still null. I am using GlassFish v3 which has all the JEE6 goodies included. Developing with Eclipse. Any help is *greatly* appreciated! -Mark
RE: Wicket and JEE6
Weld claims support, I don't know about built-in. When I use @Inject in a Wicket WebPage subclass the objects are null. Like I mentioned below, I added weld-wicket.jar and subclassed the WeldApplication and the injected objects in the Wicket WebPage subclass are still null. This was from following this example: http://docs.jboss.org/weld/reference/1.0.0/en-US/html/viewlayers.html If you track down the example code it seems that the examples from JBoss are using older versions of Wicket and Weld/Seam so I don't know if something has broken in either project, wicket or weld. Injection worked like a charm in a JSF2 controller class so I don't know what going wrong or what supporting jar is missing. Any additional help is greatly appreciated! -Mark -Original Message- From: James Carman [mailto:jcar...@carmanconsulting.com] Sent: Friday, March 26, 2010 10:52 AM To: users@wicket.apache.org Subject: Re: Wicket and JEE6 Weld has wicket support built-in I believe. On Fri, Mar 26, 2010 at 12:52 PM, Ericksen, Mark W (IS) < mark.erick...@ngc.com> wrote: > Hi, > > > > I'm building a new java project using all JEE6 technologies. That means > I'm using JPA, CDI, and JSF2 for example. Each layer came together great > with fully annotated classes until I got to the JSF2 layer which drove > me crazy because JSF wants to mess with HTML element ids and names. In > looking for alternative view layers I came across Wicket. The > technology seems great in terms of its philosophy to keep presentation > code separate, except I'm not finding much information about its support > for JEE6 technologies. > > > > In particular searches for support for CDI (aka WebBeans, aka Weld) only > got me to an old example in the Seam project. I cannot find any current > references to using Weld within a Wicket project where I can use > annotations such as @Inject, @Named, @ApplicationScoped, etc. > > > > So my very first question for this list of experts is this: Is there > currently any support for Weld in Wicket? Downloading the Weld project > from JBoss, I included the weld-wicket.jar into my project and my > application is subclassed from WeldApplication. No such luck. Any > class injected using @Inject is still null. > > > > I am using GlassFish v3 which has all the JEE6 goodies included. > Developing with Eclipse. > > > > Any help is *greatly* appreciated! > > > > -Mark > > > > > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Wicket and JEE6
Warning: Long Response with sample code to illustrate issue. I ran the following code in Glassfish v3 with the following jars: portlet-api_2.0_spec-1.0.jar (someone is relying on this??) slf4j-api-1.4.2.jar slf4j-jdk14-1.4.2.jar wicket-1.4.7.jar Be sure to add an empty beans.xml to the WEB-INF folder. After starting up Glassfish, type the following in the browser (WicketTest is the name of my project, yours may vary): localhost:8080/WicketTest/ The output it: No Util Class localhost:8080/WicketTest/jsf.faces The output is: Hello World! Code follows web.xml: http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://java.sun.com/xml/ns/javaee"; xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID" version="2.5"> WicketTest Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet /faces/* *.faces wicket example org.apache.wicket.protocol.http.WicketFilter applicationClassName com.example.wicket.ExampleApplication wicket example /* EntityUtil.java: package com.example.wicket; public class EntityUtil { public String getEntity() { return "Hello World!"; } } ExampleApplication.java: package com.example.wicket; import org.apache.wicket.Page; import org.apache.wicket.protocol.http.WebApplication; public class ExampleApplication extends WebApplication { @Override public Class getHomePage() { return HomePage.class; } } HomePage.java: package com.example.wicket; import javax.inject.Inject; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.model.Model; public class HomePage extends WebPage { @Inject private EntityUtil util; public HomePage() { super(); add(new Label("hello", new Model(this.getHello(; } private String getHello() { return (null != util) ? util.getEntity() : "No Util Class"; } } HomePage.html: http://www.w3.org/TR/html4/loose.dtd";> http://wicket.apache.org";> Insert wicket title here Yo! jsf.xhtml (in context root): http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml"; xmlns:h="http://java.sun.com/jsf/html";> Insert jsf title here #{controller.hello} Controller.java: package com.example.wicket; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; @Named @RequestScoped public class Controller { @Inject private EntityUtil util; public String getHello() { return (null != util) ? util.getEntity() : "No Util Class"; } } -Original Message- From: James Carman [mailto:jcar...@carmanconsulting.com] Sent: Friday, March 26, 2010 11:36 AM To: users@wicket.apache.org Subject: Re: Wicket and JEE6 I started a JSR-299 integration project a while back, but at the time there was no portable way (across vendors) to get to the stuff you needed to inject into your components. I believe that's been fixed in the latest API, but I haven't had a chance to dig in and verify that and then use it. My guess is that there's really not that much to it (my code was pretty small). On Fri, Mar 26, 2010 at 1:35 PM, Ericksen, Mark W (IS) < mark.erick...@ngc.com> wrote: > Weld claims support, I don't know about built-in. > > When I use @Inject in a Wicket WebPage subclass the objects are null. > Like I mentioned below, I added weld-wicket.jar and subclassed the > WeldApplication and the injected objects in the Wicket WebPage subclass > are still null. > > This was from following this example: > http://docs.jboss.org/weld/reference/1.0.0/en-US/html/viewlayers.html > > If you track down the example code it seems that the examples from JBoss > are using older versions of Wicket and Weld/Seam so I don't know if > something has broken in either project, wicket or weld. > > Injection worked like a charm in a JSF2 controller class so I don't know > what going wrong or what supporting jar is missing. > > Any additional help is greatly appreciated! > > -Mark > > > -Original Message- > From: James Carman [mailto:jcar...@carmanconsulting.com] > Sent: Friday, March 26, 2010 10:52 AM > To: users@wicket.apache.org > Subject: Re: Wicket and JEE6 > > Weld has wicket support built-in I believe. > > On Fri, Mar 26, 2010 at 12:52 PM, Ericksen, Mark W (IS) < > mark.erick...@ngc.com> wrote: > > > Hi, > > > > > > > > I'm b
RE: Wicket and JEE6
Thanks Josh. With your idea in mind I dug deeper into what Weld's support for Wicket is/was. In the Weld download is a jar called weld-wicket.jar that has a WeldApplication class for doing what you suggest. However following the instruction for using their integration code only got me an error when including their jar in my project. java.lang.NoSuchMethodError: org.jboss.weld.Container.services()Lorg/jboss/weld/bootstrap/api/Service Registry; So I included the weld-wicket code in my simple project to see what was going on. Their integration solution provides a new RequestCycle class called WeldRequestCycle. In this class they attempt to preserve a long running conversation through weld/wicket trickery. There's a line of code in a few places that causes a runtime exception that stops the request cycle. ConversationContext conversationContext = Container.instance().services().get(ContextLifecycle.class).getConversat ionContext(); These are Weld classes, but stepping through the debugger shows it goes go back through the Wicket filter. Therefore I don't know who is at fault here. Maybe something in Wicket changed that is causing Weld to croak or Weld in Glassfish is the culprit. Either way I really don't care about long running conversation support at this point so I removed the class and any dependency on it in my modified version of the weld-wicket code base. With that exception out of the way and changing my application to subclass from WeldApplication, I have simple injection working with Weld. Yippee! I'll cross my fingers there are no other side effects. Problem is now what? I guess I can post this with the Seam/Weld team and hope someone updates the Weld-Wicket integration. Or I can hope someone from the Wicket team will take a look and see if it's something in the latest version of Wicket that caused this to break and could do a patch. Anyone? :) -Mark -Original Message- From: Josh Chappelle [mailto:jchappe...@4redi.com] Sent: Friday, March 26, 2010 2:59 PM To: users@wicket.apache.org Subject: RE: Wicket and JEE6 Mark, Try taking a look at the addComponentInstantiationListener method on the Application class. It takes one parameter of type IComponentInstantiationListener and that interface has one method which is onInstantiation(Component component). Every time a component gets instantiated it will be handed to this listener so maybe you can write your own dependency injection code there. I would think that is what the WeldApplication is doing under the covers but since it isn't working for you then you may have more luck just writing it yourself. The other trick is to making this work is obtaining a reference to your weld context. I use Spring so I'm not familiar with what it takes with Weld. I hope this helps. Thanks, Josh -----Original Message- From: Ericksen, Mark W (IS) [mailto:mark.erick...@ngc.com] Sent: Friday, March 26, 2010 11:52 AM To: users@wicket.apache.org Subject: Wicket and JEE6 Hi, I'm building a new java project using all JEE6 technologies. That means I'm using JPA, CDI, and JSF2 for example. Each layer came together great with fully annotated classes until I got to the JSF2 layer which drove me crazy because JSF wants to mess with HTML element ids and names. In looking for alternative view layers I came across Wicket. The technology seems great in terms of its philosophy to keep presentation code separate, except I'm not finding much information about its support for JEE6 technologies. In particular searches for support for CDI (aka WebBeans, aka Weld) only got me to an old example in the Seam project. I cannot find any current references to using Weld within a Wicket project where I can use annotations such as @Inject, @Named, @ApplicationScoped, etc. So my very first question for this list of experts is this: Is there currently any support for Weld in Wicket? Downloading the Weld project from JBoss, I included the weld-wicket.jar into my project and my application is subclassed from WeldApplication. No such luck. Any class injected using @Inject is still null. I am using GlassFish v3 which has all the JEE6 goodies included. Developing with Eclipse. Any help is *greatly* appreciated! -Mark - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Wicket and JEE6
Thanks Olivier, Iskandar, and James! After getting Weld integration to work with the weld-wicket jar I realized that the integration is limited to classes that subclass from WebPage (or Page I suppose) to work within a request cycle. I cannot inject a DAO into a session or a singleton into an application class for example. In a JSF2 project there is no limitations. Plus the ability to annotate scope would be nice. This makes me wonder what the future holds for Wicket and JEE6. Is there work being done to fully integrate Wicket with JEE6's newly defined set of supported JSRs? It would be nice to see a comparison chart of JEE6 features and Wicket's current and expected future support for such features. I've been searching for something like this but haven't found anything. I'd love to see Wicket fully support JEE6 and become a drop in replacement for JSF2. This doesn't seem to be the case just yet. If I'm wrong be sure to let me know! -Mark -Original Message- From: Olivier Bourgeois [mailto:olivier.bourgeois@gmail.com] Sent: Monday, March 29, 2010 2:45 AM To: users@wicket.apache.org Subject: Re: Wicket and JEE6 Hi, Wicket has very good support in Weld, but to make it work I had to update the weld-integration.jar, otherwise the sample Numberguess application is looking for an unexisting method in the 1.0.0 Weld API : this is your problem. If you don't want to do it by hand like suggested by Iskandar, you can download one of the Glassfish nightly builds, this is what I have done. The latest builds are integrating Weld 1.0.1-final and the problem vanishes. If you want, I can provide you the maven profile to make the sample work nicely when you hit the "run" button in Netbeans, because there is another problem with the samples : the maven profile is not including the slf4j libraries, so there is an error in Glassfish when you run the sample. I assume this may be your next problem :) Also, you may run into trouble with the JPA2 code generation if you are using maven. But if you are using Eclipse annotation preprocessor to generate the metadata, you won't have the problem. -- Olivier - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org