uiLabelMap access from a service?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

uiLabelMap access from a service?

Peter Felts
Does anyone know if there is a way to access a uiLabelMap (the list of local text strings, etc. associated with a language in an application /Module/config/<your language here>.properties) from within a service that only has access to the DispatchContext and the Map  objects?

What I am trying to do is return errors from a service containing localized strings. Any ideas?


Thank you.




Reply | Threaded
Open this post in threaded view
|

Re: uiLabelMap access from a service?

Scott Gray
Hi Peter

You're not looking hard enough :-) there are a million examples of this.

This example is from the first java file I opened (AgreementServices.java):
            errMsg = UtilProperties.getMessage(resource,
"AccountingDataSourceError", messageMap, locale);
            return ServiceUtil.returnError(errMsg);

Regards
Scott

On 20/03/2008, Peter Felts <[hidden email]> wrote:

>
> Does anyone know if there is a way to access a uiLabelMap (the list of
> local text strings, etc. associated with a language in an application
> /Module/config/<your language here>.properties) from within a service that
> only has access to the DispatchContext and the Map  objects?
>
> What I am trying to do is return errors from a service containing
> localized strings. Any ideas?
>
>
> Thank you.
>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: uiLabelMap access from a service?

Mridul Pathak-2
In reply to this post by Peter Felts
Peter,

Are you writing your service in Java or Minilang??

1) If you are writing the service in Java then you can use *
org.ofbiz.base.util.UtilProperties* class and its methods to access the
properties files.  If you specifically want to get a map of all the
properties in a field you can use *UtilProperties.getResourceBundleMap(String
resource, Locale locale)* method which will return all the properties from
the resource file in a Map.  There are other useful methods as well which
you can use according to your purpose.

2) If you are writing your service in minilang, than there are some special
tags availble which adds, checks and return errors in a service which also
uses localized strings from property files.  The below structure can be used
to return an error in a service containing a string from properties file:
*<add-error>
    <fail-property resource=" " property=" "/>
</add-error>
<check-errors/>
*
    There is another tag *<property-to-field>* which can be used to access
any property from a property file in our service.
    If you want all the properties from a property file in a Map, than you
can use *<call-class-method>* tag to call the static method that I suggested
in first point above.

On Wed, Mar 19, 2008 at 9:53 PM, Peter Felts <[hidden email]>
wrote:

> Does anyone know if there is a way to access a uiLabelMap (the list of
> local text strings, etc. associated with a language in an application
> /Module/config/<your language here>.properties) from within a service that
> only has access to the DispatchContext and the Map  objects?
>
> What I am trying to do is return errors from a service containing
> localized strings. Any ideas?
>
>
> Thank you.
>
>
>
>
>


--
Thanks & Regards
Mridul Pathak
Hotwax Media
http://www.hotwaxmedia.com
[hidden email]
__________________________________
Office : 509.855.4113
Mobile : +919425926892
Reply | Threaded
Open this post in threaded view
|

Re: uiLabelMap access from a service?

Peter Felts
In reply to this post by Peter Felts
Thank you all. This list is awesome! I'll just need to make sure I look harder before I fall into the trap of asking the list to do my work for me :)









----- Original Message ----
From: Mridul Pathak <[hidden email]>
To: [hidden email]
Sent: Wednesday, March 19, 2008 10:35:08 PM
Subject: Re: uiLabelMap access from a service?

Peter,

Are you writing your service in Java or Minilang??

1) If you are writing the service in Java then you can use *
org.ofbiz.base.util.UtilProperties* class and its methods to access the
properties files.  If you specifically want to get a map of all the
properties in a field you can use *UtilProperties.getResourceBundleMap(String
resource, Locale locale)* method which will return all the properties from
the resource file in a Map.  There are other useful methods as well which
you can use according to your purpose.

2) If you are writing your service in minilang, than there are some special
tags availble which adds, checks and return errors in a service which also
uses localized strings from property files.  The below structure can be used
to return an error in a service containing a string from properties file:
*<add-error>
    <fail-property resource=" " property=" "/>
</add-error>
<check-errors/>
*
    There is another tag *<property-to-field>* which can be used to access
any property from a property file in our service.
    If you want all the properties from a property file in a Map, than you
can use *<call-class-method>* tag to call the static method that I suggested
in first point above.

On Wed, Mar 19, 2008 at 9:53 PM, Peter Felts <[hidden email]>
wrote:

> Does anyone know if there is a way to access a uiLabelMap (the list of
> local text strings, etc. associated with a language in an application
> /Module/config/<your language here>.properties) from within a service that
> only has access to the DispatchContext and the Map  objects?
>
> What I am trying to do is return errors from a service containing
> localized strings. Any ideas?
>
>
> Thank you.
>
>
>
>
>


--
Thanks & Regards
Mridul Pathak
Hotwax Media
http://www.hotwaxmedia.com
[hidden email]
__________________________________
Office : 509.855.4113
Mobile : +919425926892