Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Use of Image Area element with a database

Avatar

Former Community Member
Hello,

I have a database with a field containing an url to a graphic file.

I'd want to create a form which displays this image in an image area element.

I don't success in doing it. Does somebody knows how to do it ? With or without Javascript ?



Thanks in advance for your help



Philippe
10 Replies

Avatar

Former Community Member
In JavaScript here's an example of how you can set the URL the Image points to:



StaticImage1.value.image.href = "http://www.google.com/logos/olympics06_curling.gif";



Chris

Adobe Enterprise Developer Support

Avatar

Level 9
Hi Chris



I tried doing that, but the image doesn't actually seem to update?

If I do xfa.host.messageBox(StaticImage1.value.image.href) I get the original, rather than the updated value.

Is it possible that the href is a "read-only" property?



Any suggestions?



Howard

Avatar

Former Community Member
No, it's not only read-only, it works, I attached a form to prove it :D



It may have to do with the timing of the event you put the code in. Or if you save it as a static PDF it probably won't work.



If you still can't get it to work and want me to take a quick look at the form let me know.



Chris

Adobe Enterprise Developer Support

Avatar

Level 9
Hi Chris



We're both right :)



It works fine if you make the change on the doc:ready event (as you've done), but not if you do it on the click event of a button (as I've done).



I have seen elsewhere on the forum that this appears to be a regression that was introduced in V7.0.5.



If you tell me the secret for uploading attachments, I'll send you a sample.



Howard

Avatar

Former Community Member
Unfortunately the secret is working for Adobe :(



Really? It works for me in 7.0.5 and 7.0.7. You using Reader? I haven't tried Reader 7.0.5, only Acrobat, but it works for Reader 7.0.7. Here's the file I tested with.



Chris

Adobe Enterprise Developer Support

Avatar

Level 9
OK, some more testing...

Your file does work.

However, it appears that once you've set the href, you can't set it to something else. You can test this in your file by either:

- add another button that sets the href to a different url

- or, initialize the image field to a different url in its properties



Once it's set to something, it seems to just stay that way.



Howard

Avatar

Former Community Member
Good point, you got me there. I'll try to look into that some more tomorrow. It's late on this side of the world :P



Chris

Adobe Enterprise Developer Support

Avatar

Level 9
Sleep is for wimps :)



Seriously, thanks for all the help.



Howard

Avatar

Former Community Member
So, after further investigation, Static Images are behaving as they should. After setting the href the first time it can't be changed. It should be possible, however, to change the href of an Image Field as many times as you want, but it doesn't work currently in 7.0.5 or 7.0.7. This is known problem. Unfortunately I don't see any workaround possible for the time being if you need to change the image in a field multiple times. (I suppose you could have multiple image objects, one for each image, and hide/show them dynamically based on which should be shown at the time).



Chris

Adobe Enterprise Developer Support