In portlet mode, the generated JavaScript™
variables
are prefixed by the portlet namespace. Thus, their usage in the JSP™
page
is quite different.
In Rogue Wave® JViews a JavaScript action is built on a managed bean
by using the static method
encodeJavaScriptVariables of
ilog.views.faces.IlvFacesUtil.
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 result of calling this method is the final JavaScript
action with namespace-encoded variables.
The JViews JSF components
that have JavaScript handlers need only to reference these bean properties.
The following code examples show a more complete use
of JavaScript actions in the JSP page and the managed bean.
In JViews Diagrammer
Using JavaScript actions in a JSP page
[...]
<jvf:zoomInteractor id="zoom" />
<jv:imageButton onclick="#{diagrammerBean.setZoomAction}"/>
<jvdf:diagrammerView id="diagrammer" />
[...]
Using JavaScript actions in a managed bean
public class DiagrammerBean {
[...]
private String setZoomAction;
public DiagrammerBean(){
setZoomAction =
IlvFacesUtil.encodeJavaScriptVariables("${diagrammer}.setInteractor(${
zoom})");
}
public String getSetZoomAction(){
return setZoomAction;
}
[...]
}
At the JViews Framework level
Using JavaScript actions in a JSP page
[...]
<jvf:zoomInteractor id="zoom" />
<jv:imageButton onclick="#{frameworkBean.setZoomAction}"/>
<jvf:view id="view" />
[...]
Using JavaScript actions in a managed bean
public class FrameworkBean {
[...]
private String setZoomAction;
public FrameworkBean(){
setZoomAction =
IlvFacesUtil.encodeJavaScriptVariables("${view}.setInteractor(${zoom})");
}
public String getSetZoomAction(){
return setZoomAction;
}
[...]
}