You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2007/04/17 19:34:01 UTC

svn commit: r529682 - in /incubator/wicket/branches/wicket-1.x: jdk-1.4/wicket/src/main/java/org/apache/wicket/ jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/ jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/ jdk-1.5/wicket-examples/src...

Author: ehillenius
Date: Tue Apr 17 10:33:59 2007
New Revision: 529682

URL: http://svn.apache.org/viewvc?view=rev&rev=529682
Log:
WICKET-477

Added:
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.xml
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_th_TH.xml
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.xml
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.xml
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_fa_IR.xml
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ja.xml
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.xml
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ru.xml
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_th_TH.xml
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_zh_CN.xml
Removed:
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.properties
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.properties
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.properties
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.properties
Modified:
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java
    incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java

Added: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_ru.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+	<!-- have to confirm whether this is really ok -->
+	<entry key="RequiredValidator">поле '${label}' обязательно для ввода.</entry>
+	<entry key="TypeValidator">'${input}' должно быть типа ${type}.</entry>
+	<entry key="NumberValidator.range">${input} должно быть между ${minimum} и ${maximum}.</entry>
+	<entry key="NumberValidator.minimum">'${input}' должно быть больше чем ${minimum}.</entry>
+	<entry key="NumberValidator.maximum">'${input}' должно быть меньше чем ${maximum}.</entry>
+	<entry key="StringValidator.range">'${input}' должно быть длиной от ${minimum} до ${maximum} символов(а).</entry>
+	<entry key="StringValidator.minimum">'${input}' должно быть длиной не меньше ${minimum} символов(а).</entry>
+	<entry key="StringValidator.maximum">'${input}' должно быть длиной не меньше ${maximum} символов(а).</entry>
+	<entry key="StringValidator.exact">'${input}' должно быть длиной ${exact} символ(ов).</entry>
+	<entry key="DateValidator.range">дата '${input}' должна быть между ${minimum} и ${maximum}.</entry>
+	<entry key="DateValidator.minimum">дата '${input}' должна быть больше чем ${minimum}.</entry>
+	<entry key="DateValidator.maximum">дата '${input}' должна быть меньше чем ${maximum}.</entry>
+	<entry key="PatternValidator">'${input}' не соответствует шаблону '${pattern}'.</entry>
+	<entry key="EmailAddressPatternValidator">'${input}' не является корректным почтовым адресом.</entry>
+	<entry key="EqualInputValidator">'${input0}' из поля ${label0} и '${input1}' из поля ${label1} должны быть одинаковыми.</entry>
+	<entry key="EqualPasswordInputValidator">поля ${label0} и ${label1} должны быть одинаковыми.</entry>
+	<entry key="null">Выберите значение</entry>
+	<entry key="nullValid"></entry>
+</properties>
\ No newline at end of file

Added: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_th_TH.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_th_TH.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_th_TH.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Application_th_TH.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+	<!-- have to confirm whether this is really ok -->
+	<entry key="RequiredValidator">ข้อมูลใน ${label} เป็นที่ต้องการ.</entry>
+	<entry key="TypeValidator">ไม่ใช่ '${input}' ที่ใช้งานได้จริง ${type}.</entry>
+	<entry key="NumberValidator.range">${input} ต้องอยู่ระหว่าง ${minimum} และ ${maximum}.</entry>
+	<entry key="NumberValidator.minimum">'${input}' ต้องมากกว่า ${minimum}.</entry>
+	<entry key="NumberValidator.maximum">'${input}' ต้องน้อยกว่า ${maximum}.</entry>
+	<entry key="StringValidator.range">'${input}' ต้องอยู่ระหว่าง ${minimum} และ ${maximum} chars.</entry>
+	<entry key="StringValidator.minimum">'${input}' ต้องมีอย่างน้อย ${minimum} ตัวอักษร.</entry>
+	<entry key="StringValidator.maximum">'${input}' ต้องมีไม่เกิน ${maximum} ตัวอักษร.</entry>
+	<entry key="StringValidator.exact">'${input}' ต้องมี ${exact} ความยาวตัวอักษร.</entry>
+	<entry key="DateValidator.range">'${input}' must be between ${minimum} and ${maximum}.</entry>
+	<entry key="DateValidator.minimum">'${input}' must be greater than ${minimum}.</entry>
+	<entry key="DateValidator.maximum">'${input}' must be smaller than ${maximum}.</entry>
+	<entry key="PatternValidator">'${input}' ไม่ตรงกับรูปแบบ '${pattern}'</entry>
+	<entry key="EmailAddressPatternValidator">'${input}' ไม่ใช่อีเมลที่ใช้งานได้จริง.</entry>
+	<entry key="EqualInputValidator">'${input0}' จาก ${label0} และ '${input1}' จาก ${label1} ต้องเท่ากัน.</entry>
+	<entry key="EqualPasswordInputValidator">${label0} และ ${label1} ต้องเท่ากัน.</entry>
+	<entry key="null">เลือกหนึ่งอย่าง</entry>
+	<entry key="nullValid"></entry>
+</properties>

Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java?view=diff&rev=529682&r1=529681&r2=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/PropertiesFactory.java Tue Apr 17 10:33:59 2007
@@ -29,10 +29,13 @@
 import org.apache.wicket.Application;
 import org.apache.wicket.settings.IResourceSettings;
 import org.apache.wicket.util.concurrent.ConcurrentHashMap;
