You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jan Vervecken <Ja...@vlaamsparlement.be> on 2002/07/05 11:41:19 UTC

messages with parametric replacements and avoiding scriptlets

hi

Is there a way to avoid using scriptlets in a JSP an achieving the following:

I would like to use Struts tags to display a message with parametric replacements,
using a bean property to complete the message.

Can I do this without even one scriptlet on the page?

tnx
-Jan


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


Re: messages with parametric replacements and avoiding scriptlets

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 5 Jul 2002, Jan Vervecken wrote:

> Date: Fri, 05 Jul 2002 11:41:19 +0200
> From: Jan Vervecken <Ja...@vlaamsparlement.be>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: struts-user@jakarta.apache.org
> Subject: messages with parametric replacements and avoiding scriptlets
>
> hi
>
> Is there a way to avoid using scriptlets in a JSP an achieving the following:
>
> I would like to use Struts tags to display a message with parametric
> replacements, using a bean property to complete the message.
>
> Can I do this without even one scriptlet on the page?
>

Although runtime expressions are technically scriptlets, I don't really
see a problem with saying something like:

  <bean:message key="foo" arg0="<%= customer.getAddress().getCity() %>"/>

where "customer" is a bean you declared with a <jsp:useBean>.  You could
also be a little more verbose and say:

  <bean:message key="foo"
   arg0="<%= request.getAttribute("customer").getAddress().getCity() %>"/>

Once we all get to JSP 2.0, you'll be able to use the expression language
syntax for things like this:

  <bean:message key="foo" arg0="${requestScope.customer.address.city"/>

because expressions will be supported everywhere.  In the mean time, they
are available in JSTL tags (and I'd like to assist migration for Struts
users by supporting them in some Struts tags as well, but that's for a
version after 1.1).

> tnx
> -Jan

Craig


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