|
Thank you all for the suggestions!
I actually figured out the solution. Not entirely sure whether it is
most elegant one at that, but it seems to be fulfilling the purpose. It
involves creating a function that will scan for the template based on
the locale and parameters. The code is included below. Would really
love to hear some feedback and improvements. But in the meantime, can
someone tell me how to put Chinese or Japanese or whathaveyou into the
JSP file? Encoding-wise, everything is ok; all translations from the
Stripes' resource bundles comes out perfect, but the characters are
garbage on the page even though I saved the JSP as UTF-8 encoding. Am I
missing something? Here's the function code: public static String pickJspPage(HttpServletRequest request, String template) { if (template == null || (template = template.trim()).length() == 0) return template; if (template.charAt(0) != '/') template = '/' + template; Locale locale = request.getLocale(); int pos = template.lastIndexOf('.'); String filename = template.substring(0, pos); String ext = template.substring(pos + 1, template.length()); // I do have more requirements than just a locale... // But the idea is to create a of desired target filenames here String[] filenames = { filename + "." + locale, filename }; String root = request.getSession().getServletContext().getRealPath(""); for (String name : filenames) { StringBuilder buf = new StringBuilder(root); buf.append(name); buf.append('.'); buf.append(ext); File file = new File(buf.toString()); if (!file.exists()) continue; return name + '.' + ext; } return template; } And then you can use the function as follows: <jsp:include page="${o:pickJspPage(pageContext.request, '/i18n_page.jsp')}" /> Daniil |
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________ Stripes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-users
