Class I18NAction

java.lang.Object
com.zfabrik.util.microweb.actions.I18NAction
All Implemented Interfaces:
IAction

public class I18NAction extends Object implements IAction
  • Constructor Details

    • I18NAction

      public I18NAction(String baseName)
      Creates an I18N Action for the bundle defined by the given baseName The handle(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 (see ServletRequest.getLocale()).
      Parameters:
      baseName - the full-qualified name of the Resource-Bundle - see ResourceBundle.getBundle(String)
    • I18NAction

      public I18NAction(String baseName, String objName)
      Creates an I18N Action for the bundle defined by the given baseName The handle(ServletContext, HttpServletRequest, HttpServletResponse) method will create a JavaScript include which defines one object with the given objName. 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 IOException
      Computes 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 use application)
      request - the request object (in JSPs just use request)
      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 IOException
      same as cacheMarker(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 interface IAction
      Throws:
      javax.servlet.ServletException
      IOException