Archive for the ‘RSP’ Category

RSP

Posted: 2017-01-23 in RSP
Q:
I would like to add a conditional statement in a .rsp page that would only print a memory variable if it was not equal to 0. This needs to be done in a text raw portion of the .rsp page
Screenshot - 23.1.2017. , 20_11_47.png
A:

You can close and then reopen the text raw…endtext

Screenshot - 23.1.2017. , 20_14_01.png

Q:
I’ve developed an RSP page based on “desktopwebservices”.
On App builder, if I enable the embedded HTTP Server, work fine.
On App center.. not work.
A:
the ‘Enable services‘ is not being saved to the App, then they will not be enabled when you deploy the App.

Q:
web reports. I am using FoxPro as my language and am trying to launch a .rsp file I created. The do function gives me an error when activated by an object button.
Is there a different command to launch a.rsp file? The error I receive is actually related to an .rso file, but I am unsure what this is.

A:
To execute an rsp file specify it in a Webview section.
The
HTML you generate will be loaded into that Webview.
In LianjaDemo, go to Report for customer over their credit limit.
The page has a webview section on it. Click the Attributes cog:
The, in the attributes, go to the Data section:pasted-image-0

Q:
I’ve a RSP page with Hyperlink column.
If I show the RSP page with “Lianja.ShowDialog”, how can I specify the “Delegate Hyperlink“?
A:
Screenshot - 23.1.2017. , 20_14_54.png

Q:
I’ve a table,, witha a memo field.
In the grid section, I write:
Bianco,Rosso,Rosè,Nero
2016-02-15-08_30_15-lianja-app-builder-post-new-thread
If I test the field (? myField), I get:

Screenshot - 23.1.2017. , 20_17_50.png

Is possible to use standard memo field without all the HTML?
Or..
Is possible to remove all the HTML?
A:
Memo fields are rich text formatted. If an attribute was provided for this you would need to make sure you always stored plain text in the memo everywhere. That’s messy with web and mobile.


Q:
Screenshot - 23.1.2017. , 20_23_52.pngScreenshot - 23.1.2017. , 20_24_41.png

Then I’ve a Javascript Commandbutton.
Is possible to refresh the page from Javascript? As a recall the drawTable() function..
A:
Reference the section and change the URL adding arguments.
You should read the arguments using getParameter() and use these to determine what data is displayed. Seeing that this is a desktop Webview with no cloud server you can’t use Ajax, just change the URL
and issue a refresh. You can have a procedure that you call that does all this.
I notice your HTML is wrong.

border=”0px”
(needs to be in quotation marks)

Q:
How I can enable cache browser using .rsp.
Today the generated page have the modified date is 07/27/1997 02:00.
I need set to datetime()
I already try use meta tags and dont work.
I change the http settings to enable cache and dont work, too!
A:
.rsp pages are compiled dynamically if the source file is newer than the .rso object file. That’s how all dynamically generated pages work.
These pages are not cached in the browser, they are cached on the server.
Caching only affects static content such as images, JavaScript files and CSS files.

Q:

fabtest.rsp:

Screenshot - 23.1.2017. , 20_30_09.png

tabella.html:

Screenshot - 23.1.2017. , 20_31_15.png

Console command:
Code:
Lianja.ShowDialog("Search & Find", "http://localhost:8002/desktopwebservice/fabtest.rsp?firstname=Yvonne&lastname=Milne")
Name:  showdialog.png Views: 24 Size:  6.5 KB
Name:  iframe.png Views: 29 Size:  17.8 KB
in my inframe I’ve this line of HTML:
Screenshot - 23.1.2017. , 20_32_50.png
this is my RSP code:
Screenshot - 23.1.2017. , 20_35_01.png
A:
You are calling the function instead of passing it’s address. Remove the ()

Q:
I call a RSP page with this function:
Lianja.ShowDialog(“Search & Find”, “lib:/sup_quickselect.rsp?fields=valore,valore&target=va lore&caption=Valore,Valore2”)
and work fine.. it open a Dialog, whit a row of the source table.Now I’ve added a first Row, witha a text box and a button “cerca” (= find).

