2

I am facing a strange issue with netbeans and jsf, it is not fatal but quite annoying.

For some reason I am getting the error "Unexpected character % found Unexpected token ERROR found" from netbeans for the following code block.

It is complaining about the percent sign, do you have any idea how to resolve this? I tried to escape it with xml encoding of percent with "%" but then it started complaining about & character..

<div class="bar" style="width: #{cc.value.relevance}%;"></div>
cubbuk
  • 7,800
  • 4
  • 35
  • 62

1 Answers1

1

Imho, You should add a cast like:

object.toString().append("%");

before it gets call by the front-end.

TalesTk
  • 181
  • 3
  • Thats not a convenient use, I have several fields like that and they are part of an object modal, so I am looking for a front-end solution, but thanks anyway for the feedback. – cubbuk Nov 16 '12 at 08:06
  • What type of variable is this bean call returning? – TalesTk Nov 16 '12 at 15:25
  • It's a double value. But its a field of a Morphia object modal. – cubbuk Nov 22 '12 at 08:37
  • I still would recommend to parse it to String. It is better if you follow up with a pattern so if you have many pages and forget to put the "%" in one of them nothing will complain about it. So passing a string build with the "%" sign will make it more secure and you won't have to worry about it. Another thing is that you need a String builder in order to use the "append()" method, or you could do `object.toString() + "%";` . – TalesTk Nov 26 '12 at 17:56
  • I use this pattern for another case and it is a nice workaround thanks for the feedback. But it seems like a bug of the IDE (netbeans), these kind of examples should not be marked as error. – cubbuk Dec 05 '12 at 08:29
  • What does it complains about? – TalesTk Dec 05 '12 at 16:12
  • It does complain about the following code and thats annoying, otherwise your method works ok =)
    – cubbuk Dec 05 '12 at 18:44