Ticket #3660: 3660.patch

File 3660.patch, 5.6 KB (added by David Webb, 15 years ago)
  • java-core/src/main/resources/META-INF/FCKeditor.tld

     
    5656                </attribute>
    5757                <attribute>
    5858                        <description>
     59                                The parameter name to use when passing this content in
     60                                a HTTPRequest.  If not passed, parameter name is the
     61                                same as instanceName
     62                        </description>
     63                        <name>name</name>
     64                        <required>false</required>
     65                        <rtexprvalue>false</rtexprvalue>
     66                        <type>java.lang.String</type>
     67                </attribute>           
     68                <attribute>
     69                        <description>
    5970                                Width of the FCKeditor instance in the browser window.
    6071                        </description>
    6172                        <name>width</name>
  • java-core/src/main/java/net/fckeditor/tags/EditorTag.java

     
    4848        private String toolbarSet;
    4949        private String value;
    5050        private String basePath;
     51        private String name;
    5152
    5253        /** The underlying FCKeditor instance */
    5354        private transient FCKeditor fckEditor;
     
    5859        public void setInstanceName(String instanceName) {
    5960                this.instanceName = instanceName;
    6061        }
     62       
     63        /**
     64         * @see FCKeditor#setName(String)
     65         */
     66        public void setName(String name) {
     67                this.name = name;
     68        }
    6169
    6270        /**
    6371         * @see FCKeditor#setWidth(String)
     
    128136                                fckEditor.setValue(value);
    129137                        if (Utils.isNotEmpty(basePath))
    130138                                fckEditor.setBasePath(basePath);
     139                        if (Utils.isNotEmpty(name))
     140                                fckEditor.setParamName(name);
    131141
    132142                } catch (Exception e) {
    133143                        throw new JspException(e);
     
    151161                return EVAL_PAGE;
    152162        }
    153163
    154 }
    155  No newline at end of file
     164}
     165
  • java-core/src/main/java/net/fckeditor/FCKeditor.java

     
    4343
    4444        private FCKeditorConfig fckConfig = new FCKeditorConfig();
    4545        private String instanceName;
     46        private String paramName;
    4647        private String value;
    4748        private HttpServletRequest request;
    4849
     
    5152        private String width = PropertiesLoader.getEditorWidth();
    5253        private String height = PropertiesLoader.getEditorHeight();
    5354        private String basePath = PropertiesLoader.getEditorBasePath();
     55       
     56        /*
     57         * Static counter for auto generated id tags
     58         */
     59        private static long IDCounter = 0l;
     60        private String sID = "";
    5461
    5562        /**
    5663         * Class constructor with all basic parameters.
     
    7885         *             if instanceName is empty or not a valid XHTML id
    7986         */
    8087        public FCKeditor(final HttpServletRequest request,
    81                         final String instanceName, final String width, final String height,
     88                        final String instanceName, final String paramName,
     89                        final String width, final String height,
    8290                        final String toolbarSet, final String value, final String basePath) {
    8391
    8492                this(request, instanceName);
     93                this.paramName = paramName;
    8594                this.width = width;
    8695                this.height = height;
    8796                this.toolbarSet = toolbarSet;
     
    130139        }
    131140
    132141        /**
     142         * Sets the initial value of the input element's name
     143         *
     144         * @param value the name of the input element
     145         */
     146        public void setParamName(String value) {
     147                this.paramName = value;
     148        }
     149       
     150        /**
    133151         * Sets the initial value to be edited as HTML markup.
    134152         *
    135153         * @param value
     
    300318        @Override
    301319        public String toString() {
    302320                StringBuffer strEditor = new StringBuffer();
     321               
     322                /*
     323                 * Set the ID tag
     324                 */
     325                sID = instanceName;
     326                if (instanceName.equals("auto")) {
     327                        sID = "auto" + IDCounter++;
     328                }
     329               
     330                /*
     331                 * Set the paramName is not already set
     332                 */
     333                if (paramName == null || paramName.equals("")) {
     334                        paramName = sID;
     335                }
    303336
    304337                strEditor.append("<div>");
    305338                String encodedValue = escapeXml(value);
    306339
    307340                if (Compatibility.isCompatibleBrowser(request)) {
    308                         strEditor.append(createInputForVariable(instanceName, instanceName,
     341                        strEditor.append(createInputForVariable(paramName, sID,
    309342                                        encodedValue));
    310343
    311344                        // create config HTML
    312345                        String configStr = fckConfig.getUrlParams();
    313346                        if (Utils.isNotEmpty(configStr))
    314                                 strEditor.append(createInputForVariable(null, instanceName
     347                                strEditor.append(createInputForVariable(null, sID
    315348                                                .concat("___Config"), configStr));
    316349
    317350                        // create IFrame
    318351                        StringBuffer editorLink = new StringBuffer(request.getContextPath());
    319352                        editorLink.append(basePath);
    320353                        editorLink.append("/editor/fckeditor.html?InstanceName=").append(
    321                                         instanceName);
     354                                        sID);
    322355                        if (Utils.isNotEmpty(toolbarSet))
    323356                                editorLink.append("&amp;Toolbar=").append(toolbarSet);
    324 
     357                       
    325358                        XHtmlTagTool iframeTag = new XHtmlTagTool("iframe",
    326359                                        XHtmlTagTool.SPACE);
    327                         iframeTag.addAttribute("id", instanceName.concat("___Frame"));
     360                        iframeTag.addAttribute("id", sID.concat("___Frame"));
    328361                        iframeTag.addAttribute("src", editorLink.toString());
    329362                        iframeTag.addAttribute("width", width);
    330363                        iframeTag.addAttribute("height", height);
     
    335368                } else {
    336369                        XHtmlTagTool textareaTag = new XHtmlTagTool("textarea",
    337370                                        encodedValue);
    338                         textareaTag.addAttribute("name", instanceName);
     371                        textareaTag.addAttribute("name", sID);
    339372                        textareaTag.addAttribute("rows", "4");
    340373                        textareaTag.addAttribute("cols", "40");
    341374                        textareaTag.addAttribute("wrap", "virtual");
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy