I have been able to successfully write JavaScript code in a bean method during application start.
However, I am facing an issue where the JavaScript function calls the bean method and returns values when the application is initially started. When I click on the button, it does not call the bean method again. It seems to only call the bean method during application startup. Here is my button:
<p:commandLink oncomplete="myRemote();" title="my button"
/>
This is my JavaScript function:
function myRemote() {
${myBackingBean.actionMyValues()}
}
Below is my Bean class:
@Controller
@Scope("view")
public class MyBackingBean implements Serializable {
public String actionMyValues() {
String js="";
/*getting some values from database and adding it to javascript variables.*/
js += "alert('alert')";//
return js;
}
}