no comments here?

Stefan Fußenegger wrote:
> 
> While validating some of my pages, I found out that some pages do not
> validate due to & in attributes, e.g. 
> 
>  
> 
> W3 validator complains with: "character "&" is the first character of a
> delimiter but occurred as data."
> 
> I'm doing the following in code:
> 
> class Image { String path; String alt; }
> 
> // for StaticImage see
> http://cwiki.apache.org/WICKET/how-to-load-an-external-image.html
> final StaticImage img = new StaticImage("image", new PropertyModel(img,
> "path")));
> img.add(new AttributeModifier("alt", true, new PropertyModel(img,
> "alt")));
> 
> if alt contains "foo & bar", the page won't validate. I think using
> PropertyModel together with AttributeModifier is quite common. however,
> the beans won't contain escaped markup ... hopefully ;)
> 
> Should this be considered a bug? For the time beeing I use:
> 
> new AttributeModifier("alt", true, new Model(album.getName())) {
>   protected String newValue(final String currentValue, final String
> replacementValue) {
>     return Strings.escapeMarkup(replacementValue).toString();
>   }
> }
> 
> 
> 
> btw: While looking for answers, I also found this (quite old) thread:
> 
> http://www.nabble.com/Escaping-quotes-in-attributes-td11487305.html#a11487344
> 
> Al Maw mentions a comment in code: "attributes without values are
> possible, e.g. 'disabled'" inside ComponentTag.writeOutput(...). As
> mentioned and suggested in this thread, this is not true for XHTML and
> should probably be fixed. However, the comment (and corresponding code) is
> still there (at least in wicket 1.3.4).
> 
> best regards and nice weekend!
> 


-----
-------
Stefan Fußenegger
http://talk-on-tech.blogspot.com // looking for a nicer domain ;)
-- 
View this message in context: 
http://www.nabble.com/Escaping-of-strings-containing---in-attributes-tp18779532p18832765.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]

Reply via email to