RSP [examples]

Return the value of a parameter passed to a .rsp script or return an alternative value if the parameter was not passed

// WebView URL Attribute
quickreport.rsp?database=southwind&table=example&fields=*&heading=Client List (all)&columns=2,4,3,5,6,7,8,9,10,11,12&subtotals=9,10,11&gridlines=true
 
//--
// quickreport.rsp?parameter=value&parameter=value...
//
// parameters 
//--
private database   = getParameter("database", "southwind") 
private table      = getParameter("table", "example") 
private fields     = getParameter("fields", "*") 
private groupby    = getParameter("groupby", "") 
private heading    = getParameter("heading", "Report for all clients by state") 
private headings   = getParameter("headings", "") 
private filter     = getParameter("filter", "") 
private hyperlink  = getParameter("hyperlink", "") 
private columns    = getParameter("columns", "") 
private subtotals  = getParameter("subtotals", "") 
private gridlines  = getParameter("gridlines", "")
// ...

https://www.lianja.com/doc/index.php/GETPARAMETER()


Execute an rsp script

execRSP("test.rsp?customerid=alfki")

test.rsp

<%@ Language=VFP %>
<%
    local m_customerID = getParameter("customerID", "")
    local m_tempfile = tmpnam()
    if database() <> "southwind"
        open database southwind
    endif
    set strcompare on  // perform autotrim and case insensitive string comparisons in queries 
    select * from customers where customerid=m_customerid into cursor temp
    select temp
    copy to &m_tempfile type csv
    type &m_tempfile
    erase &m_tempfile
%>

https://www.lianja.com/doc/index.php/EXECRSP()


Return the value of a session variable in a .rsp script or return an alternative value if the variable does not exist

ss=len(_SESSION)
if ss > 0
	? "Active session variables ("+alltrim(str(ss))+")"
	foreach _session as name=>value 
		? "<br>   &name="+etos(value)
		next
else
	? "There are no active session variables."
endif
 
?"<br>"
? "start_time = " + getsessionvar("start_time",time())
?"<br>"

https://www.lianja.com/doc/index.php/GETSESSIONVAR()


 

example_cookies.rsp

This Visual FoxPro Server Page (.rsp) demonstrates querying of the _SERVER[], _SESSION[] and _COOKIE global associative arrays.

<%@ Language=VFP %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Lianja example - accessing cookies</title>
</head>
<body>
<%
  // Get the hostname for the remote machine requesting the page
  ? "_server[ ] elements"
  foreach _server as name=>value 
    ? "<br>   &name="+etos(value)
  next
  ? "<br><br>"
  ? date()
  ? time()
  ? "<br><br>"
 
  cc=len(_COOKIE)
  if cc > 0
	? "Active session Cookies ("+alltrim(str(cc))+")"
	foreach _cookie as name=>value 
		? "<br>   &name="+etos(value)
	endfor
  else
	? "There are no active session cookies."
  endif
  ? "<br><br>"
 
  ss=len(_SESSION)
  if ss > 0
	? "Active session variables ("+alltrim(str(ss))+")"
	foreach _session as name=>value 
		? "<br>   &name="+etos(value)
	next
  else
	? "There are no active session variables."
  endif
 
  ? "<br><br>Press the browser refresh key."
  _session["time"] = time()
%>
</body>
</html>

https://www.lianja.com/doc/index.php/Cookies_rsp

https://www.lianja.com/doc/index.php/Example_cookies_rsp


 

example_authentication.rsp

This Visual FoxPro Server Page (.rsp) demonstrates how to use the response object authenticate() method for user authentication.

<%@ Language=VFP %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Lianja example - authentication</title>
</head>
<body>
<%
  if len(_SERVER["AUTH_TYPE"]) = 0 .or. len(_SERVER["REMOTE_USER"]) = 0 .or. len(_SERVER["REMOTE_PASSWORD"]) = 0
	response.Authenticate()
  endif
  ? "Hi " + proper(_SERVER["REMOTE_USER"]) + ", You have authenticated successfully."
  ? '<br>'
