Running JViews JSF applications in JSR 168 portlets

Note
See the Release Notes for supported JSF implementations and JSF Portlet bridge combinations.
If you want to use JViews JSF components in a JSR 168 portlet environment, you first need to check with your portal vendor whether JavaServer™ Faces components are supported.
Your Web application must be correctly configured. This section describes each of the steps required to make JViews JSF components compatible with portlets.
Note
JViews JSF components are automatically switched to portlet mode if the classes of the portlet API are detected in the class path.
To avoid naming clashes between portlets, the JSR 168 specification requires content to be generated that is unique to each portlet. Therefore, the generated variables used by JViews JSF components must be prefixed by the portlet namespace.

Scripts prefixed by a namespace

Since JViews 8.1, the servlet filter IlvJSNamespaceFilter is no longer needed and must not be set on the controller servlet.

JavaScript variables prefixed by a namespace

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;
  }
[...]
}

Declaring the image servlet

In portlet mode, the servlet used to render the image must be declared:
In JViews Diagrammer
<jvdf diagrammerView [...] servlet=
    "ilog.views.diagrammer.faces.dhtml.servlet.IlvFacesDiagrammerServlet" />
At the JViews Framework level
<jvf view [...] servlet=
    "ilog.views.faces.dhtml.servlet.IlvFacesManagerServlet" />

Integrating JSF components into the portal

Depending on your portal implementation, integrating JSF components may require special configuration that is conditioned by the application server, the JSF implementation, the portlet-JSF bridge, and so on. Check with your portal vendor for what you need to do in this configuration step.