struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: struts help
Date Tue, 11 Jul 2000 16:16:41 GMT


Bauert Daniel wrote:

> Dear Sir or Madam
>
> I'm working with your struts framework and would like to do the following...
>
> <struts:link href="http://mylink/myHtmlPage.do?action=<struts:message
> key="MyKey" />" target="_top">
>

Unfortunately, this is not valid JSP syntax -- you cannot nest a JSP tag inside
another JSP tag.  If a tag allows runtime expressions, they have to be done with
scriptlets.

In my programs that do the kind of thing you are doing above, I tend to use the
canonical translation of the action ("Create" or "Edit" in the example
application, for instance), and translate it in the destination page or Action
class if I will need to display it to the user.  At the moment, if you really
want to do it as you are generating the link, you will need to use a scriptlet
-- something along these lines:

    <%
        MessageResources resources = (MessageResources)
          getServletContext().getAttribute("org.apache.struts.action.MESSAGE");
        String uri = "http://mylink/myHtmlPage.do?action=" +
          resources.getMessage("MyKey");
    %>

    <struts:link href="<%= uri %>" target="_top">...</struts:link>

>
> The error message is that MyKey has no value. Could you tell me what I must
> do to correct this error?
>
> Thanks four your help.
>
> Yours sincerely
>
> Daniel Bauert

Craig



Mime
View raw message