PDF file serving with post action

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PDF file serving with post action

Patrick Larkin-2
Hello -

I currently have a form with a button that retrieves the form data and generates a PDF. At this point, I want the PDF to generate and download to the client (this works) and then have the user sent to either the main menu of some other page.  In other words, away from the form.  The purpose is that the form is now forbidden and the PDF is the official record that cannot be changed.  

So, on the form, I have a button which goes to a Lasso page that checks for errors and if it passes, I "include" a page with the Lasso PDF code.  

[var:'MyFile'=(PDF_Doc: -File=$filename,



[PDF_Serve:$MyFile, -File=$filename]

I then want to execute an inline to insert a value into the record and send the user to the main menu.  If I put the update inline either at the end of the PDF included code or in the initial error checking file after the INCLUDE statement, it never executes.  It just creates the PDF and remains on the same page.  

Does the PDF generation kill any other actions?  


Patrick Larkin
Information Systems
Bethlehem Area School District
https://www.beth.k12.pa.us





#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: PDF file serving with post action

Patrick Larkin-2
To possibly clarify:


The user clicks the button and it does to something like this:


if(var('group_no') != '');
        redirect_url('back to the form because it failed the error check));
else;

                inline(
                -database='$db',
                -table='$table',
                -clientusername=$dbu,
                -clientpassword=$dbp,
                -update,
                -KeyField='id',
                -KeyValue=action_param('q'),
                'FINALIZED'='Y'
                );
                /inline;
               
        error_currenterror + 'Thank you.';

       
        include('includes/pdf.lasso');
       
/if;

Based on this simplistic example, it executes the inline but never displays the error or message.  It just generates the PDF and stays on the current page.



On Dec 5, 2013, at 12:06 PM, Patrick Larkin <[hidden email]> wrote:

> Hello -
>
> I currently have a form with a button that retrieves the form data and generates a PDF. At this point, I want the PDF to generate and download to the client (this works) and then have the user sent to either the main menu of some other page.  In other words, away from the form.  The purpose is that the form is now forbidden and the PDF is the official record that cannot be changed.  
>
> So, on the form, I have a button which goes to a Lasso page that checks for errors and if it passes, I "include" a page with the Lasso PDF code.  
>
> [var:'MyFile'=(PDF_Doc: -File=$filename,
>
> …
>
> [PDF_Serve:$MyFile, -File=$filename]
>
> I then want to execute an inline to insert a value into the record and send the user to the main menu.  If I put the update inline either at the end of the PDF included code or in the initial error checking file after the INCLUDE statement, it never executes.  It just creates the PDF and remains on the same page.  
>
> Does the PDF generation kill any other actions?  
>
>
> Patrick Larkin
> Information Systems
> Bethlehem Area School District
> https://www.beth.k12.pa.us
>
>
>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
>  the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>


#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: PDF file serving with post action

Ke Carlton-3
You have a couple of options.

1. An interim thank you page which then redirects to the pdf download url
(and in turn stays on the thank you page).
2. Update the current page's content with "Thank you" via JQuery or similar
when the form is submitted and OK.

Ke

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: PDF file serving with post action

Jolle Carlestam-2
In reply to this post by Patrick Larkin-2
Once you serve a file any code after that point will not execute. It is not possible to both serve a file and send back any other kind of data.

What you can do is use JavaScript (jquery) to hide or remove the form on submission. And instead present some kind of thank you splash. If the form process fails you can send back the form page again with proper error message. If not the PDF will be served.

HDB
Jolle

Sent from a thin, flat, touchy device from an undetermined place in space.

5 dec 2013 kl. 18:06 skrev Patrick Larkin <[hidden email]>:

>
> Does the PDF generation kill any other actions?  

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: PDF file serving with post action

Lasso Talk
In reply to this post by Patrick Larkin-2
here simple example with response to same page (page isn´t reloading)

Main page:
simple form, after click to button is this disabled
data are sent to generate.lasso (you PDF document generation). This page
content is loaded to Result object (div). You can use in result document
any HTML, CSS, JavaScript code, PDF document icon, link for download, etc.
This example not check form input elements contents (not used validation
scripts).
For sending generate.lasso data you can use Ajax with Get or Post method
a complete checking sending status. In this example alert is showing
after Load is completed.
generate.lasso response input fields contents (Action_Param) and random
number.

good luck

Lubos
www.lassozone.com


MAIN LASSO PAGE:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<!-- JQuery 1.9.1 -->
<script type="text/javascript" src="jquery.min.js" charset="utf-8"></script>
<!-- Custom Script -->
<script>
$( document ).ready(function() {
$( "#submitBtn" ).click(function() {
     var data = $(this).closest('#registerform').find(':input').serialize();
     $('#registerform #submitBtn').attr("disabled", true);
     $('#result').load('generate.lasso?'+data,
     function() {
         alert('Document was generated.');
         }
     )
});
});
</script>
</head>
<body>
<div id="registerform">
username: <input type="text" name="username" id="username" /><br>
email: <input type="text" name="email" id="email" /><br>
<input type="submit" name="submit" id="submitBtn" value="Submit" />
<div id="result"></div>
</div>
</body>
</html>

generate.lasso
[Math_Random: -Lower=500, -Upper=99999999]<br>
username: [Action_param:'username']<br>
email: [Action_param:'email']<br>

----------------------------------------------------------------------------------------------------------

> Patrick Larkin <mailto:[hidden email]>
> 5. decembra 2013 18:15
> To possibly clarify:
>
>
> The user clicks the button and it does to something like this:
>
>
> if(var('group_no') != '');
> redirect_url('back to the form because it failed the error check));
> else;
>
> inline(
> -database='$db',
> -table='$table',
> -clientusername=$dbu,
> -clientpassword=$dbp,
> -update,
> -KeyField='id',
> -KeyValue=action_param('q'),
> 'FINALIZED'='Y'
> );
> /inline;
>
> error_currenterror + 'Thank you.';
>
>
> include('includes/pdf.lasso');
>
> /if;
>
> Based on this simplistic example, it executes the inline but never
> displays the error or message. It just generates the PDF and stays on
> the current page.
>
>
>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to <[hidden email]>
> Patrick Larkin <mailto:[hidden email]>
> 5. decembra 2013 18:06
> Hello -
>
> I currently have a form with a button that retrieves the form data and
> generates a PDF. At this point, I want the PDF to generate and
> download to the client (this works) and then have the user sent to
> either the main menu of some other page. In other words, away from the
> form. The purpose is that the form is now forbidden and the PDF is the
> official record that cannot be changed.
>
> So, on the form, I have a button which goes to a Lasso page that
> checks for errors and if it passes, I "include" a page with the Lasso
> PDF code.
>
> [var:'MyFile'=(PDF_Doc: -File=$filename,
>
> …
>
> [PDF_Serve:$MyFile, -File=$filename]
>
> I then want to execute an inline to insert a value into the record and
> send the user to the main menu. If I put the update inline either at
> the end of the PDF included code or in the initial error checking file
> after the INCLUDE statement, it never executes. It just creates the
> PDF and remains on the same page.
>
> Does the PDF generation kill any other actions?
>
>
> Patrick Larkin
> Information Systems
> Bethlehem Area School District
> https://www.beth.k12.pa.us
>
>
>
>
>
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list Lasso
> [hidden email]
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to <[hidden email]>

#############################################################
This message is sent to you because you are subscribed to
  the mailing list Lasso
[hidden email]
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>