Hey, http://devlearnings.wordpress.com/2011/05/15/apache-openwebbeans-cdi-from-standalone-to-webapp/ http://docs.jboss.org/weld/reference/1.0.1-Final/en-US/html/environments.html - this is for jboss, but there's something for using it in tomcat as well, and it's possible to replace weld-related stuff with openwebbeans
Most of solutions I found are using Weld, but you actually don't need it. You can use Openwebbeans (tomee) as well, as Igor states out: http://web.archiveorange.com/archive/v/t3xmoyfvrPfZN7bZZbeB I'm not using maven since it made me feel from time to time loosing control, but it should work. I added some libraries (to tomcat/lib), added some code to HomePage.java and all was fine. Making it work for wicket WebSessions as well was a little harder, but I had it solved (thanks to this mailing list), so you might check out the recent archives of this list (http://wicket-users.markmail.org/search/?q=injector.get%28%29). I posted most of my code yesterday (to solve the issue with injection in WebSession). I can send the configurations this afternoon - it's morning now - and check how it made it work with tomee. Kurt 2012/11/25 Yuci Gou <ygou....@gmail.com>: > Just read the article - Status of wicket-cdi Module at > https://www.42lines.net/2012/09/11/status-of-wicket-cdi-module/. > > Wonder if wicket-cdi is part of Wicket 6.1 release and upwards. I tried a > simple Wicket 6.3 application running in TomEE, but could not get the CDI > injection to work. These are the steps I used: > > 1. Create a Wicket project with Maven (according to > http://wicket.apache.org/start/quickstart.html) > > mvn archetype:generate -DarchetypeGroupId=org.apache.wicket > -DarchetypeArtifactId=wicket-archetype-quickstart -DarchetypeVersion=6.3.0 > -DgroupId=com.mycompany -DartifactId=myproject -DarchetypeRepository= > https://repository.apache.org/ -DinteractiveMode=false > > 2. Generate the eclipse configuration files > mvn eclipse:eclipse -Dwtpversion=2.0 > > (Note: Following steps are based on the tutorial on Youtube: > http://www.youtube.com/watch?v=Lr8pxEACVRI) > 3. In folder src/main/webapp/WEB-INF, create file beans.xml > (Also in folder src/main/webapp/META-INF, create file beans.xml, according > to the explanation for this example: > http://tomee.apache.org/examples-trunk/cdi-basic/README.html, and also > src/main/resources/META-INF/beans.xml just in case) > > 4. Create a POJO > public class Faculty { > private List<String> facultyMembers; > private String facultyName; > > @PostConstruct > public void initialize() { > this.facultyMembers = new ArrayList<String>(); > facultyMembers.add("Ian Schultz"); > facultyMembers.add("Diane Reyes"); > facultyName = "Computer Science"; > } > > public List<String> getFacultyMembers() { > return facultyMembers; > } > > public String getFacultyName() { > return facultyName; > } > } > > 5. Inject the POJO in HomePage.java and display it. > public class HomePage extends WebPage { > private static final long serialVersionUID = 1L; > > @Inject > private Faculty faculty; > > public HomePage(final PageParameters parameters) { > super(parameters); > > if (faculty != null) { > add(new Label("cdi", faculty.getFacultyName())); > } else { > add(new Label("cdi", "Not working!")); > } > } > } > > Note, class HomePage is the class for the Wicket homepage, as specified > below: > public class WicketApplication extends WebApplication > { > /** > * @see org.apache.wicket.Application#getHomePage() > */ > @Override > public Class<? extends WebPage> getHomePage() > { > return HomePage.class; > } > } > > These are the steps I tried, but when running, "Not working!" is displayed > on the home page. I debugged it and confirmed that faculty is null, which > means not injected. > > Many thanks for your kind help! > > Yuci --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org