Trouble with <OBJECT>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JayBrahms

    Trouble with <OBJECT>

    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 "ApplicationRes ources.properti es" 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. (ApplicationRes ources.properti es for English,
    ApplicationReso urces_de.proper ties for German ...)

    I have a an Object looking like this:

    <OBJECT id="Application Resources"
    classid="clsid: 333C7BC4-460F-11D0-BC04-0080C7055A83">
    <PARAM name="DataURL" value="properti es/ApplicationReso urces.propertie s">
    <PARAM name="UseHeader " value="true">
    <PARAM name="FieldDeli m" value="=">
    <PARAM name="Filter" value="">
    </OBJECT>

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

    document.getEle mentById("Appli cationResources ").object.DataU RL =
    "ApplicationRes ources" + strBrowerLang + ".propertie s";
    document.getEle mentById("Appli cationResources ").Reset();

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

    function BeanMessage(str Message) {
    document.getEle mentById("Appli cationResources ").object.Filte r = "message=" +
    strMessage;
    document.getEle mentById("Appli cationResources ").Reset();
    strValue =
    document.getEle mentById("Appli cationResources ").recordset.Fi elds("content"
    ).value;

    return (strValue);
    }

    Within my BODY I use this for example:

    <P>
    <SCRIPT
    type="text/javascript">doc ument.write(Bea nMessage("start .explain.1"));</SC
    RIPT><BR>
    <SCRIPT
    type="text/javascript">doc ument.write(Bea nMessage("start .explain.2"));</SC
    RIPT><BR>
    <SCRIPT
    type="text/javascript">doc ument.write(Bea nMessage("start .explain.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 "BeanMessag e" >>Item in Collection
    not found<<. After closing the Alert no more problems.
    When building a try-Block into the function "BeanMessag e" 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.

  • Laurent Bugnion, GalaSoft

    #2
    Re: Trouble with &lt;OBJECT&g t;

    Hi,

    JayBrahms wrote:[color=blue]
    > 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:[/color]

    <snip>
    [color=blue]
    > Within my BODY I use this for example:
    >
    > <P>
    > <SCRIPT
    > type="text/javascript">doc ument.write(Bea nMessage("start .explain.1"));</SC
    > RIPT><BR>
    > <SCRIPT
    > type="text/javascript">doc ument.write(Bea nMessage("start .explain.2"));</SC
    > RIPT><BR>
    > <SCRIPT
    > type="text/javascript">doc ument.write(Bea nMessage("start .explain.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 "BeanMessag e" >>Item in Collection
    > not found<<. After closing the Alert no more problems.
    > When building a try-Block into the function "BeanMessag e" 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.[/color]

    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

    Comment

    • HikksNotAtHome

      #3
      Re: Trouble with &lt;OBJECT&g t;

      In article <20040101124850 .15462.00005315 @mb-m06.aol.com>, jaybrahms@aol.c om
      (JayBrahms) writes:
      [color=blue]
      >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.[/color]

      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=Passwor d 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="conten t"
      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

      Comment

      • Laurent Bugnion, GalaSoft

        #4
        Re: Trouble with &lt;OBJECT&g t;

        Hi,

        HikksNotAtHome wrote:
        [color=blue]
        > 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=Passwor d 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="conten t"
        > 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..[/color]

        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

        Comment

        Working...