Hello,
 
    I am trying to use Tiles with multi language support and my approach does not seem to work like I expected.
We have two tiles_defs.xml files: tiles_defs.xml and tiles_defs_en.xml. According to the docs, in order to have
tiles switch from one file to the other we must set the following key and Locale in the http session: "org.apache.struts.action.LOCALE".
 
The problem stems from the fact that Faces uses the "public Locale calculateLocale(FacesContext facesContext)"  method in order
to determine the Locale, and not the key needed by Tiles (described above). In order to map the two together, I have created my own
CustomViewHandler which extends "JspTilesViewHandlerImpl" and overrides the "calculateLocale(...)" method in order to use the
key needed by Tiles. calculateLocale() now returns the locale held in the session under "org.apache.struts.action.LOCALE".
 
Everything compiles, my server (IBM Rational Software Development Platform ... ie: WSAD 6.x) starts without a hitch, the log
shows no errors but I get a 404 when I request ANY jsp from the application...and there is absolutely no trace of an error in the console,
nor anywhere else.
 
A few questions:
    1) Is our approach sound ?
    2) Is my decorated CustomViewHandler ok (please see below) ?
    3) Any other approaches we can take ?
 
Thanks in advance !
 
Mark
 
 
 
 
**************************************************************************************************************
 
public class CustomViewHandler extends JspTilesViewHandlerImpl
{
 ViewHandler _base; 
 
 public CustomViewHandler(ViewHandler base)
 {
  super(base);  
  _base = base;
 }
 

 public Locale calculateLocale(FacesContext facesContext)
 { 
  Locale locale = code which gets it from the session under "org.apache.struts.action.LOCALE"
  
  if ( locale != null )
  {
   return locale;
  }
  else
  {
   return _base.calculateLocale(facesContext);
  }
 }
 
 
 public String calculateRenderKitId(FacesContext facesContext)
 { 
  return _base.calculateRenderKitId(facesContext);
 }
 
 public UIViewRoot createView(FacesContext facesContext, String viewName)
 {   
  return _base.createView(facesContext, viewName);
 }
 
 public String getActionURL(FacesContext facesContext, String s)
 {  
  return _base.getActionURL(facesContext, s); 
  
 }
 
 public String getResourceURL(FacesContext facesContext, String s)
 {
  return _base.getResourceURL(facesContext, s);  
 }
 
 public void renderView(FacesContext facesContext, UIViewRoot uiViewRoot) throws IOException, FacesException
 { 
  _base.renderView(facesContext, uiViewRoot);
 }
 
 public UIViewRoot restoreView(FacesContext facesContext, String viewName)
 { 
  return _base.restoreView(facesContext, viewName);
 }
 
 public void writeState(FacesContext facesContext) throws IOException
 {
  _base.writeState(facesContext);
 } 
}

Reply via email to