Simple way to use parameterised UI messages in Wicket?

后端 未结 6 612
借酒劲吻你
借酒劲吻你 2021-01-02 02:43

Wicket has a flexible internationalisation system that supports parameterising UI messages in many ways. There are examples e.g. in StringResourceModel javadocs, such as thi

6条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 03:14

    There's a way, which although still involves creating a model, doesn't requires a bean with a getter.

    given this message in a properties file:

    msg=${} persons
    

    Here's how to replace the placeholder with a value, be it a local variable, a field or a literal:

    add(new Label("label", new StringResourceModel("msg", new Model(5))));
    

提交回复
热议问题