सूची दृश्य getListItemXmlAttributes विधि बाल प्रकाशन आइटम के साथ विफल हो जाती है


358

मैंने SG / Folder सूची दृश्य डेटा को पॉप्युलेट करने के लिए JS क्लास बनाई है, जब आइटम संशोधित किए जाते हैं। ( Jaime के दृष्टिकोण के अनुसार) जब मैं उनके द्वारा बनाए गए प्रकाशन में आइटम पर काम करता हूं तो सब कुछ बहुत अच्छा होता है।

Ex: मैं एक घटक या पृष्ठ और कस्टम locked byकॉलम को तुरंत अपडेट करता हूं और अपना उपयोगकर्ता नाम दिखाता हूं।

हालाँकि, जब मैं किसी बच्चे के प्रकाशन पर जाता हूं और उस प्रक्रिया को दोहराता हूं, तो मुझे यह पूछने के लिए विंडो मिलती है कि क्या मैं मूल आइटम को स्थानीय बनाना या संपादित करना चाहता हूं। यदि मैं मूल विंडो को संपादित करने का चयन करता हूं, तो कोड काम नहीं करता है। मैंने अभी तक इसे शुरुआती डिबगिंग के साथ नहीं जोड़ा है। क्रोम त्रुटि को निगलने लगता है, फ़ायरफ़ॉक्स मुझे एक गुप्त देता है:

टाइमस्टैम्प: 6/22/2012 3:42:54 अपराह्न

त्रुटि: बिना अपवाद अपवाद: [अपवाद ... "घटक ने विफलता कोड दिया: 0x80004002 (NS_NOINTERFACE) [nsIWebProgress.DOMWindow]" nsresult: "0x80004002 (NS_NOINTERFACE)" स्थान: "जेएस फ्रेम :: क्रोम / ब्राउज़र / टैबबार। .xml :: :: पंक्ति 545 "डेटा: नहीं]

क्या किसी के पास कोई प्रारंभिक विचार है? मैं बाद में कुछ कोड पोस्ट करने की कोशिश करूंगा ...

PageEx.js से कोड:

Type.registerNamespace("MyCompany.Tridion.RTFExtensions");

/*
* Constructor
*/

MyCompany.Tridion.RTFExtensions.PageEx = function (id) {
    Type.enableInterface(this, "MyCompany.Tridion.RTFExtensions.PageEx");
    this.addInterface("Tridion.ContentManager.Page", [id]);
    var p = this.properties;
    p.versionNumberString = undefined;
    p.modifiedBy = undefined;
    p.lockedBy = undefined;
    p.approvalStatus = undefined;
    p.publishDate = undefined;
    p.previousVersion = undefined;
    p.previousApprovalStatus = undefined;
    p.customModifiedDate = undefined;
    p.initialModifierUserName = undefined;
};

/*
* sends the list xml string for the item 
*/
MyCompany.Tridion.RTFExtensions.PageEx.prototype.getListItemXmlAttributes = function (customAttributes) {
    var attribs = {};
    $extUtils.getListItemXmlAttributes(customAttributes,this, attribs);
    return this.callBase("Tridion.ContentManager.Page", "getListItemXmlAttributes", [attribs]);
};


/*
* This method gets called when an item is opened from list view. node parameter has the information
* displayed in the list view as attributes. We are getting cutom data extender column information 
* from this xml node and storing it in this class member for returning it from getListItemXmlAttributes method
*/
MyCompany.Tridion.RTFExtensions.PageEx.prototype.setDataFromList = function (node, parentId, timeStamp) {
    $extUtils.setDataFromList(node,parentId,timeStamp,this);
    this.callBase("Tridion.ContentManager.Page", "setDataFromList", [node, parentId, timeStamp]);
};

/* 
* Gets item icon 
*/
MyCompany.Tridion.RTFExtensions.PageEx.prototype.getItemIcon = function () {
    var icon = this.callBase(this.defaultBase, "getItemIcon");
    return icon;
};

Utils.js से कोड:

// reloads the list view for the given id (used in list view data refresh when JS cant get the required data without reloading)
MyCompany.Tridion.RTFExtensions.Utilities.reloadListView = function (listTcmId) {
    var registry = $models.getListsRegistry();
    for(var key in registry)
    {
        var entry = $models.getItem(registry[key]);
        if (entry && entry.getParentId() == listTcmId)
        {
           entry.unload();
           return true;
        }
    }
    return false;
}

