Getting return value from webengine.executescript when embedded in Swing

Hi,
Got a WebView embedded through a JFXPanel in a Swing app. I'm now trying to get some value back from the WebEngine.executeScript method in a synchronous way.
All examples I can find on Swing embedding use Platform.runLater, which of course doesn't return the value straight away.
Through some digging I found PlatformImpl.runAndWait(Runnable) and when I use that I do get a synchronous call and thus the return value of Webengine.executeScript immediately.
Question now is if it's save for me to use PlatformImpl.runAndWait(Runnable) or if I should refrain from using it for some reason. I wasn't able to find anything on the topic, but so far in my tests if seems to work fine.
Only thing I found were 2 implementations of sort of the same functionality: http://www.guigarage.com/2013/01/invokeandwait-for-javafx/ and https://code.google.com/p/jacp/source/browse/branches/working/JACP.JavaFX/src/main/java/org/jacp/javafx/rcp/worker/AFXComponentWorker.java (invokeOnFXThreadAndWait method)
TIA,
K.

Using the impl method for run and wait is not advised as it may be removed in a future JavaFX version.
However you can easily copy the source of this simple method to create your own implementation:
See the following thread for details:
http://markmail.org/message/kaui2t34ufx3vdwe
Note that in making what is normally an asynchronous call synchronous, you must be careful to avoid deadlock and UI freezing performance issues.

