How to use CXP pages with eXpress++ library functions

Xbase++ 2.0 Build 554 or later
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

How to use CXP pages with eXpress++ library functions

#1 Post by rdonnay »

Here are instructions for setting up CXP to use your own libraries or eXpress++ libraries.

Under the WWW root directory of your CXP application, you will need to create a new folder named Helpers.
For example, below is the CXP source code for an application that lists customers from a database. The application is in a file named CUSTOMER.CXP under C:\wamp\www\ds\customers (I am using Apache). If I were using IIS then it would be in C:\inetpub\wwwroot\ds\customers.

I created a folder named C:\wamp\www\ds\customers\Helpers and I copied DCLIPX.LIB and DCLIPX.DLL into the Helper folder.

I then created a file named C:\wamp\www\ds\customers\application.config. It has the following content:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>

<info author   = "Roger Donnay"
      version  = "1.0"
      copyright= "Copyright (C) $YEAR$ Donnay Software Designs. All rights reserved"
      title    = "Customers"
      header   = "Sample program for listing Sample Customer Database" />


<!-- List the libraries to be linked with the CXP page -->
<helpers
   lib="dclipx.lib"
/>
The CXP application program (CUSTOMERS.CXP) source code is listed below. The sample program lists the contents of the CUSTOMERS.DBF file in both "simple text format" and "html table format". Look at how flexible the CXP language is at handling both formats. Also, you will see that the CXP language handles user defined commands such as those in "dchtml.ch". Now that CXP is a reality, I intend to greatly improve on the DCREAD HTML features in eXpress++.

Your #include files must reside in the INCLUDE folder of the CXP runtime, i.e. C:\cxp20\include or
C:\Program Files (x86)\Alaska Software\cxp20\include.

To run this CXP page and view it's output in your browser click here:

http://bb.donnay-software.com/ds/custom ... tomers.cxp

Code: Select all

<%#Code locality="page-global"%>
<%
 /// This code is injected at the beginning of the intermediate
 /// code generated by the CXC Builder. This is the perfect place
 /// for the statics, classes, functions and procedures being
 /// used in your CXP page.
 ///
 #include "dcdialog.ch"
 #include "dchtml.ch"
%>

<%#Code locality="page-render"%>

<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
</head>

<body>

  <!--- Page content goes here --->

 <h1>My Customer List</h1>
 <h3>Rendering as simple text</h3>
 <pre>
 <%
    USE (::PhysicalPath+"customer.dbf") ;
      INDEX (::PhysicalPath+"\customer.cdx");
      VIA "FOXCDX"
    oRecord := CUSTOMER->(DC_DbRecord():new())
    DO WHILE !CUSTOMER->(Eof())
      CUSTOMER->(DC_DbScatter(oRecord))
      ? oRecord:bill_name, oRecord:bill_strt, oRecord:bill_city, oRecord:bill_state
      CUSTOMER->(dbSkip())
    ENDDO

 %>
 </pre>
 <h3>Rendering in an HTML Table</h3>
 <table border=1>

    @CUSTOMER->(dbGoTop())
    @DO WHILE !CUSTOMER->(Eof())
      @CUSTOMER->(DC_DbScatter(oRecord))
      <tr>
        <td>@(oRecord:bill_name)</td>
        <td>@(oRecord:bill_strt)</td>
        <td>@(oRecord:bill_city)</td>
        <td>@(oRecord:bill_state)</td>
      </tr>
       </tr>
      @CUSTOMER->(dbSkip())
    @ENDDO

 </table>

 <h3>Rendering with DCREAD HTML</h3>
 <%
     DCTABLE OBJECT oTable ROWS CUSTOMER->(RecCount()) COLUMNS 4 ;
        BGCOLOR '#33CCFF' ;
        BORDER 5 ;
        BORDERCOLORLIGHT '#FFFFFF' ;
        BORDERCOLORDARK '#FFFFFF' ;
        CELLPADDING 5 ;
        CELLSPACING 0

    CUSTOMER->(dbGoTop())
    nRow := 1
    DO WHILE !CUSTOMER->(Eof())
      @ nRow,1 DCHTML TEXT CUSTOMER->bill_name PARENT oTable
      @ nRow,2 DCHTML TEXT CUSTOMER->bill_strt PARENT oTable
      @ nRow,3 DCHTML TEXT CUSTOMER->bill_city PARENT oTable
      @ nRow,4 DCHTML TEXT CUSTOMER->bill_state PARENT oTable
      CUSTOMER->(dbSkip())
      nRow++
    ENDDO

    DCREAD HTML TO cHtml

    ? cHtml

    CUSTOMER->(dbCloseArea())
%>

 </body>

</html>
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: How to use CXP pages with eXpress++ library functions

#2 Post by unixkd »

Hi Roger,

Your efforts highly commendable.

No doubt CXP is one of the greatest milestone reached by Alaska software. We woud like to know:

1. Will our current ActiveX tools be useable in CXP, If yes, how ?

2. Will the GUI Xbps be useable in CXP ?

3. Which Reporting tool will be required ?

Seems lots of interesting things ahead.

Thanks.

Joe

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: How to use CXP pages with eXpress++ library functions

#3 Post by rdonnay »

1. Will our current ActiveX tools be useable in CXP, If yes, how ?
2. Will the GUI Xbps be useable in CXP ?
It depends on which ActiveX tools you are using. If they are .OCX, then the simple answer is NO.
Your web browser is an HTML and JavaScript client and it only renders content that follows such standards.
I have found that too many Xbase++ programmers have still not experimented with or learned about HTML and the role of the Web Browser. This is a very different paradigm for application development because it is "stateless". It must be that way for many reasons, but especially for security and because code is delivered dynamically across the internet. A web application is always interpreted by the Web Browser and visual output is rendered accordingly.

ActiveX tools that create windows compatible screen output cannot be used in this environment because Web Browsers interact very differently than your Windows OS. This is also true for GUI components such as Xbase Parts and eXpress++ commands. CXP was not designed to give you the same kind of robust application that you can get on a Windows desktop. It is limited in the same way that Microsoft's ASP is limited and PHP is limited (by the Web paradigm and the Web Browser).

CXP makes it easier to generate Web based applications that must run in a Web Browser. It integrates Xbase++ code with HTML code in a manner that is elegant and a game changer for those of us who have created web sites and web applications in the past that require Xbase++ code and access to our Xbase++ libraries. It was always done with the WAA or Xb2.Net. Yes, it was possible to do this, but was always grueling and difficult.

I am going to make it my goal to help bring eXpress++ users into the world of the web. I want to describe the concept in more simple terms. The first thing you must understand before even trying to write a CXP application is what is the role of the Web Server (IIS or Apache) and the Web Client (a web browser). I will endeavor to do this is a series of white papers and seminars on the subject over the next few months and years.

There are some Xbase Parts and ActiveX controls that can be used in CXP, but not in the way that you are familiar. I will post some samples soon.
3. Which Reporting tool will be required ?
HTML is already a very good reporting tool and I will be making modifications to the eXpress++ DCPRINT system to help you leverage your reports and render them in a Web Browser. Currently, this can be done rather simply, with almost no effort, by outputting the report to a PDF and just sending the PDF to the Web Browser. All you need is to install Win2Pdf or Bullzip on your server and then you can use eXpress++ DCPRINT commands in your CXP pages. I will give some examples soon.
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: How to use CXP pages with eXpress++ library functions

#4 Post by unixkd »

Hi Roger

"I am going to make it my goal to help bring eXpress++ users into the world of the web"

is the most importantly and refreshingly great statement on IT that I have received this month. Thanks so much you make my day !!!!

Joe

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: How to use CXP pages with eXpress++ library functions

#5 Post by unixkd »

Now one more thing.

1. If we intend to use PostgreSQL/ADS/SQLite what of web hosting will be required ? Shared or Dedicated Servers ?

2. With the arrival of CXP is there any role for WAA/Xb2.Net ?

3. Is both Windows and Linux Servers supported by CXP ?

Thanks

Joe.

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: How to use CXP pages with eXpress++ library functions

#6 Post by rdonnay »

1. If we intend to use PostgreSQL/ADS/SQLite what of web hosting will be required ? Shared or Dedicated Servers ?
I assume when you say Dedicated Server, you are talking about the Database server. This does not matter. Whatever works for your existing applications will work with CXP. If you are using a dedicated server for ADS, then it will not need to change. CXP can connect to it the same way an Xbase++ app connects to it. If you have ADS running on the same hardware as Xbase++, that will work too. This also is true for a virtual server. I don't have much experience yet with PostgreSQL but I am positive that the same rules apply.

If you wish to deploy your application remotely, such as on a virtual server in the cloud, this is also no problem, you would just install Xbase++ and IIS or Apache on the virtual server along with your application DLLs and CXP pages and FTP to copy the files.
2. With the arrival of CXP is there any role for WAA/Xb2.Net ?
If you are asking about Web applications whose client is a Web Browser then I must answer - NO. This will not make me popular with Boris Borzic, but it is the truth. If Boris ever implements a fastCGI interface in Xb2.Net that will work with CXP, then the answer will be YES. You will find that installing and working with IIS or Apache is not hard. It's only a 1-time setup. After that, all you will work with is Xbase++ and CXP pages. This does not mean that you should throw away your investment in Xb2.Net. It works very good. I have helped with writing a lot of applications with Xb2.Net and I intend to maintain them.

The eXpress++ IM and Snyffle apps are highly dependent on Xb2.Net and will continue to be so because both the client and server are Xbase++ applications. CXP is more desirable when the client is a Web Browser.

Xb2.Net has a rival with :httpEndPoint more so than CXP. I have already rewritten an Xb2.Net application that requires no web server or Xb2.Net, only Xbase++ 2.0. I will be showing examples of how to do this soon. I may also rewrite the IM system without Xb2.Net.
3. Is both Windows and Linux Servers supported by CXP ?
CXP is Xbase++, therefore it only runs on Windows 32 bit or 64 bit platforms.
The eXpress train is coming - and it has more cars.

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: How to use CXP pages with eXpress++ library functions

#7 Post by Cliff Wiernik »

Does the Xbase++ approach currently support SSL in the communication transfer between the server and remote browser. I know xb2net did not initially support SSL. Or because in the cases you are talking about, where you use IIs or Apache with the CXP pages, the CXP pages is only being used to create the content, but the content is made available via the IIs/Apache server and that portion supports the SSL communications.

But if Xbase++ 2.0/CXP are used directly to provide the pages to the webbrowser, is SSL currently supported?

bwolfsohn
Posts: 648
Joined: Thu Jan 28, 2010 7:07 am
Location: Alachua, Florida USA
Contact:

Re: How to use CXP pages with eXpress++ library functions

#8 Post by bwolfsohn »

rdonnay wrote:
2. With the arrival of CXP is there any role for WAA/Xb2.Net ?
If you are asking about Web applications whose client is a Web Browser then I must answer - NO. This will not make me popular with Boris Borzic, but it is the truth. If Boris ever implements a fastCGI interface in Xb2.Net that will work with CXP, then the answer will be YES. You will find that installing and working with IIS or Apache is not hard. It's only a 1-time setup. After that, all you will work with is Xbase++ and CXP pages. This does not mean that you should throw away your investment in Xb2.Net. It works very good. I have helped with writing a lot of applications with Xb2.Net and I intend to maintain them.

The eXpress++ IM and Snyffle apps are highly dependent on Xb2.Net and will continue to be so because both the client and server are Xbase++ applications. CXP is more desirable when the client is a Web Browser.

Xb2.Net has a rival with :httpEndPoint more so than CXP. I have already rewritten an Xb2.Net application that requires no web server or Xb2.Net, only Xbase++ 2.0. I will be showing examples of how to do this soon. I may also rewrite the IM system without Xb2.Net.
Roger,

I have not looked very far into cxp yet.. i'm waiting for boris to implement it into xb2net. But, based on my observations with php, wordpress, and fastcgi, i have BIG reservations about the scalability and security of Xbase++ / cxp / IIS or apache. We routinely handle over 200 users on our xb2net applications with ADS data on the same box and the cpu handles it without going over 4 or 5 % utilization.

fastcgi installations, however seem to generate a separate process for each call... a wordpress installation with just a few users at the same time is much more taxing on a cpu than xb2net.

I won't even address the security issues for IIS or apache here, as they are well known..

Brian
Brian Wolfsohn
Retired and traveling around the country to music festivals in my RV.
OOPS.. Corona Virus, so NOT traveling right now...
http://www.breadmanrises.com
FB travel group: The Breadman Rises

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: How to use CXP pages with eXpress++ library functions

#9 Post by rdonnay »

Does the Xbase++ approach currently support SSL
SSL is always handled by the Web Server so there is no need for CXP to do this. Xb2.Net had to support it because it is acting as a Web Server. A https request will automatically be secure via IIS or Apache.
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: How to use CXP pages with eXpress++ library functions

#10 Post by rdonnay »

I have not looked very far into cxp yet.. i'm waiting for boris to implement it into xb2net.
I had an email conversation with Boris about this. He has not spent any time on this but says he will get interested if Alaska Software will work with him.
fastcgi installations, however seem to generate a separate process for each call... a wordpress installation with just a few users at the same time is much more taxing on a cpu than xb2net
I have no experience with the performance and security issues. I would think that since every call from the Web Server is to a CXP page that Xbase++ would be able to handle the security. It all depends on what you mean by security problems. Apache is all over the web, running millions of web sites. Are you saying that the security issue is with the Microsoft platform vs Linux?

I wish you could have made it to the Phoenix conference so you could have asked Steffen these questions.
Why don't you do so now? Send him an email.

As far as I am concerned, I am jumping in because I believe that 99% of Xbase++ users can benefit greatly from this. Your website is a special case and performance is critical. Most of the Xbase++ programmers I talk to don't even have a web solution yet. They need to get their feet wet and this is a good place to start. I get asked a lot to help eXpress++ users write a small program that will give their customers access to application data via a web browser. First, they need to understand the Web Server / Web Browser relationship. I think that only a small percentage of eXpress++ programmers understand this, and so I have to teach it (hopefully via this forum.)
The eXpress train is coming - and it has more cars.

Post Reply