Form to Form communication
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Form to Form communication
I have a form (Form1) that uses the JavaScript window.open function to open Form2 in a popup window.
When a certain event occurs in Form2 (which involves deleting a record from a database), I want to send some kind of event signal or trigger to Form1 to called fetchTable() on a table.
Is there a way to do something like this on the server side JavaScript ? I cannot think of a way to do this via client JavaScript.
When a certain event occurs in Form2 (which involves deleting a record from a database), I want to send some kind of event signal or trigger to Form1 to called fetchTable() on a table.
Is there a way to do something like this on the server side JavaScript ? I cannot think of a way to do this via client JavaScript.
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
There isn't an easy to do this on the server. I would use the client to do it - use window.parent to invoke a function in the client of Form1, then use the client API to call the server to do the fetchtable. Something like this..
Note that the "true" as the last parameter of the executeFunction call requests that the page is refreshed - this is so the user can see the changes performed by the popup.
Regards
Jon
Code: Select all
.. Form1 client
window.parent.refreshTable();
..Form2 client
function refreshTable()
{
$eb.executeFunction("refreshXxxTable", null, true);
}
..On the server (for Form1)
function refreshXxxTable()
{
tables.MY_TABLE.fetchTable();
}
Regards
Jon
0 x
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Jon,
I still haven't been able to get it fully working. Also wanted to add a few comments because I had to modify your code a little bit to get it to work (mainly referencing window.opener instead of window.parent)
I create 2 new client scripts which I assigned to my forms as Client scripts under Form Properties->Web Resources->Client Scripts.
Form1:
function refreshTable() {
alert("in client side refreshTable()");
$eb.executeFunction("refreshTable",null, true);
}
Form2:
$(document).ready(function () {
window.onbeforeunload = function() {
window.opener.refreshTable();
};
});
The server side function refreshTable() referenced in $eb.executeFunction is defined as a client callable function in Form1's properties.
The alert in "in client side refreshTable()" appears indicating that the execution reaches this function but it does not appear that $eb.executeFunction is working. I am not getting an error in the eBase console window or browser developer console but it is definitely not executing the function.
I still haven't been able to get it fully working. Also wanted to add a few comments because I had to modify your code a little bit to get it to work (mainly referencing window.opener instead of window.parent)
I create 2 new client scripts which I assigned to my forms as Client scripts under Form Properties->Web Resources->Client Scripts.
Form1:
function refreshTable() {
alert("in client side refreshTable()");
$eb.executeFunction("refreshTable",null, true);
}
Form2:
$(document).ready(function () {
window.onbeforeunload = function() {
window.opener.refreshTable();
};
});
The server side function refreshTable() referenced in $eb.executeFunction is defined as a client callable function in Form1's properties.
The alert in "in client side refreshTable()" appears indicating that the execution reaches this function but it does not appear that $eb.executeFunction is working. I am not getting an error in the eBase console window or browser developer console but it is definitely not executing the function.
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
A few points that may help:
You need to be at Ebase level V4.5.0 or higher to use the $eb client API interface.
When the refreshTable function executes on the server, you should get a message on the server log, viewable via the execution log.
The script containing the refreshTable function needs to be added to the client callable functions - using the events tab of form properties. If this is not done, you should see an error message in the log.
You need to be at Ebase level V4.5.0 or higher to use the $eb client API interface.
When the refreshTable function executes on the server, you should get a message on the server log, viewable via the execution log.
The script containing the refreshTable function needs to be added to the client callable functions - using the events tab of form properties. If this is not done, you should see an error message in the log.
0 x
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Sorry, I don't know why it isn't working - it all looks good to me. These things are usually something very simple, but I can't see anything wrong. When you execute the $eb.executeFunction call you should see either a Javascript error in the client console or you should see some sort of message in the execution log on the server (though you need to be running the form from the designer to see this). I'm mystified that you don't see either of these. I can only suggest you use debug in the client browser (do you have Firebug?) and set a breakpoint on the $eb.executeFunction line, then follow it through.
0 x
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
I tried running the application directly from the designer on the same server that eBase is installed on.
During my testing, I normally run my application via a CSS based menu on a different workstation.
When I run the application from the designer, the table is refreshed. When I run the application from a different workstation, it is not refreshed. I am using the latest Google Chrome and have deleted the cache and cookies
During my testing, I normally run my application via a CSS based menu on a different workstation.
When I run the application from the designer, the table is refreshed. When I run the application from a different workstation, it is not refreshed. I am using the latest Google Chrome and have deleted the cache and cookies
0 x
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Forgot to mention, not seeing an error in the browser console window or execution log.
What's stranger is that when I put a breakpoint in the client side function, it seems to jump over it. I know that the function is being called on the client side because I put an alert into the function and it does display the alert but the execution won't stop at the alert or the call to $eb.executeFunction.
The client side function currently looks like this:
function refreshTable() {
alert("in refreshTable()");
$eb.executeFunction("refreshTable",null, true,true,function(failureMessage){alert(failureMessage);});
}
What's stranger is that when I put a breakpoint in the client side function, it seems to jump over it. I know that the function is being called on the client side because I put an alert into the function and it does display the alert but the execution won't stop at the alert or the call to $eb.executeFunction.
The client side function currently looks like this:
function refreshTable() {
alert("in refreshTable()");
$eb.executeFunction("refreshTable",null, true,true,function(failureMessage){alert(failureMessage);});
}
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
If it runs from the designer, it sounds like it's basically OK. If you run the form standalone from another workstation (i.e. not via your menu) does it also work? If yes, something in the menu is somehow interfering. If no, it sounds like it's something to do with the level of the software elements. Could you try clearing the server-side cache: stop the server, delete all 4 files in tomcat/work/Catalina/localhost/ufs, then restart the server.
As mentioned before, when the client API call arrives on the server, you should see some sort of logged message. If the form is run from the designer, you will see this in the execution log. If you are testing from your menu, you should see it in the server log - either the command window used to start the server or in file tomcat/logs/ufsserver.log. The message should look like this:
INFO Executing Javascript script Execute Function: refreshTable
One last point: I would change the fourth parameter of the $eb.executeFunction call to false. If this is set to true, all input fields are validated and transmitted to the server as part of the request. It's possible something is going wrong here.
Regards
Jon
As mentioned before, when the client API call arrives on the server, you should see some sort of logged message. If the form is run from the designer, you will see this in the execution log. If you are testing from your menu, you should see it in the server log - either the command window used to start the server or in file tomcat/logs/ufsserver.log. The message should look like this:
INFO Executing Javascript script Execute Function: refreshTable
One last point: I would change the fourth parameter of the $eb.executeFunction call to false. If this is set to true, all input fields are validated and transmitted to the server as part of the request. It's possible something is going wrong here.
Regards
Jon
0 x
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Jon,
I think that I may have located the problem although I don't understand why. I put a breakpoint on all of the references to ExecuteFunction in eBase's JavaScript API. In ufsexapi451.js specifically lines 209-214 $eb.executeFunction returns null as the value of the variable response. It seems that there may be an issue with this api function.
I shared another script and called $eb.executeFunction in both of these formats:
$eb.executeFunction("myalert",null, true); and
$eb.executeFunction("myalert",null, true,false,function(failureMessage){alert(failureMessage);});
both times, a null response is returned.
I think that I may have located the problem although I don't understand why. I put a breakpoint on all of the references to ExecuteFunction in eBase's JavaScript API. In ufsexapi451.js specifically lines 209-214 $eb.executeFunction returns null as the value of the variable response. It seems that there may be an issue with this api function.
I shared another script and called $eb.executeFunction in both of these formats:
$eb.executeFunction("myalert",null, true); and
$eb.executeFunction("myalert",null, true,false,function(failureMessage){alert(failureMessage);});
both times, a null response is returned.
0 x
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Tracing $eb.executeFunction after running my application directly from the designer gives a different result.
The result variable contains an object after the executeFunction has been called, not a null value and the server side function executes just fine.
Running my application from my CSS menu does not do anything to interfere with this behavior. The only thing that it does is add a parameter to the URL called SessionID which is automatically removed from the URL by eBase.
So my menu points to the URL
http:/intranet:3030/ufs/ufsmain?formid=RMA_TRACKING&SessionID=1234
and the URL displayed in the browser after the page has loaded is:
http://intranet:3030/ufs/ufsmain?formid ... 3529030230
The result variable contains an object after the executeFunction has been called, not a null value and the server side function executes just fine.
Running my application from my CSS menu does not do anything to interfere with this behavior. The only thing that it does is add a parameter to the URL called SessionID which is automatically removed from the URL by eBase.
So my menu points to the URL
http:/intranet:3030/ufs/ufsmain?formid=RMA_TRACKING&SessionID=1234
and the URL displayed in the browser after the page has loaded is:
http://intranet:3030/ufs/ufsmain?formid ... 3529030230
0 x
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Jon,
I managed to fix the issue by moving the server side function to an entirely separate server script (as opposed to being inside of a script that had some other code in it) and assigning it as a client callable script under Form Properties.
I don't understand why this didn't work with the previous server script that it was in.
I managed to fix the issue by moving the server side function to an entirely separate server script (as opposed to being inside of a script that had some other code in it) and assigning it as a client callable script under Form Properties.
I don't understand why this didn't work with the previous server script that it was in.
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
-
- Ebase User
- Posts: 2
- Joined: Fri Feb 28, 2014 1:08 pm
- Location: United States
- Contact:
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
basementclev2,
I don't know why it wasn't working originally.
I had a script that would run when my form first loaded which loaded the table and then had a function declaration after that so it looked something like this:
tables.MYTABLE.fetchTable();
// This is the function that will be called from the client to refresh the table.
function refreshTable() {
tables.MYTABLE.fetchTable();
}
Everything worked properly and I didn't have any syntax errors in the browser console window or my eBase server console window but I couldn't execute refreshTable() from the client side until I put it into a separate script.
I don't know why it wasn't working originally.
I had a script that would run when my form first loaded which loaded the table and then had a function declaration after that so it looked something like this:
tables.MYTABLE.fetchTable();
// This is the function that will be called from the client to refresh the table.
function refreshTable() {
tables.MYTABLE.fetchTable();
}
Everything worked properly and I didn't have any syntax errors in the browser console window or my eBase server console window but I couldn't execute refreshTable() from the client side until I put it into a separate script.
0 x
Who is online
Users browsing this forum: No registered users and 7 guests