/*
* This method gets called when an item is opened from list view. node parameter has the information
* displayed in the list view as attributes. We are getting cutom data extender column information 
* from this xml node and storing it in this class member for returning it from getListItemXmlAttributes method
*/
MyCompany.Tridion.RTFExtensions.Utilities.setDataFromList = function (node, parentId, timeStamp, itemClicked) {
    var p = itemClicked.properties;

    if (!timeStamp || timeStamp > itemClicked.getTimeStamp()) {
        var tmp;
        if (tmp = node.getAttribute('Version')) {
            p.versionNumberString = tmp;
            p.previousVersion = tmp;
        }
        if (tmp = node.getAttribute('ModifiedBy')) {
            p.modifiedBy = tmp;
            p.initialModifierUserName = tmp;
        }
        if (tmp = node.getAttribute('LockedBy')) {
            p.lockedBy = tmp;
        }
        if (tmp = node.getAttribute('ApprovalStatus')) {
            p.approvalStatus = tmp;
            p.previousApprovalStatus = tmp;
        }
        if (tmp = node.getAttribute('PublishDate')) {
            p.publishDate = tmp;
        }
        if (p.customModifiedDate === undefined) {
            if (tmp = node.getAttribute('Modified')) {
                p.customModifiedDate = tmp;
            }
        }
    }
}

/*
* sends the list xml string for the item in the list view.
*/
MyCompany.Tridion.RTFExtensions.Utilities.getListItemXmlAttributes = function (customAttributes, listViewObject,attribs) {
    var p = listViewObject.properties;
    $extUtils.getListViewItemLockedByName(p,listViewObject);

    if (customAttributes) {
        for (var attr in customAttributes) {
            attribs[attr] = customAttributes[attr];
        }
    }

    attribs["Version"] = $extUtils.getListViewItemUpdatedVersion(p,listViewObject);
    //modified name has to come after the version update...
    $extUtils.getListViewItemModifiedByName(p,listViewObject);
    attribs["ApprovalStatus"] = $extUtils.getListViewItemApprovalStatus(p,listViewObject);  
    attribs["PublishDate"] = $extUtils.getListViewItemPublishDate(p,listViewObject);

    //set default values
    if (p.versionNumberString != undefined) {
        var iResult = p.versionNumberString.localeCompare(p.previousVersion);
        if (p.previousVersion === undefined || iResult > 0) {
            //it's been updated!
            p.previousVersion = p.versionNumberString;
            p.previousApprovalStatus = p.approvalStatus;

            //also need to update modified date
            p.customModifiedDate = $extUtils.getListViewItemUpdatedModifiedDate(p,listViewObject);
            p.initialModifierUserName = p.modifiedBy;
        }

    }
    attribs["Modified"] = p.customModifiedDate;
    attribs["LockedBy"] = p.lockedBy;
    attribs["ModifiedBy"] = p.modifiedBy;

};

/*
* This method sets the property of the Revisor owner on the item in the list view. however, if it's not the current user
* we have no way to look that up in JS so we have to reload the list view.
*/
MyCompany.Tridion.RTFExtensions.Utilities.getListViewItemModifiedByName = function (p,listViewObject) {
    var p = listViewObject.properties;
    var xmlDoc = listViewObject.getXmlDocument();
    if (xmlDoc) {
        //modifier should always exist...
        var modifierId = $xml.getInnerText(xmlDoc, "/tcm:*/tcm:Info/tcm:VersionInfo/tcm:Revisor/@xlink:title");
        if (modifierId != undefined) {
            var u = Tridion.UI.UserSettings.getJsonUserSettings(true);
            if (modifierId == u.User.Data.Name) {
                var strDescription = u.User.Data.Description.split('(');
                p.modifiedBy = strDescription[0];
                return;
            } else {
                //we're in trouble...
                //let's hope it's the initial modifier we had...
                if (p.previousVersion == p.versionNumberString) {
                    //whew...
                    p.modifiedBy = p.initialModifierUserName;
                    return;
                }

                if (!$extUtils.reloadListView(listViewObject.getOrganizationalItemId())) {
                    //hrm. something failed on the reload? not sure what else to do:
                    p.modifiedBy = modifierId;
                }
            }
        } else {
            //shouldn't ever happen.
            p.modifiedBy = "";
            return;
        }
    }

};

