You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Olivier Houyoux <oh...@netcourrier.com> on 2001/08/25 11:39:21 UTC
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)
Re: Javascript & bean message tag
Posted by ma...@tumbleweed.com.
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" <oh...@netcourrier.com>
To: <st...@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)