By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,886 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Trouble with <OBJECT>

P: n/a
Hi there.

OK, this is a little bit complicated.
I would live to find a different way to do this, but evidentially I am not able
to open a Text-File in JAVASCRIPT and fill an Array with the Values, so I have
to do it this way.

I am doing the following:

I use a File called "ApplicationResources.properties" containing 2 columns
"message" & "content" with a FieldDelim "=".
This File contains Values for Labels in different Languages, so I can change
the Language always depending on the Browser-Language.
I have one for every language. (ApplicationResources.properties for English,
ApplicationResources_de.properties for German ...)

I have a an Object looking like this:

<OBJECT id="ApplicationResources"
classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM name="DataURL" value="properties/ApplicationResources.properties">
<PARAM name="UseHeader" value="true">
<PARAM name="FieldDelim" value="=">
<PARAM name="Filter" value="">
</OBJECT>

I do change the value for the "DataURL" always depending on the
Browser-Language.

document.getElementById("ApplicationResources").ob ject.DataURL =
"ApplicationResources" + strBrowerLang + ".properties";
document.getElementById("ApplicationResources").Re set();

I use this Object, to read the Data from the Recordset in changing the Filter
by using the following function:

function BeanMessage(strMessage) {
document.getElementById("ApplicationResources").ob ject.Filter = "message=" +
strMessage;
document.getElementById("ApplicationResources").Re set();
strValue =
document.getElementById("ApplicationResources").re cordset.Fields("content"
).value;

return (strValue);
}

Within my BODY I use this for example:

<P>
<SCRIPT
type="text/javascript">document.write(BeanMessage("start.expl ain.1"));</SC
RIPT><BR>
<SCRIPT
type="text/javascript">document.write(BeanMessage("start.expl ain.2"));</SC
RIPT><BR>
<SCRIPT
type="text/javascript">document.write(BeanMessage("start.expl ain.3"));</SC
RIPT><BR>
</P>

This works perfectly fine when using the site locally on my computer, but as
soon as I try to work from the WebServer it doesn't anymore.
I get en error-message within the function "BeanMessage" >>Item in Collection
not found<<. After closing the Alert no more problems.
When building a try-Block into the function "BeanMessage" returning a Value
like "not-found" when try runs into an error, nothing will be found.

It looks like when using this on a WebServer the Object isn't populated yet ...
why?

Can anyone help me, why the Object isn't populated yet?
It seems to be populated after an Error-Message-Window.
Or, even better can tell me an easier way to do this ... and please I don't
want to create all Sites in different Languages, one change means changes in
several websites ...

Jay.

Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

JayBrahms wrote:
Hi there.

OK, this is a little bit complicated.
I would live to find a different way to do this, but evidentially I am not able
to open a Text-File in JAVASCRIPT and fill an Array with the Values, so I have
to do it this way.

I am doing the following:
<snip>
Within my BODY I use this for example:

<P>
<SCRIPT
type="text/javascript">document.write(BeanMessage("start.expl ain.1"));</SC
RIPT><BR>
<SCRIPT
type="text/javascript">document.write(BeanMessage("start.expl ain.2"));</SC
RIPT><BR>
<SCRIPT
type="text/javascript">document.write(BeanMessage("start.expl ain.3"));</SC
RIPT><BR>
</P>

This works perfectly fine when using the site locally on my computer, but as
soon as I try to work from the WebServer it doesn't anymore.
I get en error-message within the function "BeanMessage" >>Item in Collection
not found<<. After closing the Alert no more problems.
When building a try-Block into the function "BeanMessage" returning a Value
like "not-found" when try runs into an error, nothing will be found.

It looks like when using this on a WebServer the Object isn't populated yet ...
why?

Can anyone help me, why the Object isn't populated yet?
It seems to be populated after an Error-Message-Window.
Or, even better can tell me an easier way to do this ... and please I don't
want to create all Sites in different Languages, one change means changes in
several websites ...

Jay.


Probably because the OBJECT (a Java applet I guess) is not started when
the first call to document.write occurs. Loading the applet takes some
time. When locally, the applet gets loaded faster, and it's started
already when you call it first. When on a server, everything goes
slower, and the applet takes time to download. Note also that the ONLOAD
of the document gets called after the applet is loaded, but before it is
started.

The only way to synchronize your page and the applet is to use the
start() method of the applet to call some JavaScript, indicating that
it's ready to be used. This complicates of course the design of your
page, since using document.write becomes impossible...

You can see the following examples to get a better idea of hot to
achieve what you try to do:

<URL: http://www.galasoft-LB.ch/myjavascript/consulting/LiveConnect102>
<URL: http://www.galasoft-LB.ch/myjava/WebLoadFile/Demo/Demo.html>

HTH,

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #2

P: n/a
In article <20***************************@mb-m06.aol.com>, ja*******@aol.com
(JayBrahms) writes:
Hi there.

OK, this is a little bit complicated.
I would live to find a different way to do this, but evidentially I am not
able to open a Text-File in JAVASCRIPT and fill an Array with the
Values, so I have to do it this way.


Simply change your text files to .js files, and load them with a src attribute
on the script tag. Then change your definitions in the .js file.

Instead of this:

message=content
error.0=The following Errors occurred during validation:
error.1=User has to be filled.
error.2=Password has to be filled.
error.3=User does not exist.
error.4=There are no shared Albums available for this User.

Something like this:

var message="content"
var error = new Array()
error[0]="The following Errors occurred during validation:"
error[1]="User has to be filled."
error[2]="Password has to be filled."
error[3]="User does not exist."
error[4]="There are no shared Albums available for this User."

etc..
--
Randy
Jul 20 '05 #3

P: n/a
Hi,

HikksNotAtHome wrote:
Simply change your text files to .js files, and load them with a src attribute
on the script tag. Then change your definitions in the .js file.

Instead of this:

message=content
error.0=The following Errors occurred during validation:
error.1=User has to be filled.
error.2=Password has to be filled.
error.3=User does not exist.
error.4=There are no shared Albums available for this User.

Something like this:

var message="content"
var error = new Array()
error[0]="The following Errors occurred during validation:"
error[1]="User has to be filled."
error[2]="Password has to be filled."
error[3]="User does not exist."
error[4]="There are no shared Albums available for this User."

etc..


While this will work in most cases, I'd like to note that this has the
disadvantage to sending the file (each file) to the user's PC. I can
imagine some cases where it is not wanted, either because some sensitive
information is included in the files (in which case the processing
should be done server-side anyway).

Just my 2 cents.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.