My target is:
the user type something in the textbox, then press “Cerca”…

I would like to launch a function that reads the values of the first line “Valore” and “Valore2”, refresh the query and make a refrsh ..
2016-02-18-11_29_32-search-find
you can make that all be in VFP.
Instead of document.write you would simple print it.

Screenshot - 23.1.2017. , 21_09_30.png

etc.

Anything in the RSP gets evaluated on the server, not on the client.

If you have a JavaScript page/section, then JavaScript you put in there runs on the client. The exception of course being a Lianja.evaluate() call, which would run on the server and then send the result back to the client.
Anything you want to have happen on the page that has already been sent has to be in JavaScript, so it will run on the page in the client. When sending the page, you can use VFP to get your work done.

The question I have is: why are you using an .rsp page for this? It seems that a Canvas section would better suit your needs (I’m assuming this is a desktop app).
On a Canvas, you can put whatever you want wherever you want it, including a grid in the canvas.
For that matter, you could use two form sections, with the textboxes in the section above, no footer on the top section, no header on the bottom, so they look like one.


Q:
I recently had a request to serve up results of a powershell command from an rsp page.
I wasn’t sure it its possible, so I thought I would ask if anyone had tried.First request is just a simple list of all services on a given server.

Code:
PowerShell.exe  Get-Service -ComputerName myserver
A:

on way is to instantiate the PowerShell object as a .Net object — check out Doug Hennigs article on using PowerShell in VFP, p.33:http://doughennig.com/papers/Pub/PowerShell.pdf.I don’t know if wwDotNetBridge, which it uses, will work in Lianja, but there’s a good chance it will. If it does, this would give you the opportunity to make a dynamic application with a list of the scripts or cmdlets or whatever.

The alternative is to run with the run command in Lianja (in a VFP code section of the .rsp) and generate a log file output and use that to display or parse/display.
I recall Barry telling us to create tempfile for rsp pages.

Like in the image example:

// Look up an employee
seek “Smith”// Create a unique temporary name (guaranteed uniqueness across concurrent users in a network)
m_tmpnam = tmpnam()// Extract the photo from the database and write it to the temporary file
objectWrite(m_tmpnam,photo)// Generate the base64 encoded contents as an IMG tag and output into the HTML5
base64_encode_file(m_tmpnam, objectType(photo), “100px”, “100px”)

// Don’t forget to remove the temporary file

erase &m_tmpnam
I probably need to output the file to m_tmpnam.
because multiple requests can be running concurrently.

That’s a great example of how to get an rsp page working with standard section. It really highlights the power of the showDocument()

Screenshot - 23.1.2017. , 20_36_52.png

There are two parts of this example (I will resort it):

Code:
    save datasession
    open database southwind
    use customers
    list html off ;
        fields customerid,companyname,city,country onclick "customerid","editCustomerID('{}')"
    restore datasession

Result is the LIST of table records in HTML format “sent somewhere into the section”. “onclick” is important here to relate clicked record shown in another section.

Second part is ShowDocument with search action (inside of click-function):Screenshot - 23.1.2017. , 14_36_48.png

Screenshot - 23.1.2017. , 20_40_14.png

 

This is how this section (vebview standard section) is populated on the fly. The webview section is not build by drag&drop the table, but like a custom section.

Imagine it has no Data Source specified in section. This is Standard section which is not data bounded. You can dynamically USE…any table in any database and specify fields in LIST HTML OFF… and maybe “onclick”.
This is impressive.

It is incredibly easy to serve up a json result set in Lianja. I was overcomplicating it, so thought some others might be doing the same (again – I turned to Yvonne and Barry for assistance).
Here is the entire RSP page. It takes a parameter, gets the data, cleans it up, and delivers.

<%@ language=VFP %>
<%
private m_term = lower( getParameter(“term”, “”) )
private aresult
set strcompare off
select contactname from southwind!customers where lower(contactname) = m_term into array aresult

m= json_encode(aresult)
m=strtran(m,”[[“,”[“)
m=strtran(m,”]]”,”]”)
m=strtran(m,”],[“,”,”)
echo m

