Class I18NAction
java.lang.Object
com.zfabrik.util.microweb.actions.I18NAction
- All Implemented Interfaces:
IAction
-
Constructor Summary
ConstructorDescriptionI18NAction(String baseName)
Creates an I18N Action for the bundle defined by the givenbaseName
Thehandle(ServletContext, HttpServletRequest, HttpServletResponse)
method will create a JavaScript include which defines one object with name 'i18n'.I18NAction(String baseName, String objName)
Creates an I18N Action for the bundle defined by the givenbaseName
Thehandle(ServletContext, HttpServletRequest, HttpServletResponse)
method will create a JavaScript include which defines one object with the givenobjName.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
cacheMarker(javax.servlet.ServletContext ctx, Locale locale)
same ascacheMarker(ServletContext, HttpServletRequest)
but the locale can be set explicitlystatic String
cacheMarker(javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest request)
Computes a marker string out of the current locale and the revision of this web-app.handle(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
-
Constructor Details
-
I18NAction
Creates an I18N Action for the bundle defined by the givenbaseName
Thehandle(ServletContext, HttpServletRequest, HttpServletResponse)
method will create a JavaScript include which defines one object with name 'i18n'. This object contains the resource bundle name-value pairs for the current locale (seeServletRequest.getLocale()
).- Parameters:
baseName
- the full-qualified name of the Resource-Bundle - seeResourceBundle.getBundle(String)
-
I18NAction
Creates an I18N Action for the bundle defined by the givenbaseName
Thehandle(ServletContext, HttpServletRequest, HttpServletResponse)
method will create a JavaScript include which defines one object with the givenobjName. This object contains the resource bundle name-value pairs for the current locale (see
ServletRequest.getLocale()
).- Parameters:
baseName
-objName
-
-
-
Method Details
-
cacheMarker
public static String cacheMarker(javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest request) throws IOExceptionComputes a marker string out of the current locale and the revision of this web-app. This string can be used as cache key in the query string of i18n JavaScript URLs. Once the browser loads the i18n JS include it is stored in the browser cache as long as this method returns the same marker string. If the locale changes or the web-app is updated the string will change forcing the browser to reload the i18n JavaScript include the next time the web-app is requested.- Parameters:
ctx
- the servlet context (in JSPs just useapplication
)request
- the request object (in JSPs just userequest
)- Returns:
- String which should be used as query string for i18n-URLs
- Throws:
IOException
-
cacheMarker
public static String cacheMarker(javax.servlet.ServletContext ctx, Locale locale) throws IOExceptionsame ascacheMarker(ServletContext, HttpServletRequest)
but the locale can be set explicitly- Throws:
IOException
-
handle
public OutCome handle(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException- Specified by:
handle
in interfaceIAction
- Throws:
javax.servlet.ServletException
IOException
-