MainPanel.html
<div class="ecmWorkTabs" style="padding: 0; border: 0; background-color: transparent; width: 100%; height: 100%;"> <div data-dojo-type="dijit.layout.StackContainer" data-dojo-attach-point="stackContainer"> <div data-dojo-type="com.itccxx.widget.dm.searchuse.searchplatform.SearchPlatform" data-dojo-props='showNavigation: false, showPagination: true, searchBarName: "unifySearch"' ></div> </div> </div>在MainPanel中,指定了Navigation与SearchBar的内容,其中SearchBar在Json数据中配置,对应于unifySearch
<div class="ecmUnifySearch" style="left: 0px; top: 0px; padding: 0px"> <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-attach-point="container" style="padding: 0px"> <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props='layoutAlign: "top"' style="padding: 0;"> <div style=" height:40px; text-align:left;margin-left:50px;"> <span style="height:70;font-size:22px; vertical-align:middle;">${resourceBundle.searchPlatformLabel}</span> <span data-dojo-type="dijit.form.TextBox" type="text" data-dojo-attach-point="inputBox" value="" trim="true" required="true" style="width:400px;height:35px;"></span> <span data-dojo-type="dijit.form.Button" data-dojo-attach-point="btnSearch1" data-dojo-attach-event="onClick: _onSearch"> ${resourceBundle.basicSearchButton} </span> <span data-dojo-type="dijit.form.Button" data-dojo-attach-point="btnSearch2" data-dojo-attach-event="onClick: _onAdvancedSearch"> ${resourceBundle.advancedSearchButton} </span> </div> </div> </div> </div>
_onSearch : function(event) { this.logger.debug("_onSearch"); var searchObj = this._buildSearchObject(); // TODO: process the event object console.dir([ "searchObj", searchObj ]); this.onSearch(searchObj); }, onSearch : function(event) { // Just for callback },
postCreate : function() { this.inherited(arguments); if (searchBar) { this.container.addChild(searchBar, 1); this.searchBar = searchBar; dojo.connect(searchBar, "onSearch", this, this.onSearch); } }, onSearch : function(event) { this.logger.debug("onSearch--->"); this.executeSearch(event); }, executeSearch : function(searchObj) { this.pagination.onPaging(searchObj); }, onPageChange : function(event) { this.logger.debug("onPageChange"); dojo.forEach( event.items, function(item) { var dijit = new com.itccxx.widget.dm.searchuse.searchplatform.dijit.ResultItem(item); dijit.setData(item); dojo.connect(dijit, "onShowDetail", this, this._onShowDetail); this.resultListNode.appendChild(dijit.domNode); //widget.setIndex(index); }, this); },
<div class="ecmSearchPlatform" style="padding: 0"> <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-attach-point="container" style="padding: 0px 0px 2px 0px;"> <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props='layoutAlign: "top"' data-dojo-attach-point ="navigationPane" style="padding: 0"> <div data-dojo-type="com.itccxx.common.dijit.searchlist.Navigation" data-dojo-attach-point ="navigation" data-dojo-attach-event="onFolderChange: onFolderChange"></div> </div> <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props='layoutAlign: "client"'> <div data-dojo-attach-point="resultListNode" tabindex="0"> </div> </div> <div data-dojo-type="com.itccxx.widget.dm.searchuse.searchplatform.dijit.ResultView" data-dojo-props='layoutAlign: "right", splitter:true' data-dojo-attach-point="resultView"></div> <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props='layoutAlign: "bottom"' data-dojo-attach-point="paginationPane" style="padding: 0"> <div data-dojo-type="com.itccxx.common.dijit.searchlist.Pagination" data-dojo-attach-point="pagination" data-dojo-attach-event="onPageChange: onPageChange"></div> </div> </div> </div>因为resultItem.html是嵌套在searchPlatform页面中的,所以调用searchPlatform中的dijit.setData()时,子页面resultItem中会直接调用
setData : function(data) { this.resultTitle.innerHTML = data.fileName; this.resultDocDate.innerHTML = data.validDate; this.data = data; }
<div data-dojo-attach-point="resultListNode" tabindex="0"/> <div data-dojo-type="com.itccxx.widget.dm.searchuse.searchplatform.dijit.ResultView" data-dojo-props='layoutAlign: "right", splitter:true' data-dojo-attach-point="resultView"/>上面两段div分别对应着两个不同的面板,分别是结果集与结果集的详细信息,这两个内容属于兄弟节点,我们如何在这两个页面间传递数据呢?
showResult : function(result) { this.logger.debug(); this.broadcastEvent("ShowResultViewDetail", { result : result }); }showResult是resultItem中Button触发时响应的方法,该方法通过broadcaseEvent向外广播一个事件,在其它页面中,只要捕获到ShowResultViewDetail方法,就可以将
handleShowResultViewDetail : function(event){ var item = event.payload.result; this.setData(item); }
通过broadcastEvent 和 handleXxxXxx就可以进行不同页面间交互了,是不是很High!