/*
* This method sets the property of the lock owner on the item in the list view. however, if it's not the current user
* we have no way to look that up in JS so we have to reload the list view.
*/
MyCompany.Tridion.RTFExtensions.Utilities.getListViewItemLockedByName = function (p,listViewObject) {
    var xmlDoc = listViewObject.getXmlDocument();
    if (xmlDoc) {
        //this will be user id. no sense getting tcmid... can't look it up without async call
        var lockedUserId = $xml.getInnerText(xmlDoc, "/tcm:*/tcm:Info/tcm:VersionInfo/tcm:ItemLock/tcm:User/@xlink:title");
        if (lockedUserId != undefined) {
            //see if it's the current user. most likely...
            var u = Tridion.UI.UserSettings.getJsonUserSettings(true);
            if (lockedUserId == u.User.Data.Name) {
                var strDescription = u.User.Data.Description.split('(');
                p.lockedBy = strDescription[0];
                return;
            }
            //it's not the current user. no synch way to do what we want, plus the JS call doesn't get the workflow version anyway. refresh the parent view
            if (!$extUtils.reloadListView(listViewObject.getOrganizationalItemId())) {
                //hrm. something failed on the reload? not sure what else to do:
                p.lockedBy = lockedUserId;
            }
        } else {
            //clear it out since there's no lock owner
            p.lockedBy = "";
        }
    }
};

/*
* Gets the ApprovalStatus from the item
* This makes absolutely no sense... but for some reason the approval status gets wiped out when this method
* enters. so I had to use a "previous approval status" variable to maintain it. no idea why. I don't see anything
* else that should be touching it... but clearly something clears it out.
*/
MyCompany.Tridion.RTFExtensions.Utilities.getListViewItemApprovalStatus = function (p,listViewObject) {
    //check if the item has actually been modified.
    if (p.versionNumberString != p.previousVersion) {
        var xmlDoc = listViewObject.getXmlDocument();
        if (xmlDoc) {
            p.approvalStatus = $xml.getInnerText(xmlDoc, "/tcm:*/tcm:Info/tcm:Data/tcm:ApprovalStatus/@xlink:title");
        }
    } else {
        p.approvalStatus = p.previousApprovalStatus;
    }
    if (p.approvalStatus === undefined || p.approvalStatus.toUpperCase() == 'UNAPPROVED') {
        var foo = p.approvalStatus;
        p.approvalStatus = 'WIP';
    }
    return p.approvalStatus;
};


/*
* Gets the PublishDate from the item list view
*/
MyCompany.Tridion.RTFExtensions.Utilities.getListViewItemPublishDate = function (p,listViewObject) {
    //modification won't alter publish date.
    var p = listViewObject.properties;
    return p.publishDate;
};


/*
*   get the modified date for the workflow version, overwrite OOB since that uses last major version
*/
MyCompany.Tridion.RTFExtensions.Utilities.getListViewItemUpdatedModifiedDate = function (p,listViewObject) {
    var xmlDoc = listViewObject.getXmlDocument();
    var modDate = $xml.getInnerText(xmlDoc, "/tcm:*/tcm:Info/tcm:VersionInfo/tcm:RevisionDate");
    return modDate;
}


/*
* Gets the updated Version information from the item
*/
MyCompany.Tridion.RTFExtensions.Utilities.getListViewItemUpdatedVersion = function (p,listViewObject) {
    var p = listViewObject.properties;
    var xmlDoc = listViewObject.getXmlDocument();
    var newVersionString = undefined;
    if (xmlDoc) {
        newVersionString = String.format("{0}.{1}", $xml.getInnerText(xmlDoc, "/tcm:*/tcm:Info/tcm:VersionInfo/tcm:Version"), $xml.getInnerText(xmlDoc, "/tcm:*/tcm:Info/tcm:VersionInfo/tcm:Revision"));
    }
    if (newVersionString != undefined) {
        //want to ensure we're getting a LATER version than we had (because it will try to load the non-workflow version afterwards...
        var iResult = newVersionString.localeCompare(p.previousVersion);
        if (p.previousVersion === undefined || iResult > 0) {
            p.versionNumberString = newVersionString;
        } else {
            p.versionNumberString = p.previousVersion;
        }
    } else {
        p.versionNumberString = p.previousVersion;
    }
    return p.versionNumberString;
};



