You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Angelo Immediata <an...@libero.it> on 2006/01/30 15:44:07 UTC

CForm: ask for confirm

Hi all.
I have this scenario:
in my application a web user can delete something. I'ld like to ask for confirm before to delete what he has choosen. I can't use javascript like "window.open...." etc... Is there a method to ask this thing to the user with no using Javascript? I'ld like to use something like a "special widget or attribute" that i can use only when the user wants to delete and i don't want to change current page but reload it by asking this confirm.

I'm using Cocoon 2.1.7 and its portal block.

Thanks to all.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: CForm: ask for confirm

Posted by Jason Johnston <co...@lojjic.net>.
Angelo Immediata wrote:
> Hi all. I have this scenario: in my application a web user can delete
> something. I'ld like to ask for confirm before to delete what he has
> choosen. I can't use javascript like "window.open...." etc... Is
> there a method to ask this thing to the user with no using
> Javascript? I'ld like to use something like a "special widget or
> attribute" that i can use only when the user wants to delete and i
> don't want to change current page but reload it by asking this
> confirm.
> 
> I'm using Cocoon 2.1.7 and its portal block.

If I understand what you're looking for, you want a way to ask for a
user's confirmation without using client-side javascript.  I've done
this in the past by creating a simple confirm() flowscript function
which roughly mimics the behavior of the confirm() function in
client-side browser javascript.  So when I get to a point in my
flowscript where I want the user to choose whether or not to do
something, all I have to do is:

  if(confirm("Are you sure you want to delete this item?")) {
     performDelete();
  }
  else {
     //redisplay form or whatever the fallback action is
  }

The confirm function looks something like this:

  // ask the user for yes/no confirmation, returns a boolean:
  function confirm(question) {
    cocoon.sendPageAndWait("confirm.jx", {question:question});
    return (cocoon.request.getParameter("confirm") == "Yes");
  }

The confirm.jx template looks something like this:

  <html>
  ...
  <form action="${cocoon.continuation.id}.continue">
    <p>${question}</p>
    <p>
      <input type="submit" name="confirm" value="No" />
      <input type="submit" name="confirm" value="Yes" />
    </p>
  </form>
  ...
  </html>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org