JSF bean property not evaluated in external JavaScript file

后端 未结 4 588
终归单人心
终归单人心 2021-01-16 10:19

If I want to evaluate a JSF bean property from within JavaScript, I see that it works if the JavaScript snippet is inside the xhtml file, but doesn\'t work when the JavaScri

4条回答
  •  别那么骄傲
    2021-01-16 10:31

    Another solution is to change your *.js file to *.xhtml and include it with "". To avoid the parser complaining about the use of &, < and > in your *.xhtml file, surround it with a CDATA tag. The disadvantage of this is if the *.js file is being used in other pages, the browser won't be able to cache it.

    MyJS.xhtml (changed from MyJS.js)

    
    
    
    
    
    
    
    
    
    
    
    
    

    In your index.xhtml file, do the following:

    
      ...
    
    

提交回复
热议问题