/** * Sets up the widget with all required information. It initializes the JQuery comment plugin with * and it parameterizes from Silverpeas settings and from the resource for which the comments * should be rendered. * * @return a container of rendering elements. * @throws JspException if an error occurs while initializing the JQuery comment plugin. */ public ElementContainer initWidget() throws JspException { String context = URLManager.getApplicationURL(); ElementContainer xhtmlcontainer = new ElementContainer(); div comments = new div(); comments.setID(COMMENT_WIDGET_DIV_ID); comments.setClass(COMMENT_WIDGET_DIV_CLASS); script checkForm = new script().setType("text/javascript").setSrc(context + "/util/javaScript/checkForm.js"); script initCommentPlugin = new script().setType("text/javascript").addElement(setUpJQueryCommentPlugin()); xhtmlcontainer.addElement(comments).addElement(checkForm); JavascriptPluginInclusion.includeUserZoom(xhtmlcontainer); JavascriptPluginInclusion.includeComment(xhtmlcontainer); xhtmlcontainer.addElement(initCommentPlugin); return xhtmlcontainer; }
/** * Displays the form part corresponding to the video input. The form input is a way to change or * to remove the video file if this one exists. * * @param attachmentId the identifier of the attached file containing the video to display. * @param template the template of the field to which is mapped the video. * @param pagesContext the context of the displaying page. */ private void displayVideoFormInput( final String attachmentId, final FieldTemplate template, final ElementContainer xhtmlContainer, final PagesContext pagesContext) { String fieldName = template.getFieldName(); String language = pagesContext.getLanguage(); String deletionIcon = Util.getIcon("delete"); String deletionLab = Util.getString("removeFile", language); String videoURL = computeVideoURL(attachmentId, pagesContext); Operation defaultOperation = Operation.ADD; if (!videoURL.isEmpty()) { defaultOperation = Operation.UPDATE; Map<String, String> parameters = template.getParameters(pagesContext.getLanguage()); parameters.remove(PARAMETER_WIDTH); parameters.remove(PARAMETER_HEIGHT); // a link to the video Element videoLink = createVideoLink(videoURL, parameters); // a link to the deletion operation img deletionImage = new img(); deletionImage .setAlt(deletionLab) .setSrc(deletionIcon) .setWidth(15) .setHeight(15) .setAlt(deletionLab) .setTitle(deletionLab); a removeLink = new a(); removeLink .setHref("#") .addElement(deletionImage) .setOnClick( "javascript: document.getElementById('" + fieldName + "Video').style.display='none'; document." + pagesContext.getFormName() + "." + fieldName + OPERATION_KEY + ".value='" + Operation.DELETION.name() + "';"); div videoDiv = new div(); videoDiv.setID(fieldName + "Video"); videoDiv.setClass("video"); videoDiv.addElement(videoLink); videoDiv.addElement(" "); videoDiv.addElement(removeLink); xhtmlContainer.addElement(videoDiv); } // the input from which a video file can be selected input fileInput = new input(); fileInput.setID(fieldName); fileInput.setType("file"); fileInput.setSize(50); fileInput.setName(fieldName); input attachmentInput = new input(); attachmentInput .setType("hidden") .setName(fieldName + Field.FILE_PARAM_NAME_SUFFIX) .setValue(attachmentId) .setID(fieldName + Field.FILE_PARAM_NAME_SUFFIX); input operationInput = new input(); operationInput .setType("hidden") .setName(fieldName + OPERATION_KEY) .setValue(defaultOperation.name()) .setID(fieldName + OPERATION_KEY); div selectionDiv = new div(); selectionDiv.setID(fieldName + "Selection"); selectionDiv.addElement(fileInput); selectionDiv.addElement(attachmentInput); selectionDiv.addElement(operationInput); if (template.isMandatory() && pagesContext.useMandatory()) { selectionDiv.addElement(Util.getMandatorySnippet()); } xhtmlContainer.addElement(selectionDiv); Element player = createVideoPlayer(videoURL, template.getParameters(pagesContext.getLanguage())); xhtmlContainer.addElement(player); }