This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 127481 - I18N - ${ENCODING} meta tag is missed
Summary: I18N - ${ENCODING} meta tag is missed
Status: CLOSED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Editor (show other bugs)
Version: 6.x
Hardware: All Linux
: P1 blocker (vote)
Assignee: pslechta
URL:
Keywords: I18N
Depends on:
Blocks:
 
Reported: 2008-02-15 14:55 UTC by soldatov
Modified: 2009-05-18 10:45 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description soldatov 2008-02-15 14:55:28 UTC
Scenario:
- Run Netbeans with C/C++ Pack only
- Create new project
- Push "File|New File..." menu item
- Select "Other|HTML File" category and create file
==> "Warning" window appears with such message:

---------------------------------------------------------------------------------------
The encoding ${ENCODING} specified in meta tag of the document newhtml.html is invalid.
Do you want to load the file using UTF-8 encoding.
---------------------------------------------------------------------------------------
Comment 1 Thomas Preisler 2008-03-18 22:32:06 UTC
html files are not part of CND. Please refile against correct module....
Comment 2 Ken Frank 2008-03-25 01:55:05 UTC
what os locale are you in when it happens ?
what project encoding is being used ?(see project properties)

does it happen if create a web project and then a new html file ?

ken.frank@sun.com
Comment 3 soldatov 2008-03-25 08:50:55 UTC
Linux
en_US.UTF-8

This bug appears if I installed NetBeans with C/C++ Pack only.If I installed NetBeans with Java SE pack (with or without
C/C++ Pack), then bug disappears.
I can install Web pack without Java SE pack, therefore I cannot reproduce this bug in web projects.
Comment 4 Ken Frank 2008-03-25 18:16:23 UTC
I see this using all packs installed in the following situation:

open template manager and choose the other->html or the web->html
and the same popup appears.

it happens also for jsp template file opened from template manager.
(also the xml file template does not have encoding variable but new xml file
itself does)

when creating a new html file from a cnd project,
it does not appear.

thus perhaps the code that avoids this msg when actually creating the file
is found in javase or web pack, but since cnd pack not have those, thats why it happens 
then when actually creates the html file ?

but in any case it seems a valid issue even for case when template manager opens the
file - and since project is in utf-8 encoding anyway or user started ide in utf-8
encoding, why should the message appear ?

marking as p2 in this case.

since the error message refers to ${encoding} rather than actual project encoding,  perhaps the code is not consulting
the feq or other encoding data ?

ken.frank@sun.com
Comment 5 Petr Jiricka 2008-03-26 10:42:05 UTC
Could this be related to issue 129775 that Andrei is currently working on?
Comment 6 Petr Jiricka 2008-03-27 12:30:02 UTC
Marku, any idea what the problem could be? Thanks.
Comment 7 pslechta 2008-03-31 09:19:19 UTC
I can reproduce this problem on NB 6.0.1 (Web & Java EE distribution).
Steps to reproduce:
(1) menu Tools > Templates
(2) select Other > HTML File
(3) click button Open in Editor
Warning window appears: "The encoding ${ENCODING} specified in meta tag of the document html.html is invalid.
Do you want to load the file using UTF-8 encoding?" (Yes + No option)
Comment 8 pslechta 2008-03-31 09:41:32 UTC
Original HTML template contains the following line:
    <meta http-equiv="Content-Type" content="text/html; charset=${encoding}">
When opening template, the variable "${encoding}" is not replaced with some value (which is OK, because we want to edit
template) and NB cannot resolve file encoding (don't know encoding "${encoding}").
The same happens when you want to save HTML template with the line above.
(If you replace "${encoding}" with "UTF-8" and save the template, then next time when opening the template there will be
no errors.)

When new HTML file is created, the variable "${encoding}" is properly replaced:
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
and there is no problem with the newly created file (at least on NB 6.0.1 Web & Java EE distribution).

It seems to me that there are two problems:
(1) Edit Template: the warning message should not be shown, encoding should be resolved somehow internally. The rule how
to check file encoding should be applied only to new/opened files, not to templates
(2) New/Open File: if encoding is not replaced properly (I was not able to reproduce this on NB 6.0.1 Web & Java EE)
then it should be fixed
Comment 9 pslechta 2008-03-31 10:35:52 UTC
Variable replacement in template for new HTML file does not work on NB 6.1beta C++ distro.

C++ file template:
// 
// File:   %<%NAME%>%.%<%EXTENSION%>%
// Author: %<%USER%>%
//
// Created on %<%DATE%>%, %<%TIME%>%
//

After replacement (on C++ distro):
// 
// File:   newmain.cpp
// Author: petr
//
// Created on March 31, 2008, 11:16 AM
//

HTML template:
<!-- 
    Document   : ${name}
    Created on : ${date}, ${time}
    Author     : ${user}
-->

After replacement (on C++ distro):
<!-- 
    Document   : ${name}
    Created on : ${date}, ${time}
    Author     : ${user}
-->

(no replacement was done)

Comment 10 pslechta 2008-04-01 09:17:52 UTC
It seems that C++ distro has some problem with freemarker lookup (freemarker not properly registered?)...

Class org.netbeans.modules.templates.ScriptingCreateFromTemplateHandler, method private static ScriptEngine
engine(FileObject fo), contains the following code:

Object obj = fo.getAttribute("javax.script.ScriptEngine"); // NOI18N
...
if (manager == null) {
    manager = new ScriptEngineManager();
}
...
return manager.getEngineByName((String)obj);

parameter for manager.getEngineByName call is "freemarker".

On C++ distro, the call returns null, so no replacements can be done.
On Web & J2EE distro, the call returns instance of org.netbeans.libs.freemarker.FreemarkerEngine, so replacements are
done correctly.

Why freemarker is registered OK on Web & J2EE distro, but is not registered on C++ distro?
Comment 11 pslechta 2008-04-01 10:43:28 UTC
ScriptEngineManager on Web & J2EE distro has two engines registered: (1) RhinoScriptEngineFactory, and (2)
FreemarkerFactory. However, ScriptEngineManager on C++ distro has only one engine registered: RhinoScriptEngineFactory...
Freemarker is missing there...
Comment 12 pslechta 2008-04-01 11:58:07 UTC
The fix for this bug is to create dependency between HTML module and FreeMarker module. FreeMarker is part of C++ disrto.
Comment 13 pslechta 2008-04-01 13:35:49 UTC
Fixed.

0281b264a972
Comment 14 Martin Schovanek 2008-04-01 19:32:48 UTC
Verified at continuous build.
Comment 15 pslechta 2008-04-03 14:34:34 UTC
The fix was ported to release61 repository.

http://hg.netbeans.org/release61/rev/b3f890dd0919
Comment 16 Martin Schovanek 2008-04-04 12:52:04 UTC
verified at release61 build.