%>

Pinegrow is a really handy tool
I am starting to play around with it and thought I would work through several examples to show it usefulness.
I am clearly not an expert on it, so anyone that wants to extend the demo’s, feel free.
Here is the first one. It just puts a nav bar in a webview.

Lianja and Pinegrow part 1 – https://youtu.be/DlEHGGe00VA

Here is my default LianjaBootstrap file.

 Screenshot - 23.1.2017. , 20_41_49.png

So – I thought it would be fun to create a fake bank called – you guessed it – the Bank of Lianja.
This would have to incorporate some site building with application building.
Lianja is perfectly suited for the job.Image.png

Pinegrow for a bootstrap page?
I did use Pinegrow to kick start it.
One thing I noticed was that pinegrow was missing the nav-pills under the nav class, so I just used nav-tabs, and manually changed it toso I could stack them in my fourth column set.

Screenshot - 23.1.2017. , 20_44_05.png

Also – as you can see, I have the columns in medium and large screens with an offset of 1 column to give more distance to the right side menu.

Next – I’ll fix the columns heights to be equal.
I also added a well around my paragraph to give it a nicer look.

Screenshot - 23.1.2017. , 20_44_58.png

Slowly but surely, it will get there.

ps – I think the course from codeschool on getting started with bootstrap is very good.
What I am finding though, is that using the standard built in sections is a lot quicker than building full apps in RSP pages.
But I think there is definitely a place for both.
Dashboards, in particular, are a good place for .rsp pages.

Many of us old VFP developers used quite a few activeX tools to extend our user interfaces.
To me, the most powerful part of the Lianja is the RSP page. It’s fast and flexible and I think is the core of Lianja.

Add to that the built in support for bootstrap and the assorted javascript libraries, the sky is the limit.

I just downloaded KendoUI from telerik tonight and love the widgets. They are used the exact same way as the other Jquery UI components.

http://www.telerik.com/kendo-ui#more-widgets

In about 15 minutes, I got this little sample up and running. You can have a look at it here.
Just like Jquery, Lianja can seamlessly use the Power of Teleriks Kendoui widgets to extend your user interface. Here’s a quick demo.
LIanja with Kendouihttps://youtu.be/ScNexbKrARA


Q:
is Response.contenttype case sensitive?
A:

<% response.contenttype = “…” %>

it is Lianja/VFP. case insensitive.


Q:
Looking in fiddler, the content-type is still text/html.
Its a very straightforward rsp page.
it grabs some parameters,updates the SQL Server and returns the row that was just updated, and outputs the json result set. All is working except the response content type.

 

Screenshot - 23.1.2017. , 20_47_14.png
Looking at the response type, it is still text/html?????
Image.png
A:
Here’s the line that works for me when sending JSON to an .rsp web service:
lcRet = posturl(lcUrl,0,array(“Content-Type: application/json”,”charset: UTF-8″),lcJson,”c:\temp\mysite.txt”)

This video illustrates how by using Lianja.execute() , you can pass values between your javascript functions and your desktop canvas section.
web controls and Lianja Desktop – https://youtu.be/heu-3M28v-s


A quick example on how to incorporate leaflet/Mapbox map in your Lianja RSP page
LianjaAndLeafletjs – https://youtu.be/gqvJ-sIFzvY


I just wanted to showcase the speed and flexibility of the RSP pages.
I am using a free theme called devoops, and have also added Kendo UI controls. The RSP pages pull everything together and make the data retrievals and data updates very fast.
https://youtu.be/z0kuRx9iqWg


Here is quick example to hook your code into Lianja from the template you built in Pinegrow.
Lianja and Pinegrow Bootstrap Part 2 – https://youtu.be/PGmVEP_YwrI


This is just a quick tutorial on getting Pinegrow to work inside a Lianja RSP page.
Lianja and Pinegrow part 1 – https://youtu.be/DlEHGGe00VA


Using the AutoComplete function I Jquery with Lianja.
Both hardcoded values and remote data from an RSP page
Lianja JQuery Autocomplete – https://youtu.be/R4USkXxARWE


