How to execute code written in java before javascript?

Hello,
is there any way to call the action or actionlistener method of a commandbutton (for instance, or any other component), before javascript is executed? (jsf 1.2_09, glassfish v2.1)
Eg: I want to open a new window with javascript for the details/editing of a row in a data table. To do so I use a request scoped backing bean for the new window, and in its constructor I pass the rowdata through the session map where I put the object beforehand using an actionlistener/action.
But this won't work, because the script happens before I can put the variable in the session map...
Is there an other way?
thanks
david

only thing I can come up with is to submit the data using Ajax. So do an Ajax call (for example using JQuery) to submit an asynchronous request to some servlet that will put the data in the session bean, then when the Ajax call finishes open the window.

Similar Messages

  • How to execute Linux command from Java app.

    Hi all,
    Could anyone show me how to execute Linux command from Java app. For example, I have the need to execute the "ls" command from my Java app (which is running on the Linux machine), how should I write the codes?
    Thanks a lot,

    You can use "built-in" shell commands, you just need to invoke the shell and tell it to run the command. See the -c switch in the man page for your shell. But, "ls" isn't built-in anyays.
    If you use exec, you will want to set the directory with the dir argument to exec, or add it to the command or cmdarray. See the API for the variants of java.lang.Runtime.exec(). (If you're invoking it repeatedly, you can most likely modify a cmdarray more efficiently than having exec() decompose your command).
    You will also definitely want to save the returned Process and read the output from it (possibly stderr too and get an exit status). See API for java.lang.Process. Here's an example
    java.io.BufferedReader br =
    new java.io.BufferedReader(new java.io.InputStreamReader(
    Runtime.getRuntime().exec ("/sbin/ifconfig ppp0").
    getInputStream()));
    while ((s = br.readLine()) != null) {...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to execute code from a text file?

    Hello all!
    How to execute some code lines from a text file? For example my file is:
    String varname = "somecontents";
    JFrame frame = new JFrame();
    frame.setVisible(true);How can I get contents of this file and parse them if I want get new JFrame and access to the variable varname?

    I mean the PHP would generate a readable Java source,
    for example some variables with some data, and I just
    dont know what to do with file if I want generate the
    xls file from my saved data, could You help? :)Some variables, some data, PHP, Java, XLS file??? Al rather vague.
    You need to explain in more detail what it is you're trying to do if you want an answer to your question!

  • How to execute .msi files from java program

    Hi friends,
    i have written a java program which invokes and thereby execute any executable files like .exe and .bat.
    So its working fine with .exe and .bat files, but it is not working with .msi files.......can you please help me how can i execute .msi files as well??
    public class Executeexe {
         public static void main(String ar[])
              try
              Process p=null;
              Runtime rt=Runtime.getRuntime();
              p=rt.exec("D:\\mysql-essential-5.0.83-win32.msi");
              p.waitFor();
    catch(Exception e)
    }here is the program

    Make sure that the command that's being exec'd works from the cmd line.
    Then read this article and do what it says:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    Then if you still are having problems explain what "...it is not working with .msi files..." really means, and provide a [SSCCE Example program|http://mindprod.com/jgloss/sscce.html]

  • How to execute PL/SQL from Java?

    I want to execute (compile) a PL/SQL file to a database and I don't know how it can be done with Java.
    Please note that I am NOT trying to call a stored procedure. I know that can be done with CallableStatement.
    Background:
    My actual requirement is to execute PL/SQL files with error notifications. I tried Ant SQL task; but it fails to give compilation error information. I also tried another open source task called Incanto - that also not that helpful as if I execute in bulk, very hard to figureout which one throws error. Hence I decided to write my own Ant task.

    Hi,
    do u want to execute PL/SQL files? or just you want to execute the block of code?
    in the case of PL/SQL file:
    you need to read total file as StringBuffer/String and then execute.
    Block of code:
    you can directly pass the code to the java file as input and then execute.
    Ex:
                   StringBuffer queryString = new StringBuffer();
                    queryString = queryString.append("BEGIN execute immediate ' ");
              queryString = queryString.append(query);
              //queryString = queryString.append("BEGIN dbms_job.run(142);END;");
              queryString = queryString.append(" '; END; ");
              final_Query = queryString.toString();
              try {
                   System.out.println("final :   "+final_Query);
                   cstmt = con.prepareCall(final_Query);
                   System.out.println("Job is Running...");
                   new ThreadCountdownExtThread().start();
                   System.out.println("bfore execute()...............");
                   cstmt.execute();Note: if you are running pl/sql file read file and save it in a Stirng , and then do the same as above stated

  • How to execute external program in java?

    My question is how to execute an external program in java.
    I need to call a unix command in java.
    Thanks.

    it depends on what you are trying to do. Following are the two methods
    1. Runtime.exec() : this method allows you just to call an external program as a seperate process
    2. JNI (Native Interface) :- As of right now only C and C++ are supported by this method. This method allows you to directly call the C/C++ methods from JAVA

  • How to generate code in Sun Java Studio Enterprise 8

    Do I miss something? I can�t find how to generate code from UML model, which is not reversed from code. Documentation also does not speak about this.
    Code update works fine if project is reversed from code, but if in such reversed model I create new class it does not appear in code and context action "Generate Code" is missing for such class.
    I use Sun Java Studio Enterprise 8

    Thank you for replay, may steps are same:
    1. I have created Java Project With Existing Source
    2. selected directory with code (not whole project but directory with java classes)
    3. After that I have created UML Java Specific project and
    4. Associated UML project with previous created java project
    5. I have selected "Code Generation" check box
    6. Classes from java project were reversed into UML model.
    7. After that I have created new class in java project.
    And there is no Generate code action in this class context menu, also this class do not appeared in code automatically.
    From UML project properties it is shown that UML project is associated with proper java project)
    Same is with Java Application project associated with UML java project.
    Documentation do not talks more about this. Only same steps. It looks like code generation should be working but it isn't. I'm I only one who face this problem, or do smth wrong?

  • Hyperlink - How to execute it action function(Java) and then JavaScript

    Hi all, I have a hyperlink in a popup window. When the hyperlink is clicked I want it's action function to be executed. This works fine, the problem is when I put java code in the hyperlink's javascript onClick() function, only the onClick() gets called and not the action function.
    I need the onClick to close the window and submit the main form and I need the action function to set some session variable.
    Thanks in advance for any replies.

    Hi, thanks to anyone that read my post. I found a solution. I removed the code from the hyperlink's javascript onClick and placed it the body onload javascript function. I also set a flag to true when the hyperlink is clicked and only execute the code in the body onLoad() when the flag is true.

  • How to execute jar file in java project

    hi,
    i have made a proj in java in which i have put all my files in a jar file.
    can somebody help me how to execute this jar file??
    thanks

    u can put that jar file in ur class path,,
    regards
    shanu

  • How to execute a backing-bean method before loading JSP Page?

    Hi everybody.
    Scene:
    An AdfForm, with
    -SelectChoice, referenced to a <list> of pageDef, which is referenced to an ADF BC.
    Goal:
    -Executing the query of the ADF BC before load the SelectChoice, to load the correct values.
    A good question to know:
    Exists any way to execute a method of backing before loading a JSP Page?
    Any similar to onload method of javascript. It could be fantastic.
    Thanks in advance,
    Jaime

    hi Jaime
    If I understand correctly, you are using the ADF Model for data binding.
    Because your goal is "Executing the query of the ADF BC ...", maybe you can also consider to refresh an executable in your Page Definition.
    See also "10.5.5 How to Use Refresh Correctly for InvokeAction and Iterator Bindings"
    at http://download.oracle.com/docs/html/B25947_01/bcdcpal005.htm#BJECHBHF
    It says "... You can use the Refresh property on iterator bindings and invokeAction executables in your page definition to control when each are evaluated during the ADF page lifecycle, either during the prepareModel phase, the prepareRender phase, or both. ...".
    Although you have posted your question in a structured way, which is a good thing, I think it would help to understand your question if you can explain how you determine "the correct values" for your list, what is varying?
    success
    Jan Vervecken

  • How to execute another application from java ?

    I want to execute another application ( not java ) from my java application. Is it possible ? How can we do it ? Please guide me...
    thanx

    Hi littlestuart,
    Yes it's possible.
    Your question is frequently asked, please search the forum or google for an answer.
    /Kaj

  • How to execute .bat file through java?

    I already create a batch file to pull & push file. Now, i want to execute this .bat file java.I got this example but it doesnt work. Did i missed something or do we have the better one?
    import java.lang.*;
    import java.io.*;
    public class Loadfile
    public static void main(String args[]) throws IOException
    Runtime load = Runtime.getRuntime();
    r.exec("C:\\pull.bat");
    }

    For Runtime,i'd change it to:
    Runtime load = Runtime.getRuntime();
            String cmd = "C:\\javaclass\\copytemp.bat";
            Process proc = load.exec(cmd.toString());Is it right? But still can't work.
    Here is the .bat file:
    @echo off
    c:
    cd "c:\Inetpub\ftproot\Debitin"
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo open localhost
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo Administrator
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo password
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo cd ftpScript
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo binary
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo lcd C:\
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo lcd "C:\Inetpub\ftproot\infile"
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo prompt n
    pause
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo mget *.txt::@rem >> C:\Inetpub\ftproot\Logrecord\pullscript.txt echo mdel *.*
    C:\Inetpub\ftproot\Logrecord\pullscript.txt echo byeftp.exe -s:C:\Inetpub\ftproot\Logrecord\pullscript.txt
    ::del C:\Inetpub\ftproot\Logrecord\pullscript.txt
    pause
    exit
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to execute ".exe" files using java

    Hi,
      This is guruvulu,
         I have a problem in executing ".exe" files.For Example InternetExplorer.

    Hi,
    You can execute .exe files in JAVA using the following code.
    Runtime rt1 = Runtime.getRuntime();
    Process pc = rt1.exec("someexe.exe");
    you can get the output of the executed exe file in
    in = pc.getInputStream(); //this returns a InputStream
    hope this solves your problem.
    regards,
    P.Venkat

  • How to execute dos command in Java program?

    In Perl, it has System(command) to call dos command.
    Does java have this thing?
    or any other way to execute dos command in java program?
    Because i must call javacto compile a file when the user inputed a java file name.

    Look in the Runtime class, it is implemented using the Singleton design pattern so you have to use the static method getRuntime to get its only instance, on that instance you can invoke methods like
    exec(String command) that will execute that command in a dos shell.
    Regards,
    Gerrit.

  • How to execute SAPgui.exe from java code

    Hi All,
    Can any one provide me the exe file name of SAP GUI related.
    I need to call the SAP GUI related exe file from java.
    i tried with a small java prog which executes the exe files.
    it works fine with notepad.exe,javac.exe . But i am unable to execute the SAPgui.exe.
    This is my java code
    try{
         Runtime rt=Runtime.getRuntime();
    //String str= "C:
    WINNT
    system32
    notepad.exe";
    //Process pp=rt.exec("C:
    j2sdk1.4.2_08
    bin
    javac");
    Process pp=rt.exec("C:
    Program Files
    SAP
    FrontEnd
    SAPgui
    SAPgui.exe");
    BufferedReader br=new BufferedReader(new InputStreamReader(pp.getErrorStream()));
                         String line;
                         while ((line = br.readLine()) != null) {
                             System.out.println(line);
              }catch(Exception e){
                   System.out.println(e);
    and may i pass any additional parameters inorder to invoke this exe.
    Please share your ideas abt  this problem.
    Its Urgent PLZ
    Adv Thanks
    Regds
    Phani.

    hi Rajesh,
    here my complete code:
              try{
                   Runtime rt=Runtime.getRuntime();
    //               String str= "C:\Programmi\SAP\FrontEnd\SAPgui\saplogon.exe";
                   String str= "C:\Programmi\SAP\FrontEnd\SAPgui\Sapgui.exe 10.113.10.201 00";
                   //               Process pp=rt.exec("C:\j2sdk1.4.2_08\bin\javac");
                   Process pp=rt.exec(str);
                   BufferedReader br=new BufferedReader(new InputStreamReader(pp.getErrorStream()));
                   String line;
                   while ((line = br.readLine()) != null) {
                   System.out.println(line);
                   }catch(Exception e){
                   System.out.println(e);
    Please note that system number is only two digit and in your case is 00.
    Another important think, i'm using the italian version of windows, so the program directory is c:\programmi, please change into c:\program files, or you can modify your code to be language indipendend using an system environment variable (if exist).
    Hope this help
    Francesco

Maybe you are looking for

  • No more sound to USB midi device Alesis iMultimix8USB

    Hello After playing hours and days without any problems it's no longer possible to communicate with my Alesis midi device iMultimix8USB. I did all the latest updates. I did on my macbook pro too and it the device is working there fine. So the device

  • Format a seagate external hard drive

    wondering if anyone can help me to format my seagate 500GB hard drive so i can you the hard drive on a PC and my mac book pro. what do i need to do and what type of format do i need to do.

  • Proxy Server "freeze" when are not request for a long time

    hi... i have the followin problem that i can't find a solution yet.. my context are: - sun java web proxy server v4.0.5 - sun java one directory server where i have my users that can use proxy - between this servers i use a self signed certificate th

  • Web session variables in Begin_SQL

    Is it possible to access web session variables using @variable (or any other means) from within a Begin_SQL?  In particular, we want the end-user's IP address (not the IP address of the BO server).

  • Dusted & Disgusted

    Im embarrassed with my iPhone, and frustrated with it as well. This isnt the first time Ive purchased an Apple first-release (MBP also had several rookie mistakes), but it is my last. Mail is the source of my problems. - No spam filter means I get in