Wicket 5: Simple page


This is part 5 of a series about Wicket.

Let’s build a simple page.

This is Hello.java

public class Hello extends WebPage {

}

And this is Hello.html

<html>
  <body>
    <h1 style="color:coral">Hello from Wicket!</h1>
  </body>
</html>

As you can see, the message is written manually in the html file.

Let’s go dynamic: Just provide a wicket:id

<html>
  <body>
    <h1 style="color:coral" wicket:id="message"></h1>
  </body>
</html>

and specify the message through Java.

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

Deploy it to see the result!

Of course, you may provide any message you like. For example the current date, a random number, a value from the database and so on.

public class Hello extends WebPage {
   public Hello() {
      add(new Label("message", new Date().toString()));
   }
}

Review

  • wicket:id is the key.
  • Learn more about WebPage, Label.
  • Remember to put Hello.html in the same directory with Hello.class!

One Response to Wicket 5: Simple page

  1. […] A simple page Tags Java, JDeveloper, Wicket Categories Quick Tutorials, Wicket […]

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: