struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martin.coo...@tumbleweed.com
Subject Re: Javascript & bean message tag
Date Sat, 25 Aug 2001 20:42:14 GMT
Remember that JSP is executed on the server, when the page is being
generated, but JavaScript is executed within the browser. The <bean:message>
tag will be evaluated before the page is sent to the browser, so you can't
pass a browser-side variable to it.

What is it that you are trying to do? Perhaps we can help you find an
alternative approach.

--
Martin Cooper


----- Original Message -----
From: "Olivier Houyoux" <ohouyoux@netcourrier.com>
To: <struts-user@jakarta.apache.org>
Sent: Saturday, August 25, 2001 2:39 AM
Subject: Javascript & bean message tag


Hi all,

To summarize my problem, I try to retrieve an internationalized message with
the bean:message tag, from a Javascript function.
The attribute key of the message tag must be a function parameter (e.g. the
simple example below).

But I always got an exception telling me that the key attribute of the
message tag must be quoted.
Of course, if i use quote in the JavaScript function (return <bean:message
key='id' />) I got another exception telling me that the message for key id
is missing.

Is there finally a way to use the message tag the way I want ?

Thanks a lot.


Simple example :

<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>

<html>
    <head>
        <title><bean:message key="title.index" /></title>
        <script language="JavaScript">
            function getMessage(id) {
                return <bean:message key=id />
            }
        </script>
    </head>
    <body>
        <script language="JavaScript">getMessage('a.message.key')</script>
    </body>
</html>

------------------------------------------------------------
NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs,
Toolbar...
Une gamme d'outils gratuits et performants à votre service.
Web/Wap : www.netcourrier.com
Téléphone/Fax : 08 92 69 00 21 (0,34 E TTC/min - 2,21 F TTC/min)
Minitel: 3615 NETCOURRIER (0,15 E TTC/min - 1,00 F TTC/min)





Mime
View raw message