cancel
Showing results for 
Search instead for 
Did you mean: 

Different images for different geographic region

Former Member
0 Kudos

Hi,

We have a requirement, webdynpro Java application will be deployed in different geographic region.

1)In the screen (view), we need to show different images depends upon the region which application is accessing. Also all geographic region should use the same URL (we cannot use different URL parameters for different regions).

2)Need to give an utility to admin user, he will upload the required image for his region, in webdynpro application , we should show that image (admin uploded) in the image place holder. In this case where to store the uploaded image and how to show in it webdynpro application.

Please help on this.

Regards,

Rakesh Mathew

Accepted Solutions (1)

Accepted Solutions (1)

Sharathmg
Active Contributor
0 Kudos

First, you have to determine the user's region.

     1. You can use the Google/Microsoft's Geolocation api to get the user's region - Runtime determination of user's region

     2. You can set a locale for the user in UME. The code can read the locale assigned to the logged in user and according behave. - Design time config of user's preferred locale and obtain it

     For option 2: Use the method:

          IWDClientUser loginUser = WDClientUser.getLoggedInClientUser();


Locale locale = loginUser.getLocale();

locale.getCountry();


   

   Now, store the images for the regions in a location - server location/central folder.

   Follow the locale naming convention.

   Either create a screen / request admins to maintain images in that folder/location.

   In your application, after determining the user's locale, retrieve  the relevant image in the location.

          - To retrieve the image/resource, use the WDResourceFactory and WDURLGenerator.

Sample: Explore the WDResourceFactory to fulfill this requirement.

// Receieve the image as file, read into stream and then build the resource and assign it to the image UI element.

byte[] buffer = wdContext.currentOutputElement().getXstring_Data(); // here am receiving -1, Array Index out of bound exp

IWDResource resource = WDResourceFactory.createCachedResource(new ByteArrayInputStream(buffer),"JPG",WDWebResourceType.JPG_IMAGE,true);

Regards,

Sharath

Former Member
0 Kudos

HI Sharath,

Thanks for your detailed replay,

can you give some more inputs on storing images in server. What is the appropriate path in server  to store images ? what type of permission is required for that? can we uploaded files into folders like /usr/sap/FD2/AAA/HH?.

Regards,

Rakesh Mathew

Sharathmg
Active Contributor
0 Kudos

There is no specific path which is ideal but recommended to keep it simpler.

Also, explore the usage of KM folder to store the images. This way, you avoid the need to have direct access to server. Once you store images in KM folder, make use of KM apis to access the folder and image in KM.

This makes the job of admin also easier, as they can log onto portal - KM and upload files.

Regards,

Sharath

Answers (0)