TheQuestionIs
TheQuestionIs

Reputation: 47

Wicket - create a dynamic label

I would like to create a dynamic label in a wicket project.

I have the variable x, which is of type boolean. If the value is true, then the label should output "Text 1". Otherwise it should display "Text 2".

I don't want to set the value from the outside, but rather the label should know what kind of value it should display.

Which method do I have to override for this?

Upvotes: 0

Views: 259

Answers (1)

thg
thg

Reputation: 1235

You dont have to override any method just put in the proper Model.

new Label("id", () -> x ? "Text 1" : "Text 2");

Upvotes: 2

Related Questions