Reputation: 31637
I am making the image slider where I want to pull the image name from server.
For dynamic, below is what I have.
<script type="text/javascript">
var firstreel=new reelslideshow({
wrapperid: "myreel", //ID of blank DIV on page to house Slideshow
dimensions: [800, 600], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
["http://www.almaktab.com/iPhoneApp/gallery/image001.jpg"], //["image_path", "optional_link", "optional_target"]
["http://www.almaktab.com/iPhoneApp/gallery/image002.jpg", "http://www.almaktab.com/iPhoneApp/gallery/image002.jpg", "_new"],
["http://www.almaktab.com/iPhoneApp/gallery/image003.jpg"],
["http://www.almaktab.com/iPhoneApp/gallery/image004.jpg"]
//-no trailing comma after very last image element!
],
displaymode: {type:'auto', pause:4000, cycles:2, pauseonmouseover:true},
orientation: "h", //Valid values: "h" or "v"
persist: true, //remember last viewed slide and recall within same session?
slideduration: 300 //transition duration (milliseconds)
})
</script>
Now I want to replace imagearray
with the image names that I have on database.
Hence what I did is below.
xmlns:c="http://java.sun.com/jsp/jstl/core"
<h:body>
<f:metadata>
// pulling image names
<f:event type="preRenderView" listener="#{FullScopeBens.pullMyImageNames()}"/>
</f:metadata>
<script type="text/javascript">
alert('perfect = ');
var data = {
<c:forEach items="${FullScopeBens.myDealsList}" var="ctag" varStatus="loop">
'${ctag.imagePath}': '${ctag.imagePath}${!loop.last ? ',' : ''}
</c:forEach>
};
alert('perfect = ' + data);
</script>
and planned to replace imagearray:...
to imagearray:data
.
But its not working.
When I print
<c:forEach items="#{FullScopeBens.myDealsList}" var="item">
${item.id}==${item.title}
</c:forEach>
I get proper id and title for that image.
Any idea how can I get image path in javascript.
Even I tried below link. But still not working.
https://community.jboss.org/thread/160332
(look for 3. Dec 23, 2010 8:31 AM (in response to Eswara MoorthyNEC)
)
Below link helped me for answer.
https://stackoverflow.com/a/4143187/1066828
Upvotes: 1
Views: 1373
Reputation: 31637
Below link helped me for answer.
https://stackoverflow.com/a/4143187/1066828
So what I was doing is assigning the bean data to textfield and through javascript I am getting the data from textfield and using that in array.
Upvotes: 1