Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use EL in external javascript file

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?

like image 574
Mahmoud Saleh Avatar asked Nov 30 '25 17:11

Mahmoud Saleh


1 Answers

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},....)"/> 
like image 61
Ken Chan Avatar answered Dec 03 '25 05:12

Ken Chan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!