You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by James Carman <jc...@carmanconsulting.com> on 2010/03/26 17:51:58 UTC

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.Ericksen@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
>
>
>
>
>
>

RE: Wicket and JEE6

Posted by "Ericksen, Mark W (IS)" <Ma...@ngc.com>.
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:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="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">
  <display-name>WicketTest</display-name>

  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>

  <filter>
    <filter-name>wicket example</filter-name>
 
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class
>
    <init-param>
      <param-name>applicationClassName</param-name>
      <param-value>com.example.wicket.ExampleApplication</param-value>
    </init-param>
  </filter>

  <filter-mapping>
    <filter-name>wicket example</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

</web-app>


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<? extends Page> 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<String>(this.getHello())));
    }
    
    private String getHello() { return (null != util) ? util.getEntity()
: "No Util Class"; }
}


HomePage.html:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:wicket="http://wicket.apache.org">
  <head>
    <meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
    <title>Insert wicket title here</title>
  </head>
  <body>
    <span wicket:id="hello">Yo!</span>
  </body>
</html>


jsf.xhtml (in context root):


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">

  <h:head>
  <title>Insert jsf title here</title>
  </h:head>
  <h:body>
    <span>#{controller.hello}</span>
  </h:body>
</html>


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:jcarman@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.Ericksen@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:jcarman@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.Ericksen@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket and JEE6

Posted by James Carman <jc...@carmanconsulting.com>.
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.Ericksen@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:jcarman@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.Ericksen@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: Wicket and JEE6

Posted by "Ericksen, Mark W (IS)" <Ma...@ngc.com>.
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:jcarman@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.Ericksen@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org