如何从SAP Ui5中的XML文件读取HTML输入字段?

问题描述 投票:0回答:1

下面是XML视图的代码片段,我能够读取ID“ Name1”,但无法读取/写入HTML标记中的“ Name2”,它返回未定义。您可以帮助我如何访问HTML标记中的“ Name2”吗?

谢谢

sap.ui.getCore().byId("Name1").setValue(oData.FirstName + " " + oData.LastName + ); // sets the value

// Retunrs undefined
sap.ui.getCore().byId("Name2").setValue(oData.FirstName + " " + oData.LastName + ); // Sets no value
<core:FragmentDefinition
  xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
  xmlns:l="sap.ui.layout" xmlns:f="sap.ui.layout.form" xmlns="sap.m"
  xmlns:html="http://www.w3.org/1999/xhtml">
  <Panel class="pnlSearchDate" id="pnlContent">
    <html:span class="textcolor">
      <html:b>TITLE</html:b>
    </html:span>
    <html:br />
    <HBox alignItems="Center">
      <Label class="textcolor" width="300px" text="{i18n>txtName}" />
      <Input id="Name1" class="inputbordercolor" editable="false" width="300px"/>
    </HBox>
    <HBox justifyContent="Center">
      <VBox width="100%">
        <html:div class="textcolor"
          style="font-size: 0.875rem;font-family: Arial,Helvetica,sans-serif;line-height:25px;color:#6a7694;text-align:justify;">
          <html:p>
            I,
            <html:input class="inputEntry" id="Name2" 
              editable="false"></html:input>
            I hereby confirm that I received one session of XXX.
          </html:p>
        </html:div>
      </VBox>
    </HBox>
  </Panel>
</core:FragmentDefinition>
xml sapui5 sap
1个回答
0
投票

尝试以下解决方案:

sap.ui.getCore().byId(this.getView().createId("Name2"));

来源:https://stackoverflow.com/a/37171149/9262488

© www.soinside.com 2019 - 2024. All rights reserved.