on 04-04-2005 12:24 PM
Hello,
I would like to create a context attribute which can contain a photo which is in a .jpeg file.
Creating an attribute with Java native type as File should do the job?
Hi,
You can pass the location of the file dynamically to the context and bind the image source to that context !!
Hope this should work !!
Regards, Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can get the server info as follows
HttpServletRequest request =Task.getCurrentTask()
.getWebContextAdapter()
.getHttpServletRequest();
wdContext.currentContextElement().setURL("http://"
+ request.getServerName()+ ":"+ request.getServerPort() "//" <<ImageName>>);
and place the file under the location "C:\usr\sap\J2E\JC00\j2ee\cluster\server0\apps\sap.com\com.sap.engine.docs.examples\servlet_jsp\_default\root"
Now if the file is present on the above location it will display the image on the view if you set this value to the context attribute.
Regards, ANilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First of all place the image file in the src -> mimes -> components -> name of the package.
Then create a context attribute of type string.
Set the context attribute to the image file name in the program.
Do get back for further clarifications.
Hope this helps you.
Regards,
Vijith
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What exactly do you want to do?
You can use any Java type for context attributes, but if you want to bind UI element properties, it must be a Java DDIC type.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roy,
For all the UI element properties u have corresponding Simple types available in local dictionary.
say For Visibility property of the UI elemnts U have
com.sap.ide.webdynpro.uielementdefinitions.Visibility.
When ever u want to bind attributes to the UI elements u can use the predefined simple types available in the local dictionary
U shuld create a Context Attribute of Type Binary
Thanks
Krishna kanth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roy,
u can create an attribute of type String which will hold the image name and place the jpeg file in the
\src\mimes\Components\..
In your UI elemnt u can just bind the attribute.
Actually in which scenario do u want to use this.Do u want to just bind it to an UI elemnt property or for any other purpose.
Regards,
Sowjanya.
Message was edited by: Sowjanya Chintala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think this is a misunderstanding: Import your images in NWDS into folder src/mimes/<component_package> as suggested.
If you redeploy, the images will be copied to the server and the Web Dynpro runtime automatically creates the correct URL for you. In your UI Element property, e.g. Image.source, you can simply provide the image filename, like "photo.jpg".
Armin
Message was edited by: Armin Reichert
Hi Roy,
for displaying dynamically loaded mime objects (e.g. retrieved via Adaptive RFC) you can follow this approach:
1.) Declare a context attribute 'File' of type binary (Should be done by context to model binding). Also declare another attribute 'FileName' of type string for storing the filename.
Define another context attribute 'URL' of type string for storing the dynamic image URL. The image UI-element is bound to this context attribute.
2.) Implement the following code in the wdDoInit()-method of the correct controller:
public void wdDoInit()
{
/*@@begin wdDoInit()*/
wdContext.currentContextElement().setImgVisibility(WDVisibility.NONE);
/* Modify datatype, prepare datatype for modifications done by the runtime */
wdContext.getNodeInfo().getAttribute("File").getModifiableSimpleType();
/* @@end*/
}
3.) Execute model class for retrieving the mime object from the backend. The binary mime data is now stored in the controller context. The filename is stored in attribute FileName.
4.) Generate URL for mime object via service class <b>WDWebResource</b>
...
IWDCachedWebResource cachedResource = null;
String imgUrl = null;
WDWebResourceType type =
((IWDModifiableBinaryType) wdContext.getNodeInfo().getAttribute("File").getModifiableSimpleType())
.getMimeType();
byte[] file = wdContext.currentContextElement().getFile();
if (file != null) {
cachedResource = WDWebResource.getWebResource(file, type);
try {
imgUrl = cachedResource.getURL();
wdContext.currentContextElement().setUrl(imgUrl);
wdContext.currentContextElement().setImgVisibility(WDVisibility.VISIBLE);
} catch (WDURLException e) {
wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessage(), true);
}
}
...
Result: The dynamically retrieved image is displayed in the image UI-element
Regards, Bertram
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.