[icf-dev] Re:[icf-dev] Dynamic Images in WebUI

Posted by LegacyUser on 04-Feb-2003 05:26

Jamie,

this is actually achieved quite easily (after you figured it out :-).

Indeed you have to write a .jpg

var pic_number, pic_url;

pic_number = apph.action('custfullo.custnum.get');

pic_url = "http://localhost/" + pic_number + ".jpg";

// window.alert("picture URL: " + pic_url);

// assume the field in the viewer is called img_cust

document.all.img_cust.src = pic_url;

}

HTH,

Bronco

WOW! My Test worked. I wonder what's different. Oh well, time for my

question.

I have a dynamic viewer with a dynamic image on it. I have overridden

displayFields to do something like dynImage:LOAD-IMAGE(table.field).

To achieve the same results in the WebUI, I know I have to create .js

file and do something in a fuction called sdoname_view. The only

problem is that I have no idea what to do there.

Any clues??

Thanks,

Jamie

To unsubscribe, e-mail: dev-unsubscribe@icf.possenet.org

For additional commands, e-mail: dev-help@icf.possenet.org

To unsubscribe, e-mail: dev-unsubscribe@icf.possenet.org

For additional commands, e-mail: dev-help@icf.possenet.org

All Replies

Posted by LegacyUser on 04-Feb-2003 05:51

Hi,

Yes, so you need to change the SRC attribute of the IMG tag (with the ID

"img_cust" in this case) to the appropriate picture URL. You can also

precache a lot of the images (if it is a finite set). Changing the URL

will go back to the server to go fetch the image and this can also take

some time if the images are large. If you do not want the delay you can

cache the images as follows:

You can create an array of JavaScript image objects to hold the

pictures:

var myPicsArray = new Array();

// Create the image objects

myPicsArray[0] = new Image( , );

myPicsArray[1] = new Image( , );

myPicsArray[2] = new Image( , );

// Set the URLs for each image

myPicsArray[0].src = "images/mypic0.jpg";

myPicsArray[1].src = "images/mypic1.jpg";

myPicsArray[2].src = "images/mypic2.jpg";

Then when the event occurs:

// Swap image

document.images.src = myPicsArray.src;

Ciao!

Frank

-Original Message-

From: Bronco Oostermeyer

Sent: dinsdag 4 februari 2003 12:26

To: Jamie Townsend; dev@icf.possenet.org

Subject: Re: Dynamic Images in WebUI

Jamie,

this is actually achieved quite easily (after you figured it

out :-). Indeed you have to write a _view function.

Put this in the .js you attach to the window (dynobjc), this

is important.

