-
Notifications
You must be signed in to change notification settings - Fork 298
How to use @Resource annotation
Michael O'Cleirigh edited this page Apr 12, 2011
·
1 revision
- Add a resource reference in your web.xml descriptor, i.e.
<env-entry>
<env-entry-name>welcomeMessage</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>@Welcome</env-entry-value>
</env-entry>
- Use the @Resource annotation in your wicket page, always specifing the name of the referenced resource, i.e.
public class ListContacts extends WebPage {
@Resource(name="welcomeMessage") private String welcome;
public ListContacts() {
new Label(this, "welcomeMessage", welcome);
//.......
- Add the line
addComponentInstantiationListener(new JavaEEComponentInjector(this));
inside the init() method of your Wicket WebApplication?, like in the example:
public class WicketJavaEEApplication extends WebApplication {
protected void init() {
addComponentInstantiationListener(new JavaEEComponentInjector(this));
}
}