如何在sapui5中打开媒体源?

如何在sapui5中打开媒体源?,sapui5,Sapui5,我有一个sap网关服务,它从类型/iwbep/cl_mgw_abs_data=>ty_s_media_resource返回一个文件流 我的问题是:如何在sapui5中打开此文件 因此,在sapui5中,我有一个包含listitems的列表。这些列表项必须在单击时打开文件流(pdf)。提供pdf的OData URL将如下所示。 /sap/opu/odata/…/$value 你有两个选择 选择项目后,在新选项卡中打开相应的URL。 “新建”选项卡将自动呈现PDF 创建一个UI5视图,其中 包含一个

我有一个sap网关服务,它从类型/iwbep/cl_mgw_abs_data=>ty_s_media_resource返回一个文件流

我的问题是:如何在sapui5中打开此文件


因此,在sapui5中,我有一个包含listitems的列表。这些列表项必须在单击时打开文件流(pdf)。

提供pdf的OData URL将如下所示。 /sap/opu/odata/…/$value

你有两个选择

  • 选择项目后,在新选项卡中打开相应的URL。 “新建”选项卡将自动呈现PDF
  • 创建一个UI5视图,其中 包含一个iframe(使用UI5 html控件)并呈现上述URL 在iframe内部
  • 我同意@Krisho

    选项1.-在单独选项卡中打开URL。像这样的

    <Button text="Open PDF" press="onPress"></Button>
    
    onPress: function(oEvent){
        sap.m.URLHelper.redirect("https://sapui5.hana.ondemand.com/docs/maintenancestrategy.pdf", true)
    }
    
    
    onPress:功能(oEvent){
    sap.m.URLHelper.redirect(“https://sapui5.hana.ondemand.com/docs/maintenancestrategy.pdf“,对)
    }
    
    这里有一个片段:

    选项2-创建iFrame

    大概是这样的:

      createContent : function(oController) {
                var html = new sap.ui.core.HTML();
                html.setContent("<div id=\"divPdf\"><iframe id='pdfFrame' style=\"height:1000px;\"></iframe>");
                return new sap.m.Page({
                      title : "PDF View",
                      showNavButton : true,
                      navButtonPress : oController.fnGoback,
                      content : [ html ],
                      footer : new sap.m.Bar({
                      })
                });
          }
    
    createContent:函数(oController){
    var html=new sap.ui.core.html();
    html.setContent(“”);
    返回新的sap.m.Page({
    标题:“PDF视图”,
    showNavButton:对,
    导航按钮按:oController.fngback,
    内容:[html],
    页脚:新的sap.m.Bar({
    })
    });
    }
    
    我从这篇旧文章中选取了最后一段: