Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to pass variable for PARAM's value.

Posted on 1998-06-24
6
Medium Priority
?
219 Views
Last Modified: 2010-03-30
I want to pass parameter value to JAVA applet.
The value is not a Constant-value String, rather, it is
a Variable-value String.
eg
<applet code="RainbowText9.class" width=340  height=22>
<param name=text value=varnam>
                 (instead of value="Welcome to ...."
Note : varnam is a SCRIPT variable that have been assigned
       with value.
</applet>

My question is :-
   a) It is allow to pass a SCRIPT's variable (varnam)
      to the Applet's PARAM VALUE=varnam
   b) If (a) above is not allow, then how can this be done?  
Rgds,

0
Comment
Question by:heng03
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:msmolyak
ID: 1223639
No, Java expects a constant string as a parameter. The simplest solution is to use JavaScript to modify the applet tag before the applet is started. I'll try to come up with an example.
0
 
LVL 4

Accepted Solution

by:
evijay earned 60 total points
ID: 1223640
the syntax is &{javascriptvariablename}

So, your tag becomes


<applet code="RainbowText9.class" width=340  height=22>
       <param name=text value=&{javascriptvarnam}>
 
       </applet>
0
 
LVL 4

Expert Comment

by:evijay
ID: 1223641
Sorry for the typo

the answer is like this


       the syntax is &{javascriptvariablename};

       So, your tag becomes


       <applet code="RainbowText9.class" width=340  height=22>
              <param name=text value=&{javascriptvarnam};>

 
         
              </applet>
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:heng03
ID: 1223642
Hi evijay,
Thanks for your help.
I have a few question related to the above example applet.
I want to pass variable to the applet's width= parameter
 
   eg
   <applet code="RainbowText9.class" width=varsize  height=22>
                         (instead of width=320)
   Note : varsize is a SCRIPT variable that have been assigned
          with numeric value. eg varsize=250;
   </applet>

   P.S. : I tried width=&{varsize}, but do not work
          I tried width=varsize & width=&varsize, also
          do not work.
Pls advice, thank you.

0
 

Author Comment

by:heng03
ID: 1223643
Hi Evijay,
I have one more question :-
a) This RainbowText9 class is extends Applet and Implement Runnable. Beside running in browser as applet, how can I run
it in DOS/window as a application.

Note :
I tried C:\JAVA\BIN\JAVA RainbowText9
But got message "In class RainbowText9: void main(String argv[])
is undefined.

Pls help. Thanks.


0
 

Author Comment

by:heng03
ID: 1223644
Hi Evijay,

I tried width=&{varsize};   (this work OK)
Thanks

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question