on 07-06-2007 1:08 PM
Hi All,
My problem is as follows: I have many different projects each using different logos in accordance to different users. But what I want is make one project which will contain all logos and rest of the projects should be able to get the path and port and in accordance check whether the image desired is available or not.
I am able to get the path and port but I am facing the problem in checking whether the image exists if it does it should be displayed and if it doesn't then it should become invisible but in this case I am getting a cross. The reason for keeping all the images in one project is that if any changes take place in adding and removal of images with time then I should not fiddle with each and every project all can be done through one single project.
Thanks & Regards
Jaspreet Kaur
HI JasPreet,
Let the Image be inside ImgProj/src/mimes/com.sap.test/A.jpg in project=>ImgProj.
You can access this image in another project by using the following code.
I am assuming that the image source context variable in the project is Img;
File f=new File("temp
webdynpro
web
local
ImgProj
Components
com.sap.test
A.jpg");//File name is Case sensitive
FileInputStream fis=new FileInputStream(f);
byte b[]=new byte[fis.available()];
fis.read(b);
IWDResource res=WDResourceFactory.createCachedResource(b,"A.jpg",WDWebResourceType.UNKNOWN);
String url=res.getUrl(1);
wdContext.currentContextElement().setImg(r);
Regards
Fahad Hamsa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fahad
Its throwing file not found exception:
String hostName = TaskBinder.getCurrentTask().getProtocolAdapter().getServerName();
int port = TaskBinder.getCurrentTask().getProtocolAdapter().getServerPort();
String Protocol =TaskBinder.getCurrentTask().getProtocolAdapter().getProtocolScheme();
String logoName = "logo_" + wdContext.currentCompaniesElement().getBukrs()+".gif";
String abpath = Protocol + "://" + hostName + ":" + port + "/webdynpro/resources/local/eScCommonLogos_Jas/Components/com.ko.CommonLogos/";
String companylogourl = Protocol + "://" + hostName + ":" + port + "/webdynpro/resources/local/eScCommonLogos_Jas/Components/com.ko.CommonLogos/" + logoName;
File f=new File(abpath);//File name is Case sensitive
FileInputStream fis=new FileInputStream(f);
byte b[]=new byte[fis.available()];
fis.read(b);
IWDResource res=WDResourceFactory.createCachedResource(b,companylogourl,WDWebResourceType.UNKNOWN);
String url=res.getUrl(1);
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(url);
wdContext.currentContextElement().setCxt_CompanyLogo(companylogourl);
now here as u can see my abpath for all images will be same only the logoname will differ which i am getting dynamically as it depends on my user in accordance to which image shall come...so basically using the abpath which shall take me to the file containing the images and comparing it with the companylogo which contains the path+exact image required i want to display the image else set its visibility none....Please guide me if ur getting me.
Thanks & Regards
Jaspreet Kaur
Hai,
You can store images in km . you can access and show images form KM.
regarding storing it in different projects
uploading images into km
/people/rohit.radhakrishnan/blog/2005/05/27/uploading-files-to-km-repository-using-webdynpro-apis
accessing images from Km
/people/bobu.georgeputheeckal/blog/2006/12/22/getting-an-image-from-km-documents-to-be-used-in-web-dynpro
Regards,
Naga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
Control the visibility of Image, to avoid the cross symbol.
ie. Make image as invisible if image doesn't exist else make it visible
Use a variable of type com.sap.ide.webdynpro.uielementdefinitions.Visibility and bind it to "visiblie" property of image.
Then control the visibility of image as
if(exists)
wdContext.current....().setvisibilityVar(WDVisibility.VISIBLE);
else
wdContext.current....().setvisibilityVar(WDVisibility.NONE);
Regards
Fahad Hamsa
Fahad Hamsa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can create a "image" attribute in the context. Bind this to the UI element which should be displayed.
Now make another attribute "image_visibility" of type "Visibility". Map the visibility of the attribute of the Image UI element in the view to the attribute "image_visibility".
At runtime check whether image can be located, if yes set the Visibility to true else set it to false.
Regards,
Ashwani Kr Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I dont think check the presence of image/any resource via url+port is correct idea.
Better is to store these images in one compoent of a web dynpro project. Store the images in mimes folder of this component. Later access the images via context attribute(s) of the component.
Create dependecy to this component in all the component where you want to use the images. The map the context to the "mapped to" component context. Now try to get Resource via WDResource APIs. If you are able to access the resources=> the images are there.
Regards,
Ashwani Kr Sharma
Actually I require to check the existence as with time logs may change..so to giv u a better idea this is the code i used....
String hostName = TaskBinder.getCurrentTask().getProtocolAdapter().getServerName();
int port = TaskBinder.getCurrentTask().getProtocolAdapter().getServerPort();
String Protocol =TaskBinder.getCurrentTask().getProtocolAdapter().getProtocolScheme();
String logoName = "logo_" + wdContext.currentCompaniesElement().getBukrs()+".gif";
String companylogourl = Protocol + "://" + hostName + ":" + port + "/webdynpro/resources/local/eScCommonLogos/Components/com.ko.CommonLogos/" + logoName;
wdContext.currentContextElement().setCxt_CompanyLogo(companylogourl);
thanks& regards
Jaspreet Kaur
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.