Example #1
0
 public void setValueBinding(String s, ValueBinding vb) {
   if (s != null && s.indexOf("effect") != -1) {
     // If this is an effect attribute make sure Ice Extras is included
     JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
   }
   super.setValueBinding(s, vb);
 }
Example #2
0
 public void broadcast(FacesEvent event) throws AbortProcessingException {
   super.broadcast(event);
   if (event != null) {
     FacesContext facesContext = FacesContext.getCurrentInstance();
     String type = getType();
     UIData uiData = getUIData();
     File output = createFile(facesContext, type, uiData);
     setResource(new FileResource(output));
     getResource();
     JavascriptContext.addJavascriptCall(
         facesContext,
         "Ice.DataExporters['" + getClientId(facesContext) + "'].url('" + getPath() + "');");
   }
 }
Example #3
0
 /** Set the value of the <code>onkeyupeffect</code> property. */
 public void setOnkeyupeffect(Effect onkeyupeffect) {
   this.onkeyupeffect = onkeyupeffect;
   JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
 }
Example #4
0
 /** Set the value of the <code>effect</code> property. */
 public void setEffect(Effect effect) {
   this.effect = effect;
   JavascriptContext.includeLib(JavascriptContext.ICE_EXTRAS, getFacesContext());
 }
Example #5
0
 /**
  * This method is used to communicate a focus request from the application to the client browser.
  */
 public void requestFocus() {
   CoreComponentUtils.setFocusId("null");
   JavascriptContext.focus(
       FacesContext.getCurrentInstance(), this.getClientId(FacesContext.getCurrentInstance()));
 }
  private void renderKindEditorJavascipt(FacesContext facesContext, UIComponent uiComponent) {
    KindEditor ke = (KindEditor) uiComponent;

    ke.loadJavaScript();

    //    String editorId=ke.getId();
    String clientId = uiComponent.getClientId(facesContext);

    String htmlContent = "";
    String htmlContentEscaped = "";
    if (ke.getValue() != null) {
      htmlContent = (String) ke.getValue();
      htmlContentEscaped = StringEscapeUtils.escapeHtml(htmlContent);
    }
    String contextPath = facesContext.getExternalContext().getRequestContextPath();
    log.debug("contextPath:" + contextPath);

    // 三种方式调用kindeditor脚本:直接调用、使用外部配置文件、使用组件属性配置
    // 如果不使用JQuery扩展,则直接调用kindeditor的脚本
    StringBuffer scriptCall = new StringBuffer();
    String scriptPath = ke.getBaseURI().getPath(); // 调用getBaseURI()方法会自动装载javascript相关的资源

    if (ke.getUsingJQueryExt() == false) {
      scriptCall.append(
          "try{\n"
              + "KE.remove('"
              + clientId
              + "');\n"
              + "}"
              + "catch(e){;}\n"
              + "KE.init({\n"
              + " id:'"
              + clientId
              + "',\n"
              + " imageUploadJson:'"
              + contextPath
              + "/uploadJson',\n"
              + " fileManagerJson:'"
              + contextPath
              + "/fileManagerJson',\n"
              + " allowFileManager:true,\n"
              + " allowUpload:true,\n"
              + " skinsPath:'"
              + scriptPath
              + "skins/',\n"
              + " pluginsPath:'"
              + scriptPath
              + "plugins/',\n"
              + " height:'"
              + ke.getHeight()
              + "',\n"
              + " width:'"
              + ke.getWidth()
              + "',\n"
              + " skinType:'"
              + ke.getSkin()
              + "',\n"
              + " items:"
              + ke.getItems()
              + "\n"
              + "});\n"
              + "KE.create('"
              + clientId
              + "');");
    }
    // 优先使用外部配置文件
    else if (ke.getExtConfigPath() != null && ke.getExtConfigPath().length() > 0) {
      JavascriptContext.includeLib(ke.getExtConfigPath(), facesContext);
      String configProfile = ke.getConfigProfile();
      JavascriptContext.addJavascriptCall(
          facesContext,
          configProfile
              + ".editorId='"
              + clientId
              + "';\n"
              + configProfile
              + ".baseURL='"
              + scriptPath
              + "';\n"
              + configProfile
              + ".contextPath='"
              + contextPath
              + "',\n"
              + "new KindEditorExt("
              + configProfile
              + ").setupWhenDocumentIsReady();");
    }
    // 使用页面中的组件属性值构造配置
    else {
      scriptCall.append(
          "new KindEditorExt(\n"
              + "new KindEditorConfig(\n"
              + "'"
              + clientId
              + "',\n"
              + "'"
              + ke.getBaseURI().getPath()
              + "',\n"
              + "'"
              + ke.getHeight()
              + "',\n"
              + "'"
              + ke.getWidth()
              + "',\n"
              + "'"
              + ke.getSkin()
              + "',\n"
              + "'"
              + contextPath
              + "',\n"
              + ke.getItems()
              + "\n"
              + ")\n"
              + ").setupWhenDocumentIsReady();");
    }
    if (scriptCall.length() > 0) {
      DOMContext domContext = DOMContext.attachDOMContext(facesContext, uiComponent);
      if (!domContext.isInitialized()) {
        Element script = domContext.createRootElement(HTML.SCRIPT_ELEM);
        script.setAttribute(HTML.TYPE_ATTR, "text/javascript");
        script.setAttribute(HTML.ID_ATTR, ClientIdPool.get(clientId + "script"));
        script.appendChild(domContext.createTextNode(scriptCall.toString()));
      }
    }
  }