2 Replies Latest reply on Sep 17, 2009 4:44 PM by Oguzhan YALCIN

    Problem with modalpanel rerender

    Oguzhan YALCIN Newbie

      Hi,


      I'm listing results with extended data table on a page which acquires data from a Datamodel. Every row has an edit button (the code an xhtml files are below). When I click the edit button . I assign the Id value to the Home object (using the datamodelselection), refresh the panel(which contains the edit form) and display the modal panel.  But there is a problem: The buttons Save/Update is displayed correctly in relation to whether the Home object is managed or not. But the field values inside the panel are not refreshed (Altough  the data in the home object is right). I couldn't find out what  the problem is. maybe missing stg?or stg is really wrong?


      Thanks for your help.


      The code is below:



      EntityQuery based list :



      @Stateful
      @Scope(ScopeType.CONVERSATION)
      @Name("registryNoteList")
      public class RegistryNoteList extends com.taykos.session.RegistryNoteList
                      implements IList<RegistryNote> {
      
              private static final long serialVersionUID = -8036003573137106118L;
      
              @In(create=true)
              RegistryChooser registryChooser;
              
              @DataModel
              List<RegistryNote> dmRegistryNote;
      
              @DataModelSelection
              RegistryNote dmsRegistryNote;
      
              @In(create = true)
              RegistryNoteHome registryNoteHome;
      
              @Logger
              Log log;
      
              boolean allSelected=false;
      
      
              public void setRelatedValue(Object entity) {
              }
      
              public void assignSelected() {
                      registryNoteHome.setId(dmsRegistryNote.getRecordId());
                      log.info("year value is " + registryNoteHome.getInstance().getYear());
                      log.info("note value is " + registryNoteHome.getInstance().getNote());
              }
      
              public void checkSelected() {
                      log.info("allselected value is " + allSelected);
                      allSelected = !allSelected;
                      for (RegistryNote registryNote : dmRegistryNote)
                              registryNote.setSelected(allSelected);
              }
      
              public void deleteSelected() {
                      for (RegistryNote registryNote : dmRegistryNote)
                              if (registryNote.isSelected()) {
                                      registryNoteHome.setInstance(registryNote);
                                      registryNoteHome.remove();
                              }
                      initializeDataModel();
              }
      
              public Object getRelatedValue() {
                      return null;
              }
      
              public void initHome() {
                      registryNoteHome.clearInstance();
              }
              @Factory("dmRegistryNote")
              public void initializeDataModel() {
                      dmRegistryNote=null;
                      log.info("registry requested from registryChooser");
                      if(registryChooser.getRegistry()==null)return;
                      log.info("registryid is now set to:" + registryChooser.getRegistry().getRecordId());
                      getRegistryNote().setRegistry(registryChooser.getRegistry());
                      parseEjbql();
                      refresh();
                      dmRegistryNote=getResultList();
              }
      
              public boolean isAllSelected() {
                      return allSelected;
              }
      
              @Remove @Destroy
              public void removeInstance() {
              }
      
              public void setAllSelected(boolean allSelected) {
                      this.allSelected=allSelected;
              }
      
      }
      




      Main xhtml


      <f:view xmlns="http://www.w3.org/1999/xhtml"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:richfaces="http://richfaces.ajax4jsf.org/rich"
              xmlns:ajax="https://ajax4jsf.dev.java.net/ajax"
              xmlns:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich"
              xmlns:s="http://jboss.com/products/seam/taglib">
      
              <ui:include src="/UC/employee/RegistryChooser.xhtml" />
              <rich:panel>
                      <a4j:outputPanel >
                              <rich:extendedDataTable value="#{dmRegistryNote}" var="_regNote"
                                      id="tblRegistryNote" width="100%" height="400px">
                                      <rich:column id="checkBoxColumn">
                                              <f:facet name="header">
                                                      <h:selectBooleanCheckbox value="#{registryNoteList.allSelected}">
                                                              <a4j:support event="onchange"
                                                                      action="#{registryNoteList.checkSelected}"
                                                                      reRender="checkBoxColumn" />
                                                      </h:selectBooleanCheckbox>
                                              </f:facet>
                                              <h:selectBooleanCheckbox value="#{_permission.selected}" />
                                      </rich:column>
      
      
                                      <rich:column sortable="false" label="Tarih">
                                              <f:facet name="header">Yıl</f:facet>
                                              <h:outputText value="#{_regNote.year}" />
                                      </rich:column>
      
                                      <rich:column sortable="false" label="Açıklama">
                                              <f:facet name="header">Puan</f:facet>
                                              <h:outputText value="#{_regNote.note}" />
                                      </rich:column>
      
                                      <rich:column sortable="false" label="Ortalama">
                                              <f:facet name="header">Ortalama</f:facet>
                                              <h:outputText value="#{_regNote.average==0?'':_regNote.average}" />
                                      </rich:column>
      
      
                                      <rich:column sortable="false" label="Düzenle">
                                              <a4j:commandButton value="Düzenle"
                                                      action="#{registryNoteList.assignSelected}" ajaxSingle="true"
                                                      bypassUpdates="false" reRender="panelRegistryNote">
                                                      <rich:componentControl for="RegistryNotePanel" operation="show" event="onclick" />
                                                      <s:conversationId />
                                              </a4j:commandButton>
                                      </rich:column>
      
                              </rich:extendedDataTable>
                      </a4j:outputPanel>
                      
                      <div id="MainContainer">
                      <div id="LeftContainer"></div>
                      <div id="CenterContainer"><a4j:commandButton value="Yeni"
                              action="#{registryNoteList.initHome}" reRender="panelRegistryNote"
                              image="/img/buttons/new.png" ajaxSingle="true">
                              <rich:componentControl event="onclick" for="RegistryNotePanel"
                                      operation="show" />
                              <s:conversationId />
                      </a4j:commandButton> <a4j:commandButton value="Sil" image="/img/buttons/delete.png"
                              onclick="if(!confirm('Seçtiğiniz öğeler silinecektir. Bu işlemi yapmak istediğinize emin misiniz?'))return false;"
                              action="#{registryNoteList.deleteSelected}"
                              reRender="tblRegistryNote" process="checkBoxColumn">
                              <s:conversationId />
                      </a4j:commandButton></div>
                      <div id="RightContainer"></div>
                      <br clear="both" />
                      </div>
      
              </rich:panel>
      
              <rich:modalPanel id="RegistryNotePanel" autosized="true">
                      <a4j:support event="onhide" reRender="tblRegistryNote"
                              action="#{registryNoteList.initializeDataModel}" bypassUpdates="true"
                              ajaxSingle="true" />
                      <!-- <a4j:support event="onshow" reRender="panelRegistryNote"
                              ajaxSingle="true" /> -->
                      <f:facet name="header">
                              <h:panelGroup>
                                      <h:outputText value="Sicil Notu Düzenleme Ekranı:" />
                              </h:panelGroup>
                      </f:facet>
                      <f:facet name="controls">
                              <h:panelGroup>
                                      <h:graphicImage value="img/cancel.png" styleClass="hidelink"
                                              id="hidelink_RegistryNote" />
                                      <rich:componentControl for="RegistryNotePanel"
                                              attachTo="hidelink_RegistryNote" operation="hide" event="onclick" />
                              </h:panelGroup>
                      </f:facet>
                      <ui:include src="/UC/employee/RegistryNote.xhtml" />
              </rich:modalPanel>
      </f:view>
      
      



      /UC/employee/RegistryNote.xhtml



      <f:view xmlns="http://www.w3.org/1999/xhtml"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:richfaces="http://richfaces.ajax4jsf.org/rich"
              xmlns:ajax="https://ajax4jsf.dev.java.net/ajax"
              xmlns:a4j="http://richfaces.org/a4j"
              xmlns:s="http://jboss.com/products/seam/taglib"
              xmlns:rich="http://richfaces.org/rich">
              <a4j:region>
                      <rich:panel id="panelRegistryNote">
                              <a4j:outputPanel ajaxRendered="true">
                                      <h:panelGrid columns="2" style="cell-padding:0px;cell-spacing:0px;"
                                              rowClasses="oddRow,evenRow">
                                              <h:outputLabel value="Yıl" for="insYear" />
                                              <h:inputText value="#{registryNoteHome.instance.year}" />
                                              <h:outputLabel value="Not" for="insScore" />
                                              <h:inputText value="#{registryNoteHome.instance.note}" />
                                      </h:panelGrid>
                              </a4j:outputPanel>
                              <a4j:commandButton action="#{registryNoteHome.persist}"
                                      value="Kaydet" rendered="#{!registryNoteHome.managed}"
                                      oncomplete="Richfaces.hideModalPanel('RegistryNotePanel');">
                                      <s:conversationId />
                              </a4j:commandButton>
                              <a4j:commandButton action="#{registryNoteHome.update}"
                                      value="Güncelle" rendered="#{registryNoteHome.managed}">
                                      <s:conversationId />
                                      <rich:componentControl for="RegistryNotePanel" operation="hide"
                                              event="onclick" />
                              </a4j:commandButton>
                      </rich:panel>
              </a4j:region>
      </f:view>