GHANIFIED! examples - advanced searching with autoupdate
Origins and where we use thisWell ... Google does is, Microsoft as well and many other toolkits have a capable widget too. But let us use Google as a example on how we use this very often.
As you start typing, the first fitting results are brought back to you offering a possible search result. This is quiete fancy and very appreciated, because we don't need to type in the complete phrase of what we are searching for.
The technical aspectWith every character we type into the search field, a new request is launched into Uniface (or whatever BackEnd is on duty). The cheap trick is to modify a retrieve profile (stop laughing, I know this is not rocket science :) ) with every new character entered. This produces some traffic on the DBMS but well ... this is fancier than every trigger within Uniface forms and makes our software smarter :))
Live exampleThe example will pick the first 10 hits on what you type and put the result into an output container below the input field. Keep in mind, that these are only demo values and I dont keep a million occurences ready to proof my stuff (*big smile to George*). At the moment we have about 250 words in store :)
Sorry- ... please log-in or register to get this!
Uniface takes the request and builds a retrieve profile with the given phrase. Each occurence is buffered in a STRING with desired format. This could be html, json, xml or simple text. For my example I took plain text. You will have to put the output into $webinfo("output").
Consider to make an operation within your Uniface server page beginning with "ajax_". Naming those operations like that makes it easier to scope. I will here name it "ajax_get_phrase". Putting the code into an operation leaves us the option of adding more function to it, without having to many if-param-x-is-then-do statements in the EXEC() trigger!
Further we need to tweak the READ trigger a bit, in order not to stress Uniface to much. We just want 10 occurences in each poll! Therefor we take a component var $MAX_OCCS$ (numeric) holding the amount of wanted occurences. If this is set to 0, the read trigger will do a normal read. If not, it will try to get a maximum of $MAX_OCCS$ occurences.
In order to get the maximum speed out of this server page, whipe the GETSTATE and SETSTATE trigger!
All this together finishes this example.
Thanks for reading!
I managed to extend my html knowledge with the above example but even better it all simply works.. wow.. html, ajax and a usp (called with input, data retrieve, and output RIA stylie). I did it without Ghanified just to fully understand what is going on in the background.