1

I was wondering what is the best practice to replace a common string in wicket page.

The problem is that I have a HTLM file with many components added. In between these components there is some text here and there and I wonder if there is for example a way using maybe wildcards to alter some of these text without having to add a bunch of Label components.

Imagine that I have this in an abstract page and I want the descendants commonly replace the wildcards.

<htlm>
<head>
   <title>
      Example
   </title>
</head>
<body>
   Mauris sed nulla $replace_me$. Fusce sodales eros id augue lobortis faucibus. Integer tincidunt, urna in egestas euismod, $replace_me$ sapien tincidunt lectus, quis sodales sem urna non lacus. Donec blandit lacus eget venenatis placerat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per $replace_me$ himenaeos. Suspendisse non accumsan eros. In nec lacinia dolor, ut congue diam. Suspendisse cursus, $replace_me$ id rutrum tempor, arcu diam facilisis nunc, eget vulputate elit nisi non tellus. Suspendisse aliquet enim ex, nec $replace_me$ neque porta a. Suspendisse potenti. Curabitur nec vestibulum risus.
</body>
</html>
Peter Jaloveczki
  • 2,039
  • 1
  • 19
  • 35
  • 1
    Why do you want to avoid useing `Label`s? This seems like just the thing they are intended for. – Dragondraikk Apr 07 '15 at 08:54
  • Might be so. I only felt like using Labels here is a bit of a waste. If I want these $replace_me$ string I'd have to add as many Labels and I want to avoid that. Keep in my I'm only looking for a best practice there might be a very easy way to do this with one label. – Peter Jaloveczki Apr 07 '15 at 09:14
  • you might find helpful using . With this tag you can read bundles and place them directly into you markup. See 'Reading bundles with tag ' from here https://wicket.apache.org/guide/guide/single.html – Andrea Del Bene Apr 07 '15 at 09:49

1 Answers1

1

You can create one Label component in YourPage.java and feed it with the interpolated String as a model object. I.e. replace all the placeholders at the server and pass the final String to the Label.

martin-g
  • 17,243
  • 2
  • 23
  • 35