This discussion is archived
11 Replies Latest reply: Dec 18, 2008 1:49 AM by 843833 RSS

Auto complete field whith nonenglish characters

843833 Newbie
Currently Being Moderated
How can I set autocomplete to work with nonenglish characters (UTF - 8)?
  • 1. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    I looked into this request and found that we don't set the ServletResponse to use UTF-8 encoding. But everything else looks to be workable.

    I can try to make this change for the next release or if you need in sooner you can make the change in the AutoCompleteHandler class.

    Hope this helps...

    Thanks - Mark
  • 2. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    Thanks for your answer
    I'll try to set response.setContentType("text/xml;charset=UTF-8")
    and I hope that is sufficiently
  • 3. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    Did the workaround I gave fix your problem???

    Please let us know when you have a chance...

    Thanks - Mark
  • 4. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    Hi, I have to make an interesting contribution to this issue.

    I use Windows XP Pro SP2 German, Sun Java Studio Creator 2 Update 1, Blueprint Ajax ui.0.1.0 and the AutoComplete feature.

    When I use the "result.addItem(String)" method to add something to the autocomplete result list and this String contains characters like "������� ..." and I type something like "��� ..." in the input field of the compiled Web App, my Firefox 2.0.0.1 displays the auto completion results with the corresponding results while my Internet Explorer 6 just displays an empty result list.

    Any idea why this is that way ? Does it help to change the file "AutoCompletePhaseListener.java" inside the ui.complib to "response.setContentType("text/xml; charset=UTF-8")" ? How do I recompile the whole ui.complib again ?

    Thanks.
  • 5. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    Hi KeenOnJSF,

    First, please make sure that your data in the file is really encoded in UTF-8.
    If that doesn't work, you might want to try ISO-8859-1. It may be
    more suitable for your case(German).

    To compile, just go down to
    * Java EE 5
    bpcatalog/ee5/components
    * J2EE 1.4
    bpcatalog/ui/runtime

    and do "ant"
  • 6. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    Hi,

    I've finally found a solution for non-english characters inside the response of the AutoComplete result list. Thank you yuta for your hints.

    First of all I downloaded the "Java BluePrints AJAX components" sources on https://blueprints.dev.java.net/ajaxcomponents.html (download). There I chose "bpcatalogs-14-ea-0.8-installer.jar" because my platform is J2EE 1.4.

    - Run the jar file which unpacks itself into a folder named "bpcatalog-14-ea-0.8"
    - Look for AutoCompletePhaseListener.java and AutoCompleteHandeler.java under the runtime\src\... folder.
    - Inside AutoCompletePhaseListener.java change response.setContentType("text/xml") to response.setContentType("text/xml; charset=UTF-8")
    - Inside AutoCompleteHandler.java add response.setContentType("text/xml; charset=UTF-8") after HttpServletResponse response = ... in the "completions()" method.
    - Now you have to compile and pack everything

    In Windows:
    - Be sure that you have set the ANT_HOME variable to <Your Creator-folder>\Creator2_1\ide5\ant and the JAVA_HOME variable to <Your Creator-folder>\Creator2_1\java
    - The PATH-Variable should have this included: <Your Creator-folder>\Creator2_1\java\bin;%ANT_HOME%\bin;
    - Open a command prompt window and change to folder "bpcatalog-14-ea-0.8\runtime"
    - Type "ant all" to compile everything

    - Use a normal ZIP program and extract the old "ui.complib" (Version 0.1.0 that you get through the Sun Java Studio Creator Update Service) which should be somewhere in your Creator folder, e.g. <Your Creator-folder>\Creator2_1\samples
    - Overwrite "ui.jar", "ui-doc.zip" and "ui-src.zip" with your new versions from the folder "bpcatalog-14-ea-0.8\runtime\dist"
    - Zip everything again to a new ui.complib using a normal ZIP program
    - Update your Studio with the new library. Description here: http://blogs.sun.com/edwingo. Blog entry "AJAX Complib Versioning or Lack Thereof"

    Hope this can help someone.

    Greetings, KeenOnJSF

    Message was edited by:
    KeenOnJSF
  • 7. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    Thanks for posting this.

    Just a note, in the runtime directory, the default ant task "all" will pack the jar for you.

    Also, we have migrated this component to jsf1.2. The source resides in the bpcatalog-ee5-ea-0.8 components/ui directory.

    I will create an issue in the bpcatalog.dev.java.net site for the ee5 bundle. The 1.4 bundle is a final release.

    Thanks - Mark
  • 8. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    I just created the issue located at https://bpcatalog.dev.java.net/issues/show_bug.cgi?id=62

    Thanks again - Mark
  • 9. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    I have a related problem with the AutoComplete. Page encoding is always UTF-8. If I enter a german '�' the prefix becomes "%FC" in the call of the completion method.

    After trying to fix the problem with a CharacterEncodingFilter but without success I looked at the META-INF/autocomplete/script.js.

    In this._callback() = function() ... I found the following
    ...
    var params = this.parameters();
    ...
    holder += param + "=" + escape(params[param]);
    ...
    and in this.parameters = function() ...
    var params = {
      ...
      prefix : escape(this.target.value)
    }
    Ergo, the prefix is escaped twice. This may explain the behaviour. Now I removed the second escape and the '�' was successfull transmitted to '�'. Unfortunately this isn't a full solution. I entered a polish '&#322;' and the prefix becomes null.

    Has anybody a solution or suggestion?
  • 10. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    I have a problem with entering polish letters into the AutoComplete field.

    In the callback I use java.net.URLDecoder.decode(prefix, "UTF-8"); because I want to convert the prefix of all these '%20' etc. The problem is, when I enter a polish character, it gets encoded to something like this %u0105 ('&#261;') and the URLDecoder throws:

    URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "u0"

    Does anyone know a solution to this problem?
  • 11. Re: Auto complete field whith nonenglish characters
    843833 Newbie
    Currently Being Moderated
    hello, I have same problem. in my base the russian names, a base returns a valid response, but avtocomplete them doesn't display. what can advise?