cancel
Showing results for 
Search instead for 
Did you mean: 

Display image thru context attribute

Former Member
0 Kudos

Hi Friends,

I want to display an image using context attribute.

I copied my image in src/mimes/components folder.

I created an attribute of type string and set it's value to my image.jpg file , which is there in above mentioned folder.

Still at runtime, my image is not displayed.

I tried changing the type to binary, but in that case, i don't know how to set a value to this attribute type.

Can you please tell me how to proceed on this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If the image URL is fixed you can just set the "source" property of the Image UI element to the image filename. The image must be stored in folder src/mimes/component/<componentName>.

Armin

Former Member
0 Kudos

Hi Armin,

Thanks for your reply.

I have saved my image in src/mimes/components/component_name folder as you mentioned.

I am using NW 7.0, hence there is no browse option for image source property.(which is available in 7.1).

Therefore, I have to display this image using value attribute. I am confused whether attribute type shoud be string or binary.

Which can be a better option ?

Also, I tried both the options, one after the other, but the image is not getting displayed.

Can you please tell me the exact steps involved in it?

Former Member
0 Kudos

You don't need a context attribute, just set the property value in the View Designer to the filename. (A context attribute should have type "string")

Armin

Former Member
0 Kudos

Thanks Armin.

One more thing : We have assigned values to two properties, alt and source.

At source, we directly wrote the image name. alt is used to display something if the image is not displayed.

And at alt, we bound it to context attribute of type string and we are setting image name to this context attribute in init method.

Still it doesn't display any image. What mistake may we be doing?

Also, it i thought WD explorer will automatically show my component name under components, but it didn't. Hence we created one folder with our component name. We manually pasted image in that folder. But now, the folder appears, but it doesn't display the image under that folder.! . Something wrong, here itself?

Former Member
0 Kudos

Yes, there is. At first, your mimes folder will be empty. This means, you will have no "directories" inside it when you have a newly created Component.

You need to create a folder using NWDS (Navigator view, Right-Click mimes/Components, New -> Other -> Simple -> Folder) - I assume the full qualified Component name is required as the folder name.

Paste your image in that folder. From now on, if you "Refresh" the WD Explorer view the folder and image should be displayed there) - To use an Attribute, you can create any Attribute Name, type String, and remember to set the Cardinality of your Node correctly. You can use wdDoInit to set up the the image filename (as you did before). You need to bind the source property of your Image to this new Context Attribute just created. Or you can just "use" the image filename directly under the source property as Armin commented before (If this is some sort of Icon that might be used along several applications, consider having a DC to supply you the images, so this will avoid replication and consenquently, lower maintenance times).

Regards,

Daniel

Former Member
0 Kudos

That's not correct. The folder structure is created automatically by the NWDS. If you import an existing project, you sometimes have to use the "Repair -> Project Structure and Classpath" context menu entry to restore the folder structure.

If you ever find that the above is not true, please open an OSS message on BC-DWB-WD-JAV.

Armin

Former Member
0 Kudos

Amazing..

I've tried already like three or four NWDS versions, during all the upgrades, all of them bugged. I never opened OSS messages, I don't find worth it opening them. Seriously, I think I would have to open two OSS messages per week or more, too much time consuming.

But I guess it's always an option.. 😛

Daniel

Former Member
0 Kudos

Seems you always get software created on mondays

But seriously. Please open OSS messages for any bug you find, this will help not only you but all other users as well.

Armin

Former Member
0 Kudos

Thanks Armin and Daniel.

We changed the image type from .jpg to .bmp and I don't know why, the image is displayed now!!

Your replies taught me several amazing things. Thanks a lot.

Former Member
0 Kudos

That's rather strange. BMP should not be used because not all browsers support it. You should use JPEG, GIF or PNG.

Armin

Answers (0)