This is what I ended up with to include a solution for my colored circle
images in case someone else finds the need for such a solution. I am
assuming it was a reasonable way to go:
...
/*
* Checkbox column for the color blind
*/
if (colorblind) {
columns.add(new CheckBoxColumn("checkBox"));
}
/*
* Check Item State column
*/
columns
.add(new PropertyColumn(new ResourceModel("state"), "state",
"state") {
private static final long serialVersionUID = 1L;
@Override
public String getCellCssClass(IModel rowModel, int rowNum) {
return "state";
}
@Override
public boolean isEscapeMarkup() {
return false;
}
@Override
protected IConverter getConverter(final Class<?> varType) {
return new IConverter() {
// serialVersionUID.
private static final long serialVersionUID = 1L;
public Object convertToObject(String value,
java.util.Locale locale) {
// TODO Auto-generated method stub
return null;
}
public String convertToString(Object value,
java.util.Locale locale) {
String color = "white";
switch ((Integer) value) {
case 0:
color = "black";
break;
case 1:
color = "gray";
break;
case 2:
color = "red";
break;
case 3:
color = "yellow";
break;
case 4:
color = "blue";
break;
case 5:
color = "green";
}
if (!colorblind) {
return "[lt]img src=\"images/".concat(color).concat(
"-circle.png\"").concat(" alt=\"").concat(
value.toString()).concat("\[gt]");
} else {
return value.toString();
}
}
};
}
}.setInitialSize(3).setSizeUnit(SizeUnit.EM).setResizable(false)
.setReorderable(true).setHeaderTooltipModel(
new Model("State of the check item")));
...
where [lt]=<
and [gt]=>
Not sure how to address this problem when replying...
I stored all my image files under webapp/images. I am a beginner with Wicket
but this seemed to work fine for me and I can see it coming up for someone
else so figured I would share my outcome.
--
View this message in context:
http://www.nabble.com/A-packaged-resource-that-has-a-variable-image-based-on-component--value-tp24422634p24434326.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]