Just a quick example of interaction between Jquery and the Lianja framework.
Lianja and Jquery – https://youtu.be/FXUtccC4Xcw


RSP

Posted: 2017-01-22 in RSP

Q:
I’ve a table,, witha a memo field.
In the grid section, I write:
Bianco,Rosso,Rosè,Nero

If I test the field (? myField), I get:

Code:


p, li { white-space: pre-wrap; }

Bianco,Rosso,Rosè,Nero

Is possible to use standard memo field without all the HTML?
Or..
Is possible to remove all the HTML?
A:
Memo fields are rich text formatted. If an attribute was provided for this you would need to make sure you always stored plain text in the memo everywhere. That’s messy with web and mobile.


 

Code:
<%    
// test.sn

proc drawTable()
    laFields = explode(",", m_fields)
    laCaption = explode(",", m_caption)
    laQuery = explode(",", m_query)

    ? ('') 

    ? ('')
    
    ? ('')
    ? ('')   

    ? ('')
    for lnI = 1 to alen(laFields)
  lsQueryValue = ""
  if !empty(m_query)
   laQueryValue = explode("|", m_query)
   lsQueryValue = laQueryValue(2)   
  endif
  
  ? ''   
    endfor

    ? ('

' + m_query + '

') ? ('') ? ('') ? ('') ? ('') lnRiga = 1 scan if mod(lnRiga, 2) = 1 rowcolor = "#f1f6fe" altcolor = "#FFFFFF" else rowcolor = "#FFFFFF" altcolor = "#f1f6fe" endif lnRiga = lnRiga + 1 ? ('') for lnI = 1 to alen(laFields) ? ('') endfor ? ('') endscan ? ('
') ? ('
' ? '' ? '
') if laFields(lnI) = m_target lsField = &laFields(lnI) ? [<a href="javascript:selectitem('&lsField')">] + &laFields(lnI) + [] else ? (&laFields(lnI)) endif ? ('
') endproc drawTable() %>

Then I’ve a Javascript Commandbutton.
Is possible to refresh the page from Javascript? As a recall the drawTable() function..
A:
Reference the section and change the URL adding arguments.
You should read the arguments using getParameter() and use these to determine what data is displayed. Seeing that this is a desktop Webview with no cloud server you can’t use Ajax, just change the URL
and issue a refresh. You can have a procedure that you call that does all this.
I notice your HTML is wrong.

Code:
border="0px"

(needs to be in quotation marks)


Q:
How I can enable cache browser using .rsp.
Today the generated page have the modified date is 07/27/1997 02:00.
I need set to datetime()
I already try use meta tags and dont work.
I change the http settings to enable cache and dont work, too!
A:
.rsp pages are compiled dynamically if the source file is newer than the .rso object file. That’s how all dynamically generated pages work.
These pages are not cached in the browser, they are cached on the server.
Caching only affects static content such as images, JavaScript files and CSS files.



RSP

Posted: 2017-01-22 in RSP
Q:
I would like to add a conditional statement in a .rsp page that would only print a memory variable if it was not equal to 0. This needs to be done in a text raw portion of the .rsp page

Code:
if pra_no  0 
?"OUR RA No.: " +pra_no+ ""
endif

A:
You can close and then reopen the text raw…endtext

Code:
text raw
...
endtext
if pra_no <> 0 
?"OUR RA No.: " +pra_no+ ""
endif
text raw
...
endtext

Q:
I’ve developed an RSP page based on “desktopwebservices”.
On App builder, if I enable the embedded HTTP Server, work fine.
http://localhost:8002/desktopwebservice/…..
On App center.. not work.
A:
the ‘Enable services‘ is not being saved to the App, then they will not be enabled when you deploy the App.


Q:
web reports. I am using FoxPro as my language and am trying to launch a .rsp file I created. The do function gives me an error when activated by an object button.
Is there a different command to launch a.rsp file? The error I receive is actually related to an .rso file, but I am unsure what this is.

A:
To execute an rsp file specify it in a Webview section.
The
HTML you generate will be loaded into that Webview.
In LianjaDemo, go to Report for customer over their credit limit.
The page has a webview section on it. Click the Attributes cog:
The, in the attributes, go to the Data section:


Q:
I’ve a RSP page with Hyperlink column.
If I show the RSP page with “Lianja.ShowDialog”, how can I specify the “Delegate Hyperlink“?
A:
Generate an HTML tag with onclick=”Lianja…..”

Code:
Click me

RSP

Posted: 2017-01-22 in RSP

rsp files contain HTML and directives that embed scripting code so that HTML can dynamically generated.
When the rsp file is executed it is compiled at that point in time if no corresponding rso file exists or the rsp file is newer than the rso file.

You should be copying report.rsp to your own name not editing the standard one which will be overwritten on an update.


The error is displayed in the webview with a traceback.
Variables are saved to the error directory
.
rsp pages are just like PHP pages but you write in Lianja/VFP rather than PHP.
use the codebehind directive which will let you have a prg embedded in the rsp page.

If a compile error occurs the following files have the information in:

c:\lianja\error\error.mem


and


c:\lianja\debug\debug.txt


SET DEBUGOUT ON and DEBUGOUT commands can now be used in .rsp pages to assist in debugging.
If an error occurs and SET DEBUGOUT is ON then error details are written to a file in the lianja\debug directory.
This file is called firecat_debugXXX.txt where XXX is the unique connection id as many requests can occur concurrently.


You do not compile an rsp file. It is done for you.
You do not COMPILE filename.rsp



RSP

Posted: 2017-01-22 in RSP

When building Web and Mobile Apps in Lianja, WebViews can be dynamically generated using dynamic server pages.
Dynamic server pages contain HTML5 and directives that tell the Cloud Server how to process the contents of the page.

Code:
<%@ Language=VFP %>

or

Code:
<%@ Language=JavaScript %>

When a Lianja/VFP Server Page is executed the following are available to the script in addition to the complete VFP compatible cross-platform scripting language implemented in Lianja.

Global associative arrays:

_REQUEST[]
_SERVER[]
_ARGS[]
_GET[]
_POST[]
_FILES[]
_COOKIE[]
_SESSION[]

Global objects:

Response
write( text )
writeFile( filename )
addCookie(name, value)
addHeader(name, value)
clear()
flush()
redirect( url )
authenticate( [message] )
appendToLog( message )
include( filename )
Built-in commands/functions:
? cExpression
echo cExpression
move_uploaded_file(tofilename, fromfilename)
die(message)
include( cExpression )
object = require( cExpression )
odata_Create( url, jsondatastring )
odata_Read( url [, filename] )
odata_Update( url, jsondatastring )
odata_Delete( url, jsondatastring )

JavaScript Server Pages are modelled on PHP Server Pages. When a JavaScript Server Page is executed the following are available to the script in addition to the built-in JavaScript functions.
These will be familiar to PHP Web developers.

Global associative arrays(objects):

$_REQUEST[]
$_SERVER[]
$_ARGS[]
$_GET[]
$_POST[]
$_FILES[]
$_COOKIE[]
$_SESSION[]

Global objects:

Lianja.
execute( vfp_command )
evaluate( vfp_expression )
openDatabase( databasename )
openRecordSet( table_or_sqlselect )
moveFirst()
moveNext()
movePrevious()
moveLast()
move()
moveRelative()
moveBookmark()
findFirst( condition )
findNext( condition )
findPrevious( condition )
findLast( condition )
edit()
update()
delete()
requery()
field( name_or_number )
.name
.type
.width
.decimals
.value
close()
bof
eof
found
nomatch
recno
reccount
fieldcount
index
filter
close()

Response

write( text )
writeFile( filename )
addCookie(name, value)
addHeader(name, value)
clear()
flush()
redirect( url )
authenticate( [message] )
appendToLog( message )
include( filename )

Built-in functions:

print( cExpression );
echo( cExpression );
move_uploaded_file(tofilename, fromfilename);
die(message);
debugout(message);
include( cExpression );
object = require( cExpression );
odata_Create( url, jsondatastring );
odata_Read( url [, filename] );
odata_Update( url, jsondatastring );
odata_Delete( url, jsondatastring );
tmpnam()
objectType( object_fieldname )
objectRead( from_filename, object_fieldname )
objectWrite( to_filename, object_fieldname )
base64_encode_object( object_fieldname, width, height)
unlink( filename )

The following is an example Lianja JavaScript Server Page.

Code:
<html>
<body>
<%
    // Note that just as in PHP, JavaScript Server Pages can use include_once( filename) and include(filename)
    // The path of the filename is relative to the directory containing this script.
    include_once("library_example.jssp");


    // The Lianja global object provides embedded database access
    db = Lianja.openDatabase("southwind");
    print("db=" + typeof db); 
    print("<br>");
    
    // Lianja.openDatabase() returns a Database object so now we can open a RecordSet
    rs = db.openRecordSet("select * from customers");
    print("rs=" + typeof rs); 
    print("<br>");
    print("Fieldcount="+rs.fieldcount);
    print("<br>");
%>
<table>
<%
    print("<tr>");
    for (i=0; i<rs.fieldcount; ++i)
    {
        print("<td>"+rs.field(i).name+"</td>");
    }
    print("</tr>");
    rs.moveFirst();
    for (j=0; j<rs.reccount; ++j)
    {
        print("<tr valign='top'>");
        for (i=0; i<rs.fieldcount; ++i)
        {
            print("<td>"+rs.field(i).value+"</td>");
        }
        print("</tr>");
        rs.moveNext();
    }
    rs.close();
    db.close();
%>
</table>
</body>
</html>

Q:
Do you need to write code like this to run Lianja Web and Mobile Apps.

A:
If you follow best practices no you don’t but if you want to format a custom WebView section or use a third party JavaScript framework this is when you would use dynamic server pages.

And by the way, they are *very* fast. HTTP web connections and ODBC connections to MSSQL / MySQL / PostgreSQL etc are pooled internally.


the use of .rsp pages in WebView sections together with the fact that the Lianja system object reference is injected into them means that any custom WebView code can interact with the other parts of the Lianja Web Framework using Lianja.showDocument(), Lianja.evaluate(), Lianja.getElementByiD() etc.

These custom webviews can be dynamically generated by ,rsp pages and are inner framework agnostic. This provides you with the ability to create some quite compelling Apps.

Remember also that you can generate dynamic content in JavaScript too using .jssp files in the same way as you would use .rsp files.

For anyone who is not yet familiar with .rsp files, they contain html5 with code blocks in them that generate dynamic content. They are very similar to .php files but you write in Lianja/VFP instead of PHP.

Its worth pointing out that the LianjaWebFramework is a meta framework that includes a lot of pre-built data-bound sections as well as full client / server CRUD integration, App center and dynamic app loading, page navigation for SPA (Single Page Applications), etc. It integrates the front end UI view with the Lianja Cloud Server that handles business logic and database independent data access.

This is what constitutes the whole Lianja Platform (The Lianja APaaS) together with the Lianja App Builder for visually designing and building the Apps whether they be desktop, web or mobile.

What some developers do not yet realize is that the Lianja platform itself has been designed to provide a means of developing Apps using Agile Development techniques with continuous delivery. As we release the Mobile App building functionality in v2.0 this will become more obvious and we will be providing some tutorials on the blogs that explain Agile Development and Continous Delivery and how these relate to Lianja.



 

RSP

Posted: 2017-01-22 in RSP

Q:
Can I reference a field in a table directly without having to use an array in an RSP page?

Code:
<%
open database southwind
use example in 0 current

tmpfile = sys(2015)     
select * from example save as [&tmpfile]

private m_notes = tmpfile.lastname
?(m_notes)

%>

A:
Try it in a script from the console. It works the same.


Q:
Is it possible to set a default .rsp page, where that page resides in an application?
A:
The “Start page” for an App is in the App Settings.
If you want this to be a .rsp page then just put it in a webview with “Stretch last section” and the .rsp page will be displayed as the first page in the App.