UI5 – ValueHelpRequest with the storage functionality

Home / Blog / UI5 – ValueHelpRequest with the storage functionality

Well, for those of you that don’t really care about the technical nuances of UI5, you’ll be happy to know that I can give it a rest for a bit after today.  Now, this took me way more time than it should have.  I kept looking for elegant solutions to solve this, and at the end of the day, I really should have just kept it simple (it’s ultimately what worked).  So, the issue with the valuehelprequest is that it doesn’t send back a text value, rather it sends back and object.  This object has Tokens and other pieces.  Well, since I”m using the storage method to save this to the browser so it can be saved for the user, storage can NOT write an object.  It pretty much has to be JSON text.  It initially took me some time to figure out why it stopped saving anything to my browser.  Once I finally figured out the cause, then I went into solution mode.

My first idea (that spent entirely too much time on) was to build a simple JSON model and assign that model to my storage object.  Well, I didn’t really think it through, since a JSON model is an object itself…  but I tried for a while with arrays, JSON, etc…  Needless to say, this approach did not work for me.  Finally, I decided to just convert it to a text string.  Even this took a little time, since I needed to figure out keys to use in order to be able to read it back without the possibility of random data screwing it up (and it could still happen… but it’s at least unlikely).

So, I chose to capture it in the following format:

Key%%%Text;;; Key%%%Text;;;  for as many search criteria as the user entered.

Then, when I come back, I can read the method I wrote about yesterday to get all the values I needed to create a filter or to re-write the values into the input fields.  I used a simple while loop to get it back:

iLen = val.length;
while (iLen > 0) {
iEnd = val.indexOf(“%%%”);
sKey = val.slice(0, iEnd);
val = val.slice(iEnd + 3, iLen);
iEnd = val.indexOf(“;;;”);
sText = val.slice(0, iEnd);
val = val.slice(iEnd + 3, iLen);
iLen = val.length;
// call my method from yesterday’s post
oTok = ProxProdSup.util.Formatter.getFilters(sKey, sText);
//  then either create tokens for the input field or create filters.

Thanks for reading,

As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,
Mike

Leave a Reply

Your email address will not be published. Required fields are marked *