Wednesday, September 23, 2015

SAPUI5 DatePicker backed by sap internal date format yyyymmdd

new sap.ui.commons.DatePicker({ 
 value: { path: "/KEYDATE", 
    type:  new sap.ui.model.type.Date({
     source: {pattern: "yyyyMMdd"},  
     pattern: "dd.MM.yyyy"})
}}),

Thursday, April 16, 2015

How to manage browser cache on SapUI5 / OpenUI5 applications - CacheBuster

The problem: you have an SapUI5 / OpenUI5 application currently being used and you want to change something to it. How do you force users to start loading the latest version?

Webapps are comprised of objects loaded via HTTP. These objects are mostly, images, html, javascript or css files. All these files are served with a validity date that can be set on the server. Browsers, for performance reasons, only load an url if they don't already have a copy of that resource in their cache or if the copy's validity already expired.

On *UI5 apps we cannot easily set the validity of the objects loaded server side so the only way to force users to load a new version is to force a change on the url being requested. This can be done by appending a parameter, changing the name of the object (view/controller, etc.) or, using the CacheBuster feature on UI5 that does this automatically.

When using CacheBuster, everything that is loaded via the jQuery.sap.require function has a timestamp inserted in the middle of the url. Because this timestamp can be controlled by developers, they can force browsers to load the latest version of the urls.

So, instead of the browser making this example request:
https://<hostname>/sap/bc/ui5_ui5/sap/<projname>/<appname>/main.view.js
It does the following:
https://<hostname>/sap/bc/ui5_ui5/sap/<projname>/~20141018120538~/<appname>/main.view.js

 This timestamp makes the url unique and it theoretically contains the timestamp this object was last changed. When the application is first started, the framework does a request to an url to get a json that tells it the timestamps when each file was last modified. These timestamps are then automatically appended to all requests.
This url to this json is something like :
https://<hostname>/sap/bc/ui5_ui5/sap/<projname>/sap-ui-cachebuster-info.json

 How to enable cachebuster on your ui5 app?
Too easy, just append data-sap-ui-appCacheBuster="./" to the script tag that loads the ui5.
e.g.

 <!DOCTYPE HTML>
<html>
 <head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  <script src="resources/sap-ui-core.js"
    id="sap-ui-bootstrap"
    data-sap-ui-libs="sap.ui.commons"
    data-sap-ui-theme="sap_goldreflection"
    data-sap-ui-appCacheBuster="./">
  </script>



Now, whenever you change the project or transport a new version, execute report /UI5/RESET_CACHEBUSTER on the backend. This report resets all these timestamps. I do not know if they are supposed to be reset automatically when checking in a new version or when transporting, but from my experience, manually executing is the only reliable way.

 Hope it helps

Wednesday, March 18, 2015

Extract MSI without admin rights

The following worked to install python on a windows machine without admin rights.
msiexec /a python-3.4.3.amd64.msi /qb TARGETDIR=C:\tiago\programas\python33

Saturday, March 14, 2015

Finding and deleting duplicate files with fdupes

In a large tree of files, it is common to have duplicate files under different paths. Let's say you want to find them and possibly delete them automatically.
First install fdupes
sudo apt-get install fdupes
Now 'cd' into your directory.
To make a summary of how much space you can save by deleting duplicate files, execute the following:
fdupes -r -m ./
To really delete the duplicate files:
fdupes -r -d -N ./
-N means no prompt (deleting wihout asking anything)
-d means delete
-r means recurse into all subdirectories
without any flag fdupes will print, for each duplicated file, its duplicates, for all files that have duplicates

Tuesday, March 3, 2015

Clear sapui5 cachebuster cache

To clear cache on sapui5 cachebuster functionality run report /UI5/RESET_CACHEBUSTER on sap.

Sunday, March 1, 2015

SapUI5 snippets

Get data of selected table row

var sPath = oEvent.getParameter("rowContext").getPath();
var oRowData = oModel.getProperty(sPath);
var oData = oModel.getData();

Route to another view (using latest component concept)

var router = sap.ui.core.UIComponent.getRouterFor(oController);
router.navTo("name_of_view", {}, false);