Passing parameter to Applet Dynamically

Hi All,
How can i pass the parameter to applet at the runtime?
I want to play a video file. So 'm using one applet(I got this from JMF Documentation).
Here is the Applet._
import java.applet.Applet;
import java.awt.*;
import java.io.File;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
import javax.media.*;
import javax.swing.JOptionPane;
public class TypicalPlayerApplet extends Applet implements ControllerListener
// media player
Player player = null;
String mediaFile = null;
// component in which video is playing
Component visualComponent = null;
// controls gain, position, start, stop
Component controlComponent = null;
// displays progress during download
Component progressBar = null;
* Read the applet file parameter and create the media
* player.
public void init()
setLayout(new BorderLayout());
// input file name from html param
//String mediaFile = null;
// URL for our media file
URL url = null;
// URL for doc containing applet
URL codeBase = getDocumentBase();
// Get the media filename info.
// The applet tag should contain the path to the
// source media file, relative to the html page.
if ((mediaFile = getParameter("FILE")) == null)
Fatal("Invalid media file parameter");
try
// Create an url from the file name and the url to the
// document containing this applet.
if ((url = ((new File(mediaFile)).toURI()).toURL()) == null)
Fatal("Can't build URL for " + mediaFile);
// Create an instance of a player for this media
if ((player = Manager.createPlayer(url)) == null)
Fatal("Could not create player for "+url);
// Add ourselves as a listener for player's events
player.addControllerListener(this);
catch (NoPlayerException ex)
JOptionPane.showMessageDialog(null, "Error "+ex.getMessage());
catch (MalformedURLException u)
Fatal("Invalid media file URL!");
catch(IOException i)
Fatal("IO exception creating player for "+url);
* Start media file playback. This function is called the
* first time that the Applet runs and every
* time the user re-enters the page.
public void start()
// Call start() to prefetch and start the player.
if (player != null) player.start();
* Stop media file playback and release resources before
* leaving the page.
public void stop()
if (player != null)
player.stop();
player.deallocate();
* This controllerUpdate function must be defined in order
* to implement a ControllerListener interface. This
* function will be called whenever there is a media event.
public synchronized void controllerUpdate(ControllerEvent event)
// If we're getting messages from a dead player,
// just leave
if (player == null) return;
// When the player is Realized, get the visual
// and control components and add them to the Applet
if (event instanceof RealizeCompleteEvent)
if ((visualComponent = player.getVisualComponent()) != null)
add("Center", visualComponent);
if ((controlComponent = player.getControlPanelComponent()) != null)
add("South",controlComponent);
// force the applet to draw the components
validate();
else if (event instanceof CachingControlEvent)
// Put a progress bar up when downloading starts,
// take it down when downloading ends.
CachingControlEvent e = (CachingControlEvent) event;
CachingControl cc = e.getCachingControl();
long cc_progress = e.getContentProgress();
long cc_length = cc.getContentLength();
// Add the bar if not already there ...
if (progressBar == null)
if ((progressBar = cc.getProgressBarComponent()) != null)
add("North", progressBar);
validate();
// Remove bar when finished ownloading
if (progressBar != null)
if (cc_progress == cc_length)
remove (progressBar);
progressBar = null;
validate();
else if (event instanceof EndOfMediaEvent)
// We've reached the end of the media; rewind and
// start over
player.setMediaTime(new Time(0));
player.start();
else if (event instanceof ControllerErrorEvent)
// Tell TypicalPlayerApplet.start() to call it a day
player = null;
Fatal (((ControllerErrorEvent)event).getMessage());
void Fatal (String s)
// Applications will make various choices about what
// to do here. We print a message and then exit
System.err.println("FATAL ERROR: " + s);
throw new Error(s); // Invoke the uncaught exception
// handler System.exit() is another
// choice
Following is my HTML Code,_
<applet id="TypicalPlayerApplet" name="TypicalPlayerApplet" code="TypicalPlayerApplet.class" codebase="app" width=320 height=300>
<param name=file id="param1" value="c:\\avi\\cineloop1.avi" />
</applet>
What my question is how can i pass this location "c:\\avi\\cineloop1.avi" at the runtime. I am passing the cineloop location along with the URL. Now i want to pass this location which is taken from the URL, to the Applet.
How can i achieve this. Will some one help me out.
Thanks and regards
Chennaibee.

Thanks winj,
I tried to pass the cine loop filename via java script on page load event.
function assignit()
var filename='c:\\avi\\loop3.avi';
var myapplet = document.getElementById('TypicalPlayerApplet');
myapplet.mediaFile=filename;
And in the page load event i called this JS.
*<body onload='assignit();'>*
It's passing the file name after the applet getting started.
How can i pass the file name before the applet getting starts.
Is it possible to call this Java Script during the page initialization.
Regards
Chennaibee.

Similar Messages

  • Passing parameter from applet to portal is failing

    hi all.
    We have an external applet that we can view on the portal. We want to have two parameter (parm1 and parm2) passed from the applet to the gateway and thus have them re-written by the portal gateway.
    When we access the applet from the portal, and View Source inside the browser's window, we see that the gateway URL does not precede the parameter's url:
    we see:
    <PARAM NAME = "param1" VALUE="http://host.domain.com:8080/JUPL/...
    instead of:
    <PARAM NAME = "param1" VALUE="https://http://host.domain.com/http://host.domain.com:8080/JUPL/...
    However, we are following sun docs on how to apply rules for HTML content (As in http://docs.sun.com/source/816-6359-10/rewrtadm.html#23362).
    here's our rule:
         <Applet source="*/applet1.jsp" code="java2.applet1.client.MApplet.class"
         param="param1;param2;"/>
    Any ideas on how to solve this?
    Thanks!

    Here this shold work for ya
    you just have to add a extra text file or what ever but this will give you some ideas
      import java.awt.*;
    import java.net.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    public class a extends Applet implements ActionListener {
    Button button = new Button("click");
    TextField field = new TextField(20);
    JFrame frame = new JFrame();
      String gg;
    public void init() {
      add(button);
       add(field);
       button.addActionListener(this);
    public void actionPerformed(ActionEvent eve) {
           if(eve.getSource() == button) {
                try{
                         gg = field.getText();
                     JOptionPane.showMessageDialog(frame, gg);
               } catch(Exception e) {}
    }hope this helps

  • Passing parameter to a dynamic page portlet

    We need to create a drill-down report using pl/sql, but it's not working when we passed a parameter. We did the following:
    1. Create a package and a store procedure.
    2. The store procedure creates the report and the look-and-feel of the report.
    3. Create a dynamic page with the following code:
    <ORACLE>DECLARE
    BEGIN
    mvdata.interbay_ops_rpts_pkg.ops_detail_procssr_rpt(p_processor);
    END;
    </ORACLE>
    4. Set the parameter to "public" in the "customization form display option".
    5. Create a page group and a page.
    6. Clicked on properties of page and then clicked on the parameter tab.
    7. Added a parameter named "p_processor_code"
    8. We also added the portlet parameter under the "portlet parameter values" and set the parameter to be a page parameter and select the name of the parameter and click OK.
    9. Launch the URL: ttp://iasdev01.bftg.com:7782/pls/portal/url/page/PG_GRP_DEVELOPMENT/PG_OPS_DETAIL_PROCESSOR?p_processor_code=DUBOIS.
    10. When we tried to launch the application we get an empty report(doesn't execute the parameter).
    11. Edit the page and went into layout mode.
    12. Click on the "edit default" of the dynamic page portlet and put the value of the parameter and it works without any problems.
    I don't understand why it doesn't take the parameter with the page url. Any help is greatly appreciated.

    I had more luck with PL/SQL items. Try something like this:
    declare
    zip varchar2(10);
    begin
    zip := portal.wwpro_api_parameters.get_value('zip', 'a');
    if zip='94065' then
       ... do something ...
    end if;
    end;Peter

  • Passing parameter in query dynamically

    -- I have a query that is stored in a table column, the query contains a parameter 
    -- I tried to pass the parameter, but failed. How can I accomplish this task?
    CREATE TABLE #testFullQuery(longString varchar(Max))
    INSERT INTO #testFullQuery(longString) VALUES ('SELECT * FROM @NewValue');
    DECLARE @SourceCode nvarchar(MAX);
    SELECT @SourceCode = longString FROM #testFullQuery
    DECLARE @NewValue VARCHAR(MAX) = 'TableName';  
    DECLARE @FullQuery nvarchar(MAX);
    SET @FullQuery = '';
    SET @FullQuery = @SourceCode 
    EXEC sp_executesql @FullQuery;
    print @fullQuery, @NewValue
    l__j

    Simply replace the placeholder with the value of the variable:
    DECLARE @testFullQuery TABLE (longString varchar(Max))
    INSERT INTO @testFullQuery(longString) VALUES ('SELECT * FROM @NewValue');
    DECLARE @SourceCode nvarchar(MAX);
    SELECT @SourceCode = longString FROM @testFullQuery
    DECLARE @NewValue VARCHAR(MAX) = 'TableName';
    DECLARE @FullQuery nvarchar(MAX);
    SET @FullQuery = '';
    SET @FullQuery = REPLACE(@SourceCode,'@NewValue',@newValue)
    EXEC sp_executesql @FullQuery;
    print @fullQuery

  • Parameter to applet - applet as app

    Hi,
    I want to use applet(third party) as application in client machine.
    applet running fine in browser (needs signing file as parameter)
    but my problem is how can i pass parameter to applet, if i want it to in dialog(application)
    i can't change applet code, i have to use it as application.
    any clue or suggestion is helpful.
    Thanks

    I've never tried this, but maybe your app can create a java.applet.AppletStub, and then after instantiating the applet call setStub on it.

  • Passing parameters to an applet dynamically

    I am looking for suggestions on how I can pass parameters to my applet which generates a simple bar graph. If I pass parameter names and values using HTML tags the number of bars are fixed. I want my applet to accept variable number of values for the x and y axes.

    Then use a JSP for the HTML page. This can then pass dynamically generated numbers as params. Alternatively, your applet could communicate to the server through a Socket (package java.net) - although this can cause problems if there are firewalls inbetween client and server.

  • How to Pass parameter to Custom Scheduler dynamically

    hi ,
    I am new to OIM.
    Need your help in passing parameters dynamically to Custom Scheduler.
    I have created Custom Scheduler by extending Task Support.
    I have registered the plugin through API , using PlatformService.registerPlugin() method.
    As I need to send the parameter(s) to this CustomScheduler, I have defined them in Metadata (CustomScheduleTask.xml) file as below and got it imported into DB
    through weblogicImportMetadata.sh script by providing the path of the file.
    <scheduledTasks xmlns="http://xmlns.oracle.com/oim/scheduler">
    <task>
    <name>CustomScheduleTask</name>
    <class>org.schedule.custom.task.CustomScheduleTask</class>
    <description>Fetch details of the given user_id</description>
    <retry>5</retry>
    <parameters>
    <string-param required="true" helpText="Login Name">Login Name</string-param>
    </parameters>
    </task>
    </scheduledTasks>
    Iam able to import this plugin as well as register the plugin successfully. Now I have defined a job to which this Custom SchedulerTask is mapped.
    Now in order to run this job(schedule task) I need to provide Login name( or id) which needs to be send as a parameter for the scheduler to get executed.
    But while defining the job with this Schedule Task on OIM console, I was not able to define or pass parameter to this job. hence parameter is null in
    CustomSchedule 's execute method .
    Kindly help me how to pass parameter dynamically while running the scheduler from OIM console so that the execute method would be able to receive it.
    Thank you in Advance.
    Regards,
    Kumar

    Hi,
    When you have created the schedule job for your custom schedule task, you should see your Login Name textfield in the schedule task. If not, then there verify your schedule task xml.
    In your schedule class code, add:
    public void execute(HashMap arg0) {
              final String METHOD_NAME = "execute :: ";
              logger.debug(CLASS_NAME + METHOD_NAME + "Entering Method - execute");
              try {
                   String LoginName = arg0.get("Login Name");
    Regards,
    Sunny

  • Passing parameter between two applets

    hi all,
    i want to pass parameter between two applets. in other words, when user clicks the button; close the running applet, pass parameter to another applet and run another applet.
    now i think that could be, ( creating a parameter table in database, when user click on button write parameters to table and stop active applet and run other applet. when other applet runs in init methot it takes parameter from table). but it will be very indirect way.
    if you have an idea or information, plesae tell me.
    thanks for your interest

    Hi ,
    Plz pay a visit to this wonderful website,
    http://www.rgagnon.com/javadetails/java-0022.html / http://www.rgagnon.com/howto.html
    Best Wishes,
    Gaurav
    PS : Thanks to Real Gagnon. This is all I can do at this stage, but wanted to say you are doing a wonderful job.

  • Passing unicode parameter to applet

    Dear all,
    I would like to pass some unicode "\uxxxx" as parameter using <param XXXX> to an applet; however, when the applet tried to display these unicode in its textfield, it displays the string "\uxxxx" instead of the chinese character. It seems it treats that as several characters instead of one. Is there any special method to pass unicode parameter to applet? if not, is there way to convert "\uxxxx" back as treated as a single character?
    Thank you!

    pass the unicode code point (only the int value without \u) as parameter, then something like:
    String s = getParameter("character");
    String v1 = new String(Character.toChars(Integer.parseInt(s)));should convert the codepoint to a String containing the unicode character. I cannot check it here so please keep me informed if it worked ok,
    lars.

  • Parameter passing from java applet

    Hi all.
    currently i'm trying to create online testing applet (like TOEFL exam) for fun.
    i've create basic testing rutine, but i got stuck on showing the results.
    i want to show the results on the HTML so that users can print it out easily. but i donw know how to pass parameter from Java to some other language.
    I've searched for JavaScript, but it seems that it's only possible when using NetScape. Also, I searched for PHP, but it's just not possible. HTML seems that it's only possible from "HTML to Java"...
    if anyone knows how i can do it, and which language i should use, please let me know.
    thanx!

    i want to print out the questions that user have mistaken. print out the question, wrong answer, and right answer.
    all the answers are created by radiobutton so i want to get the only the Strig values, which wouldn' be so difficult.
    I've searched about JSObject, but could u tell me where can i install the package (or SDK)?
    And do users need to install the package as well?
    thanks for your time.

  • Pass parameter to page fragment in dynamic region

    Hello.
    I am using Jdeveloper 11.1.1.3.
    Can anyone explain to me how to pass parameter to page fragment in dynamic region?
    My situation is:
    I have only 1 page: index.jspx.
    This page include 2 elements:
    1. <af:tree>
    <af:tree id="t1" var="node" rowSelection="single"
    value="#{bindings.FpsrVO1.treeModel}" rendered="true" expandAllEnabled="true"
    contentDelivery="lazy" initiallyExpanded="false"
    contextMenuSelect="false" fetchSize="-1">
    <f:facet name="nodeStamp">
    <af:commandLink id="cl1" rendered="true"
    actionListener="#{backingBeanScope.RegionDynamicBean.treeClick}">
    <af:outputFormatted id="outForm" value="#{node.Name}" rendered="true"/>
    <f:attribute name="menuId" value="#{node.Code}"/>
    </af:commandLink>
    </f:facet>
    </af:tree>2. <af:region> :
    <af:region value="#{bindings.dynamicRegion1.regionModel}"
    id="r1"/>Region could be changed to 3 bounded taskFows wich have only one page fragment.
    Can anyone explain to me how i can send <f:attribute name="menuId" value="#{node.Code}"/> from tree element to page fragment which will be rendered on screen?

    You can pass a map to the dynamic region which would take the task flow parameters as key-value pairs.
    <taskFlow id="dynamicRegion1"
    taskFlowId="${backingBeanScope.TestPageBean.dynamicTaskFlowId}"
    activation="deferred"
    xmlns="http://xmlns.oracle.com/adf/controller/binding"
    parametersMap="#{backingBeanScope.TestPageBean.parameters}"/>
    When reloading the taskflow, ensure that the necessary parameters are loaded into the taskflow.
    Check this example exactly based on your use-case:
    http://adfsampleapplications.googlecode.com/svn/trunk/TaskflowParamSampleApp.zip
    Thanks,
    Navaneeth

  • Pass Parameter Value Dynamically in Pivot

    Hi All,
     I have sql Query and I am filtering the query based on two dates in Sql editor.
     Now I want to pass values to this two dates from PowerPivot dynamically and fetch the data.
    Can any one help me how can I pass the date values dynamically to the query and fetch the data in Power Pivot or Power Query
    Thanks,
    Sid

    Please have a look at these links:
    Implement Parameters using Slicers in #powerpivot #dax #tabular
    PowerPivot and query parameters
    Dynamically filtering data before importing from SQL Server in Excel
    “Drill Across” in PowerPivot – Live Demo
    sqldevelop.wordpress.com

  • Import statement: pass parameter or variable in import statement ??

    Hi All..
    Is there a way to pass parameter or a variable to a url in the import statement..
    I'll be using a url in the import statement, the url will be having a dynamic .rtf file...something like
    <?import:http://#server#:#port#/xmlpserver/<mySubTemplate>.rtf?>
    where <mySubTemplate> is dynamic..
    I've been searching this thread for a while now and ended up close...
    Import sub template dynamically
    Thanks in Advance..

    Have you tried replacing the mySubtemplate.rtf part with a variable, or replace the entire URL using a variable? Try using the same construct from this example in the Report Designer's guide (page 7-14, 10.1.3.4).
    In Microsoft Word's Format Picture dialog box select the Web tab. Enter the
    following syntax in the Alternative text region to reference the image URL:
    url:{IMAGE_LOCATION}
    where IMAGE_LOCATION is an element from your XML file that holds the full
    URL to the image.
    You can also build a URL based on multiple elements at runtime. Just use the
    concat function to build the URL string. For example:
    url:{concat(SERVER,'/',IMAGE_DIR,'/',IMAGE_FILE)}
    where SERVER, IMAGE_DIR, and IMAGE_FILE are element names from your XML
    file that hold the values to construct the URL.
    This method can also be used with the OA_MEDIA reference as follows:
    url:{concat('${OA_MEDIA}','/',IMAGE_FILE)}

  • How to get month value from custom calendar without passing parameter from SSRS in MDX query

    Could you please throw some light to achieve below requirement?  
    I need to filter the data between two periods dynamically . The date calendar here works differently(ex:-Date 26-Aug-2014 will fall in period 7 which is last date and 27-Aug-2014 will fall in period 8 and it is first date of period 8),so I cannot go
    with system date period/Month. Date Hierarchy is like YEAR,QUARTER,PERIOD ,WEEK and DAY.
    I cannot use SSRS for passing parameter. Requirement is to extract last 2 period of data dynamically in Power Pivot with MDX.
    Thanks Chandan

    Hi Chandan,
    You might try something like this
    Tail(null:
    Extract(
    StrToMember("[FYDay].[DATE].&[ + cStr(Format(Now(),"yyyy-MM-ddT00:00:00")) + "]")
    *[FYDay].[DateHierarchy].[Day]
    ,[FYDay].[DateHierarchy]).parent.parent
    ,2)
    What it is doing is multiplying Day by the current date, which returns a set of one date with cardinality of (Date,Day).  The Extract is pulling out just the datehierarchy Day.  the the Tail() is getting it and the previous day.
    Hope that helps,
    Richard

  • Error while passing parameter in Oracle Jdeveloper

    Hi All,
    I was passed Crystal report viewer object  From Servlet it is Running fine but one problem in that while passing parameter from that page  to data base it is not supporting (The ok Button on page).
    can any one tell me how to find Action Button (.Jsp page)
    Because i am using .jsp  page That was made in CR4E
    in that i found only jsp code I have not get how to work Action of that button
    Also another problem while making Viewer.jsp pge ..rpt-Crystal reports--->>Create Viewer Jsp->>Insert CrysatlReport viewer API code------->>>1.Connectparameterinthat report 2.connect the crystalreportPageViewer  while makin this page  i was running on Apache tomcat Server it is not displaying Anything only Displaying Blank Browser
    Can Any one help me...
    Sincerly
    Amol

    For your first question can you please be a little more clear as to what you are referring to?  I am not familiar with an action button for the parameter pages.... what I can tell you is that we don't have any jsp code for the viewer controls, all of that is generated dynamically at runtime.  We do have a viewer SDK that you can use to set properties on the viewer; information about this can be found in the [Developer Library|https://boc.sdn.sap.com/developer/library] in the Viewer SDK documentation book.
    For your second question, I assume you are referring to generating a viewer page from a report in Crystal Reports for Eclipse.  You will need to uncomment the viewer code (for some reason when the page is generated, the viewer code has block comments surrounding it).  You will probably want to make sure the parameter code is uncommented as well. 
    In addition to this, there is a helper file called JRCHelperSample.java that contains all of the helper methods for the automatically generated viewer page.  This can be modified in whatever way you wish to suit your needs.

Maybe you are looking for

  • "The request failed with HTTP status 401: Unauthorized"

    Hi, I'm trying to get both RSS feeds and SSRS reports on a web application which is having NTLM authentication without Kerberos. The catch is proxy setting, if I give <proxy autoDetect="false" /> in web.config of my sharepoint web application SSRS re

  • How do I start the Setup Assistant???

    Okay, so I upgraded to Leopard, but the Setup Assistant got stuck on the "connecting" page during registration and stayed like that for an hour. I had no choice but to cancel and disconnected -- and that froze for another 20 minutes. So, I closed the

  • Database link create but not fatch data from link database give me this err

    Sir I create database link with this command system create link but when I user query then system give me this error you see in blow SQL> create database link xyz connect to mfatest identified by mfa786 using 'aamir'; Database link created. SQL> sele

  • There i something stuck in my disk drive

    My macbook pro has something stuck in the disk drive can i fish it out or something? im scared to open it or void warranty

  • Why is the sound like this?

    Hi there. I have just finished one of my project, and now I notice, that when the person talks, starting at 1:05, the sound is not that good. Why is it? It sounds perfect on my computer when I play it. So what is wrong?? http://vimeo.com/3682191