Wicket 2: Make a page in JDeveloper


This is part 2 of a series about Wicket.

JDeveloper provides out-of-the-box support for this excellent framework.

For initial setup information you may recall part 1.

Out-of-the-box

Assume the page Hello that of course IS-A WebPage.

package nikos;

import org.apache.wicket.markup.html.WebPage;

public class Hello extends WebPage {
   public Hello() {
   }
}

To create its HTML file right-click on the project → New… → Web Tier → HTML → HTML Page

In the “Create HTML File” dialog give the name Hello.html, click on “Browse…”

and select the classes/nikos directory.

We’d like a simple page. This is the markup.

<html>
   <body>
      <h1 wicket:id="label"></h1>
   </body>
</html>

Thus we don’t specify any value for the <h1> element. Instead we provide a wicket:id. We’ll use this id to get the element and fill its value through Java!

Let’s return to the class for some action.

package nikos;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;

public class Hello extends WebPage {
   public Hello() {
      add(new Label("label", "Hello from Wicket in JDeveloper!"));
   }
}

Review

  • All the action gets inside this constructor
  • Use JDev’s handy “Create HTML File” dialog to place the html in the same directory as the class file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: