Why does this JSF expression not work?
Asked Answered
L

2

5

I have a simple problem on .xhtml page. This expression is not working :-

<a href="Photos.jsf?albumId=#{item.albumId}&blogId=#{PhotoAlbumsCommonBean.blogId}">
 photos
</a>

I get this error :-

Error Parsing /Common/PhotoAlbums.xhtml: Error Traced[line: 20] The reference to entity "blogId" must end with the ';' delimiter.

And this is causing some kind of error.

Latoya answered 13/5, 2010 at 16:8 Comment(1)
I was making the same mistake, but puzzling over my '&&' logical operator in javascript.Erring
A
16

Try to encode the ampersand - & with &amp;

An answered 13/5, 2010 at 16:10 Comment(5)
It doesn't work :(. Now the error is :-The reference to entity "ampblogId" must end with the ';' delimiter.Latoya
Have you put the semicolon after the &amp?An
Replace it with "&amp;" and it will work. The URL should be Photos.jsf?albumId=#{item.albumId}&amp;blogId=#{PhotoAlbumsCommonBean.blogId}Hoosegow
@Petar - you can use the backtick character to escape code in the Markdown editorMalefactor
using &#38; (an xhtml code for ampersand character) is a safer option, i reckon!Dissertation
W
0

The error is caused by the # signs.

Try this. It fixes the problem with the JSP EL and having ampersands encoded in XHTML pages:

<a href="Photos.jsf?albumId=${item.albumId}&amp;blogId=${PhotoAlbumsCommonBean.blogId}">
 photos
</a>
Wolters answered 13/5, 2010 at 16:10 Comment(3)
@Nitesh What do you mean it disappears? Does the querystring just look like this: "?albumId=&amp;blogId=..."?Wolters
Hi Steven, your answer is also correct. Don't know which one to vote as correct and give points :p. But i think, $ is not meant for JSF. It is for JSP, though it works.Latoya
I guess the correct symbol to use depends if you want immediate or delayed variable expansion. Good point.Wolters

© 2022 - 2024 — McMap. All rights reserved.