function launchPopup(winURL, winName, winFeatures, winObj) {
    // this will hold our opened window
    var theWin;
    // first check to see if the window already exists
    if (winObj != null) {
        // the window has already been created, but did the user close it?
        // if so, then reopen it. Otherwise make it the active window.
        if (!winObj.closed) {
            winObj.focus();
            return winObj;
        }
        // otherwise fall through to the code below to re-open the window
    }
    // if we get here, then the window hasn't been created yet, or it
    // was closed by the user.
    theWin = window.open(winURL, winName, winFeatures);
    return theWin;
}

var $extUtils = MyCompany.Tridion.RTFExtensions.Utilities;

11
मुझे ऐसा त्रुटि संदेश सबसे अधिक बार किसी डोमेन में कुछ डालने से होता है अवैध रूप से उस कोड पर कोई अपडेट? इसके बिना आपको अधिक ठोस जवाब देना बहुत मुश्किल होगा।
फ्रैंक वैन पफलेन

4
मुझे देखने दो कि मैं कोड कैसे पोस्ट कर सकता हूं। यह बहुत बड़ा है। अगर मैं कर सकता हूं तो मैं अप्रासंगिक सामान को ट्रिम करने की कोशिश करूंगा। मुझे सीएमई सर्वर पर लॉग में कोई त्रुटि नहीं मिलती है। फ़ायरफ़ॉक्स एकमात्र ब्राउज़र है जो त्रुटि देता है। अन्य लोग कोई त्रुटि नहीं दिखाते हैं बस डेटा के साथ "कस्टम" कॉलम को आबाद नहीं करते हैं।
वार्नर सोडिटस

14
यह वर्तमान में Bugzilla पर अनसुलझा है । प्रासंगिक मोज़िला कोड
डेविडकॉन्ड्री

23
इसका शायद इससे कोई लेना-देना नहीं है, लेकिन आपकी क्लास के शुरुआती लोग आपके लिए MyCompany.Tridion.RTFExtensions.PageExसब कुछ सेट कर रहे हैं undefined। जब आप किसी विशेषता को परिभाषित कर रहे हैं, तब यह बता सकता है कि यह अपरिभाषित है - जिसका कोई मतलब नहीं है। nullयदि आप एक मूल्य नहीं चाहते हैं तो प्रारंभिक मूल्य निर्धारित करना बेहतर है । जैसा कि मैंने कहा कि यह कोई मायने नहीं रखता है, जब तक कि अन्य कोड परिभाषित कुंजियों के लिए जाँच नहीं कर रहा है ..
माइकल कॉक्सन

1
शायद यह मदद कर सकता है: w3schools.com/js/js_strict.asp इसके अलावा, यह आपकी समस्या को ठीक नहीं कर सकता है, लेकिन undefinedमैंने जो चेक देखा है वह काम typeof something === 'undefined'===, ==; =! =, या! == के साथ भी है। आप getOuterXml के बाद setXml निष्पादित करने के लिए setTimeout का उपयोग करने की कोशिश कर सकते हैं
Rivenfall

जवाबों:


2

[अपवाद ... "घटक ने विफलता कोड दिया: 0x80004002 (NS_NOINTERFACE) [nsIWebProgress.DOMWindow]"

इसका मतलब यह है कि nsIWebProgress ऑब्जेक्ट को कोई विंडो असाइन नहीं की गई थी । तो यह डेटा प्रदर्शित करने के लिए कहीं नहीं है।

nsresult: "0x80004002 (NS_NOINTERFACE)" स्थान: "JS फ्रेम :: क्रोम: //browser/content/tabbrowser.xml :: :: line 545" डेटा: नहीं]

यह आपको बता रहा है कि कौन सी फाइल उस त्रुटि से जुड़ी है। और किस लाइन पर यह फाल्ट हुआ।

लेकिन असली कुंजी NS_NOINTERFACE त्रुटि है। जिसका अर्थ है कि इंटरफ़ेस पंजीकृत नहीं किया गया है।

आप उपयोग कर रहे हैं Type.enableInterface()। क्या यह एक कस्टम तरीका है जिसे आप कहीं और घोषित कर रहे हैं? मैं इसे नहीं देखता। आप इसे बदलना चाह सकते हैं.registerInterface()

इस लिंक को देखें टाइप क्लास और Type.registerInterface ()

हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.