[
https://issues.apache.org/jira/browse/WICKET-5702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14144764#comment-14144764
]
Martijn Dashorst commented on WICKET-5702:
------------------------------------------
We use the following class to wrap around StringResourceModel and I think it
has a much better API:
{code:java}
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.Component;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.StringResourceModel;
public class I18N implements Serializable
{
private static final long serialVersionUID = 1L;
private String key;
private Component component;
private IModel< ? > model;
private String defaultValue;
private List<Serializable> parameters = new ArrayList<>();
private I18N(String key)
{
this.key = key;
}
public static I18N of(String key)
{
return new I18N(key);
}
public I18N from(Component component)
{
this.component = component;
return this;
}
public I18N withModel(IModel< ? > model)
{
this.model = model;
return this;
}
public I18N with(Serializable parameter)
{
parameters.add(parameter);
return this;
}
public I18N withDefault(String defaultValue)
{
this.defaultValue = defaultValue;
return this;
}
public IModel<String> toStringModel()
{
return new StringResourceModel(key, component, model,
defaultValue, parameters.toArray());
}
@Override
public String toString()
{
return toStringModel().getObject();
}
}
{code}
> Placeholders not substituted with StringResourceModel
> -----------------------------------------------------
>
> Key: WICKET-5702
> URL: https://issues.apache.org/jira/browse/WICKET-5702
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 7.0.0-M2, 7.0.0-M3
> Environment: Linux 3.16/JDK7
> Reporter: Thomas Geese
> Assignee: Andrea Del Bene
> Attachments: mytestproject.tar.gz
>
>
> When using StringResourceModel with substitution parameters the placeholders
> in the resulting string are not replaced.
> We are migrating from 6.14 to 7.0.0-M3 and in 6.14 (and 6.17) it was working
> es expected. I attached a quickstart-project to show how we use
> StringResourceModel in our project and how to reproduce this issue.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)