//new to java /
Fortunately, we can just have NetBeans
do this for us.
1. Right-click the wicket package.
2. From the New menu, select Java
Package.
3. Enter org.duchess.example.wicket
.product in the Package field, and click
Finish.
4. Right-click the new product package.
5. From the New menu, select Other.
6. Select Web in the Categories list.
7. Select Wicket Panel in the File Types
list, and click Next.
8. Enter ProductsPanel in the File Name
field, and click Finish.
9. Fill the ProductsPanel.html file with
the code shown in Listing 21.
10. Fill the ProductsPanel.java file with
the code shown in Listing 22.
11. And finally, add the new Panel to
the HomePage by changing both the
HomePage.java file (Listing 23) and
the HomePage.html file (Listing 24).
Creating a second page to show the
details of a product. Next, we want to
create a page where we can show the
details of a product. First, we need to
create a ProductDetailPage:
1. Right-click the product
package.
2. From the New menu, select
Other.
3. Select Web in the Categories
list.
4. Select Wicket Page in the File
Types list, and click Next.
5. Enter ProductDetailPage in
the File Name field, and click
Finish.
6. Fill the ProductDetailPage
.html file with the code
shown in Listing 25. And format the code to make it more
readable.
7. Fill the ProductDetailPage
.java file with the code shown
in Listing 26. And organize
the imports.
8. Create a class called
ImagesView in the product
package.
9. Fill the ImagesView.java
file with the code shown in
Listing 27.
LISTING 20 LISTING 21 LISTING 22 LISTING 23 LISTING 24
package org.duchess.example.wicket.dataproviders;
COMMUNITY
// imports
abstract public class ProductDataProvider implements IEjbDataProvider<Product> {
@Override
public Iterator<? extends Product> iterator(int first, int count) {
// to make sure we are not going to get a negative number of values
// to retrieve, we need to reset the count
if (count < first) {
}
int[] range = {first, count};
List<Product> products = getFacade().findRange(range);
return products.iterator();
}
JAVA IN ACTION
ABOUT US
Watch the Create Entities movie to see the
steps to create entities.
@Override
public IModel<Product> model(final Product object) {
final Long id = object.getProductId();
LoadableDetachableModel<Product> ldm = new
LoadableDetachableModel<Product>(object) {
@Override
protected Product load() {
return getFacade().find(id);
}
};
return ldm;
}
@Override
public int size() {
}
@Override
public void detach() {
}
}
blog
Watch the Create Session Beans movie to
see the steps to create session beans.
Download all listings in this issue as text
29
ORACLE.COM/JAVAMAGAZINE /////////////////////////////////////////////// MAY/JUNE 2012