28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2. Specify the name, for example MyApplication, and location for your project. Select Desktop and Create an<br />

Initial View.<br />

You can also add a view later on by creating a separate <strong>SAP</strong>UI5 application view. If a new view has been<br />

created for an existing <strong>SAP</strong>UI5 application project, the view needs to be manually called either from the<br />

index.html page, or from another view via view nesting. For more information, see the Demo Kit -<br />

<strong>Developer</strong> <strong>Guide</strong> under Model View Controller Concept.<br />

3. Enter a name for the initial view in the Name field, for example, helloworld. Do not add a file extension.<br />

This is done automatically based on the respective view type.<br />

4. Choose JavaScript and finish the wizard.<br />

The following application parts are created:<br />

○ View file; in this example, a JSview file<br />

○ Controller file<br />

○ index.html file containing the references for the sap.ui.core and sap.ui.commons libraries, the<br />

theme (sap_goldreflection), and information about the script type and the script ID. In a second script<br />

block, the index file refers to the project name, view type, and name. A content default for placing the<br />

controls on the UI later on and the ARIA application role.<br />

5. Change the bootstrap tag (located in the index.html file) to enable the application to access the <strong>SAP</strong>UI5<br />

libraries on the xsengine as follows: src="resources/sap-ui-core.js" to src="/sap/ui5/1/<br />

resources/sap-ui-core.js".<br />

6. Create a new folder i18n in the WebContent folder. Add a new file messagebundle.hdbtextbundle<br />

to the i18n folder with the following content:<br />

# TRANSLATE<br />

# XBUT,30<br />

MY_BUTTON_TEXT=Hello {0} button<br />

Note: A specific suffix .hdbtextbundle is needed for the resource bundles on <strong>SAP</strong> <strong>HANA</strong> (so<br />

called .properties file on other platforms).<br />

7. To add a control to your view (in this example to the helloworld.view.js), insert the following coding:<br />

createContent : function(oController) {<br />

// require the jQuery.sap.resources module<br />

jQuery.sap.require("jquery.sap.resources");<br />

value<br />

}<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Building UIs with <strong>SAP</strong>UI5<br />

// load the resource bundle<br />

var oBundle = jQuery.sap.resources({<br />

// specify url of the .hdbtextbundle<br />

url : "i18n/messagebundle.hdbtextbundle"<br />

});<br />

var aControls = [];<br />

var oButton = new sap.ui.commons.Button({<br />

id : this.createId("MyButton"),<br />

// access the text using the welcome key and pass the<br />

// for the placeholder ( {0} ) via an array<br />

text : oBundle.getText("MY_BUTTON_TEXT", [ "World" ])<br />

});<br />

aControls.push(oButton.attachPress(oController.doIt));<br />

return aControls;<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved. 231

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!