4 Replies Latest reply on Aug 7, 2007 1:21 AM by szaccaria

    modalpannel confirmation box: "Save changes: YES, NO, CANCEL

    szaccaria

      Hello to all,
      It are some days that I'm in the trouble with the modalpanel.
      That I want to do is a form like "Confirmation Box" of others programs, that inform the user about change unsaved in the work.
      In example, the user insert some data in the form, so if she left the page without save the change a modalpanel popup. Now I saw with seam that a entity bean when are changed its fields the entity manager flush the change in db. So I've thought that I check with a SFSB if the entity is changed ad ad hoc to pop up a modelpanel that request about save o no the data.
      Somebody have a idea?
      I read the http://jboss.com/index.html?module=bb&op=viewtopic&t=113360
      but I don't understand what I do need make

        • 1. Re: modalpannel confirmation box:
          fernando_jmt

          If you are using SEAM, you can use SMPC and start a conversation with manual flush mode, with this you will have the control over the flush operation , to be specific you must call entityManager.flush() in order to save the changes in the database.

          e.g.:

          @Begin(ifOutcome = {Outcome.SUCCESS}, flushMode = FlushModeType.MANUAL)
           public String select() {
           ...(load entity)
           }
           @End
           public void save (){
           ...(save entity operations)
           entityManager.flush();
           }
          


          HTH.

          • 2. Re: modalpannel confirmation box:
            szaccaria

            Thanks Fernando,
            that I do have made is that you write to me.
            The problem is not to the server site but in the client, in fact I don't know how to pop up programmaticaly the modalpannel when refresh the windows.

            I have thought to control, before to flush the data, if the data need the flush
            es:

            ((Session)entityManager.getDelegate()).isDirty()

            in a action method, therefore set a flag and after return null from action method pop up the modal pannel...
            But I don't know like making in the js to pop up a modal panell conditionedly. Any help will be appreciated.

            Thanks in advance

            • 3. Re: modalpannel confirmation box:
              fernando_jmt

              Ok, I think is more clear for me now.

              Well, I didn't do anything similar yet, but these are my suggestions:

              A)
              - Add a variable in you backing bean, a boolean which will indicate if modal panel must be shown.
              - If you talk about page refresing, what about to use the onload of the page body, calling a js function.
              - Such js function must be written programatically, it means it depends of your boolean flag. Inside the function you only need to throw Richfaces.showModalPanel(...).

              B)
              May be you can use a4j:js in order to find a solution or even better, to accomplish the point A)

              c)
              I'm not sure, but an alternative could be a4j:pool, in order to get the state of you boolean flag and the throw JS functions.


              HTH.

              • 4. Re: modalpannel confirmation box:
                szaccaria

                Thanks again Fernando,
                today I will try with the suggestions that you have given to me.
                However me it is not still luminosity like activating dynamically the script js? knows to me that today I will have to study a few of java script!!!

                Thanks