Expand my Community achievements bar.

Setting Image URL dynamically

Avatar

Level 3

OK, I have a dynamic form that I am using an Image control on. I am using an Image, NOT an Image Field because I don't want the user to be able to click on the image and change it. I can set the URL property of the Image on Designer's object tab and the image shows up fine when I view the form. Here's the complication: the image URL needs to change a bit each time the form is rendered. So one time it may be http://www.domain.com/generate_image.php?image_id=1 and the next time it may be http://www.domain.com/generate_image.php?image_id=2. I tried setting the URL via JavaScript like this:

Page1.logo.value.image.href = "http://www.domain.com/generate_image.php?image_id=1";

The image_id will be pulled from the XML data that gets passed to the form. This successfully sets the URL property, but the image at the URL doesn't show up in the image control. I tried putting the JavaScript in several different events, like form:ready, docReady, etc, but none of them work.

I really need to show an image via a URL that can change, but I don't want to use an Image Field since the user can click on it and change the image.

Ideas?

Thanks in advance,

Nathan D

17 Replies

Avatar

Former Community Member

You cannot change the URL after the form has been rendered. Are you using Form Server to render the form or are you simply distributing a PDF?

Paul

Avatar

Level 3

I am using Forms Server to render the form.

Avatar

Former Community Member

Great ...then you will want to set that code that changes the URL to render server side. Don't forget to clear the Form Server cache before testing again.

Paul

Avatar

Level 3

OK, great. How exactly do I do that? I've only done client-side rendering up to this point.

Avatar

Former Community Member

In the script editor simply set the runAt dropdown to server. I assume that you are executing this codein the Initialize event. Not all events will fire on the server so if your code is on a different event let me know.

Paul

Avatar

Level 3

OK, forget that last question. I now see the "Run At" box at the top of the JS window. Is there a particular event I should put my JS code in?

Avatar

Former Community Member

I woudl suggest the form ready or the initialize.

Paul

Avatar

Level 3

Hmmm....something still isn't working correctly. I took the following code:

Ultra_Form.Page1.logo.value.image.href = "http://www.floridarealtorforms.org/public/officelogo?sStateID=FL&sFirmID=200901&sUserType=F";

and put it in the initialize event. I then set that event to run at the server. I uploaded the form and reset the cache. But for some reason the logo did not show up in the image. I also tried it with an Image Field for the heck of it and that didn't work either. I also tried the form:ready and docReady events (both set to run at the server) and it still didn't work, even after a cache reset. Not sure what is wrong.

Any ideas for other things I can check?

Thanks for all your help so far!

- Nathan

Avatar

Former Community Member

Can you try and access an image on the local server instead of going elsewhere? You may have to have a crossdomain.xml file in place to have cross server references.

Paul

Avatar

Level 3

OK, I'll try that and get back to you, although being able to pass a URL to a different server would be ideal. I may need to try to figure out how to do a crossdomain.xml file. I'll let you know what happens.

Avatar

Former Community Member

Lets validate that before going down that path.

Paul

Avatar

Level 3

No luck. I uploaded an image to the same directory as the PDF. I tried referencing it as both an absolute path from the root and a relative path. Neither worked.

Avatar

Former Community Member

Ok I just tried it too and got the same result.....in most cases I create an orchestration to retrieve the image and then bind the result to the image field as the rawValue. I have done it with Soap and Rest and I have tested and know that it works. Are you against doing that? What version of LC Server are you using?

Paul

Avatar

Level 3

We are on ES2. I will need some guidance on how to do it the way you are describing, so any help would be extremely helpful.I'm unfamiliar with orchestrations unfortunately.

If it will help, let me give you some background on what I am doing with LC at the moment: I basically am using PHP to call the renderPDFForm method of the FormsService API to generate my form. I pass in an XML file with the data for the form. I get the result back and display it.

Avatar

Former Community Member

I have a sample LCA that shows a form using a dyna,ic image through a rest call. In my case I am using data on the form to determine which image to load. The technique shoudl be pretty much the same for you. Here is the LCA ..do you know how to import it?

Paul

Avatar

Level 3

Yep, I know how to use LCAs. I'll mess with it this evening and let you know how it works. Thanks!

- Nathan

Avatar

Level 3

FYI, I'm not currently able to import anything into LC because of some sort of LC installation or configuration error. I'll need to get with LC tech support first to see if they can help me figure it out. I'll get back to you after I get the server problem figured out and get the LCA imported.

Don't know if you know much about LC installations, but the error I'm getting is:

ALC-DSC-012-000: com.adobe.idp.dsc.registry.ServiceNotFoundException: Service: ApplicationManager not found.

Anyway, I'll get on the phone with support tomorrow.

Thanks again!

- Nathan