2 Replies Latest reply on Jan 26, 2012 5:34 PM by josiman87

    Popup problem

    josiman87

      hi, I try to do a edition to data with a popupPanel, I have a list in extendedDataTable, and when I select a data and click to button Edit show a popup with the information but i don't know like chage tha data in the popup

       

      my source

       

      <h:form>

                                                                                      <div class="left-margin">

                                                                                                <rich:extendedDataTable value="#{attendersBean.attendee}"

                                                                                                          style="height:100px;"

                                                                                                          selection="#{attendersBean.selection}"

                                                                                                          selectionMode="single" var="attenderr"

                                                                                                          id="attenderlist"

                                                                                                          >

                                                                                                          <a4j:ajax execute="@form" event="selectionchange"

                                                                                                                    listener="#{attendersBean.selectionAttenderListener}" render="EdAttendee" />

                                                                                                          <f:facet name="header">Attendees</f:facet>

                                                                                                          <rich:column>

                                                                                                                    <f:facet name="header">Nombre</f:facet>

                                                                                                                    <h:outputText value="#{attenderr.nombre}" />

                                                                                                          </rich:column>

                                                                                                          <rich:column>

                                                                                                                    <f:facet name="header">Email</f:facet>

                                                                                                                    <h:outputText value="#{attenderr.email}" />

                                                                                                          </rich:column>

                                                                                                </rich:extendedDataTable>

                                                                                      </div>

                                                                                      <div class="buttonLeft">

                                                                                                <h:commandButton value="Edit" action="#">

                                                                                                          <rich:componentControl event="click" target="EditAt" operation="show" />

                                                                                                </h:commandButton>

                                                                                                <br />

                                                                                                <h:commandButton value="Delete" action="#">

                                                                                                          <rich:componentControl event="click" target="DeleteA" operation="show" />

                                                                                                </h:commandButton>

                                                                                      </div>

                                                                            </h:form>

       

      My Beans

       

           private List<Attenders> attendee;

           private Collection<Object> selection;

           private List<Attenders> selectionAttender = new ArrayList<Attenders>();

       

      public List<Attenders> getAttendee() {

                          Session session = HibernateUtil.getSession().openSession();

                          session.beginTransaction();

                          List result = session.createQuery("from Attenders").list();

                          session.getTransaction().commit();

                          session.close();

                          attendee = (List<Attenders>) result;

                          return attendee;

                }

       

       

                public void setAttendee(List<Attenders> attendee) {

                          this.attendee = attendee;

                }

       

       

      public void selectionAttenderListener(AjaxBehaviorEvent event) {

              UIExtendedDataTable dataTable = (UIExtendedDataTable) event.getComponent();

              Object originalKey = dataTable.getRowKey();

              selectionAttender.clear();

              for (Object selectionKey : selection) {

                  dataTable.setRowKey(selectionKey);

                  if (dataTable.isRowAvailable()) {

                            selectionAttender.add((Attenders) dataTable.getRowData());

                            if(editAttender==null){this.editAttender = ((Attenders) dataTable.getRowData());}

                  }

              }

              dataTable.setRowKey(originalKey);

          }

       

      ublic Collection<Object> getSelection() {

              return selection;

          }

       

          public void setSelection(Collection<Object> selection) {

              this.selection = selection;

          }

       

      public List<Attenders> getSelectionAttender() {

              return selectionAttender;

          }

       

          public void setSelectionAttender(List<Attenders> selectionAttender) {

              this.selectionAttender = selectionAttender;

          }

       

       

       

      The PopupPanel:

       

      <rich:popupPanel id="EditAt" autosized="true" width="350"

                                              resizeable="false" onmaskclick="#{rich:component('EditAt')}.hide()">

                                              <f:facet name="header">Edit Attendee</f:facet>

                                              <f:facet name="controls">

                                                        <h:outputLink value="#"

                                                                  onclick="#{rich:component('EditAt')}.hide()">

                             X

                         </h:outputLink>

                                              </f:facet>

                                              <h:form>

                                                                  <rich:dataGrid id="EdAttendee" value="#{attendersBean.selectionAttender}" var="atendeer" style="width:100%;">

                                                                  <h:panelGrid columns="3" id="editAttendeeGrid">

                                                                  <h:outputLabel value="ID: " />

                                                                  <h:inputText required="true" value="#{atendeer.idAttenders}" disabled="true" /><h:inputHidden />

                                                                  <h:outputLabel value="Nombre: " />

                                                                  <h:inputText id="nombre" required="true" value="#{attendersBean.nombre}" /><h:outputLabel value="#{atendeer.nombre}" />

                                                                  <h:outputLabel value="Email: " />

                                                                  <h:inputText id="email" required="true" value="#{attendersBean.email}"  /><h:outputLabel value="#{atendeer.email}" />

                                                                  </h:panelGrid>

                                                                  </rich:dataGrid>

                                                        <div style="text-align: center;">

                                                                  <h:commandButton value="Save" onclick="#{attendersBean.recargaAttenders()}" />

       

       

                                                                  <h:commandButton style="margin-bottom: 40px;" value="Cancel"

                                                                            onclick="#{rich:component('EditAt')}.hide();return false;" />

                                                        </div>

                                              </h:form>

                                    </rich:popupPanel>

       

      I DON'T KNOW LIKE TO DO, I TRY TO ValueListenerChange but nothing. THAKS FOR YOUR HELP.