• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Make email send optional for user

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have an app that has many emails when the form is submit or when the request is approved etc.

How can I make the email sending optional.

Example once say the form is submit before the success or the next page is loaded , a pop up is given to the user (Do you wish to send this so and so emails ok and cancel)
If ok is clicked send the email else cancel the email generation and move on to the next page.

Is this possible?

Thanks
 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lets say if the user clicks the OK button it will return true and then you might forward the request to next page.

So read the return value from the pop up window and if the return value is true then add new paratmer to the request lets say sendMail then in the next page check for this parameter value if it has some value then send email if it is null then do not send email.
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.

Where can I put the js code for the pop up?

If my current workflow is request form -> controller servlet -> Servlet to process the logic (sets request with information required to send the email) -> success page.

And is this a good idea if I have to implement ? is there any library , any alternative i can use?

Thanks
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i believe request form is a jsp page lets say A.jsp

then in A.jsp

function confirmation() {
var answer = confirm("Ok to submit the form?")
if (answer){
set the request parameter here.
<%request.setAttribute("sendMail","Yes"); %>
submit the form.
}
}

then in the servlet

String isMailsend=request.getAttribute("sendMail");

if isMailsend ==null then do not send mail

 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Siva Masilamani wrote:
function confirmation() {
var answer = confirm("Ok to submit the form?")
if (answer){
set the request parameter here.
<%request.setAttribute("sendMail","Yes"); %>
submit the form.
}
}


That won't even come close to working. The attribute will be set on the server long before any JavaScript is executed in the browser.
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how about using hidden field then and reading the value of the hidden field.
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Set the hidden feild upon submit based on the users input...That might work.
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah that works.

On submit I set a hidden true or false based on the users input.

Thanks a lot !
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic