Web Connection
problems with login page
Gravatar is a globally recognized avatar based on your email address. problems with login page
  Adam W
  All
  Feb 27, 2017 @ 03:02pm

I think there is a bug in a default template for login page (Web\views_login.wcs).

Every new project has: (bug on first "if" - should be: if vartype(pcErrorMessage) !="C' ):

<% pcPageTitle = "Application Sign in" %>
<% Layout="~/views/_layoutpage.wcs" %>
<%
if vartype(pcUsername) !="C"
  pcErrorMessage =""
endif
if vartype(pcUsername) !="C"
  pcUserName =""
endif
if vartype(pcPassword) !="C"
  pcPassword =""
endif
if vartype(pcRedirectUrl) !="C"
  pcRedirectUrl =""
endif
if vartype(pcDisplayMessage) != "C"
   pcDisplayMessage = ""
endif
%>

Anyway - even after correcting this template simple login page (code below) still gives me error message: Variable 'PCDISPLAYMESSAGE' is not found.

<%= RenderPartial("~/Views/_login.wcs") %>
    
<% section="scripts" %>
<% endsection %>

Gravatar is a globally recognized avatar based on your email address. re: problems with login page
  Rick Strahl
  Adam W
  Feb 27, 2017 @ 03:33pm

Are you overriding the Login method? pcDisplayError has to be defined in the callig code that shows this template and the default handler should do this.

Can you check the Web Connection demo and run the auth demo and check what you see there?

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: problems with login page
  Adam W
  Rick Strahl
  Mar 1, 2017 @ 11:44am

No, I wasn't loading it from VFP code, I just created login page in Visual Studio... Samples would help a lot but unfortunately most your samples (and documentation) are using DBFs and I'm fully on Ms SQL.

Is there any sample using SQL Server you can point me on ?

Thanks, Adam

Gravatar is a globally recognized avatar based on your email address. re: problems with login page
  Rick Strahl
  Adam W
  Mar 2, 2017 @ 04:40pm

Thanks for pointing out the error in the login template.

But this shouldn't cause any errors as the vartype(pcDisplayMessage) initializes the value if it's not in scope. I've tried to make this break, but I can't. So I'm not sure what's different for you to see this break.

As to SQL examples that's just a language feature.

You can take a look at the MVC sample using business objects. You can hook the business objects to a SQL Database instead.

In the business object Wizard select SQL Server and then point at a SQL connection string for a database you want to work with. You'll have to precreate the data.

We also provide the wwSql class which makes it easy to access and use SQL server data.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: problems with login page
  Adam W
  Rick Strahl
  Mar 3, 2017 @ 11:57am

Thanks Rick! I went throu MVC sample and below is my first impression:

Currently on every business object you have to provide SQL connection string and this string is written into prg. This is perfect when each b. obj comes from different database but this is very rare case... It would be very nice to re-use connection string already provided for whole app - similiar way as Visual Studio shows dropdown with connection strings from web.config file or allows you to add one on the fly - just my 2 cents.

Also I notice that after upgrade to 6.10 when I run VFP it still shows 6.07 on the header. I think c:\wconnect\config.fpw still has title from previous version...

Adam

Gravatar is a globally recognized avatar based on your email address. re: problems with login page
  Rick Strahl
  Adam W
  Mar 3, 2017 @ 02:09pm

The business object just has a proeprty for the connection string, but it's up to you to set that. It's not the responsibility of the bus object to discover configuration settings although you're free to build that into the Init() of the bus object if you choose.

Personally I prefer to use a factory method in my application or process class that creates my wwBusiness instance and that sets up the connection based on whatever location the config information is stored in:

FUNCTION CreateBusObject(lcBusClassName)

lcConnection = Server.oConfig.cSqlConnectionString

loBus = CREATE(lcBusClassName)
loBus.nDataMode = 2 && Sql Server
loBus.cConnectString = lcConnection


RETURN loBus
ENDFUNC

This can be a process class method or a standalone function (if you use bus objects in other places).

Then in your code in the process class:

loCustomer = THIS.CreateBusObject("cCustomer")
lnCount = loCustomer.Query("select * from customers")

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: problems with login page
  Adam W
  Rick Strahl
  Mar 3, 2017 @ 02:24pm

"It's not the responsibility of the bus object to discover configuration settings"

I agree - It would be nice if the "business object builder" will find that for you - otherwise you have to do it manually... I ususally navigate back to ini file and copy the connection string from there just to satisfy the builder. Later on I go back to the code - delete connection string and type the code to reuse existing connection....

Adam

Gravatar is a globally recognized avatar based on your email address. re: problems with login page
  Rick Strahl
  Adam W
  Mar 4, 2017 @ 01:30pm

It would be nice if the "business object builder" will find that for you

Not sure what you mean. The builder remembers your last settings and will generate a business object with the values you specify in the Wizard. However, hardcoding connection strings is never a good idea IMHO - this stuff should always come from configuration so you can switch connection strings and even providers more easily.

That's where a factory method or even a constructor helper comes in that lets the object configure itself when it starts up. But these things are application specific so there's no good way to make this generic and it's easy enough to create a factory or helper manually.

+++ Rick ---

© 1996-2017