2 Replies Latest reply on Dec 15, 2006 2:50 AM by None None

    Using DataModelSelection and @Out for an "are you sure" page

    None None Master

      Here's the scenario:

      I use a DataModel in my SFSB to present a table to a user. Let's say it's a table of important things that you wouldn't normally delete, like a table of Customers. I display this table, using the DataModel, and next to each Customer there is a "delete" button. Clicking "delete" will take the user to another page where the details of the customer are shown, and it says, "are you sure you want to delete this customer?" Then there is a "yes really delete" button there.

      Obviously I can know which entry was clicked with a @DataModelSelection, and I can use an <s:link> to get to the "are you sure" page. I put an @Out along with the @DataModelSelection. When I do this, the DataModelSelection is being set and outjected, but it is being outjected after the "are you sure" page is rendered, so the details can't be displayed on that page.

      As a hack, I have used a <h:commandButton> instaed of an <s:link>, and for the action I have used a method call that looks like this:

      public String doIt() {
       return "/are-you-sure.jsp";
      }


      What this does is it gets the value outjected before it needs to render the are-you-sure.jsp page.

      So, that works, but it involves writing a method that doesn't do anything more than returning a string, and seems hackish.

      Is there some nicer way to do this? This is important to me because I do this kind of thing all the time in my application.

      Thanks


        • 1. Re: Using DataModelSelection and @Out for an
          Gavin King Master

          There is nothing wrong with the donothing method. It is needed. but it would be better to make it a page action (or an s:link action) than to use a commandButton.

          • 2. Re: Using DataModelSelection and @Out for an
            None None Master

             

            "gavin.king@jboss.com" wrote:
            There is nothing wrong with the donothing method. It is needed. but it would be better to make it a page action (or an s:link action) than to use a commandButton.


            Ok, interesting, I had thought there must be some other way, but I guess not. I will then use do-nothing methods, and maybe in the process of using them I'll sometimes notice cases where I do have some work for them to do. And I'll use s:links, which I'm using more frequently in my pages.

            At some point I might come accross some kind of AJAX component that will handle the "are you sure" thing, which could make this whole thing even easier.