Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 20
Registered: ‎11-22-2011
My Device: blackberry bold- 9700
My Carrier: none
Accepted Solution

showing captured image after taking photo

[ Edited ]
/*******
works when "Take Photo" button clicked
********/
function takePicture() {
    var result = blackberry.media.camera.takePicture(successCB);
}


/*******
post processing of photo click event
********/
function successCB(filePath) {
    try{
        blackberry.media.camera.close();
        var imagePath = "file://" + filePath;
        document.getElementById('images').setAttribute('src', imagePath.toString());
        document.getElementById("photoDetails").innerHTML = imagePath;
    }
    catch(e) {
        document.getElementById("photoDetails").innerHTML = e.ToString();
    }
}


//ConfigFile includes the following,  <access subdomains="false" uri="file:///store/home/user/camera/">
<ul>
                <li id="Li1">
                    <img id="Img1" alt="image" src="file:///store/home/user/camera/IMG-20120118-00001.jpg" /></li>
                <li id="photoDetails">
                    <img id="images" alt="image" src="kkkoj" /></li>
            </ul>

 

 

the imagePath variable successfully prints => "file:///store/home/user/camera/IMG-20120118-00001.jpg". but the photo is not showing up. 

 

i don't understand whats the problem with the code i have written. image path came alright.

 

Strangely when i hardcode the imagePath as a src of image it can show the image. but when i set it using javascript in successCB(), it doesn't work. i tested the functionality of my javascript code in firefox. it works in basic html. i am using Blackberry 9700 with os 6 bundle 2921. i need immediate help. please i am stuck with this for a whole day

Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: showing captured image after taking photo

Try:

 

document.getElementById('images').src=imagePath;

 

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Contributor
Posts: 20
Registered: ‎11-22-2011
My Device: blackberry bold- 9700
My Carrier: none

Re: showing captured image after taking photo

i got another answer by Core.B which solved my problem. thank you jcarty for being responsive with me. happy coding everybody. :Punk:

 

"You're use of document.getElementById("photoDetails").innerHTML is the problem. .innerHTML replaces everything in between the opening and closing tags of <li id="photoDetails">. Since images is in photoDetails, it is getting erased with just the imagePath.

If you want to display the imagePath, try adding a <div> or <span> and updating them with the path.

Also, I don't think you need the <access> element in your configuration file, since that is only used for accessing external servers."

 


Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: showing captured image after taking photo

Great! Glad you figured it out.
Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Contributor
Posts: 10
Registered: ‎02-24-2011
My Device: Bold 9700
My Carrier: AT&T

Re: showing captured image after taking photo

Oooh. I'm getting mentions here too :smileyhappy:

 

Maybe I should hang out here more often than on Stack Overflow.

Contributor
Posts: 20
Registered: ‎11-22-2011
My Device: blackberry bold- 9700
My Carrier: none

Re: showing captured image after taking photo

welcome to blackberry community coreb. :smileyhappy: your help was in right time.