I would like to implement something similar to the Cell Validation showcase example, which can be found here
http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwCellValidation
After looking through the code and trying to implement it, there seems to be a class/variable deffinition missing for template. which shows up in the code in 2 places
public ValidatableInputCell(String errorMessage) {
super("change");
if (template == null) {
template = GWT.create(Template.class);
}
this.errorMessage = SimpleHtmlSanitizer.sanitizeHtml(errorMessage);
}
SafeStyles safeColor = SafeStylesUtils.fromTrustedString("color: " + color + ";");
sb.append(template.input(pendingValue != null ? pendingValue : value, safeColor));
if (invalid) {
sb.appendHtmlConstant(" <span style='color:red;'>");
sb.append(errorMessage);
sb.appendHtmlConstant("</span>");
}
After searching the web i found a few examples of what the template variable definition should be and came up with
interface Template extends SafeHtmlTemplates {
@Template("<input type=\"text\" value=\"{0}\" tabindex=\"-1\" size=\"{1}\"></input>")
SafeHtml input(String value, SafeHtml safeStyles);
}
private Template template;
with the above code added in there are no compiler warning howver when the code is executed i get this error
SafeStyles used in a non-CSS attribute context. Did you mean to use java.lang.String or SafeHtml instead?
Any ideas of how to fix this problem?
The template definition you are looking for, misses the
@ShowcaseSource
annotation, hence you do not see it in the source tab of the validation sample.Anyway, here is the original code. And the template is:
The error you see is because you are using a
SafeStyle
element (referenced by{1}
) as a value of thesize
attribute (instead ofstyle
).