Forum LAMS for Tech-Heads - General Forum: Javascript error with save from tool created by RenameTool


 
You may request notification for Javascript error with save from tool created by RenameTool.
Search: 

1: Javascript error with save from tool created by RenameTool
09/06/06 06:49 AM
[ Reply | Forward ]
When I click on Save while authoring of my tool (which was created by RenameTool of the Submit File tool and has yet to be editted further) I get a JavaScript error "Object doesn't support his property or method". It occurs in the line

document.getElementById("authoringForm").behaviourComposer();

inside of

<!-- begin tab content -->
<script type="text/javascript">
    if(false){
          location.href="/lams/tool/kkbc10/clearsession.do?action=confirm&mode=author&signature=kkbc10&toolContentID=13&defineLater=&customiseSessionID=sessionMapID-2";
    }
    function doBehaviourComposer_Form_Only() {
        document.getElementById("authoringForm").behaviourComposer();
    }
    function doCancel() {
        if(confirm("Do you want to close this window without saving?")){
            location.href="/lams/tool/kkbc10/clearsession.do?action=cancel&mode=author&customiseSessionID=sessionMapID-2";
            //just for depress alert window when call window.close()
            //only available for IE browser
            var userAgent=navigator.userAgent;
            if(userAgent.indexOf('MSIE') != -1)
                window.opener = "authoring"
            window.close();
        }
    }
</script>
<p align="right">
    <a href="javascript:doBehaviourComposer_Form_Only();" class="button">Save</a>
    <a href="javascript:;" class="button" onclick="javascript:doCancel()">Cancel</a>
</p>
<!-- end tab content -->

Is this happening because RenameTool didn't rename some of the strings in the JavaScript?

Best,

-ken

Posted by Ken Kahn

2: Re: Javascript error with save from tool created by RenameTool
In response to 1 09/07/06 02:25 AM
[ Reply | Forward ]
Ken,

I hope you will laugh (and not cry) when you hear what the problem is.

The tool we suggested you use was "submit files". So the rename tool has replaced a whole lot of "submit"  entries with "behaviourComposer".

Including in the jsps, the tlds, and tag files. The 6 letters "submit" gets used a lot in jsp pages. e.g. onsubmit, doSubmit(), etc.

Attached is an updated set of your code that compiles deploys and the authoring and learning screens at least appear, and  you can save authoring. Its a version that has the bcSubmissionFileDAO naming stuff sorted out (I hope) and has updated jsps, tlds and tag files. If you have a decent recursive diff utility then you might want to run it over the attached code and your code to see what I changed.

There was also an update to the conf/xdoclet/web-security.xml file - replacing STAFF with MONITOR. This was a bug we fixed up just after you took your cut of the code.

What did I fix?

In web/authoring/authoring.jsp there is a function:

      function doBehaviourComposer(method) {
            document.getElementById("authoringForm").dispatch.value=method;
            document.getElementById("authoringForm").behaviourComposer();
        }

changed it to "doSubmit(method)":

        function doSubmit(method) {
            document.getElementById("authoringForm").dispatch.value=method;
            document.getElementById("authoringForm").submit();
        }

----------------------------------

In web/authoring/instructions.jsp there are references to:
    javascript:doBehaviourComposer

They were changed to
    javascript:doSubmit

----------------------------------

In web/WEB-INF/tags/AuthoringButton.tag there were bits:

    function doBehaviourComposer_Form_Only() {
        document.getElementById("${formID}").behaviourComposer();
    }

    <html:link href="javascript:doBehaviourComposer_Form_Only();" property="behaviourComposer" styleClass="button">
        <fmt:message key="${saveButtonLabelKey}" />
    </html:link>

They were changed to:

    function doSubmit_Form_Only() {
        document.getElementById("authoringForm").submit();
    }

    <html:link href="javascript:doSubmit_Form_Only();" property="submit" styleClass="button">
        <fmt:message key="${saveButtonLabelKey}" />
    </html:link>


In web\WEB-INF\struts\struts-html.tld also has a few submits that had turned into behaviourComposer and I changed them back.

If you do try to change your current copy (rather than working from the attached files), it would be best copy AuthoringButton.tag and struts-html.tld files from the original project, rather than trying to edit them.

----------------------------------

I also had to fix up similar problems in web\error.jsp, web\learner\behaviourComposerLearner.jsp, monitoring.jsp, web\mark\allmarks.jsp, web\mark\fileinfo\.jsp, web\mark\filelist.jsp, web\mark\mark.jsp\, web\mark\updatemark.jsp.

Regards,

Fiona

Posted by Fiona Malikoff

Attachments:
3: Re: Re: Javascript error with save from tool created by RenameTool
In response to 2 09/07/06 03:11 AM
[ Reply | Forward ]
Thanks -- seems to be working fine now. Now the real work begins.

I once heard a story about a novelist whose agent suggested he change a character's name from David to Brad. He did so and a reviewer wrote that he had never heard of the biblical story of Brad and Goliath.

Same lesson.

Thanks again.

Best,

-ken

Posted by Ken Kahn

Reply to first post on this page
Back to LAMS for Tech-Heads - General Forum