the rest looks like this (let's say the sdoname is 'custfullo'):

function custfullo_view() {

// assume you want to display a file call pic.jpg

var pic_number, pic_url;

pic_number = apph.action('custfullo.custnum.get');

pic_url = "http://localhost/" + pic_number + ".jpg";

// window.alert("picture URL: " + pic_url);

// assume the field in the viewer is called img_cust

document.all.img_cust.src = pic_url;

}

HTH,

Bronco

WOW! My Test worked. I wonder what's different. Oh well,

time for my

question.

I have a dynamic viewer with a dynamic image on it. I have

overridden

displayFields to do something like dynImage:LOAD-IMAGE(table.field).

To achieve the same results in the WebUI, I know I have to create .js

file and do something in a fuction called sdoname_view. The only

problem is that I have no idea what to do there.

Any clues??

Thanks,

Jamie

To unsubscribe, e-mail: dev-unsubscribe@icf.possenet.org

For additional commands, e-mail: dev-help@icf.possenet.org

To unsubscribe, e-mail: dev-unsubscribe@icf.possenet.org

For additional commands, e-mail: dev-help@icf.possenet.org

To unsubscribe, e-mail: dev-unsubscribe@icf.possenet.org

For additional commands, e-mail: dev-help@icf.possenet.org

Posted by LegacyUser on 10-Feb-2003 14:42

Hi. Firstly can I say thanks to Bronco & Frank for helping me to solve this

issue. I just want to let everyone know a little more about what I did to

solve my particular problem.

Since the viewer I need to display the dynamic image on is on a dependent

window, I had to modify the solution, but not very much. The windows I was

working with are a Object Controller that launches a Folder Window (if you

don't know what I'm talking about here, it's very similar to the Currency

Maintenance windows).

Because the Folder Window doesn't have an SDO of it's own, the name of the

SDO (as we are referring to it in the example) is "master". However, when

you reference the field that you want to retrieve the value from, you still

use the real SDO name.

Here is my actual javascript function.

function master_view() {

// assume you want to display a file with the name stored in

zmcmbrfullo.brand_logo_location

var pic_url;

pic_url = apph.action('zmcmbrfullo.brand_logo_location.get');

if(pic_url == "") pic_url = 'images/noimage.jpg';

// window.alert("picture URL: " + pic_url);

// assume the field in the viewer is called img_cust

document.all.brand_logo.src = pic_url;

}

One interesting thing that I found is that I lack commitment. That is to

say, Bronco gave me the full solution, but I wanted to test each step along

the way rather than trying the whole thing to see if it worked.

When you click one of the buttons on the Dynamics generated web page, you

can type in your own VB/JavaScript to test things out. I found out (the

hard way) that there seems to be some kind of context difference between

javascript run from there as apposed to javascript run from a .js file

included in the page.

I am no javascript programmer, so perhaps this makes perfect sense, but I

tried for a long time to figure out why I couldn't reference the object

"document.all.brand_logo". When I finally tried to whole example, it worked

fine.

From now on, if I have to test any javascript I want to use in a Dynamics

page, I will code what I want to test into a .js file and put a dynamic

button on the page with the call to onClick run "function_I_want_to_test".

That way I will get the right "context" (or whatever it is).

Well, I hope those hints save someone some time.

Jamie Townsend

-Original Message-

From: Bronco Oostermeyer

Sent: Dienstag, 4. Februar 2003 12:26

To: Jamie Townsend; dev@icf.possenet.org

Subject: Re: Dynamic Images in WebUI

Jamie,

this is actually achieved quite easily (after you figured it

out :-). Indeed you have to write a _view function.

Put this in the .js you attach to the window (dynobjc), this

is important.

the rest looks like this (let's say the sdoname is 'custfullo'):

function custfullo_view() {

// assume you want to display a file call pic.jpg

var pic_number, pic_url;

pic_number = apph.action('custfullo.custnum.get');

pic_url = "http://localhost/" + pic_number + ".jpg";

// window.alert("picture URL: " + pic_url);

// assume the field in the viewer is called img_cust

document.all.img_cust.src = pic_url;

}

HTH,

Bronco

To unsubscribe, e-mail: dev-unsubscribe@icf.possenet.org

For additional commands, e-mail: dev-help@icf.possenet.org

Posted by LegacyUser on 10-Feb-2003 18:01

Hey Jamie,

Hows things?

Thanks for posting this back. I actually tried (well I guess you would call

it a try, I got no where near a solution) to do this and failed badly.

But also thanks for passing on your observations it should help me in

future.

TIA

Molly

-Original Message-

From: Jamie Townsend

Sent: Tuesday, 11 February 2003 7:42 AM

To: dev@icf.possenet.org

Subject: Re: Dynamic Images in WebUI - Solved

Hi. Firstly can I say thanks to Bronco & Frank for helping me to solve this

issue. I just want to let everyone know a little more about what I did to

solve my particular problem.

Since the viewer I need to display the dynamic image on is on a dependent

window, I had to modify the solution, but not very much. The windows I was

working with are a Object Controller that launches a Folder Window (if you

don't know what I'm talking about here, it's very similar to the Currency

Maintenance windows).

Because the Folder Window doesn't have an SDO of it's own, the name of the

SDO (as we are referring to it in the example) is "master". However, when

you reference the field that you want to retrieve the value from, you still

use the real SDO name.

Here is my actual javascript function.

function master_view() {

// assume you want to display a file with the name stored in

zmcmbrfullo.brand_logo_location

var pic_url;

pic_url = apph.action('zmcmbrfullo.brand_logo_location.get');

if(pic_url == "") pic_url = 'images/noimage.jpg';

// window.alert("picture URL: " + pic_url);

// assume the field in the viewer is called img_cust

document.all.brand_logo.src = pic_url;

}

One interesting thing that I found is that I lack commitment. That is to

say, Bronco gave me the full solution, but I wanted to test each step along

the way rather than trying the whole thing to see if it worked.

When you click one of the buttons on the Dynamics generated web page, you

can type in your own VB/JavaScript to test things out. I found out (the

hard way) that there seems to be some kind of context difference between

javascript run from there as apposed to javascript run from a .js file

included in the page.

I am no javascript programmer, so perhaps this makes perfect sense, but I

tried for a long time to figure out why I couldn't reference the object

"document.all.brand_logo". When I finally tried to whole example, it worked

fine.

From now on, if I have to test any javascript I want to use in a Dynamics

page, I will code what I want to test into a .js file and put a dynamic

button on the page with the call to onClick run "function_I_want_to_test".

That way I will get the right "context" (or whatever it is).

Well, I hope those hints save someone some time.

Jamie Townsend

-Original Message-

From: Bronco Oostermeyer

Sent: Dienstag, 4. Februar 2003 12:26

To: Jamie Townsend; dev@icf.possenet.org

Subject: Re: Dynamic Images in WebUI

Jamie,

this is actually achieved quite easily (after you figured it

out :-). Indeed you have to write a _view function.

Put this in the .js you attach to the window (dynobjc), this

is important.

the rest looks like this (let's say the sdoname is 'custfullo'):

function custfullo_view() {

// assume you want to display a file call pic.jpg

var pic_number, pic_url;

pic_number = apph.action('custfullo.custnum.get');

pic_url = "http://localhost/" + pic_number + ".jpg";

// window.alert("picture URL: " + pic_url);

// assume the field in the viewer is called img_cust

document.all.img_cust.src = pic_url;

}

HTH,

Bronco

To unsubscribe, e-mail: dev-unsubscribe@icf.possenet.org

For additional commands, e-mail: dev-help@icf.possenet.org

To unsubscribe, e-mail: dev-unsubscribe@icf.possenet.org

For additional commands, e-mail: dev-help@icf.possenet.org

This thread is closed