JSF bean property not evaluated in external JavaScript file

后端 未结 4 587
终归单人心
终归单人心 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:37

    I just was want to check something before answer, like I said in my comment :

    I think you can't from external JS, the only way as a workaround you need to pass that value to JS function from JSF page by calling it like functionName(#{value}); and do what you want in JS file like a normal JS value.

    Like in your index.xhtml:

    
    

    or like :

    
    

    and in your js file:

    function functionName(var1) {
    // DO what you want to do with var1 or varN like normal JS value
    }
    

    Sure you can pass a multi-parameters not only single parameter.

提交回复
热议问题