In portlet mode, the generated JavaScript™
variables are prefixed by the portlet namespace. Thus, their
usage in the JSP™ page is quite different.
A JavaScript action is built on a managed bean by using the
IlvFacesUtil.encodeJavaScriptVariables(String)
static method.
The parameter is the desired JavaScript action where the
variables are declared with the
${id}
notation. For example:
IlvFacesUtil.encodeJavaScriptVariables("${view}.setInteractor(${interactor})");
where
view
and
interactor
represent JavaScript variables.
The JViews JSF components that have
JavaScript handlers need only to reference these bean properties.
The following code shows a more complete
use of JavaScript actions in the JSP page and the managed bean.
Example 1:
[...]
<jvf:zoomInteractor id="zoom" />
<jv:imageButton onclick="#{frameworkBean.setZoomAction}"/>
<jvf:view id="view" />
[...]
Example 2:
public class FrameworkBean {
[...]
private String setZoomAction;
public FrameworkBean(){
setZoomAction =
IlvFacesUtil.encodeJavaScriptVariables("${view}.setInteractor(${zoom})");
}
public String getSetZoomAction(){
return setZoomAction;
}
[...]
}