1 9 package org.openuss.presentation.enhydra.framework.multilanguage; 10 11 import com.lutris.appserver.server.httpPresentation.*; 12 13 import java.lang.reflect.*; 14 15 import java.util.*; 16 17 import org.enhydra.xml.xmlc.html.*; 18 19 20 26 public class PageTranslatorFactory { 27 private static String TRANSLATION_SUFFIX = "Translator"; 29 30 33 public static HTMLObjectImpl createAndTranslate(HttpPresentationComms comms, 34 Locale locale, 35 String fullClassName) 36 throws Exception { 37 String translationFullClassName = new String (fullClassName.concat( 43 TRANSLATION_SUFFIX)); 44 45 Class objectClass = Class.forName(translationFullClassName); 47 48 Class myHttpPresentationComms = Class.forName( 50 "com.lutris.appserver.server.httpPresentation.HttpPresentationComms"); 51 Class myLocale = Class.forName("java.util.Locale"); 52 Class [] parameterTypes = new Class [2]; 53 parameterTypes[0] = myHttpPresentationComms; 54 parameterTypes[1] = myLocale; 55 56 Constructor objectConstructor = objectClass.getConstructor( 57 parameterTypes); 58 59 Object [] initArgs = new Object [2]; 62 initArgs[0] = comms; 63 initArgs[1] = locale; 64 65 BasePageTranslator translator = (BasePageTranslator) objectConstructor.newInstance( 66 initArgs); 67 68 try { 69 translator.translatePage(); 70 } catch (Exception ex) { 71 System.out.println("Error on translating the page: " + 73 translator + " - " + ex); 74 } 75 76 return translator.getPage(); 77 } 78 } | Popular Tags |