Web Connection
Mixing angular approach with 'classic' webconnection
Gravatar is a globally recognized avatar based on your email address. Mixing angular approach with 'classic' webconnection
  n/a
  All
  Nov 25, 2014 @ 02:04am
Hi,

I have been looking through the documentation, but have not found an answer there to my question: Is it possible to use the 'classic' wwweblogin functionality together with an angular app? This would mean 2 process-classes in my project, one wwc_restprocess and one wwc_process. Is that possible? If not, how would you do authentication in an angular app?

Thanks for your help,
Stan

Gravatar is a globally recognized avatar based on your email address. Re: Mixing angular approach with 'classic' webconnection
  Harvey Mushman
  Stan
  Nov 25, 2014 @ 04:21am
Before the RESTProcess, adding callback functions to a subclass of Process was very straight forward and fast. Otherwise, you can always callback to the _page.wc file but that is a bit slower.

DEFINE CLASS myProcess AS WWC_PROCESS
*************************************************************

*** Response class used - override as needed
cResponseClass = [WWC_PAGERESPONSE]

...

FUNCTION CallBack37()

* Autocomplete search string
lcString = LOWER(Request.QueryString('SearchStr'))

* subclass of wwBusines already loaded
oItems = CREATEOBJECT('items')
oItems.cSql= [pk,itemname where LOWER(itemname) LIKE '] + lcString+ [%' ORDER BY itemname ]
oItems.cSqlCursor='tCursor'
oItems.Query()


loSerializer = CREATEOBJECT("wwJsonSerializer")
lcJSON = loSerializer.Serialize("cursor_rawarray:tCursor")

Response.Write(lcJSON)

RETURN .t.
ENDFUNC

In the above code example, Callback37 is used to fetch data of an autocomplete dropdown text box. All of the code to handle the callback and populating the control is handled with AngularJS. The Autocomplete code I started with was written by Daryl Rowland and is in the public domain. His samples were fairly easy to follow once I understood how to do the VFP Callback.

Oh, one other thing... I'm running on my laptop which is about five years old. I'm seeing hit times between 0.009 and 0.015. The Items.dbf file contains about 5500 records and the returned subset after the first three letters of the autocomplete are typed into the control which fires the first (worse case) hit is about 25 records. I'm not sure how much faster WC will get on the backend once I move onto a production server but for my purposes what I'm seeing on my laptop will be fine.

--hm


Hi,

I have been looking through the documentation, but have not found an answer there to my question: Is it possible to use the 'classic' wwweblogin functionality together with an angular app? This would mean 2 process-classes in my project, one wwc_restprocess and one wwc_process. Is that possible? If not, how would you do authentication in an angular app?

Thanks for your help,
Stan

Gravatar is a globally recognized avatar based on your email address. Re: Mixing angular approach with 'classic' webconnection
  Rick Strahl
  Stan
  Nov 25, 2014 @ 03:40pm
It depends :-) There are a number of ways to do this.

You could authenticate through an AJAX callback by calling an Authenticate API method. That API can then set the required cookie (or whatever you do validate the user). That way you don't need a separate class. Even without that you can override any Rest service method to return whatever you want:

this.oService.IsRawResponse = .t.

This basically disables the serialization of the result and returns whatever you send. Here you could return HTML (ExpandTemplate perhaps) or whatever you need.

Finally you can use the built in authentication stuff in a non REST process class (so yes you need a separate class). If you authenticate through the stock mechanism the Session cookie gets set and that cookie is valid for the REST HTTP requests as well so you can check authentication in the REST methods.

+++ Rick ---


Hi,

I have been looking through the documentation, but have not found an answer there to my question: Is it possible to use the 'classic' wwweblogin functionality together with an angular app? This would mean 2 process-classes in my project, one wwc_restprocess and one wwc_process. Is that possible? If not, how would you do authentication in an angular app?

Thanks for your help,
Stan



Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

© 1996-2024