I'm having an existing database and i have to show the list of images in my worklight application to user so that they can select and adds to cart.
The image column in database is having only path of images at server. i.e "memory/toppings/nuts/hazelnuts.jpg" "memory/toppings/nuts/macadamia_nuts.jpg"
so how to get all these images and show on my worklight application.
What you should do is concatenate the server URL and the image path after you retrieve it from the database.
Lets say in the database I store this: "/uploads/original/6/63935/1570735-master_chief.jpg", so the concatenation would be like this:
Below is a working example.
Upon clicking a button, a SQL adapter procedure is invoked and returns a URL stored in the database. This URL is inserted into a pre-existing
img
tag'ssrc
attribute, which then gets displayed.You need to take this implementation and alter it to fit your needs.
HTML:
JS:
Alternate JS:
This code snippet shows how to add several images into dynamically created
img
tags.Adapter JS:
Adapter XML:
In the database: