on 07-13-2012 4:00 PM
Hello,
I am working on fixing a date bug with Mii, however I am pulling my hair out due to one hurdle I cannot seem to get over.
Long story short, I am trying to retrieve a value from the database, and display it on the page. I give it a formatted date, and it used that to get the corresponding value.
However, it keeps giving me the scripting error "document.Fiscal.CurrentFiscalYearApp is null or not an object".
I am new to this application, but I have looked at existing examples, and I cannot find anything wrong.
All it's suppose to do is set a value of a global variable to the current fiscal year (according to the DB, as well as keeping it behind the scenes), and also displays it on the page.
It keeps bringing up the test parameter result. If I remove it, I get nothing.
Below is code I've added. This is found on a separate javascript file, which the main page references.
-----------------------
var intYear = fncGetFiscalYear();
function fncGetFiscalYear()
{
var dt = new Date();
var dateString = dt.getMonth() + "/" + dt.getDay() + "/" + dt.getFullYear() + " " + dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
document.CurrentFiscalYearApp.getQueryObject().setParam(1,dateString);
document.CurrentFiscalYearApp.refresh();
return document.CurrentFiscalYearApp.getItemAt(1);
}
--------------------------
This is the object on the main page
--------------------------
<APPLET NAME="CurrentFiscalYearApp" CODEBASE="/XMII/Classes" CODE="iBrowser" ARCHIVE="illum8.zip" WIDTH="120" HEIGHT="19" MAYSCRIPT>
<PARAM NAME="QueryTemplate" VALUE="FootPrint/Reports/CurrentFiscalYearQry" />
<PARAM NAME="DisplayTemplate" VALUE="FootPrint/Defaults/FiscalYearBrowser" />
</APPLET>
--------------------------
The query is perfectly fine. I've tested it numerous times, always gives the correct result.
I don't know why it's keeping telling me that document.CurrentFiscalYearApp is null or not an object, when there are other functions on the same page that do the exact same thing (referencing the mii objects on the parent page).
Any ideas would be helpful.
You can't call the .getQueryObject method if the object (null) doesn't exist. I would speculate that you have a client side script executing before the JRE applet has been created or available for scripting. If you are using a body onload script or javascript outside of a function that is attempting to address an applet, then you will likely hit timing issues and throw null pointer exceptions.
If you were to use [ED] in your query in place of '[Param.1]' --> note, the string delimiters are built into the ED token. Then the query would automatically default to now() on the server and the query would run automatically when the applet is ready.
Using the applet's FirstUpdateEvent you could then fire a js function that gets the item from the browser - this would eliminate the timing issues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks guys. You've been a great help.
It works great now. Part of the problem was that Javascript's getMonth function goes from 0 to 11, rather than 1 to 12, so that was totally screwing up my results. As well as getDay, which was suppose to be getDate.
Oh well, c'est la vie.
Thanks again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try document.CurrentFiscalYearApp.getBrowserObject().getItemAt(1);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your quick response, however, I do not think it helps me with the error. The error itself (at least not yet) is not grabbing the value from the Applet, but rather saying that such an applet does not exist or I'm not casting something correctly.
According to IE's Scripting Error console, it gives an error on this line, everytime:
document.CurrentFiscalYearApp.getQueryObject().setParam(1,dateString); |
When it hits that line that's when I get the null scripting error.
Looking closer at your code I think your right. I think the line "var intYear = fncGetFiscalYear();" might be causing the function to be called before the applet has been created on the page. Try adding an update event or sim param to the applet and a corresponding function to set initYear :
<PARAM NAME="UpdateEvent" VALUE="intYearInit">
var intYear;
function intYearInit(){
intYear = fncGetFiscalYear();
}
User | Count |
---|---|
12 | |
7 | |
3 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.