<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: If-else statement in XML view in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118440#M4527775</link>
    <description>&lt;P&gt;As mentioned by the author, I was not able to find the namespace for template. I am surprised that SAP UI5 does not support something as simple as control statements in the XML views out of the box! What is the workaround for this?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Dec 2020 04:46:50 GMT</pubDate>
    <dc:creator>former_member509100</dc:creator>
    <dc:date>2020-12-02T04:46:50Z</dc:date>
    <item>
      <title>If-else statement in XML view</title>
      <link>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaq-p/12118435</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;
  &lt;P&gt;I'm a SAPUI5 beginner, having a problem with if-else statement in XML view.&lt;/P&gt;
  &lt;P&gt;I'm trying to create a table in XML view. Values in table are binded from .json file (in the future, values will be binded via oData service). Below is the code.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;mvc:View
	controllerName="demo.prototype.controller.TestController"
	xmlns:t="sap.ui.table"
	xmlns:mvc="sap.ui.core.mvc"
	xmlns:u="sap.ui.unified"
	xmlns:c="sap.ui.core"
	xmlns="sap.m"
	xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"&amp;gt;
        &amp;lt;t:Table
			rows="{/ProductCollection}"
			visibleRowCount="7"
			selectionMode="MultiToggle"
			width="75rem"&amp;gt;
		&amp;lt;t:columns&amp;gt;
			&amp;lt;t:Column width="10rem"&amp;gt;
				&amp;lt;Label text="{i18n&amp;gt;modelGroup}" /&amp;gt;
	        	&amp;lt;t:template&amp;gt;
					&amp;lt;Label text="{modelGroup}" /&amp;gt;
				&amp;lt;/t:template&amp;gt;
			&amp;lt;/t:Column&amp;gt;
                        &amp;lt;t:Column width="4rem"&amp;gt;
				&amp;lt;Label text="{i18n&amp;gt;line}" /&amp;gt;
				&amp;lt;t:template&amp;gt;
					&amp;lt;Label text="{line}"/&amp;gt;
				&amp;lt;/t:template&amp;gt;
			&amp;lt;/t:Column&amp;gt;
                        &amp;lt;t:Column width="6rem"&amp;gt;
				&amp;lt;Label text="{i18n&amp;gt;date}" /&amp;gt;
				&amp;lt;t:template&amp;gt;
					&amp;lt;Input value="{data1}"
					       description="/100" /&amp;gt;
				&amp;lt;/t:template&amp;gt;
			&amp;lt;/t:Column&amp;gt;
               &amp;lt;/t:columns&amp;gt;
	&amp;lt;/t:Table&amp;gt;
&amp;lt;/mvc:View&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I want to switch Control(Input or Label) or to switch "display &lt;EM&gt;description &lt;/EM&gt;or not" in Input control, depending on flg (true or false) in .json file. But I cannot find the way to do that. I found "http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1" in other questions and tried, but it did not work.&lt;/P&gt;
  &lt;P&gt;There are 2 ways probably・Implement in Controller ・Implement in XML view.&lt;/P&gt;
  &lt;P&gt;The 2nd way is preferable for me.&lt;/P&gt;
  &lt;P&gt;Could anyone help me?&lt;/P&gt;
  &lt;P&gt;If there is missing information, please point them out.&lt;/P&gt;
  &lt;P&gt;Thank you for your support.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 02:15:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaq-p/12118435</guid>
      <dc:creator>former_member659355</dc:creator>
      <dc:date>2019-10-08T02:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: If-else statement in XML view</title>
      <link>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118436#M4527771</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I  think you are looking for preprocessing concept in XML View - &lt;/P&gt;&lt;P&gt;Have a look on - &lt;A href="https://sapui5.hana.ondemand.com/#/topic/fc185952184c48618ef46306a1517f8c"&gt;https://sapui5.hana.ondemand.com/#/topic/fc185952184c48618ef46306a1517f8c&lt;/A&gt;&lt;/P&gt;&lt;P&gt;With &lt;EM&gt;Preprocessing Instructions&lt;/EM&gt; you can do stuff like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;template:iftest="{marketed}"&amp;gt;
 &amp;lt;template:then&amp;gt;
  &amp;lt;Labeltext="product is marketed"/&amp;gt;
 &amp;lt;/template:then&amp;gt;&amp;lt;template:else&amp;gt;
  &amp;lt;Imagesrc="path.jpg"/&amp;gt;
 &amp;lt;/template:else&amp;gt;
&amp;lt;/template:if&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you are looking for simple solution (Not Recommended/Suggetsed approach), you can use expression binding,  create two columns(Label and Input) then set the visibility as below &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Input visible= "{= ${condition} === true ? &amp;lt;option1&amp;gt; : &amp;lt;option2&amp;gt;}"&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Oct 2019 03:40:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118436#M4527771</guid>
      <dc:creator>bhuvneshkumar_gupta</dc:creator>
      <dc:date>2019-10-08T03:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: If-else statement in XML view</title>
      <link>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118437#M4527772</link>
      <description>&lt;P&gt;Thank you for your comment. I checked URL and tried, but it does not work.&lt;/P&gt;&lt;P&gt;Do you know whether xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1" is correct or not?&lt;/P&gt;&lt;P&gt;According to message, error is caused by &lt;EM&gt;Error: failed to load 'http://schemas/sap/com/sapui5/extension/sap/ui/core/template/1/if.js'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I was looking for alternate but cannot found.&lt;/P&gt;&lt;P&gt;Sorry to bother you again.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 09:59:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118437#M4527772</guid>
      <dc:creator>former_member659355</dc:creator>
      <dc:date>2019-10-08T09:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: If-else statement in XML view</title>
      <link>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118438#M4527773</link>
      <description>&lt;P&gt;you cannot use view with template directly. you have to pre-process the template.&lt;/P&gt;&lt;P&gt;use the easy way : a flag to control the visibility&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 13:13:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118438#M4527773</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2019-10-08T13:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: If-else statement in XML view</title>
      <link>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118439#M4527774</link>
      <description>&lt;P&gt;Thank you for your comment and advice.&lt;/P&gt;&lt;P&gt;I read the document about pre-processing, but it takes a little more time for me to understand that...&lt;/P&gt;&lt;P&gt;I will implement with &lt;EM&gt;visible &lt;/EM&gt;in control for now.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 00:50:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118439#M4527774</guid>
      <dc:creator>former_member659355</dc:creator>
      <dc:date>2019-10-10T00:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: If-else statement in XML view</title>
      <link>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118440#M4527775</link>
      <description>&lt;P&gt;As mentioned by the author, I was not able to find the namespace for template. I am surprised that SAP UI5 does not support something as simple as control statements in the XML views out of the box! What is the workaround for this?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2020 04:46:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/if-else-statement-in-xml-view/qaa-p/12118440#M4527775</guid>
      <dc:creator>former_member509100</dc:creator>
      <dc:date>2020-12-02T04:46:50Z</dc:date>
    </item>
  </channel>
</rss>

