velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nat...@esha.com>
Subject Re: Another problem with multiple application resources
Date Wed, 07 Jan 2004 23:07:08 GMT
Iván Escobedo said:
> Nathan, tell me something, am I missing something?

first, i'm not the only person on this list, you don't need to address
questions personally to me. :)

second, have you tried taking Marino's advice?  he's much more experienced
with modules and alternate resource bundles than i am.

> I tried these and none of them worked out
>
> $errors.get($null, "adminResources")
...
> $errors.get("org.apache.struts.action.GLOBAL_ERROR", "adminResources")

if these don't work, than my guess is that the resources can't be found.  what
happens in your logs when this method is called?  if the resources can't be
found, there should be a warning about that in the logs.

> I tried these and look at the results
>
> $errors.getMsgs($null, "adminResources") --> "The is required"
>
> There's nothing between "The" and "is" and there should be the
>  "user.email.displayName" key, translated to the word "email" which
> is in AppliationReources-admin.xml

huh?  i think i don't understand what you're asking here, but it sounds like
you expect Struts to lookup your replacement parameter in the resources and
replace that before putting it into the error message.  AFAIK, Struts doesn't
do that.

if your error message in "adminResources" is:

error.required=This {0} is required.

and in your Action you do:

    ActionErrors errors = new ActionErrors();
    ActionError e = new ActionError("error.required",
"user.email.displayName")
    errors.add(ActionErrors.GLOBAL_ERROR, e);
    saveErrors(request, errors);

and in your template you do:

    #set( $property = "org.apache.struts.action.GLOBAL_ERROR" )
    #foreach($e in $errors.get($property, "adminResources") )
      $e <br>
    #end

then if your current module contains a resource bundle with the key
"adminResources", the result you should get is:

    This user.email.displayName is required.

but, if you take Marino's advice and simply specify a different default
resource bundle (i.e. with no key="foo" property in the config xml) for each
module, you should be able to simplify the template back down to

    #foreach( $e in $errors.all )
        $e <br>
    #end

> And I still don't get why the get method of $errors doesn't show anything.

neither do i.  it's worked when i've tried it. :-/

by the way, you might have better luck finding help with this question in the
struts documentation or on the struts-user list.  it sounds like your problem
is with configuring and using Struts with modules than it is with using the
ErrorsTool.

Nathan Bubna
nathan@esha.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message