%>
</body>
</html>

https://www.lianja.com/doc/index.php/Authentication_rsp

https://www.lianja.com/doc/index.php/Example_authentication_rsp


 

example_imagequery.rsp

This Visual FoxPro Server Page (.rsp) demonstrates the use of the base64_encode_file() function to generate the base64 encoded contents of an object field image as an IMG tag and output it into the HTML5.

<%@ Language=VFP %>
<html>
<head>
</head>
<body>
<%
  ? "<table width='80%' align=center cellpadding=12>"
  ? "<tr>"
  ? "<td align=center colspan=2>"
  ? "<h1>Lianja example - image queries</h1>"
  ? '<p>Customize this to suit your own needs. This is a just an example.<p>'
  ? '<hr size="1px" color="lightgray"/>'
  ? "</td>"
  ? "</tr>"
  ? "<tr>"
  ? "<td colspan=2>"
  ? "<h3>Employees</h3>"
  ? "</td>"
  ? "</tr>"
 
  // scan through the employees table
  open database southwind
  use employees
  scan
	? "<tr>"
	? "<td>"
	m_tmpnam = tmpnam()
	objectwrite(m_tmpnam,photo)
	base64_encode_file(m_tmpnam, objectType(photo), "200px", "200px")
	erase &m_tmpnam
	? "</td>"
	? "<td>"
	? mtos(notes) + "<a href='../odata/southwind/orders("+etos(employeeid)+",employeeid)'> JSON download of orders for ";
          + trim(firstname) + " " + lastname + "</a>"
	? "</td>"
	? "<tr>"
	? '<td colspan="2">'
	? '<hr size="1px" color="lightgray"/>'
	? "</td>"
	? "</tr>"
	? "</tr>"
  endscan
  close data
 
  ? "<tr>"
  ? "<td align=center colspan=2>"
  ? "<p>Copyright © 2013 Lianja Inc. All rights reserved worldwide.</p>"
  ? "<h3><a href 'http://www.lianja.com'> www.lianja.com</a></h3>"
  ? "</td>"
  ? "</tr>"
  ? "</table>"
%>
</body>
</html>

https://www.lianja.com/doc/index.php/Example_imagequery_rsp

https://www.lianja.com/doc/index.php/Imagequery_rsp


 

example_datanavigation.rsp

Example Visual FoxPro Server Page (.rsp) demonstrating basic data navigation.

<%@ Language=VFP %>
<html>
<body>
<%
    // Open the database
    open database southwind
    ? "<br>"
 
    // Open the table
    use customers
 
%>
<table>
<tr>
<%
     // Display the table headings
    for i = 1 to fcount()
        ? "<td>" + field(i) + "</td>"
    next
%>
</tr>
<%
    // Display the data in a table
    scan
        ? "<tr valign='top'>"
        for i = 1 to fcount()
            ? "<td>"
            ? &(field(i))
            ? "</td>"	
        next
        ? "</tr>"
    endscan
    // close the table and the database
    use
    close database
%>
</table>
</body>
</html>

https://www.lianja.com/doc/index.php/Example_rsp

https://www.lianja.com/doc/index.php/Example_datanavigation_rsp


 

example_redirection.rsp

This Visual FoxPro Server Page (.rsp) demonstrates the use of the response object redirect() method for URL redirection.

<%@ Language=VFP %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Lianja example - redirection</title>
</head>
<body>
<%
	response.redirect("/default.rsp")
%>
</body>

https://www.lianja.com/doc/index.php/Example_redirection_rsp


 

pfooter.rsp

This Visual FoxPro Server Page (.rsp) is a Page Footer gadget example. See Page Footers for more information.

