Hello, All!

I'll try to write here.

1. Bug fix:
I like freemarker's, dependencies in separate jars and i haven't
'velocity' in my classpath.
So I found bug: common click core depends on Velocity.

Namely:
org.apache.click.ClickServlet.java
org.apache.click.util.ErrorReport.java

They both depend on
org.apache.velocity.exception.ParseErrorException   (search:
instanceof ParseErrorException)
and require Velocity be present in classpath even if freemarker are used.


My workaround:
I made fake public class ParseErrorException extends Exception {}.


But you can make generic solution, for example:

TemplateService
+ boolean isParseErrorException (Exception e)
+ Map<String, Object> describeParseErrorException (Exception e)



===
2. org.apache.click.util.ClickUtils.java
Instead of few .close(SomeIoObject) methods you can use ONE:

public static void close (Closeable someStreamOrWriter) {
    if (someStreamOrWriter != null) {
      try {
        someStreamOrWriter.close();
      } catch (Throwable ignore) {} //don't believe in IOException
    }
  }//close


My own code looks like this:
public static void close (@Nullable Closeable someStreamOrWriter) {
    if (someStreamOrWriter != null) {
      try {
        someStreamOrWriter.close();
      } catch (Throwable e) {
        log.debug("close: can't close "+ someStreamOrWriter, e);
      }
    }//i
  }//close


All them: reader, writer and streams implement Closeable.


====
3. properties files encoding

J2SE 5.0 reached its End of Service Life (EOSL) on November 3, 2009

So we can try to use some Java6 features with care.

For example (somewhere in Click core):

  private static volatile Boolean java6;//def: null=unknown

public static void loadProperties (Properties properties, InputStream
in, final Charset charset)
    throws IOException, IllegalArgumentException  {

    if (java6 == null) { //1st run
      try {
        java6 = Properties.class.getMethod("load", Reader.class) != null;
      } catch (Exception ignore) {
        java6 = false;
      }//t
    }//i

    if (java6.booleanValue()) {
      properties.load(new InputStreamReader(in, charset));

    } else { //older than 1.6. load(Reader) not supported
      properties.load(in);
    }//i
  }//loadProperties

Profit:  click property files can be in UTF-8 encoding instead of that
ugly \u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234

and it is full backward compatible - you don't need to convert ISO
8859-1 encoded property files (with these \ucafe\ubebe) to UTF-8.
But you can.



4. I made russian translation for click-control_ru.properties
Attached.


> If I have found bug in Click core and have few small improvements -
> can I write about them to this community or must use dev-list or JIRA
> instead?

Attachment: click-control_ru.properties.utf8
Description: Binary data

Attachment: click-control_ru.properties
Description: Binary data

Reply via email to