Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1486

Allow child components inside of wicket:message

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3.2
    • 1.4-M1
    • wicket
    • None

    Description

      Currently you can't put a link or text in the middle of a wicket:message. You need to break up the message into 2 parts as text before the link and text after the link.

      I've made a modification to the WicketMessageResolver class that allows you to nest child components inside a wicket:message and then reference them from the properties file. For example in the html
      <wicket:message key="myKey">
      This text will be replaced with text from the properties file.
      <span wicket:id="amount">[amount]</span>.
      <a wicket:id="link">
      <wicket:message key="linkText"/>
      </a>
      </wicket:message>

      Then in the properties file have a variable with a name that matches the wicket:id for each child component. The variables can be in any order, they do NOT have to match the order in the HTML file.
      myKey=Your balance is ${amount}. Click ${link} to view the details.
      linkText=here

      And in the java
      add(new Label("amount",new Model("$5.00")));
      add(new BookmarkablePageLink("link",DetailsPage.class));

      In the browser this will output
      Your balance is $5.00. Click here to view the details.

      I'll attach a quick start as well as an svn diff.

      Attachments

        1. MessageQuickStart.zip
          3.71 MB
          John Ray
        2. Message.diff
          8 kB
          John Ray

        Activity

          People

            jdonnerstag Juegen Donnerstag
            johnray John Ray
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: