wood burning stoves 2.0*
The moose likes Applets and the fly likes dynamically change Applet param via javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "dynamically change Applet param via javascript" Watch "dynamically change Applet param via javascript" New topic
Author

dynamically change Applet param via javascript

Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

Hi guys,

I have an Applet which i'm loading through an HTML file with a list of parameters names and values.
I would like to add the feature of being able to dynamically change param values via javascript.

is this possible and how can it be done?

thanking you much
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
You may be able to change the page DOM through JavaScript, but once an applet is initialized, any change of the page won't be reflected in the applet. To influence a running applet via JavaScript, you need to access its public fields and methods via LiveConnect, and react accordingly in your applet code. The Applets FAQ has some links about LiveConnect.


Ping & DNS - my free Android networking tools app
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

Moved to the Applets forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

Thanks Ulf for replying

I do agree with you on the issue of applet params never get updated once applet is initialized.
This means I'm in a real trouble how to handel this issue.
are you aware of some open source library for updating applet params via javascript ?
i would appreciate any help.
thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
I think you missed my point. It may actually be possible to update the parameters in the page DOM, but that's irrelevant because they are never read again after the initial loading of the applet. Have a look at LiveConnect instead.
Yahya Elyasse
Ranch Hand

Joined: Jul 07, 2005
Posts: 510

I probably need to explain more what I want to do in this applet/javascript communication:

My applet has a param named "urlList" .it's value is a comma delimited list of http urls.
in applet init() method I getParameter("urlList") parse the value and store the urls in a vector.

Now I want to be able to add and remove URLs to the url List via javascript in RunTime i.e after applet is loaded and initialized.
I suspect the add/remove will be applied to this Vector via Javascript as explained by other posters.
what is the best way to approach this problem ?

Many thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
I'm not sure what "other posters" said -there don't seem to be any in this thread- but that's precisely what LiveConnect can do, and no other approach will work.
 
 
subject: dynamically change Applet param via javascript