+import org.apache.wicket.util.io.Streams;
 import org.apache.wicket.util.listener.IChangeListener;
+import org.apache.wicket.util.resource.IFixedLocationResourceStream;
 import org.apache.wicket.util.resource.IResourceStream;
 import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
 import org.apache.wicket.util.resource.locator.ResourceStreamLocator;
+import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.util.value.ValueMap;
 import org.apache.wicket.util.watch.ModificationWatcher;
 
@@ -99,12 +102,13 @@
 
 	/**
 	 * 
-	 * @see org.apache.wicket.resource.IPropertiesFactory#load(java.lang.Class, java.lang.String)
+	 * @see org.apache.wicket.resource.IPropertiesFactory#load(java.lang.Class,
+	 *      java.lang.String)
 	 */
 	public Properties load(final Class clazz, final String path)
 	{
 		// Check the cache
-		Properties properties = (Properties) propertiesCache.get(path);
+		Properties properties = (Properties)propertiesCache.get(path);
 		if (properties != null)
 		{
 			// Return null, if no resource stream was found
@@ -165,15 +169,12 @@
 	{
 		// Make sure someone else didn't load our resources while we were
 		// waiting for the synchronized lock on the method
-		Properties props = (Properties) propertiesCache.get(key);
+		Properties props = (Properties)propertiesCache.get(key);
 		if (props != null)
 		{
 			return props;
 		}
 
-		// Do the resource load
-		final java.util.Properties properties = new java.util.Properties();
-
 		if (resourceStream == null)
 		{
 			props = new Properties(key, ValueMap.EMPTY_MAP);
@@ -186,32 +187,33 @@
 			{
 				try
 				{
-					// Get the InputStream 
+					// Get the InputStream
 					BufferedInputStream in = new BufferedInputStream(resourceStream
 							.getInputStream());
-					
+
 					// Determine if resource is a XML File
-//					boolean loadAsXml = false;
-//					if (resourceStream instanceof IFixedLocationResourceStream)
-//					{
-//						String location = ((IFixedLocationResourceStream)resourceStream)
-//								.locationAsString();
-//						if (location != null)
-//						{
-//							String ext = Strings.lastPathComponent(location, '.').toLowerCase();
-//							if ("xml".equals(ext))
-//							{
-//								loadAsXml = true;
-//							}
-//						}
-//					}
-//
-//					// Load the properties
-//					if (loadAsXml)
-//					{
-//						properties.loadFromXML(in);
-//					}
-//					else
+					boolean loadAsXml = false;
+					if (resourceStream instanceof IFixedLocationResourceStream)
+					{
+						String location = ((IFixedLocationResourceStream)resourceStream)
+								.locationAsString();
+						if (location != null)
+						{
+							String ext = Strings.lastPathComponent(location, '.').toLowerCase();
+							if ("xml".equals(ext))
+							{
+								loadAsXml = true;
+							}
+						}
+					}
+
+					// Load the properties
+					java.util.Properties properties = new java.util.Properties();
+					if (loadAsXml)
+					{
+						Streams.loadFromXml(properties, in);
+					}
+					else
 					{
 						properties.load(in);
 					}
@@ -273,7 +275,7 @@
 							+ "from the cache. Resource: " + resourceStream);
 
 					// Clear the whole cache as associated localized files may
-					// be affected and may need reloading as well. 
+					// be affected and may need reloading as well.
 					clearCache();
 
 					// Inform all listeners

Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java?view=diff&rev=529682&r1=529681&r2=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java Tue Apr 17 10:33:59 2007
@@ -22,6 +22,23 @@
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.Reader;
+import java.io.StringReader;
+import java.util.Properties;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.wicket.WicketRuntimeException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
 
 /**
  * Utilities methods for working with input and output streams.
@@ -30,6 +47,12 @@
  */
 public final class Streams
 {
+	private static final String XML_PROPERTIES_DTD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+			+ "<!-- DTD for properties -->" + "<!ELEMENT properties ( comment?, entry* ) >"
+			+ "<!ATTLIST properties" + " version CDATA #FIXED \"1.0\">"
+			+ "<!ELEMENT comment (#PCDATA) >" + "<!ELEMENT entry (#PCDATA) >" + "<!ATTLIST entry "
+			+ " key CDATA #REQUIRED>";
+
 	/**
 	 * Writes the input stream to the output stream. Input is done without a
 	 * Reader object, meaning that the input is copied in its raw form.
@@ -56,6 +79,100 @@
 			bytesCopied += byteCount;
 		}
 		return bytesCopied;
+	}
+
+	/**
+	 * Loads properties from an XML input stream into the provided properties
+	 * object.
+	 * 
+	 * @param properties
+	 *            The object to load the properties into
+	 * @param inputStream
+	 * @throws IOException
+	 *             When the input stream could not be read from
+	 */
+	public static void loadFromXml(Properties properties, InputStream inputStream)
+			throws IOException
+	{
+		if (properties == null)
+		{
+			throw new IllegalArgumentException("properties must not be null");
+		}
+		if (inputStream == null)
+		{
+			throw new IllegalArgumentException("inputStream must not be null");
+		}
+
+		// TODO in a Wicket version that supports Java 5 (Wicket 2.0?), we can
+		// just use the loadFromXml method on java.util.Properties directly
+		// rather than manual as we do here
+
+		DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+		documentBuilderFactory.setIgnoringElementContentWhitespace(true);
+		documentBuilderFactory.setValidating(true);
+		documentBuilderFactory.setCoalescing(true);
+		documentBuilderFactory.setIgnoringComments(true);
+		try
+		{
+			DocumentBuilder db = documentBuilderFactory.newDocumentBuilder();
+			db.setEntityResolver(new EntityResolver()
+			{
+				public InputSource resolveEntity(String publicId, String systemId)
+						throws SAXException
+				{
+					if (systemId.equals("http://java.sun.com/dtd/properties.dtd"))
+					{
+						InputSource inputSource;
+						inputSource = new InputSource(new StringReader(XML_PROPERTIES_DTD));
+						inputSource.setSystemId("http://java.sun.com/dtd/properties.dtd");
+						return inputSource;
+					}
+					else
+					{
+						throw new SAXException("Invalid system identifier: " + systemId);
+					}
+				}
+			});
+			db.setErrorHandler(new ErrorHandler()
+			{
+				public void error(SAXParseException e) throws SAXException
+				{
+					throw e;
+				}
+
+				public void fatalError(SAXParseException e) throws SAXException
+				{
+					throw e;
+				}
+
+				public void warning(SAXParseException e) throws SAXException
+				{
+					throw e;
+				}
+			});
+			InputSource is = new InputSource(inputStream);
+			Document doc = db.parse(is);
+			NodeList entries = ((Element)doc.getChildNodes().item(1)).getChildNodes();
+			int len = entries.getLength();
+			for (int i = (len > 0 && entries.item(0).getNodeName().equals("comment")) ? 1 : 0; i < len; i++)
+			{
+				Element entry = (Element)entries.item(i);
+				if (entry.hasAttribute("key"))
+				{
+					Node node = entry.getFirstChild();
+					String val = (node == null) ? "" : node.getNodeValue();
+					properties.setProperty(entry.getAttribute("key"), val);
+				}
+			}
+		}
+		catch (ParserConfigurationException e)
+		{
+			throw new WicketRuntimeException(e);
+		}
+		catch (SAXException e)
+		{
+			throw new WicketRuntimeException("invalid XML properties format", e);
+		}
 	}
 
 	/**

Modified: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java?view=diff&rev=529682&r1=529681&r2=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput.java Tue Apr 17 10:33:59 2007
@@ -292,7 +292,9 @@
 
 	/** Relevant locales wrapped in a list. */
 	private static final List LOCALES = Arrays.asList(new Locale[] { Locale.ENGLISH,
-			new Locale("nl"), Locale.GERMAN, new Locale("pt", "BR"), new Locale("da", "DK") });
+			new Locale("nl"), Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE,
+			new Locale("pt", "BR"), new Locale("fa", "IR"), new Locale("da", "DK"),
+			new Locale("th", "TH"), new Locale("ru") });
 
 	/** available sites for the multiple select. */
 	private static final List SITES = Arrays.asList(new String[] { "The Server Side", "Java Lobby",

Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_da_DK.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+	<entry key="inputForm.urlProperty.TypeValidator">'${input}' er ikke en gyldig URL adresse</entry>
+	<entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' er ikke et gyldigt US telefonnummer</entry>
+	<entry key="use.locale">Brug locale:</entry>
+	<entry key="default">default</entry>
+	<entry key="input">Indtastningsform</entry>
+	<entry key="string">Tekststreng</entry>
+	<entry key="integer">Heltal</entry>
+	<entry key="double">Kommatal</entry>
+	<entry key="date">Dato</entry>
+	<entry key="boolean">Boolean</entry>
+	<entry key="value.between.0.and.100">Værdi mellem 0 og 100</entry>
+	<entry key="valid.url">URL adresse (skal være en gyldig URL)</entry>
+	<entry key="us.phone.number.mask">US telefonnummer (format: '(###) ###-####')</entry>
+	<entry key="select.a.number">Vælg et nummer</entry>
+	<entry key="select.one.or.more.numbers">Vælg et eller flere numre</entry>
+	<entry key="your.favorite.sites">Dine favorit sider</entry>
+	<entry key="save">Gem</entry>
+	<entry key="reset">Nulstil</entry>
+</properties>
\ No newline at end of file

Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_de.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+	<entry key="inputForm.urlProperty.TypeValidator">'${input}' ist keine gültige URL</entry>
+	<entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' nicht ist keine gültige US Telefonnummerุ</entry>
+	<entry key="use.locale">Locale:</entry>
+	<entry key="default">standard</entry>
+	<entry key="input">input</entry>
+	<entry key="string">String</entry>
+	<entry key="integer">Integer</entry>
+	<entry key="double">Double</entry>
+	<entry key="date">Datum</entry>
+	<entry key="boolean">Boolean</entry>
+	<entry key="value.between.0.and.100">Nur Werte zwischen 0 und 100 sind erlaubt</entry>
+	<entry key="valid.url">URL (muss eine gültige URL sein)</entry>
+	<entry key="us.phone.number.mask">Amerikanische Telefonnummer (mask: '(###) ###-####')</entry>
+	<entry key="select.a.number">Bitte eine Zahl auswählen</entry>
+	<entry key="select.one.or.more.numbers">Bitte eins oder mehr auswählen</entry>
+	<entry key="your.favorite.sites">Deine bevorzugten Seiten</entry>
+	<entry key="save">Sichern</entry>
+	<entry key="reset">Zurücksetzen</entry>
+</properties>
\ No newline at end of file

Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_fa_IR.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_fa_IR.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_fa_IR.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_fa_IR.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+	<entry key="inputForm.urlProperty.TypeValidator">'${input}' یک آدرس معتبر نمی باشد</entry>
+	<entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' یک شماره معتبر در ایالات متحده نمی باشุ</entry>
+	<entry key="use.locale">استفاده از محلی سازی:</entry>
+	<entry key="default">standard</entry>
+				<entry key="input">فرم ورودی</entry>
+				<entry key="string">رشته</entry>
+				<entry key="integer">عدد صحیح</entry>
+				<entry key="double">اعشاری بزرگ</entry>
+				<entry key="date">تاریخ</entry>
+				<entry key="boolean">متغیر بولی</entry>
+				<entry key="value.between.0.and.100">عدد بین 0 تا 100</entry>
+				<entry key="valid.url">آدرس (باید یک آدرس معتبر باشد)</entry>
+				<entry key="us.phone.number.mask">شماره تلفن ایالات متحده (ماسک: '(###) ###-####')</entry>
+				<entry key="select.a.number">یک شماره انتخاب کنید</entry>
+				<entry key="select.one.or.more.numbers">یک یا چند شماره انتخاب کنید (انتخاب گروهی)</entry>
+				<entry key="your.favorite.sites">سایت های محبوب شما</entry>
+				<entry key="save">ذخيره</entry>
+				<entry key="reset">بازنشاني</entry>
+</properties>
\ No newline at end of file

Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ja.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ja.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ja.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ja.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+	<entry key="inputForm.urlProperty.TypeValidator">'${input}' は正しいURLではありません。</entry>
+	<entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' は正しい電話番号ではありません。ุ</entry>
+	<entry key="use.locale">使用するロケール:</entry>
+	<entry key="default">standard</entry>
+	<entry key="input">input</entry>
+	<entry key="string">String</entry>
+	<entry key="integer">Integer</entry>
+	<entry key="double">Double</entry>
+	<entry key="date">Datum</entry>
+	<entry key="boolean">Boolean</entry>
+	<entry key="value.between.0.and.100">0から100の値</entry>
+	<entry key="valid.url">URL (有効なURLを入力してください)</entry>
+	<entry key="us.phone.number.mask">電話番号 (形式: '(###) ###-####')</entry>
+	<entry key="select.a.number">番号を選択してください</entry>
+	<entry key="select.one.or.more.numbers">1つ以上の番号を選択してください</entry>
+	<entry key="your.favorite.sites">お気に入り</entry>
+	<entry key="save">保存</entry>
+	<entry key="reset">リセット</entry>
+</properties>
\ No newline at end of file

Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_pt_BR.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+	<entry key="inputForm.urlProperty.TypeValidator">'${input}' não é uma URL válida</entry>
+	<entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' não é um telefone válido</entry>
+	<entry key="use.locale">Usar localização:</entry>
+	<entry key="default">padrão</entry>
+	<entry key="input">Formulário</entry>
+	<entry key="string">Texto</entry>
+	<entry key="integer">Inteiro</entry>
+	<entry key="double">Double</entry>
+	<entry key="date">Data</entry>
+	<entry key="boolean">Booleano</entry>
+	<entry key="value.between.0.and.100">Valor entre 0 e 100</entry>
+	<entry key="valid.url">URL (deve ser uma url válida)</entry>
+	<entry key="us.phone.number.mask">Número Telefônico EUA (máscara: '(###) ###-####')</entry>
+	<entry key="select.a.number">Selecione um número</entry>
+	<entry key="select.one.or.more.numbers">Selecione hum ou mais números</entry>
+	<entry key="your.favorite.sites">Seus sites favoritos</entry>
+	<entry key="save">Save</entry>
+	<entry key="reset">Reset</entry>
+</properties>
\ No newline at end of file

Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ru.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ru.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ru.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_ru.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+	<entry key="inputForm.urlProperty.TypeValidator">'${input}' не является корректным URL</entry>
+	<entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' не является корректным телефонным номером США</entry>
+	<entry key="use.locale">Локаль:</entry>
+	<entry key="default">по-умолчанию</entry>
+	<entry key="input">Ввод</entry>
+	<entry key="string">String</entry>
+	<entry key="integer">Integer</entry>
+	<entry key="double">Double</entry>
+	<entry key="date">Дата</entry>
+	<entry key="boolean">Boolean</entry>
+	<entry key="value.between.0.and.100">Число между 0 и 100</entry>
+	<entry key="valid.url">URL (должен быть корректным URL)</entry>
+	<entry key="us.phone.number.mask">Телефонный номер США (маска: '(###) ###-####')</entry>
+	<entry key="select.a.number">Выберите число</entry>
+	<entry key="select.one.or.more.numbers">Выберите одно или несколько чисел</entry>
+	<entry key="your.favorite.sites">Любимые сайты</entry>
+	<entry key="save">Сохранить</entry>
+	<entry key="reset">Сброс</entry>
+</properties>
\ No newline at end of file

Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_th_TH.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_th_TH.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_th_TH.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_th_TH.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+	<entry key="inputForm.urlProperty.TypeValidator">'${input}' ไม่ใช URL ที่ใช้งานได้จริง</entry>
+	<entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' ไม่ใช่หมายเลขโทรศัพท์ที่ใช้งานได</entry>
+	<entry key="use.locale">เลือกใช้ภาษาหลัก:</entry>
+	<entry key="default">ค่ามาตรฐาน</entry>
+	<entry key="input">ข้อมูลนำเข้า</entry>
+	<entry key="string">ข้อมูลชนิดข้อความ</entry>
+	<entry key="integer">จำนวนเต็ม</entry>
+	<entry key="double">Double</entry>
+	<entry key="date">วันที</entry>
+	<entry key="boolean">Boolean</entry>
+	<entry key="value.between.0.and.100">ค่าระหว่าง 0 และ 100</entry>
+	<entry key="valid.url">URL (ต้องเป็น URL ที่ใช้งานได)</entry>
+	<entry key="us.phone.number.mask">หมายเลขโทรศัพท์ (รูปแบบ: '(###) ###-####')</entry>
+	<entry key="select.a.number">เลือกตัวเลขหนึ่งตัว</entry>
+	<entry key="select.one.or.more.numbers">เลือกตัวเลขหนึ่งตัวหรือมากกว่า</entry>
+	<entry key="your.favorite.sites">เวปไซด์ที่ชอบ</entry>
+	<entry key="save">บันทึก</entry>
+	<entry key="reset">ล้างข้อมูลเพื่อเริ่มใหม</entry>
+</properties>
\ No newline at end of file

Added: incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_zh_CN.xml
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_zh_CN.xml?view=auto&rev=529682
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_zh_CN.xml (added)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInput_zh_CN.xml Tue Apr 17 10:33:59 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+	<entry key="inputForm.urlProperty.TypeValidator">'${input}' 不是合法的URL</entry>
+	<entry key="inputForm.phoneNumberUS.TypeValidator">'${input}' 不是一个合法的美国电话号码ุ</entry>
+	<entry key="use.locale">使用地点:</entry>
+	<entry key="default">缺省</entry>
+	<entry key="input">输入</entry>
+	<entry key="string">字符串</entry>
+	<entry key="integer">整数</entry>
+	<entry key="double">数字</entry>
+	<entry key="date">日期</entry>
+	<entry key="boolean">布尔值</entry>
+	<entry key="value.between.0.and.100">在 0 和 100 之间的整数</entry>
+	<entry key="valid.url">URL (必须是合法的URL)</entry>
+	<entry key="us.phone.number.mask">美国电话号码 (格式: '(###) ###-####')</entry>
+	<entry key="select.a.number">选择一个数字</entry>
+	<entry key="select.one.or.more.numbers">选择一个或多个数字</entry>
+	<entry key="your.favorite.sites">您喜爱的网站</entry>
+	<entry key="save">保存</entry>
+	<entry key="reset">重置</entry>
+</properties>
\ No newline at end of file



Re: WICKET-477 (Was: svn commit: r529682 - in /incubator/wicket/branches/wicket-1.x: jdk-1.4/wicket/src/main/java/org/apache/wicket/ jdk-1.4/wicket/src/main/java/org/apache/wicket/resource/ jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/ jdk-1.5/wicket-examples/src...)

Posted by Jean-Baptiste Quenot <jb...@apache.org>.
* ehillenius@apache.org:
> Author: ehillenius
> Date: Tue Apr 17 10:33:59 2007
> New Revision: 529682
> 
> URL: http://svn.apache.org/viewvc?view=rev&rev=529682
> Log:
> WICKET-477
> 
> Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java
> URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java?view=diff&rev=529682&r1=529681&r2=529682
> ==============================================================================
> --- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java (original)
> +++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/util/io/Streams.java Tue Apr 17 10:33:59 2007
> @@ -22,6 +22,23 @@
>  import java.io.InputStreamReader;
>  import java.io.OutputStream;
>  import java.io.Reader;
> +import java.io.StringReader;
> +import java.util.Properties;
> +
> +import javax.xml.parsers.DocumentBuilder;
> +import javax.xml.parsers.DocumentBuilderFactory;
> +import javax.xml.parsers.ParserConfigurationException;
> +
> +import org.apache.wicket.WicketRuntimeException;
> +import org.w3c.dom.Document;
> +import org.w3c.dom.Element;
> +import org.w3c.dom.Node;
> +import org.w3c.dom.NodeList;
> +import org.xml.sax.EntityResolver;
> +import org.xml.sax.ErrorHandler;
> +import org.xml.sax.InputSource;
> +import org.xml.sax.SAXException;
> +import org.xml.sax.SAXParseException;
>  
>  /**
>   * Utilities methods for working with input and output streams.
> @@ -30,6 +47,12 @@
>   */
>  public final class Streams
>  {
> +	private static final String XML_PROPERTIES_DTD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
> +			+ "<!-- DTD for properties -->" + "<!ELEMENT properties ( comment?, entry* ) >"
> +			+ "<!ATTLIST properties" + " version CDATA #FIXED \"1.0\">"
> +			+ "<!ELEMENT comment (#PCDATA) >" + "<!ELEMENT entry (#PCDATA) >" + "<!ATTLIST entry "
> +			+ " key CDATA #REQUIRED>";
> +
>  	/**
>  	 * Writes the input stream to the output stream. Input is done without a
>  	 * Reader object, meaning that the input is copied in its raw form.
> @@ -56,6 +79,100 @@
>  			bytesCopied += byteCount;
>  		}
>  		return bytesCopied;
> +	}
> +
> +	/**
> +	 * Loads properties from an XML input stream into the provided properties
> +	 * object.
> +	 * 
> +	 * @param properties
> +	 *            The object to load the properties into
> +	 * @param inputStream
> +	 * @throws IOException
> +	 *             When the input stream could not be read from
> +	 */
> +	public static void loadFromXml(Properties properties, InputStream inputStream)
> +			throws IOException
> +	{
> +		if (properties == null)
> +		{
> +			throw new IllegalArgumentException("properties must not be null");
> +		}
> +		if (inputStream == null)
> +		{
> +			throw new IllegalArgumentException("inputStream must not be null");
> +		}
> +
> +		// TODO in a Wicket version that supports Java 5 (Wicket 2.0?), we can
> +		// just use the loadFromXml method on java.util.Properties directly
> +		// rather than manual as we do here
> +
> +		DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
> +		documentBuilderFactory.setIgnoringElementContentWhitespace(true);
> +		documentBuilderFactory.setValidating(true);
> +		documentBuilderFactory.setCoalescing(true);
> +		documentBuilderFactory.setIgnoringComments(true);
> +		try
> +		{
> +			DocumentBuilder db = documentBuilderFactory.newDocumentBuilder();
> +			db.setEntityResolver(new EntityResolver()
> +			{
> +				public InputSource resolveEntity(String publicId, String systemId)
> +						throws SAXException
> +				{
> +					if (systemId.equals("http://java.sun.com/dtd/properties.dtd"))
> +					{
> +						InputSource inputSource;
> +						inputSource = new InputSource(new StringReader(XML_PROPERTIES_DTD));
> +						inputSource.setSystemId("http://java.sun.com/dtd/properties.dtd");
> +						return inputSource;
> +					}
> +					else
> +					{
> +						throw new SAXException("Invalid system identifier: " + systemId);
> +					}
> +				}
> +			});
> +			db.setErrorHandler(new ErrorHandler()
> +			{
> +				public void error(SAXParseException e) throws SAXException
> +				{
> +					throw e;
> +				}
> +
> +				public void fatalError(SAXParseException e) throws SAXException
> +				{
> +					throw e;
> +				}
> +
> +				public void warning(SAXParseException e) throws SAXException
> +				{
> +					throw e;
> +				}
> +			});
> +			InputSource is = new InputSource(inputStream);
> +			Document doc = db.parse(is);
> +			NodeList entries = ((Element)doc.getChildNodes().item(1)).getChildNodes();
> +			int len = entries.getLength();
> +			for (int i = (len > 0 && entries.item(0).getNodeName().equals("comment")) ? 1 : 0; i < len; i++)
> +			{
> +				Element entry = (Element)entries.item(i);
> +				if (entry.hasAttribute("key"))
> +				{
> +					Node node = entry.getFirstChild();
> +					String val = (node == null) ? "" : node.getNodeValue();
> +					properties.setProperty(entry.getAttribute("key"), val);
> +				}
> +			}
> +		}
> +		catch (ParserConfigurationException e)
> +		{
> +			throw new WicketRuntimeException(e);
> +		}
> +		catch (SAXException e)
> +		{
> +			throw new WicketRuntimeException("invalid XML properties format", e);
> +		}
>  	}

Hi Eelco,

Indeed it would be good to use the native XML properties loading
on 1.5.  And on 1.4, do you think it's OK to use DOM?  We could as
well use our pseudo-Stax parser for maximal efficiency.
-- 
     Jean-Baptiste Quenot
aka  John Banana   Qwerty
http://caraldi.com/jbq/