0 Replies Latest reply: Feb 6, 2009 2:36 PM by 807575 RSS

    The Init() method of abstract pagebean always it excute, and i lost data.

    807575
      Hi,

      I have applicaction to buid in NetBean 6.1 and JDK 1.6 using Visual Web Java Server Pages. This application to present a view that have a 2 calendar component, 1 dropdownlist, button component and table component.

      The table component show rows where calendar1.date > date1 and calendar2.date < date2 and estado(DropDownList)= status1

      In the init() method of abstractpagebean i set de initial calendar's date that follow


      java.util.Calendar dateAntes = GregorianCalendar.getInstance();
      java.util.Calendar date = GregorianCalendar.getInstance();
      dateAntes.add(java.util.Calendar.MONTH, -1);

      GregorianCalendar gc = new GregorianCalendar(2000, 11, 20);
      //tablePhaseListener = getSessionBean1().getTablePhaseListener();

      calendar1.setSelectedDate(dateAntes.getTime());
      calendar2.setSelectedDate(date.getTime());

      With this initial dates dates i show the table row thw follow

      String command = "SELECT ALL codreqgmc, fechareq,cliente.nomclie,estado.Descripcion as Estado, " +
      "requerimiento.codtecnico, requerimiento.rutclie, requerimiento.codestado " +
      "FROM requerimiento,cliente,estado " +
      "WHERE requerimiento.rutclie=cliente.rutclie and requerimiento.codestado=estado.codestado and fechareq>=" + "'" + formatoFecha.format(calendar1.getSelectedDate()) + "'" +
      "AND fechareq<=" + "'" + formatoFecha.format(calendar2.getSelectedDate()) + "'";

      try {
      getSessionBean1().getRequerimientoRowSet().setCommand(command);
      getSessionBean1().getRequerimientoRowSet().getCommand();

      getSessionBean1().getRequerimientoDataProvider().refresh();
      } catch (Exception e) {
      error("No puede levantar comando");
      log("Cannot switch to person " +
      estados.getSelected().toString(), e);

      }

      The DropDownList implement the ProcessValueChange Event with AutoSubmit On Change properties. At Change choise of DropDown List Component it trigger a event that and execute estados_processValueChange method that to show a table rows accord to the new filter (include the new calendar date if necessary that follow:


      String command = "SELECT ALL codreqgmc, fechareq,cliente.nomclie,estado.Descripcion as Estado, " +
      "requerimiento.codtecnico, requerimiento.rutclie, requerimiento.codestado " +
      "FROM requerimiento,cliente,estado " +
      "WHERE requerimiento.rutclie=cliente.rutclie and requerimiento.codestado=estado.codestado and fechareq>=" + "'" + formatoFecha.format(calendar1.getSelectedDate()) + "'" +
      "AND fechareq<=" + "'" + formatoFecha.format(calendar2.getSelectedDate()) + "'";

      try {

      getSessionBean1().getRequerimientoRowSet().setCommand(command + " AND requerimiento.codestado =" + "'" + (String) estados.getSelected() + "'");
      getSessionBean1().getRequerimientoRowSet().getCommand();
      getSessionBean1().getRequerimientoDataProvider().refresh();

      } catch (Exception e) {
      error("No puede levantar comando");
      log("Cannot switch to person " +
      estados.getSelected().toString(), e);

      }

      The Table component have a column of checkbox type for select a particular(s) row(s). With a Button it to choose all the rows that has been to set checkbox, in the session bean to save this selected rows and link to another page that show the details about seletec rows.

      The Problem

      Every time that i press the button, after to the select the rows, for another page showme detail, this page is empty because it execute the init method before the button_action, to re initialize and erase the user selection and lost it

      I try with another component that trigger event, por exmaple dropdownlist, and it the same, even to press the pagin in teh table it execute init meth, re-initialize and erase all.

      Result prove

      1.- I execute the application for first time:

                Execute      Init()

      2.- I Chage choos en the DropDownList

                Execute      Init() and
                after           estado_processValueChange()

      3.- I change choos again in the DropDownList

                Execute      Init() and
                after           estado_processValueChange()


      4.- I press pagin button in table

                Execute      Init()

      5.- I press button detail, for detail

           Execute      Init() ----> I reinitialize and lost the user select.
           after          Butoon_action


      How ia can to preven that every time it execute init(),
      Why alway it execute init method?, the init methd() is for initialize application and not RE INTIALIZED
      Why is the relation INIT(); PREPROCESS(), PRERENDER(), PROCESSVALUECHANGE, BUTTON_ACTION. What it execute first, what secodn?

      I need execute init method only one , at first time

      I hope i undertandme, i not native english.


      Thank for advance