Results 1 to 9 of 9

Thread: [Answers] RSP

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] 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.



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2017-01-16 at 04:21.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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.



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352




    Last edited by josipradnik; 2017-01-16 at 02:54.

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2017-01-16 at 02:48.

  4. #4
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    [Sorry for splitting this topic into more posts. Forum post engine sometimes interprets RSP code snippets - giving unpredictable results and complicating post editing]

    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:
    <script>
    if pra_no <> 0 
    ?"<big><b>OUR RA No.: " +pra_no+ "</b></big>"
    endif
    </script>
    A:
    You can close and then reopen the text raw...endtext

    Code:
    text raw
    ...
    endtext
    if pra_no <> 0 
    ?"<big><b>OUR RA No.: " +pra_no+ "</b></big>"
    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 <a> tag with onclick="Lianja....."
    Code:
    <a href="#" onclick="myjavascriptfunction()">Click me</a>

    Last edited by josipradnik; 2017-01-16 at 02:44.

  5. #5
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
    <html><head><meta name="qrichtext" content="1" /><style type="text/css">
    p, li { white-space: pre-wrap; }
    </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Bianco,Rosso,Rosè,Nero</p></body></html>
    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:
    <body>
    <%    
    // test.sn
    
    proc drawTable()
        laFields = explode(",", m_fields)
        laCaption = explode(",", m_caption)
        laQuery = explode(",", m_query)
    
        ? ('<table width="100%" height="10%" cellpadding="5" cellspacing="0" bgcolor="white" border=0px >') 
    
        ? ('<tr bgcolor="gray">')
        
        ? ('<td align="center" colspan="&(alen(lafields))">')
        ? ('</td>')
        ? ('</tr>')   
    
        ? ('<tr bgcolor="#eaeaea">')
        for lnI = 1 to alen(laFields)
      lsQueryValue = ""
      if !empty(m_query)
       laQueryValue = explode("|", m_query)
       lsQueryValue = laQueryValue(2)   
      endif
      
      ? '<td>'
      ? '<input width="100%" type="text" value="' + lsQueryValue + '" id="' + rtrim(laFields[lnI]) + '" onchange="filterComments()" ' + '>'
      ? '</td>'   
        endfor
    
        ? ('<p id="Query">' + m_query + '</p>')
       
        ? ('</tr>')
    
        ? ('<tr bgcolor="#eaeaea">')
        ? ('<input name="Cerca" type="button" value="Cerca" onclick="filterComments()"/>')
        ? ('</tr>')
        
        
        lnRiga = 1
        scan
      if mod(lnRiga, 2) = 1
          rowcolor = "#f1f6fe"
          altcolor = "#FFFFFF"
      else
       rowcolor = "#FFFFFF"         
       altcolor = "#f1f6fe"
      endif
      lnRiga = lnRiga + 1
      
      ? ('<tr bgcolor="&rowcolor" class="datacellgridline">')
        
      for lnI = 1 to alen(laFields)
       ? ('<td valign=top align=left class="datacellgridline&css_type">')
          
       if laFields(lnI) = m_target
        lsField = &laFields(lnI)
        ? [<a href="javascript:selectitem('&lsField')">] + &laFields(lnI) + [</a>]
       else
        ? (&laFields(lnI))
       endif
           
       ? ('</td>')
       
      endfor 
      ? ('</tr>')
    
        endscan
    
        ? ('</table>') 
    
    endproc
    
    drawTable()
    
    %>
    </body>
    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.




    ​All topics in [Answers] alphabetically: http://www.lianja.com/community/showthread.php?2717-Answers


  6. #6
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    fabtest.rsp:

    Code:
    <%@ Language=VFP %>
    <html>
    <head>
    <script type='text/javascript'>
    function readText()
    {
            window.alert("ReadText");
            document.getElementById("DivTabella").innerHTML ='<iframe id = "myframe" src="http:/localhost:8002/tabella.html?firstname=Yvonne&lastname=Milne" width="100%" height="100" scrolling="no" frameborder="0"></iframe>';
    };
    function filterComments(m_empty)
    {
            window.alert("in parent filterComments");
    
    };
    
    if (typeof window.parent !== 'undefined' && typeof window.parent.Lianja !== 'undefined')
    {
    window.Lianja = window.parent.Lianja;
    };
    </script>
    </head>
    <body>
    <button id=test" type="button" onclick="readText()">Test</button>
    <div id="DivTabella">
    Click Test
    <%
    m_firstname = getparameter("firstname","Unknown")
    m_lastname = getparameter("lastname","Unknown")
    ? m_firstname + "<br>"
    ? m_lastname
    %>
    </div>
    </body>
    </html>
    tabella.html:

    Code:
    <script type="text/javascript">
    </script>
    <table width="100%" height="10%" cellpadding="5" cellspacing="2" bgcolor="white" border=2px id="tabella">
    <tr bgcolor="gray">
    <td align="center" colspan="3">
    </td>
    </tr>
    <tr bgcolor="#eaeaea">
    <tr bgcolor="&rowcolor" class="datacellgridline">
    <td valign=top align=left> <b>
    Articolo
    </td> </b>
    <td valign=top align=left> <b>
    Cat. merc.
    </td> </b>
    <td valign=top align=left> <b>
    Descrizione
    </td> </b>
    </tr>
    <td>
    <input width="100%" type="text" value="" id="cod_art" onchange="window.parent.filterComments('Z')" >
    </td>
    <td>
    <input width="100%" type="text" value="" id="catmercgam" onchange="parent.filterComments('Z')" >
    </td>
    <td>
    <input width="100%" type="text" value="" id="des_web" onchange="parent.filterComments('Z')" >
    </td>
    </tr>
    </table>
    Console command:

    Code:
    Lianja.ShowDialog("Search & Find", "http://localhost:8002/desktopwebservice/fabtest.rsp?firstname=Yvonne&lastname=Milne")



    in my inframe I've this line of HTML:
    Code:
    <input width="100%" type="text" value="" id="catmercgam" onchange="window.parent.testClick()" >
    this is my RSP code:

    Code:
           function readText()
            {
                    window.alert("ReadText");
                    document.getElementById("DivTabella").innerHTML ='<iframe id = "myframe" src="http:/localhost:8002/_000000c40014.html?firstname=Yvonne&lastname=Milne" width="100%" height="100%" scrolling="yes" frameborder="0"></iframe>';
            };
           
            function filterComments(m_empty)
            {
                    window.alert("in parent filterComments");
                   
                    readText();
           
            };
                   
            function testClick()
            {
                    var myVar;
                    myVar = setTimeout(filterComments(), 10000);
                   
                    window.alert("Passo otre");
            };
    A:
    You are calling the function instead of passing it's address. Remove the ().



    ​All topics in [Answers] alphabetically: http://www.lianja.com/community/showthread.php?2717-Answers

  7. #7
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    I call a RSP page with this function:
    Code:
    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 .


    A:
    you can make that all be in VFP.
    Instead of document.write you would simple print it.

    Code:
    ? "<tr>"
    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.

    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:
    Code:
    // 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()

    Code:
    <%@ Language=VFP %>
    <html>
    <head>
    <%
    if not isServer()
            ? "<link rel='stylesheet' href='lib:/bootstrap/css/bootstrap.min.css' type='text/css'/>"
    else
            ? "<link rel='stylesheet' href='../../library/bootstrap/css/bootstrap.min.css' type='text/css'/>"
    endif
    %>
    <style type='text/css'>
    body {
            margin:10px;
    }
    </style>
    </head>
    <body>
    <%
    text raw
    <script>
    function editCustomerID(customerid)
    {
            Lianja.showDocument("page:page1?action=search&text="+customerid);
    };
    </script>
    endtext
            save datasession
            open database southwind
            use customers
            list html off ;
                    fields customerid,companyname,contacttitle,contactname,address,region,city,country ; 
                    onclick "customerid","editCustomerID('{}')"
            restore datasession
    %>
    </body>
    </html>
    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):

    Code:
    text raw
    <script>
    function editCustomerID(customerid)
    {
        Lianja.showDocument("page:page1?action=search&text="+customerid);
    };
    </script>
    endtext
    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.




    ​All topics in [Answers] alphabetically: http://www.lianja.com/community/showthread.php?2717-Answers

  8. #8
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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.

    Code:
    <%@ 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.

    Code:
    <%@ Language=VFP%>
    <%
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
    private m_embedded = getParameter("embedded", "false")
    private m_libpath
    set macros on
    set fixed on 
    if isServer()
            m_libpath = "../../library/"
    else
            m_libpath = "lib:/"
    endif
    if m_embedded = "false"
            ? '<html>'
            ? '<head>'
            ? '<link rel="stylesheet" href="&m_libpath/bootstrap-3.3.4/css/bootstrap.min.css">'
            ? '<script src="&m_libpath/jquery-1.10.2/jquery-1.10.2.min.js" type="text/javascript"></script>'
            ? '<script src="&m_libpath/bootstrap-3.3.4/js/bootstrap.min.js" type="text/javascript"></script>'
            ? '</head>'
           
    endif
    %>
    <body style="overflow-y:hidden;">
    </body>
    </html>



    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.



    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 to <nav nav-pills nav-stacked> so I could stack them in my fourth column set.

    Code:
    <div class="col-md-2 col-md-offset-1 col-lg-2 col-lg-offset-1">
    <ul class="nav nav-pills nav-stacked"> 
    <li class="active">
    <a href="#">Personal Banking</a>
    </li> 
    <li>
    <a href="#">Business Banking</a>
    </li> 
    <li>
    <a href="#">Investing</a>
    </li> 
    <li>
    <a href="#">Insurance</a>
    </li> 
    </ul> 
    </div>
    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.

    Code:
    <div class="col-md-3 col-lg-3 well" data-pg-collapsed>
    <h3>Bank Of Lianja</h3> 
    <p>Bank of Lianja has been a leader in thick skin savings and Loans since 1985. Bank of Lianja is built with combination of Visual Foxpro, HTML5, CSS3, Bootstrap and Jquery (and probably some less files befor all is said and done).</p> 
    <a class="btn btn-primary pull-right" href="#" role="button">View details &raquo;</a>
    </div>
    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 Kendoui - https://youtu.be/ScNexbKrARA




    Q:
    is Response.contenttype case sensitive?
    A:
    Code:
    <%
    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.

    Code:
    <%@ language=VFP %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="application/json; charset="UTF-8" />
    </head>
    <body>
    <%
    
    response.contenttype = "application/json"
    
    private aresult
    
    set strcompare off
    private m_procname=getParameter("procname","")
    private m_uid=getParameter("m_uid","")
    private m_pwd=getParameter("m_pwd","")
    private m_db = getParameter("db","")
    private m_custid = getParameter("custid","")
    private m_custname = getParameter("custname","")
    
    
    gnConnHandle = SQLSTRINGCONNECT("driver={SQL server};server=testsql2;uid=m_uid;pwd=m_pwd")
    strw = "update demo2..customers set custname ='"+m_custname+"' where custid ="+m_custid+""
    = SQLPREPARE(gnConnHandle,strw)
    = SQLEXEC(gnConnHandle)
    
    strw = "select custid,custname from demo2..customers where custid ="+m_custid+""
    = SQLPREPARE(gnConnHandle,strw,'v_SQLresult')
    = SQLEXEC(gnConnHandle)
    
    select * from v_SQLresult into arrayofobjects aresult
    
    print_json(aresult)
    
    = SQLEXEC(gnConnHandle)
    
    =sqldisconnect(gnConnHandle)
    
    %>
    </body>
    </html>
    Looking at the response type, it is still text/html?????



    A:
    Here's the line that works for me when sending JSON to an .rsp web service:

    Code:
    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




    ​All topics in [Answers] alphabetically: http://www.lianja.com/community/showthread.php?2717-Answers

  9. #9
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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 :
    Code:
    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\myTargetFolder\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:
    Code:
    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:
    Code:
    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.




    All topics in [Answers] alphabetically: https://www.lianja.com/community/sho...ll=1#post13748

    These answers are also systematized on the site "Lianja developer": https://lianjadeveloper.wordpress.com/category/rsp/

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us