You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Iván Escobedo <ie...@nacion.co.cr> on 2004/01/07 19:26:53 UTC

Another problem with multiple application resources

Guys, now I have another problem, the ErrorTool is not working

 

Background

      I'm using velocitytools 1.1 beta

      Struts 1.1

      A default module and another module called admin

 

      In Struts-Config.xml I have:

            <!-- ================================ Message Resources Definitions -->

            <message-resources key="defaultResources" parameter="ApplicationResources"/>

 

      In Struts-Config-admin.xml I have:

            <!-- ================================ Message Resources Definitions -->

            <message-resources key="adminResources" parameter="ApplicationResources-admin"/>

 

Problem

     I'm working on admin module and I have a vm file, the look up for the messages is working ok, like this

    

         $msg.get("users.state.displayName", "adminResources")

 

    but this one is not working

 

         #if ($errors.exist())
             $msg.get("errors.header")
             #foreach ($e in $errors.all )
                $msg.get("errors.prefix) $e $msg.get("errors.suffix")
             #end
             $msg.get("errors.footer")
       #end


    I changed the $msg and put the "adminResources" and it works fine, but the #foreach function is not displying anything, it's like $errors is not using the ApplicationResources-admin

 

How does the ErrorTool know which applicationresources to use?  This worked fine in velocity tools 1.0 and now this is the only and the last problem i have with modules-struts-velocity

 

Thank you


Re: Another problem with multiple application resources

Posted by "Marino A. Jonsson" <ma...@hotmail.com>.
I have to add ... since you are only using a single bundle in each module
you shouldn't have to specify bundle names at all!

In Struts-Config.xml:

            <!-- ================================ Message Resources
Definitions -->

            <message-resources parameter="ApplicationResources"/>



      In Struts-Config-admin.xml :

            <!-- ================================ Message Resources
Definitions -->

            <message-resources parameter="ApplicationResources-admin"/>


You only need to use bundle names (keys) if you use more than one bundle for
a single module.
This way you only need $msg.get("users.state.displayName") and the foreach
loop should also work :)

cheers,
Marin�


"Nathan Bubna" <na...@esha.com> wrote in message
news:010d01c3d550$883e7380$667ba8c0@zeus.esha.com...
> Iv�n Escobedo said:
> ...
> >       I'm using velocitytools 1.1 beta
> >
> >       Struts 1.1
> >
> >       A default module and another module called admin
> ...
> >      I'm working on admin module and I have a vm file, the look up
> > for the messages is working ok, like this
> >
> >          $msg.get("users.state.displayName", "adminResources")
> >
> >     but this one is not working
> >
> >          #if ($errors.exist())
> >              $msg.get("errors.header")
> >              #foreach ($e in $errors.all )
> >                 $msg.get("errors.prefix) $e $msg.get("errors.suffix")
> >              #end
> >              $msg.get("errors.footer")
> >        #end
> >
> >     I changed the $msg and put the "adminResources" and it works fine,
> > but the #foreach function is not displying anything, it's like $errors
is
> > not using the ApplicationResources-admin
>
> you're right, it's not.
>
> > How does the ErrorTool know which applicationresources to use?
> > This worked fine in velocity tools 1.0 and now this is the only and
> > the last problem i have with modules-struts-velocity
>
> just like the MessageTool, you have to tell it which resource bundle to
use.
> the getAll() method ($errors.all) doesn't specify a bundle.
>
> try doing  #foreach( $e in $errors.get($null, "adminResources") )
>
> also, i'm going to add a getAll(String bundle) method for the next
release.
> i'll check the change in today, so you can use it if you don't mind
building
> VelocityTools from CVS on your own.
>
> 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


Re: Another problem with multiple application resources

Posted by Nathan Bubna <na...@esha.com>.
Iván Escobedo said:
...
>       I'm using velocitytools 1.1 beta
>
>       Struts 1.1
>
>       A default module and another module called admin
...
>      I'm working on admin module and I have a vm file, the look up
> for the messages is working ok, like this
>
>          $msg.get("users.state.displayName", "adminResources")
>
>     but this one is not working
>
>          #if ($errors.exist())
>              $msg.get("errors.header")
>              #foreach ($e in $errors.all )
>                 $msg.get("errors.prefix) $e $msg.get("errors.suffix")
>              #end
>              $msg.get("errors.footer")
>        #end
>
>     I changed the $msg and put the "adminResources" and it works fine,
> but the #foreach function is not displying anything, it's like $errors is
> not using the ApplicationResources-admin

you're right, it's not.

> How does the ErrorTool know which applicationresources to use?
> This worked fine in velocity tools 1.0 and now this is the only and
> the last problem i have with modules-struts-velocity

just like the MessageTool, you have to tell it which resource bundle to use.
the getAll() method ($errors.all) doesn't specify a bundle.

try doing  #foreach( $e in $errors.get($null, "adminResources") )

also, i'm going to add a getAll(String bundle) method for the next release.
i'll check the change in today, so you can use it if you don't mind building
VelocityTools from CVS on your own.

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