You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Cedric Dumoulin <ce...@lifl.fr> on 2002/06/12 18:18:36 UTC

Re: Tiles and session bean org.apache.struts.action.LOCALE strange !

  Hello,

  Let follow your page and tiles are processed :

   * You browse your page url /test.jsp
   * The page is processed
        o The insert tag is encountered, its attributes are processed
             + the <bean:message key=...> tag is processed
             + the logic tag is processed
        o The insert tag insert requested layout
             + the layout tags are processed, so the <html:html locale="true">

   So, the local is set into session only after you check it ! It is why you have
such behavior.

  Usually, you pass the key to your inserted tiles, and only in the inserted tiles
you retrieve the value for the key.

    Hope this help,
      Cedric

kristof.pelckmans@b-rail.be wrote:

> Hi all,
>
> I have troubles accessing the org.apache.struts.action.LOCALE session bean
> using tiles. I wrote a simple example to reproduce my problem :
>
> My template (/templates/test_templates.jsp) is :
>
> <%@ page language='java' %>
> <%@ taglib uri="/WEB-INF/tiles.tld" prefix="template" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
>
> <html:html locale="true">
> <head></head>
> <body>
> <template:get name='title'/>
> </body>
> </html:html>
>
> Important to notice is that the attribute locale="true" at <html:hml...> forces
> the creation of a locale in the user's session (if one was not present).
>
> Now my jsp page (/test.jsp) will try to see if the locale bean is present and
> also use the locale bean by calling <bean:message...> which will use the locale
> to get the right resource bundle :
> <%@ page language='java' %>
> <%@ taglib uri="/WEB-INF/tiles.tld" prefix="template" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
> <template:insert template='/templates/test_template.jsp'>
>   <template:put name='title' type='string'><bean:message key="index.title"/>
>        <logic:notPresent name="org.apache.struts.action.LOCALE" scope="session">
>               No locale !!!
>        </logic:notPresent>
>   </template:put>
> </template:insert>
>
> Third essential type of files are the resource bundles : I have three different
> ones, each with there own index.title=... line.
>
> When I run all this, my application gives me that there is no locale present,
> BUT it does provide me with a string for index.title (not the right one - see
> below).
>
> When I run the example without tiles (simply do tiles' job manually) :
> <%@ page language='java' %>
> <%@ taglib uri="/WEB-INF/tiles.tld" prefix="template" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
>
> <html:html locale="true">
> <head></head>
> <body>
> <bean:message key="index.title"/>
> <logic:notPresent name="org.apache.struts.action.LOCALE" scope="session">
>   No locale !!!
> </logic:notPresent>
> </body>
> </html:html>
>
> I don't get the error message that there is no locale AND I get a different
> string for index.title than I got with Tiles (this is the default language one
> I expected)
>
> I suppose Tiles doesn't get the right session bean... Can anyone explain this
> strange behavior ?
>
> Thanks !
>
> Kristof Pelckmans
> Consultant Unisys
> Hallepoortlaan 41-58 - 1060 Brussel
> IT 219 Sectie 13/4
> Bureau 4de verdieping - B022
> E-Mail NMBS : kristof.pelckmans@b-rail.be
> E-Mail UNISYS :      kristof.pelckmans@be.unisys.com
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>