4.4.2.6. getPreviewURL

Every time a user clicks a node in the product tree, a preview of the node is shown in the preview area of Docmenta. The getPreviewURL method has to return the URL of the page to be loaded in the preview area. Note that the preview area of Docmenta is an internal browser frame, for which the HTML <iframe> element is used.
If the preview of a node shall not be supported, then this method just has to return null. In our example, the relative path to a JSP page named view.jsp is returned:
    public String getPreviewURL(WebUserSession webSess, String nodeId)
    {
        File viewJSP = relativeURL + "/view.jsp?docsess=" +
                       encode(webSess.getSessionId()) +
                       "&nodeid=" + encode(nodeId);
        return webSess.encodeURL(viewJSP);
    }

    private String encode(String value)
    {
        try {
            return URLEncoder.encode(value, "UTF-8");
        } catch (UnsupportedEncodingException ex) {
            return value;
        }
    }
Note that the session-ID and node-ID are appended to the URL as parameters. The java.net.URLEncoder.encode method is used to encode the IDs as URL parameters. For more information on these parameters see the description of the view.jsp page below.