Xpages - 脚本停止保存/更新文档

时间:2018-04-10 12:10:09

标签: xpages datetimepicker xpages-ssjs

我有一个奇怪的问题,只会影响一些用户。

我在xpage上有一个自定义控件,其中包含一个模态,其中有一个基于此的日期时间选择器:https://xpagesandmore.blogspot.co.uk/2014/09/using-bootstrap-datetimepicker-in-xpages.html

当某些用户点击以下保存按钮时,页面会刷新,但不保存任何更改:

    <xp:button value="Save Changes" id="button8"
            styleClass="btn-header">
            <xp:this.rendered><![CDATA[#{javascript:try{

    var strOwner:string = document1.getItemValueString("owner");
    var strStatus:string = document1.getItemValueString("status");
    var booVisible:boolean = false;
    var booOwner:boolean = false;
    var booStatus:boolean = false;

    if (userBean.displayName==strOwner){
        booOwner = true;
    }

    if(strStatus=="Objectives Completed" || strStatus=="Self Assessment Due"){
        booStatus = true;
    }

    if (document1.isEditable()&& booOwner && booStatus){
        booVisible = true;
    }

    return booVisible;

    }catch(e){
        openLogBean.addError(e,this);
    }}]]></xp:this.rendered>
            <xp:eventHandler event="onclick" submit="true"
                refreshMode="complete">
                <xp:this.action>
                    <xp:actionGroup>

                    <xp:executeScript>
                            <xp:this.script><![CDATA[#{javascript:try{

    var dt = new Date();

    var arrHistory:array = AddObjectivesHistoryItem(currentDocument, dt, "Saved", userBean.displayName);

    document1.replaceItemValue("rows",viewScope.rows);
    var o = {}
    o.title = "Document Saved";
    o.body = "This document has been succesfully saved";
    o.alertIcon = "fa-thumbs-up fa-lg";
    o.autoClose = true;
    o.alertType = "success";
    //o.growl = true;
    requestScope.put("alertServer",o)
    document1.save();
    context.reloadPage();
    }catch(e){
        openLogBean.addError(e,this.getParent());
    }}]]></xp:this.script>
                        </xp:executeScript>
                    </xp:actionGroup>
                </xp:this.action>
            </xp:eventHandler>
        </xp:button>

对我而言,它有效(可能因为我有管理员权限?)

但如果我删除自定义控件,它适用于所有人。我的想法是我的自定义控件上的脚本出错了,代码是:

<xp:this.resources>
        <xp:headTag tagName="script">
            <xp:this.attributes>
                <xp:parameter name="type" value="text/javascript" />
                <xp:parameter name="src"
                    value="moment210/moment-with-locales.js" />
            </xp:this.attributes> 
    </xp:headTag>

        <xp:script
            src="bootstrapdatetimepicker4/js/bootstrap-datetimepicker.js"
            clientSide="true" />
                    <xp:styleSheet
            href="bootstrapdatetimepicker4/css/bootstrap-datetimepicker.css" />
    </xp:this.resources>

    <xp:this.data>
        <xp:dominoDocument var="document2"></xp:dominoDocument>
    </xp:this.data>


    <xp:scriptBlock id="scriptBlock1">
        <xp:this.value><![CDATA[$(document).ready(
    function() {
        x$( "#{id:datetimepicker1}" ).datetimepicker({
            locale: 'en-gb',
            showTodayButton:true,
            showClose: true,
            daysOfWeekDisabled: [0,6],
            format:('DD/MM/YYYY')
    });
});
]]>
        </xp:this.value>
    </xp:scriptBlock>

                <!-- Modal ONE -->
    <div class="modal fade" data-keyboard="false" data-backdrop="static"
        tabindex="-1" role="dialog" id="modalDueDate">

        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-header modal-header-default">
                    <h4 class="modal-title">Change Due Date</h4>
                </div>
                <div class="modal-body">


<div class='input-group date'
       id='datetimepicker1'>
       <xp:inputText id="dtChangeDueDate" styleClass="form-control"
        value="#{document2.DueDate}" style="height:34px">
        <xp:this.attrs>
            <xp:attr name="data-date-format" value="DD/MM/YYYY">
            </xp:attr>
            <xp:attr name="placeholder" value="Enter data"></xp:attr>
        </xp:this.attrs>
        <xp:this.converter>
            <xp:convertDateTime type="date" dateStyle="short">
            </xp:convertDateTime>
        </xp:this.converter>
       </xp:inputText>
       <span class="input-group-addon">
        <span
         class="glyphicon glyphicon-calendar">
        </span>
       </span>
      </div>

                </div>

                <div class="modal-footer">
                    <xp:button type="button" styleClass="btn btn-danger"
                        id="button4">

                        <xp:this.attrs>
                            <xp:attr name="data-toggle" value="modal" />
                            <xp:attr name="data-target"
                                value="#modalDueDate" />
                        </xp:this.attrs>
                        Cancel

                    </xp:button>

                    <xp:button type="button" styleClass="btn btn-success"
                        id="button5">

                        <xp:this.attrs>
                            <xp:attr name="data-toggle" value="modal" />
                            <xp:attr name="data-target"
                                value="#modalDueDate" />
                        </xp:this.attrs>
                        Update

                        <xp:eventHandler event="onclick" submit="true"
                            refreshMode="complete">
                            <xp:this.action><![CDATA[#{javascript:try{

var noteID:string = compositeData.noteID;
var doc:NotesDocument = database.getDocumentByID(noteID);
var dueDate = getComponent("dtChangeDueDate").getValue();

var docWrap = wrapDocument(doc);

var dateTimeFormat = new java.text.SimpleDateFormat("dd/MM/yyyy");
var dateTimeString = dateTimeFormat.format(dueDate);

var dt = new Date();
var arrHistory:array = AddObjectivesHistoryItem(docWrap, dt, "Due Date Changed To "+dateTimeString, userBean.displayName);

docWrap.replaceItemValue("DueDate",dueDate);
docWrap.save();

var o = {}
o.title = "Due Date Updated";
o.body = "The due date has been succesfully updated to " + dateTimeString;
o.alertIcon = "fa-thumbs-up fa-lg";
o.autoClose = true;
o.alertType = "success";
//o.growl = true;
requestScope.put("alertServer",o);
context.reloadPage();

}catch(e){
    openLogBean.addError(e,this.getParent());
}}]]></xp:this.action>
                        </xp:eventHandler></xp:button> 

                </div>
            </div>
        </div>
    </div><!-- Modal ONE End-->

日志中没有错误,屏幕上没有错误,服务器控制台上没有错误,或者在浏览器中使用DEV工具时,我无法确定问题所在。

根据用户的来源,文档的URL可能会有所不同,例如,它可能是:

/ppg/aqo.nsf/%24%24OpenDominoDocument.xsp?documentId=60D9F30F3098008A80258266003BA63F&action=editDocument

OR

/ppg/aqo.nsf/xpObjectives.xsp?documentId=FBC1DB984CD8A25880258266003BAE1A&action=editDocument

与其他网址相比,脚本是否可能无法从一个网址加载或引用?我是否有更好的方法来包含这些脚本,并确保它们适用于所有URL?

任何指示赞赏。

由于

1 个答案:

答案 0 :(得分:0)

可能是用户的ACL权限吗?即创建文档,作者或更高版本?