Similar Messages

  • How to get the values from a html form embedded in a swing container

    Hi all,
    I am developing an application in which i have to read a html file and display it in a swing container.That task i made it with the help of a tool.But now i want to get the values from that page.ie when the submit button is clicked all the values of that form should be retrived by a servlet/standalone application.I don't know how to proceed further.Any help in this regard will be very greatful
    Thanks in advance,
    Prakash

    By parsing the HTML.

  • How to get return value from Java runtime.getRuntime.exec?

    I'm running shell commands from an Oracle db (11gr2) on aix.
    But, I would like to get a return value from a shell comand... like you get with "echo $?"
    I use a code like
    CREATE OR REPLACE JAVA SOURCE NAMED common."Host" AS
    import java.io.*;
    public class Host {
      public static int executeCommand(String command) {
        int retval=0;
        try {
            String[] finalCommand;
            finalCommand = new String[3];
            finalCommand[0] = "/bin/sh";
            finalCommand[1] = "-c";
            finalCommand[2] = command;
          final Process pr = Runtime.getRuntime().exec(finalCommand);
          pr.waitFor();
       catch (Exception ex) {
          System.out.println(ex.getLocalizedMessage());
          retval=-1;
        return retval;
    /but I do not get a return value... because I don't know how to get return value..
    Edited by: user9158455 on 22-Sep-2010 07:33

    Hi,
    Have your tried pr.exitValue() ?
    I think you also need a finally block that destroys the subprocess
    Regards
    Peter

  • How to get return values from stored procedure to ssis packge?

    Hi,
    I need returnn values from my stored procedure to ssis package -
    My procedure look like  and ssis package .Kindly help me to oget returnn value to my ssis package
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author: <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description: <Description,,>
    -- =============================================
    ALTER PROCEDURE [TSC]
    -- Add the parameters for the stored procedure here
    @P_STAGE VARCHAR(2000)
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    -- Insert statements for procedure here
    --SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
    truncate table [INPUTS];
    INSERT
    INTO
    [INPUTS_BASE]
    SELECT
    [COLUMN]
    FROM [INPUTS];
    RETURN
    END
    and i am trying to get the return value from execute sql task and shown below
    and i am taking my returnn value to result set variable

    You need to have either OUTPUT parameters or use RETURN statement to return a value in stored procedures. RETURN can only return integer values whereas OUTPUT parameters can be of any type
    First modify your procedure to define return value or OUTPUT parameter based on requirement
    for details see
    http://www.sqlteam.com/article/stored-procedures-returning-data
    Once that is done in SSIS call sp from Execute SQL Task and in parameter mapping tabe shown above add required parameters and map them to variables created in SSIS and select Direction as Output or Return Value based on what option you used in your
    procedure.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Getting Return values from RFC function call with visual basic

    Hi,
    I am creating a sample app to connect to a SAP system which call its RFC functions created with ABAP. It was known that the function will return more than 1 return values.
       SAP Function name ==> "ZFMTP_RFC_GET_RESULT"
            Export parameters (to SAP):
                    - Student Name [char 10]         ==> "STUNAME"
                    - Student ID         [char 20]        ==> "STUID"
           Return values (From SAP):
                    - Results [char 10]        ==> "RESULT"
                    - Remarks [char 200]        ==> "REMARKS"
    i have managed to get sample codes for connecting and call a RFC function with vb but they only get a return value. How do i retrieve multiple return values like the above function "RESULT" and "REMARKS"?
    Here's my vb code to accessing the function
            Dim R3 As Object
            Dim FBFunc As Object
            Dim returnFunc As Boolean
            Dim connected As Boolean
            R3 = CreateObject("SAP.Functions")
            R3.Connection.Client = "000"
            R3.Connection.User = "BCUSER"
            R3.Connection.Password = "minisap"
            R3.Connection.Language = "DE"
            R3.Connection.System = "dtsystem"
            R3.Connection.Applicationserver = "xxx.xxx.xxx.xxx" 
            connected = R3.Connection.Logon(0, True)
            If connected <> True Then
                MsgBox("Unable to connect to SAP")
            End If
            FBFunc = R3.add("ZFMTP_RFC_GET_RESULT")
            FBFunc.exports("STUNAME") = "Jonny"
            FBFunc.exports("STUID") = "12345"
            returnFunc = FBFunc.Call() <<== How do i get the return value? or RESULT and REMARKS of the RFC Function?
    thanks alot.
    Edited by: Eugene Tan on Mar 4, 2008 7:17 AM

    Hi Gregor,
    Thanks for the link....i am having some doubts with the codes, hope you can clarify them for me if you know the codes..
    Below is the code snippet.
    Set impReturn = CHPASS_FN.Imports("RETURN")  <<=== is RETURN the standard keyword to get a                                                                                return object?
      expPassword.Value = currpass
      expNewPass.Value = newpass
      expFillRet.Value = "1"
    ''' Call change password function
      If CHPASS_FN.Call = True Then
        outFile.Write (", Called Function")
        Message = impReturn("MESSAGE") <<==== So if i have 3 return values..i just replace with the return                                                               value variable names?
        outFile.WriteLine " : " & Message
      Else
        outFile.Write (", Call to function failed")
      End If
    thanks alot...all your help is very appreciated.

  • How to get return value from java and read by other application?

    i want to read return value from java and the other application read it.
    for example:
    public class test_return {
        test_return(){
        public int check(){
            return 1;
        public static void main(String args[]){
           new test_return().check();
    }from that class i make as jar file. How to read the return value (1) by other application?
    thx..

    If your installer is requiring some process it invokes to return a particular value on failure, then the installer is seriously broken. There are a bazillion commands your installer could invoke, and any of them could fail, which in turn could invalidate the entire install process, and any of them could return any value on failure. The only value that's consistent (in my experience) is that zero means success and non-zero means failure, with specific non-zero values being different in different programs.
    About the only control you have over the JVM's exit code is that if your main method completes without throwing an exception, the JVM will have an exit code of 0, and if main throws an exception (either explicitly or by not catching one thrown from below), it will be non-zero. I'm not even sure if that's guaranteed, but I would guess that's the case.
    EDIT: I'm kind of full of crap here. If you're writing the Java code, you can call System.exit(whatever). But nonetheless, if your installer requires certain exit codes from any app--java or otherwise--you have a problem.
    Edited by: jverd on Oct 29, 2009 1:27 AM

  • Error getting return value from function

    Hello
    I'm getting a error calling a function with ODP.NET from C#
    Code:
    OracleCommand oraCom = new OracleCommand("NORMALIZACION.nif",oraCon);
    oraCom.CommandType = CommandType.StoredProcedure;
    OracleParameter param1 = new OracleParameter("numnif",OracleDbType.Varchar2);
    param1.Value= "73667866A";
    param1.Direction = ParameterDirection.Input;
    OracleParameter param2 = new OracleParameter("nif",OracleDbType.Varchar2);
    param2.Size = 10; //FIXME line
    param2.Direction = ParameterDirection.ReturnValue;
    oraCom.Parameters.Add(param1);
    oraCom.Parameters.Add(param2);
    oraCom.ExecuteNonQuery();
    nif_norm = oraCom.Parameters["nif"].Value.ToString();
    if i write the FIXME line i get a error (ORA-06502) complaining about the size, no matter the value i wrote.
    If i don't write the FIXME line, it works but nif_norm is always empty, although the function i call is a single return 'Hello';
    Where am I wrong??
    Any help, examples with varchar2 as return value???
    BTW: the same code with the MS provider for Oracle works fine.

    Good point -- i shall do so.
    What I think I'm missing, in my quest for ODP.NET competence, is a solid set of example code. I've searched around and found various fragements here and there, but when it comes to data access from .NET there must surely be some finitie set of possibilities (if we can discount bad practices like building dynamic SQL statements without bind variables).
    For example, possibly in increasing order of complexity ...
    * Read a single value from a SQL statement ... "select emp_name from emp where rownum < 2"
    * Read a single value by passing in a parameter ... "select emp_name from emp where user_id = :?"
    * read multiple values ... "select emp_name from emp where user_id in (:?,:?)"
    * execute a stored procedure with no in or out parameters
    * retreive a value from a function with no parameters
    * pass a parameter to a stored procedure
    * read an out parameter from a stored procedure
    Then work with in and out ref cursors, blobs, whatever.
    Thoughts?

  • How to get return values from task flow in af:region ?

    Hi!
    I'm working with a taskFlow that is rendered inside a popup using the "popup inside a region pattern" (http://www.oracle.com/technology/products/adf/patterns/popupregionpattern.pdf), but now this taskFlow has an input parameter and a return value definition. So the question is how to get a value returned by this taskFlow thas is called inside a region?
    Any suggestion?
    Thanks in advance!

    Hi,
    write the value to a shared memory scope like session and read it in the regionNavigation listener. If you follow the paper you refer to then the listener determines of the viewId is null, this a return happens. It wuld then look in the memory scope for the return value.
    Another option would be to use an object that you pass as an argument to the task flow you open in the popup. Then you change the object you passed in, which then makes the return information available in teh calling flow. The object you pass in would have to be in a shared scope too
    Frank

  • How to get return values from region?

    I add a page flow as region into a page. The page flow has a return parameter. How to get the return value in parent page?

    I have been also intrigued by this question.
    There is however a workaround that you can set the values in requestScope.
    We can have a regionNavigationListener on the region and catch the end of taskflow if viewid is null.
    regionNavigationEvent.getNewViewId() == null
    Here we can read the request values and set wherever to be used.
    maniesh (sid)

  • Getting return value from sqlplus script while running a unix job

    I am trying to run a unix script that calls sqlplus. The following code outlines the unix/sql code that I trying to execute:
    return_count=`sqlplus $ORACLE_ID/$ORACLE_PWD@$ORACLE_SID <<EOF | grep '^RETURN_VAL' | sed 's/^RETURN_VAL//'
    SET SERVEROUTPUT ON
    VARIABLE ReturnValue NUMBER
    EXEC :ReturnValue := 1
    BEGIN
    UPDATE seq_control_nbr
    SET table_seq_nbr = table_seq_nbr + 1,
    last_updt_dttmstp = systimestamp,
    last_updt_user_id = 'ECVMSONS'
    WHERE table_key = 'ONSTAR';
    IF SQL%ROWCOUNT = 1 THEN
    COMMIT;
    :ReturnValue := 0;
    ELSE
    ROLLBACK;
    :ReturnValue := 99;
    END IF;
    DBMS_OUTPUT.PUT_LINE ('RETURN_VAL '||:ReturnValue);
    END;
    EXIT
    EOF`
    The above outlined sqlplus script does run because the values on the table are updated. However, I cannot get the value of ReturnValue to be displayed, so it can be returned to the unix script.
    Any ideas?

    ok do the following:-
    return_count=`sqlplus $ORACLE_ID/$ORACLE_PWD@$ORACLE_SID <<EOF
    SET SERVEROUTPUT ON
    whenever OSERROR exit 1
    whenever SQLERROR exit 2
    UPDATE seq_control_nbr
    SET table_seq_nbr = table_seq_nbr + 1,
    last_updt_dttmstp = systimestamp,
    last_updt_user_id = 'ECVMSONS'
    WHERE table_key = 'ONSTAR';
    EXIT
    EOF`
    rowsupdated=`echo $return_count|cut -f1 -d' '`
    echo "Rows updated =" $rowsupdated
    retcode=`echo $?`
    case "$retcode" in
    0) echo "Update executed successfully on " ;;
    1) echo "Update failed OSERROR ";;
    2) echo "Update failed SQLError " ;;
    *) echo "Update failed - Unknown Error ";;
    esac

  • Getting return value from sql funtion

    I have to following plsql.
    declare x number;
    begin
      x := PK_GET_STUDENT_ID(parm1, parm2 parm3);
    end;My question is how can I get the value of x so I can store it in a variable in side java? Please help.

    How should this callable statement look? I thought I could just remove the declare statement and then replace "X :=" with "?=" but that will not work b/c if I do that then how is it supposed to know what to put in the second statment. Will someone please help me out on how I should make statement look? I know I have to register the variable before I execute the statement but how do this is done. Obiviously I know the registerOutParameter(...) but which ones do I need so I can execute this statement?
    (PLSQL)
    ================
    " DECLARE X NUMBER; "+
    " BEGIN " +
    " X := DOSOMETHING?,?,?,?,?,?,?,?,?,?,?,?,?); " +
    " PK_CUSTOMER.ASSIGN_MAILING_CONTACT(?,?,X); " + "END; ";

  • How to get return values from a button to main program.

    hello,
    I have a main program which has a button Authenticate. On click of authenticate open a form for auth which has USERNAME FIELS AND PASSWORD.
    If entered fields are true then enable editing of jtable in main program..
    Basically something like this :
    //main program
    Authenticate.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    UpdateAuth ua=new UpdateAuth();// opens form which has username and pass for authentication
    ua.setVisible(true);
    //need code here for enabling table
    if(s=="mactus")
    enable table editing
    //table.repaint();
    // form open for auth..(class UpdateAuth )
    private String SigninMouseClicked(java.awt.event.MouseEvent evt) {
    String aname=Aname.getText();
    String apass=Apassword.getText();
    if(aname.equals("") && apass.equals(""))
    JOptionPane.showMessageDialog(null,"Enter login name or password","Error",JOptionPane.ERROR_MESSAGE);
    if(!(aname.equals("") && apass.equals("")))
    if(aname.equals("harshil") && apass.equals("harshil123"))
    String s="mactus"; /// if username and password is success enable table editing in main program
    return s;
    else if (!aname.equals("mactus") && !apass.equals("mactus123"))
    Aname.setText("");
    Apassword.setText("");     
    return null;
    }

    986154 wrote:
    hello,
    I have a main program which has a button Authenticate. On click of authenticate open a form for auth which has USERNAME FIELS AND PASSWORD.
    If entered fields are true then enable editing of jtable in main program..Well, you might be in over your head.
    //need code here for enabling table
    if(s=="mactus") If you don't know how to correctly test for String equality, you will have no chance of getting this to work.
    You need to hit the tutorials. First the basic one, then the Swing one.

  • How to get a value from JavaScript

    How to get return value from Java Script and catch it in c++ code. I have tried following code, but its not working in my case.
    what I want is if it returns true then call some function if it returns false then do nothing, so how to get those values in c++
    ScriptData::ScriptDataType fDataType = resultData.GetType();
    if (fDataType == kTrue)
           CAlert::InformationAlert("sucess");
           //call some function
                        else
                                  CAlert::InformationAlert("Error");
         // do nothing
    JavaScript Code:
        if(app.scriptArgs.isDefined("paramkeyname1"))
               var value = app.scriptArgs.get("paramkeyname1");
               alert(value);
                return true;
      else
               alert ("SORRY");
               return false;

    How to get java script result into JSResult i m not getting it.
    I have wriiten follwing code in c++ :
              WideString scriptPath("\\InDesign\\Source1.jsx");
              IDFile scriptFile(scriptPath);
              InterfacePtr<IScriptRunner>scriptRunner(Utils<IScriptUtils>()->QueryScriptRunner(scriptFi le));
              if(scriptRunner)
                        ScriptRecordData arguments;
                        ScriptIDValuePair arg;
                        ScriptID aID;
                        ScriptData script(scriptFile);
                        ScriptData resultData;
                        PMString errorString;
                        KeyValuePair<ScriptID,ScriptData> ScriptIDValuePair(aID,script);
                        arguments.push_back(ScriptIDValuePair);
                        PMString paramkeyname1;
                        Utils<IScriptArgs>()->Save();
                        Utils<IScriptArgs>()->Set("paramkeyname1",scriptPath);
                        Utils<IScriptUtils>()->DispatchScriptRunner(scriptRunner,script,arguments,resultData,erro rString,kFalse);
                        Utils<IScriptArgs>()->Restore();
                        ScriptData::ScriptDataType fDataType = resultData.GetType(); // here i should get true or false which i m passing it from javascript code......not as s_boolean
                        if (fDataType == kTrue)
                                       //CAlert::InformationAlert("sucess");
                                     iOrigActionComponent->DoAction(ac, actionID, mousePoint, widget);
                        else
                                    this->PreProcess(PMString(kCstAFltAboutBoxStringKey));
    Java script code:
    function main()
           var scrpt_var;
           var scriptPath,scrptMsg;
           var frntDoc=app.documents[0];
           if(app.scriptArgs.isDefined("paramkeyname1"))
               var value = app.scriptArgs.get("paramkeyname1");
                alert(value);
                 return true; // i want this value i should get in c++ code...How to get these values in c++
           else
              alert ("Error");
              return false; // i want this value i should get in c++ code...How to get these values in c++

  • [MDX]can't get the value from two variables (@FromDimTimeFiscalYearMonthWeekLastDateDay &(@ToDimTimeFiscalYearMonthWeekLastDateDay

    can't get the value from two variables when execute MDX : Anyone who can help ?
    ================================
    with member [Measures].[APGC Replied Volume] as
     ([Measures].[Question],[Dim Replied By].[Replied By].&[APGC])
    member [Measures].[APGC Moderated Volume] as
     ([Measures].[DashBoard Thread Number],[Dim Moderated By].[Moderated By].&[APGC])
    member [Measures].[APGC Answered Volume] as
     ([Measures].[Question],[Dim Answered By].[Answered By].&[APGC])
     SELECT
     NON EMPTY
     [Measures].[Forum Thread Number],
     [Measures].[Reply In24 Hour],
     [Measures].[Question],
     [Measures].[Deliverale Minute],
     [Measures].[Working minutes],
     [Measures].[Answered],
     [Measures].[1D Answer],
     [Measures].[2D Answer],
     [Measures].[7D Answer],
     [Measures].[APGC Replied Volume],
     [Measures].[APGC Moderated Volume],
     [Measures].[APGC Answered Volume],
    [Measures].[Avg HTR],
    [Measures].[Avg HTA],
     [Measures].[Total Labor]
     } ON COLUMNS, 
     NON EMPTY { ([Dim Engineer].[SubGroup-Alias].[Alias].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
    FROM (
     SELECT ( STRTOMEMBER(@FromDimTimeFiscalYearMonthWeekLastDateDay, CONSTRAINED) : STRTOMEMBER(@ToDimTimeFiscalYearMonthWeekLastDateDay,
    CONSTRAINED) ) ON COLUMNS
    FROM [O365]) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

    Hi Ada,
    According to your description, you can't get the member when using the strtomember() function in your MDX. Right?
    In Analysis Services, while the member name string provided contains a valid MDX member expression that resolves to a qualified member name, the CONSTRAINED flag requires qualified or unqualified member names in the member name string. Please check if the
    variable is a Multidimensional Expressions (MDX)–formatted string.
    Reference:
    StrToMember (MDX)
    If you have any question, please feel free to ask.
    Simon Hou
    TechNet Community Support

  • Return values for WebEngine's ExecuteScript function?

    Hey guys and gals,
    I'm trying to write some code to load a webpage and get some values from the POST header, but unfortunately I'm having trouble with the basics.
    I can't get the executeScript function to return a JSObject! I'm having no luck finding what the executeScript function decides to return based on input. Every time I run the Java code, executeScript returns me the value of the POSTresponses variable as a String. Or it return
    Any suggestions of what could be happening?
    Error message:
    "java.lang.ClassCastException: java.lang.String cannot be cast to netscape.javascript.JSObject"
    Portion of Java file:
    public void changed(ObservableValue ov, State oldState, State newState) {
           Document document;
                                JSObject returnObject;
                                if(newState == State.SUCCEEDED) {
                                    document = webEngine.getDocument();
                                    if(document != null) {
                                        returnObject = (JSObject)webEngine.executeScript(receivedPostJs);
    Entire Javascript file:
    function getPostResponses() {
        var requestHandler = new XMLHttpRequest();
        var POSTresponses;
        if (requestHandler.readyState == 0) {
            POSTresponses = "Nada";
        } else if (requestHandler.readyState == 1) {
            POSTresponses = "Still nuthin";
        } else if (requestHandler.readyState == 2) {
            POSTresponses = requestHandler.getAllResponseHeaders();

    HI,
    I think one good approach could be generate a table API to perform the tasks that you want (insertion, select, update, delete) and put all of these procedures in a package. Each procedure has a return code (0 if succesful for example or the SQLCODE) and a message of the result of the operation ('Success' or the SQLERRM).
    Regards,

Maybe you are looking for