You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by to...@apache.org on 2005/01/07 12:05:38 UTC
cvs commit: ws-axis/java/webapps/axis happyaxis.jsp i18nLib.jsp index.jsp
toshi 2005/01/07 03:05:37
Modified: java/webapps/axis happyaxis.jsp i18nLib.jsp index.jsp
Log:
For i18n of Axis webapps.
Added some methods to enhance the reusability.
Revision Changes Path
1.20 +3 -0 ws-axis/java/webapps/axis/happyaxis.jsp
Index: happyaxis.jsp
===================================================================
RCS file: /home/cvs/ws-axis/java/webapps/axis/happyaxis.jsp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- happyaxis.jsp 6 Jan 2005 07:27:20 -0000 1.19
+++ happyaxis.jsp 7 Jan 2005 11:05:37 -0000 1.20
@@ -278,6 +278,9 @@
<%
// initialize a private HttpServletRequest
setRequest(request);
+
+ // set a resouce base
+ setResouceBase("i18n");
%>
<head>
1.2 +33 -6 ws-axis/java/webapps/axis/i18nLib.jsp
Index: i18nLib.jsp
===================================================================
RCS file: /home/cvs/ws-axis/java/webapps/axis/i18nLib.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- i18nLib.jsp 6 Jan 2005 07:27:20 -0000 1.1
+++ i18nLib.jsp 7 Jan 2005 11:05:37 -0000 1.2
@@ -1,4 +1,4 @@
-<%@ page contentType="text/html; charset=utf-8" import="java.util.*" %>
+<%@ page import="java.util.*" %>
<%
/*
* Copyright 2005 The Apache Software Foundation.
@@ -27,6 +27,9 @@
// private variable
HttpServletRequest _req = null;
+ // private variable
+ String _strResourceName = null;
+
/**
* Set a HttpServletRequest to a private variable.
* @param request HttpServletRequest
@@ -36,22 +39,46 @@
}
/**
+ * Get the private variable of the HttpServletRequest.
+ * @return HttpServletRequest
+ */
+ HttpServletRequest getRequest() {
+ return _req;
+ }
+
+ /**
+ * Set a resouce base name to a private variable.
+ * @param resouce The resouce base name
+ */
+ void setResouceBase(String resource) {
+ _strResourceName = resource;
+ }
+
+ /**
+ * Get the private variable of the resouce base name.
+ * @return resouce The resouce base name
+ */
+ String getResouceBase() {
+ return _strResourceName;
+ }
+
+ /**
* Get a ResourceBundle object.
* @return a ResourceBundle object
*/
ResourceBundle getRB() {
- String strLocale = _req.getParameter("locale");
+ String strLocale = getRequest().getParameter("locale");
ResourceBundle objRb = null;
Locale objLcl = null;
if (strLocale!=null) {
objLcl=new Locale(strLocale,"");
} else {
- objLcl=_req.getLocale();
+ objLcl=getRequest().getLocale();
}
Locale.setDefault(objLcl);
- objRb = ResourceBundle.getBundle("i18n",objLcl);
+ objRb = ResourceBundle.getBundle(getResouceBase(),objLcl);
return objRb;
}
@@ -61,11 +88,11 @@
* @return a list of supported locales
*/
String getLocaleChoice() {
- String choice = getRB().getString("locales");
+ String choice = getMessage("locales");
StringBuffer buf = new StringBuffer();
buf.append("<div align=\"right\">\n");
- buf.append(getRB().getString("language"));
+ buf.append(getMessage("language"));
buf.append(": ");
StringTokenizer st = new StringTokenizer(choice);
1.2 +3 -0 ws-axis/java/webapps/axis/index.jsp
Index: index.jsp
===================================================================
RCS file: /home/cvs/ws-axis/java/webapps/axis/index.jsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- index.jsp 6 Jan 2005 07:27:20 -0000 1.1
+++ index.jsp 7 Jan 2005 11:05:37 -0000 1.2
@@ -23,6 +23,9 @@
<%
// initialize a private HttpServletRequest
setRequest(request);
+
+ // set a resouce base
+ setResouceBase("i18n");
%>
<head>