2017-01-31 6 views
0

UI5アプリケーションとシンプルなフォームに問題があります。探検されたアプリの例に表示されているように。XMLへのフラグメントイベントバインディングが動作しない

編集を押すと、ページの内容がフラグメントの別のSimpleForm(コントローラのコードビハインド)に置き換えられます。

私も同じです。唯一の違いは、SimpleFormのコンテンツをXMLフラグメントに格納されているコントロールに置き換えることです。

今、私はボタンをクリックするイベントは、基になるコントローラにバインドする必要があります。しかし、コードビハインドでこれを行うと、コントローラ上のイベントはもう発生しません。これは、XMLビュー定義ファイルでフラグメントを使用していたときに機能しましたが、現在はありません。

controllerModelPropertyChanged(oEvent: sap.ui.base.Event) { 
      let cdata = (oEvent.getSource() as any).getData() as agenttemplatesdetailcontroller; 
      let p = this.byId("form") as sap.ui.layout.form.SimpleForm; 
      for(let c of p.getContent()) 
       c.destroy(); 
      p.removeAllContent(); 
      let f = sap.ui.xmlfragment("ifm.datalink.linerecorder.ams.frontend.view.fragments.agentTemplates."+ (cdata.edit ? "AgentTemplateDetailsEdit" : "AgentTemplateDetailsDisplay")) as sap.ui.core.Control[]; 
      f.forEach((v) => { p.addContent(v); }); 
     } 

コントロールを追加するときにコントローラにバインドされたイベントはバインドされていませんか?手動でバインドする必要がありますか?

EDIT:

ディスプレイフラグメント:

<core:FragmentDefinition 
     xmlns="sap.m" 
     xmlns:core="sap.ui.core" 
     xmlns:u="sap.ui.unified"> 
     <Label text="{i18n>templates.details.name}"/> 
     <Text text="{template>/Name}" enabled="{form>/enabled}"/> 
     <Label text="{i18n>templates.details.description}"/> 
     <Text text="{template>/Description}" editable="{form>/enabled}"/> 
     <List headerText="{i18n>templates.details.versionsTitle}" items="{template>/Versions}"> 
     <CustomListItem> 
      <HBox> 
      <Label text="{template>Version/Major}.{template>Version/Minor}.{template>Version/Build}"/> 
      <Label text=" ({parts: [{path: 'template>CreationDate', type: 'sap.ui.model.odata.type.Date'}, {path: 'i18n>global.dateformat', type: 'sap.ui.model.type.String'}], formatter: '.odatadateformatter'})"/> 
      <Label text="{ams>Guarantor/username}"/> 
      </HBox> 
      </CustomListItem> 
     </List> 
</core:FragmentDefinition> 

編集フラグメント:

<core:FragmentDefinition 
     xmlns="sap.m" 
     xmlns:core="sap.ui.core" 
     xmlns:u="sap.ui.unified"> 
     <Label text="Name"/> 
     <Input value="{template>/Name}" enabled="{form>/enabled}"/> 
     <Label text="Description"/> 
     <TextArea value="{template>/Description}" editable="{form>/enabled}"/> 
     <Label text="Upload new Version"/> 
     <u:FileUploader id="fileUploader" name="MyFileUpload" uploadUrl="http://localhost:13917/api/fileupload/uploadfile" tooltip="Upload your file to the local server" uploadComplete="handleUploadComplete"/> 
     <Button text="Upload File" press="AddNewTemplateVersion"/> 
     <List headerText="{i18n>templates.details.versionsTitle}" items="{template>/Versions}"> 
     <CustomListItem> 
      <HBox> 
      <Label text="{template>Version/Major}.{template>Version/Minor}.{template>Version/Build}"/> 
      <Label text=" ({parts: [{path: 'template>CreationDate', type: 'sap.ui.model.odata.type.Date'}, {path: 'i18n>global.dateformat', type: 'sap.ui.model.type.String'}], 
          formatter: '.odatadateformatter'})"/> 
      <!--<Label text="{ams>Guarantor/username}"/>--> 
      </HBox> 
      </CustomListItem> 
     </List> 
    </core:FragmentDefinition> 

ビュー:

<mvc:View 
     controllerName="ifm.datalink.linerecorder.ams.frontend.controller.agentTemplates.AgentTemplatesDetail" 
     xmlns="sap.m" 
     xmlns:core="sap.ui.core" 
     xmlns:commons="sap.ui.commons" 
     xmlns:f="sap.ui.layout.form" 
     xmlns:l="sap.ui.layout" 
     xmlns:mvc="sap.ui.core.mvc"> 
    <f:SimpleForm 
      class="lra5form" 
      minWidth="500" 
      maxContainerCols="2" 
      layout="ResponsiveGridLayout" 
      title="{i18n>templates.details.title}" 
      editable="{controller>/edit}" 
      labelSpanL="3" 
      labelSpanM="3" 
      emptySpanL="4" 
      emptySpanM="4" 
      columnsL="1" 
      columnsM="1" 
      id="form"> 
    <f:toolbar> 
     <Toolbar> 
     <Button text="{i18n>templates.details.edit}" icon="sap-icon://edit" enabled="{= !${controller>/edit}}" press="onEditPressed" /> 
     <Button text="{i18n>templates.details.delete}" icon="sap-icon://delete" press="onDelete" visible="{= !${controller>/edit}}" /> 
     <ToolbarSpacer/> 
     <Button text="{i18n>global.accept}" icon="sap-icon://accept" press="onAcceptClicked" visible="{controller>/edit}" enabled="{controller>/changed}"/> 
     <Button text="{i18n>global.cancel}" icon="sap-icon://cancel" press="onCancelClicked" visible="{controller>/edit}" /> 
     </Toolbar> 
    </f:toolbar> 
    <f:content> 
     <core:Fragment fragmentName="ifm.datalink.linerecorder.ams.frontend.view.fragments.agentTemplates.AgentTemplateDetailsDisplay" type="XML"/> 
    </f:content> 
    </f:SimpleForm> 
</mvc:View> 
+0

あなたがフラグメント+フラグメントのコードを参照するビューのXML宣言を共有することができます。

ここフラグメントのコールバックのドキュメントへのリンクがありますか? –

+0

あなたはあなたの助けに感謝します。私はコントローラのイベントハンドラの名前を変更しませんでした。 –

+0

press = "controllerModelPropertyChanged"イベントのボタンが表示されません。このイベントは関数を呼び出すはずですか? –

答えて

関連する問題