<%@ Language=VFP %>
<html>
<head>
<style>
table, td, th {
    border: 1px solid black;
}
table {
    border-collapse: collapse;
    width: 100%;
}
td {
    text-align: center;
}
</style>
</head>
<body>
<%
	private m_count = 0
	private m_total = 0
	private m_min = 0
	private m_max = 0
	private m_ordertotal = 0
	private m_linetotal = 0
 
	save recordview
 
	if used("orders") and used("customers")
		select orders
		seek customers.customerid
		scan while customerid = customers.customerid
			++m_count
			select order_details
			seek orders.orderid
			m_ordertotal = 0
			m_linetotal = 0
			scan while orderid = orders.orderid
				m_linetotal = (order_details.unitprice*order_details.quantity) - order_details.discount
				m_ordertotal = m_ordertotal + m_linetotal
			endscan
			if m_min = 0 or m_min > m_ordertotal
				m_min = m_ordertotal
			endif
			if m_max = 0 or m_max < m_ordertotal
				m_max = m_ordertotal
			endif
			m_total = m_total + m_ordertotal
		endscan
	endif
 
	m_min = currency(m_min)
	m_max = currency(m_max)
	m_total = currency(m_total)
 
	restore recordview
 
	text raw 
	<table>
	<tr>
	<th>
    <font color=darkgray>Total Orders</font>
	</th>
	<th>
	<font color=darkgray>Min Order Value</font>
	</th>
	<th>
	<font color=darkgray>Max Order Value</font>
	</th>
	<th>
	<font color=darkgray>Total Order Value</font>
	</th>
	</tr>
	<tr>
	<td>
	<font color=gray>&m_count</font>
	</td>
	<td>
    <font color=gray>&m_min</font>
	</td>
	<td>
    <font color=gray>&m_max</font>
	</td>
	<td>
    <font color=gray>&m_total</font>
	</td>
	</tr>
	</table>
	</body>
	endtext
%>
</body>
</html>

https://www.lianja.com/doc/index.php/Pfooter.rsp


 

Advertisements
Categories RSP

RSP

Q:

Is there a way I can assign the associative array elements to a variable in the .rsp file?
E.g. m_cTmpStr = _files[i].tmp_name
The above returns me an “Unrecognized phrase/keyword near column 32” error

I am trying to move the uploaded file to another location, since I am having problem using the _files[1].tmp_name as a memory var, I used the following temp workaround in .rsp :

move_uploaded_file(_files[1].tmp_name, ‘My_Temp_Name.jpg’)
copy file ‘C:\lianja\cloudserver\tenants\public\wwwroot\My_T emp_Name.jpg’ to “C:\lianja\cloudserver\tenants\public\wwwroot\myTa rgetFolder\My_Perm_Name.jpg’

Being able to access the _files[1].tmp_name will be ideal, as the program will need the filename and extension to move to the correct location. Anybody has any luck assigning the _files[1] into temp memory variables?

A:

To access tmp_name store _FILES[1] to a new array:

myfilearray = _FILES[1]
m_cTmpStr = myfilearray.tmp_name


Q:

tried running a dos command in the rsp to scale an image, with the following codes:

m.cArg = “c:\mydoscommand\myimagescaling.exe C:\lianja\cloudserver\tenants\public\wwwroot\_myim ages\_upload_000022f4_3.jpg /scale=(800,600)”

run (m.cArg)

**************************
I can execute the above 2 lines in the console to successfully scale the image.
But when i run the browser, the uploaded image does not get scale.

A:

Lianja.run() is not supported in web and mobile.

A2:

I believe this is a security precaution: running system commands from a server connected to the web is a major security risk.

I would suggest seeing if you can run execPython in an RSP page (I’m thinking not, but it’s worth a try). There are Python libraries readily available for scaling images.

node.js libraries are available for image scaling also: node.js is distributed with Lianja, and Lianja.evalJavascript() is available in web/mobile, so this definitely should work.


Q:

When using VFP for server side scripting of functions and/or RSP pages, can you instantiate and use VFP class libraries to perform work?

Most of our current code base in held in straight prg class libraries and I’m assuming we can utilise these classes within Lianja.

A:

Yes you can use both procedure libraries and class libraries in server side rsp pages.

Generating JSON using a single sql statement is trivial.


 

Categories RSP

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


Categories RSP

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.



Categories RSP

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

Categories RSP

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



Categories RSP

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.



 

Categories RSP