i have a javascript function that was defined in the xhtml page, and i was able to use EL inside it, now when i moved the function to an external JS file, i am not able to use EL like:
#{request.contextPath}
#{myBackingBean.myProperty}
so, i was wondering how to accomplish something like that in external JS?
You can just declare some input parameters for the external java script 's function .When calling the external java script 's function in JSF , you can use the EL expression to access the values from the beans and pass them to the external java script 's function.
Something like this:
function someExternalJsFunction(var1,var2,...,varX)
{
}
Then in the JSF:
<h:commandLink action="....."
onclick="someExternalJsFunction(#{request.contextPath},#{myBackingBean.myProperty},....)"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With