事实上我的问题在SAPUI5 OData Binding not refreshing on route navigation之前已经被问到了,但是因为在那个特定的帖子中没有提供答案,我需要在这里以某种方式重新发布它,因为我不能对上述帖子发表评论,我也不能在海报上留言。
我的应用程序中的几乎所有内容都应该正常工作,但Detailview中ObjectHeaders的所有数据字段只会写入一次。在第一次写入值之后,它永远不会再次更改。
有人知道为什么会这样吗?
编辑:你是对的,我很吵。这就是我设置App模型的init函数:
init : function () {
this.oListSelector = new ListSelector();
this._oErrorHandler = new ErrorHandler(this);
// set the device model
this.setModel(models.createDeviceModel(), "device");
// set the FLP model
this.setModel(models.createFLPModel(), "FLP");
// set the dataSource model
this.setModel(new sap.ui.model.json.JSONModel({"uri":"*placeholder*/sap/opu/odata/SAP/Z_APPROVALSERVICE_SRV/"}), "dataSource");
// call the base component's init function and create the App view
UIComponent.prototype.init.apply(this, arguments);
// create the views based on the url/hash
this.getRouter().initialize();
}
接下来是我对Split应用程序的主视图:
<mvc:View xmlns:mvc="sap.ui.core.mvc" controllerName="com.sap.build.standard.approvalApp.controller.Worklist" xmlns:m="sap.m">
<m:Page showHeader="true" title="{masterView>/title}" showFooter="true">
<m:content>
<m:List id="sap_m_List_1" mode="SingleSelectMaster" width="100%" headerText="Header" footerText="" backgroundDesign="Solid" showSeparators="All" growing="false" growingThreshold="20" growingScrollToLoad="true" itemPress="_onListItemPress1" items="{/GeneralDataSet}">
<m:items>
<m:ObjectListItem intro="{Description}" title="{path: 'DueDate', type: 'sap.ui.model.type.Date', formatOptions: { UTC: true, style: 'short' }}" number="{Priority}" numberUnit="" numberState="None" type="Active" selected="false" showMarkers="false">
<m:attributes/>
<m:firstStatus>
<m:ObjectStatus title="Estimated Validation Effort" text="{EstimatedValidationEffort}" state="None"/>
</m:firstStatus>
<m:secondStatus>
<m:ObjectStatus title="Estimated Implementation Effort" text="{EstimatedImplEffort}" state="None"/>
</m:secondStatus>
</m:ObjectListItem>
</m:items>
<m:headerToolbar>
<m:Toolbar visible="true" enabled="true" width="" design="Solid">
<m:content>
<m:SearchField value="" placeholder="Insert term to search for" showSearchButton="false" visible="true" liveChange="_onSearchFieldLiveChange"/>
</m:content>
</m:Toolbar>
</m:headerToolbar>
</m:List>
</m:content>
<m:footer>
<m:Bar design="Footer">
<m:contentLeft/>
<m:contentMiddle/>
<m:contentRight/>
</m:Bar>
</m:footer>
<m:headerContent/>
<m:subHeader/>
</m:Page>
...详情视图
<mvc:View xmlns:mvc="sap.ui.core.mvc" controllerName="com.sap.build.standard.approvalApp.controller.BusinessTransaction" xmlns:m="sap.m" xmlns:layout="sap.ui.layout" xmlns:form="sap.ui.layout.form">
<m:Page showHeader="true" title="Master View" showFooter="true" showNavButton="false">
<m:content>
<layout:VerticalLayout width="100%" visible="true">
<layout:content>
<m:ObjectHeader intro="Due Date" title="{path: 'DueDate', type: 'sap.ui.model.type.Date', formatOptions: { UTC: true, style: 'short' }}" number="{Priority}" numberUnit="" numberState="None" showMarkers="false" markFavorite="false" markFlagged="false" backgroundDesign="Transparent" condensed="false">
<m:attributes>
<m:ObjectAttribute title="" text="{Description}" active="false"/>
</m:attributes>
<m:statuses/>
</m:ObjectHeader>
<m:IconTabBar expandable="true" expanded="true" applyContentPadding="false" backgroundDesign="Solid" upperCase="false" visible="true" selectedKey="Ok">
<m:content/>
<m:items>
<m:IconTabFilter icon="sap-icon://hint" iconColor="Default" text="Header Data" count="" design="Vertical" enabled="true" showAll="false" textDirection="Inherit" visible="true">
<m:content>
<m:ObjectHeader intro="" title="{ID}" icon="" number="" numberUnit="" numberState="None" showMarkers="false" markFavorite="false" markFlagged="false" backgroundDesign="Translucent" condensed="false">
<m:attributes>
<m:ObjectAttribute title="Current Status" text="{Status}" active="false"/>
<m:ObjectAttribute title="Category" text="{Category}" active="false"/>
<m:ObjectAttribute title="Classification" text="{Classification}" active="false"/>
<m:ObjectAttribute title="Assignee" text="{Assignee}" active="false"/>
<m:ObjectAttribute title="Created by" text="{CreatedBy}" active="false"/>
<m:ObjectAttribute title="Created at" text="{path: 'CreatedAt', type: 'sap.ui.model.type.Date', formatOptions: { UTC: true, style: 'short' }}" active="false"/>
<m:ObjectAttribute title="Last changed by" text="{LastChangedBy}" active="false"/>
<m:ObjectAttribute title="Last changed at" text="{path: 'LastChangedAt', type: 'sap.ui.model.type.Date', formatOptions: { UTC: true, style: 'short' }}" active="false"/>
</m:attributes>
<m:statuses/>
</m:ObjectHeader>
</m:content>
</m:IconTabFilter>
<m:IconTabFilter icon="sap-icon://comment" iconColor="Default" text="Comments" count="" design="Vertical" showAll="false" textDirection="Inherit" enabled="true" visible="true" iconDensityAware="false">
<m:content>
<m:List width="100%" growing="false" growingThreshold="20" growingScrollToLoad="false" backgroundDesign="Solid" items="{commented}">
<m:items>
<m:FeedListItem icon="" sender="{ID}" text="{CreatedBy}" info="{path: 'CreatedAt', type: 'sap.ui.model.type.Date', formatOptions: { UTC: true, style: 'short' }}" timestamp="{Comment}"/>
</m:items>
</m:List>
<m:FeedInput showIcon="false" icon="" placeholder="Type your comment here" enabled="true" visible="true" maxLength="0" buttonTooltip="Submit"/>
</m:content>
</m:IconTabFilter>
<m:IconTabFilter icon="sap-icon://approvals" iconColor="Default" text="Approvals" count="" design="Vertical" showAll="false" textDirection="Inherit" enabled="true" visible="true" iconDensityAware="false">
<m:content>
<m:List id="approvalList" mode="SingleSelectMaster" width="100%" headerText="Header" footerText="" backgroundDesign="Solid" showSeparators="All" growing="true" growingThreshold="20" growingScrollToLoad="true" items="{wantToBeApproved}" press="_onButtonPress8">
<m:infoToolbar>
<m:Toolbar width="100%" height="auto" design="Auto" visible="false" enabled="true">
<m:content>
<m:Label text="Label" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit"/>
</m:content>
</m:Toolbar>
</m:infoToolbar>
<m:headerToolbar>
<m:Toolbar visible="true" enabled="true" width="" design="Solid">
<m:content>
<m:SearchField placeholder="Search" showSearchButton="true" visible="true" width="100%"/>
</m:content>
</m:Toolbar>
</m:headerToolbar>
<m:items>
<m:ObjectListItem intro="{ID}" title="{ApproverRole}" number="{Decision}" numberUnit="" numberState="None" type="Active" selected="true" showMarkers="false">
<m:attributes>
<m:ObjectAttribute text="{ApproverName}" active="false"/>
<m:ObjectAttribute text="{ApproverUser}" active="false"/>
</m:attributes>
<m:firstStatus>
<m:ObjectStatus text="{ApproverRole}" state="None"/>
</m:firstStatus>
<m:secondStatus>
<m:ObjectStatus title="Pass" text="{Pass}" state="None"/>
</m:secondStatus>
</m:ObjectListItem>
</m:items>
</m:List>
</m:content>
</m:IconTabFilter>
<m:IconTabFilter icon="sap-icon://project-definition-triangle" iconColor="Default" text="Change Definitions" count="" design="Vertical" showAll="false" textDirection="Inherit" enabled="true" visible="true" iconDensityAware="false">
<m:content>
<m:List mode="SingleSelectMaster" width="100%" headerText="Header" footerText="" backgroundDesign="Solid" showSeparators="All" growing="true" growingThreshold="20" growingScrollToLoad="true">
<m:infoToolbar>
<m:Toolbar width="100%" height="auto" design="Auto" visible="false" enabled="true">
<m:content>
<m:Label text="Label" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit"/>
</m:content>
</m:Toolbar>
</m:infoToolbar>
<m:headerToolbar>
<m:Toolbar visible="true" enabled="true" width="" design="Solid">
<m:content>
<m:SearchField placeholder="Search" showSearchButton="true" visible="true" width="100%"/>
</m:content>
</m:Toolbar>
</m:headerToolbar>
<m:items/>
</m:List>
</m:content>
</m:IconTabFilter>
<m:IconTabFilter icon="sap-icon://attachment" iconColor="Default" text="Attachments" count="" design="Vertical" showAll="false" textDirection="Inherit" enabled="true" visible="true" iconDensityAware="false">
<m:content>
<m:UploadCollection uploadEnabled="false" numberOfAttachmentsText="" showSeparators="All" noDataText="The UploadCollection coming from BUILD cannot work in WebIDE without additional work" maximumFileSize="10" mimeType="image/jpeg,image/gif,image/png,text/plain,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" multiple="false" uploadUrl="" sameFilenameAllowed="false" mode="SingleSelectMaster" uploadComplete="_onUploadCollectionUploadComplete" change="_onUploadCollectionChange" typeMissmatch="_onUploadCollectionTypeMissmatch" fileSizeExceed="_onUploadCollectionFileSizeExceed">
<m:headerParameters/>
<m:items/>
<m:parameters/>
<m:toolbar/>
</m:UploadCollection>
</m:content>
</m:IconTabFilter>
<m:IconTabFilter icon="sap-icon://history" iconColor="Default" text="Protocol" count="" design="Vertical" showAll="false" textDirection="Inherit" enabled="true" visible="true" iconDensityAware="false">
<m:content>
<m:List mode="SingleSelectMaster" width="100%" headerText="Header" footerText="" backgroundDesign="Solid" showSeparators="All" growing="true" growingThreshold="20" growingScrollToLoad="true">
<m:infoToolbar>
<m:Toolbar width="100%" height="auto" design="Auto" visible="false" enabled="true">
<m:content>
<m:Label text="Label" design="Standard" width="100%" required="false" textAlign="Begin" textDirection="Inherit"/>
</m:content>
</m:Toolbar>
</m:infoToolbar>
<m:headerToolbar>
<m:Toolbar visible="true" enabled="true" width="" design="Solid">
<m:content>
<m:SearchField placeholder="Search" showSearchButton="true" visible="true" width="100%"/>
</m:content>
</m:Toolbar>
</m:headerToolbar>
<m:items/>
</m:List>
</m:content>
</m:IconTabFilter>
</m:items>
</m:IconTabBar>
</layout:content>
</layout:VerticalLayout>
<form:ResponsiveGridLayout columnsM="1" columnsL="2" emptySpanL="0" emptySpanM="0" emptySpanS="0" visible="true" labelSpanS="12" labelSpanM="2" labelSpanL="4"/>
</m:content>
<m:footer>
<m:Bar design="Auto">
<m:contentLeft/>
<m:contentMiddle/>
<m:contentRight>
<m:Button text="Forward" type="Default" iconFirst="true" width="auto" enabled="false" visible="false" iconDensityAware="false" press="_onButtonPress7"/>
<m:Button text="Approve" type="Accept" iconFirst="true" width="auto" enabled="true" visible="true" iconDensityAware="false" press="_onButtonPress8"/>
<m:Button text="Reject" type="Reject" iconFirst="true" width="auto" enabled="true" visible="true" iconDensityAware="false" press="_onButtonPress9"/>
</m:contentRight>
</m:Bar>
</m:footer>
<m:headerContent/>
<m:subHeader/>
</m:Page>
由于我不是一个优秀的程序员,我不确定你还需要什么,所以如果有任何遗漏,请告诉我。
问题是,详细信息视图中的ObjectHeaders仅使用数据刷新一次。此外,似乎字段只写了一次,如果它是空的。在第一次将数据设置为ObjectAttribute字段后,之后不会再次更改数据。
这是为什么? (这与引用的帖子提到的问题完全相同)
答案 0 :(得分:0)
由于这是JSON模型,因此您可以尝试以下方法:
var oModel = new sap.ui.model.json.JSONModel();
setInterval(function() {
var uri = "*placeholder*/sap/opu/odata/SAP/Z_APPROVALSERVICE_SRV/"
oModel.loadData(uri, true);
}, 1000);
this.setData(oModel, "dataSource");
尽管我不建议您使用setInterval
,但您可以将uri
包装在deltatimer
DeltaTimer