Simple way to use parameterised UI messages in Wicket?

后端 未结 6 610
借酒劲吻你
借酒劲吻你 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:35

    In case you have a Model in your Component which holds an object with values you want to access from your placeholders as substitutions, you can write:

    new StringResourceModel("salutation.text", getModel());
    

    Let's imagine getModel()'s return type is IModel and User contains fields like firstName and lastName. In this case you can easily access firstName and lastName fields inside your property string:

    salutation.text=Hej ${firstName} ${lastName}, have a nice day!
    

    Further information you can find here: https://ci.apache.org/projects/wicket/apidocs/8.x/org/apache/wicket/model/StringResourceModel.html#StringResourceModel-java.lang.String-org.apache.wicket.model.IModel-

提交回复
热议问题