admin管理员组文章数量:1415139
I am still new a Javascript tried earching and tried the development tool in Chrome, too see if I could find the problem.
Working in Intellij IDEA 13, Java, javascript and xhtml.
My problem is that I have a piece of javascript, then in IDEA when moused over, says that
Expression Expected
the javascript code looks the following
<script type="text/javascript>
function nameOfFunction(){
if(#{trendAnalysisLocationReportController.model.showTargetLine}){
this.cfg.series[this.cfg.data.length-1].pointLabels = {
show: false
};
}
}
<\script>
the method in the if sentence is a java method with a boolean return value. the error is shown when hovering
'#{'
if Had a look at the following questions, before : Expected Expression boolean in an if statement
But didnt get me a solution. what Iam I doing wrong ?
I am still new a Javascript tried earching and tried the development tool in Chrome, too see if I could find the problem.
Working in Intellij IDEA 13, Java, javascript and xhtml.
My problem is that I have a piece of javascript, then in IDEA when moused over, says that
Expression Expected
the javascript code looks the following
<script type="text/javascript>
function nameOfFunction(){
if(#{trendAnalysisLocationReportController.model.showTargetLine}){
this.cfg.series[this.cfg.data.length-1].pointLabels = {
show: false
};
}
}
<\script>
the method in the if sentence is a java method with a boolean return value. the error is shown when hovering
'#{'
if Had a look at the following questions, before : Expected Expression boolean in an if statement
But didnt get me a solution. what Iam I doing wrong ?
Share Improve this question edited May 23, 2017 at 12:30 CommunityBot 11 silver badge asked Aug 17, 2015 at 7:58 JesperJesper 1291 gold badge3 silver badges17 bronze badges 3- 1 why are you trying to mix java and javascript? showTargetLine doesn't strike me as a methodname that returns a boolean, btw – Stultuske Commented Aug 17, 2015 at 8:01
-
1
#
is not a proper JavaScript code, thus the if condition can't be executed. – cezar Commented Aug 17, 2015 at 8:01 -
Also if you need a boolean you have to make some parison or call a method that returns a boolean value. The curly braces are used in JavaScript for object literal notation. In your if-condition they aren't properly used. Assuming that
showTargetLine
is a method, the concerned line should beif ( trendAnalysisLocationReportController.model.showTargetLIne() ) { // condition body }
. – cezar Commented Aug 17, 2015 at 8:04
1 Answer
Reset to default 2It looks as though the problem is the part that you've got within the #{...} block. Without knowing the context, it's hard to be sure, but is this something in a view/JSP page that's supposed to be replaced with a property at runtime? The if block will expect the part inside the brackets to be a boolean value, so if that's rendered to either 'true' or 'false' it would execute at runtime but would likely show the error you're seeing in your IDE as it's not actually a valid piece of JavaScript. If, on the other hand, you're expecting to be able to call your Java method/property from your JavaScript code, you're going to need to do something that requests that value from the server-side code - AJAX or similar.
Also worth noting that we can't see what this.cfg is supposed to represent. If that's your entire script block, then there's nothing that defines the cfg object within the current scope.
One last thing, you should change the <\script> end element to as it won't be understood properly by some browsers.
本文标签: intellij ideajavascript expression expectedStack Overflow
版权声明:本文标题:intellij idea - javascript expression expected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745221791a2648426.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论