0 Replies Latest reply on Jul 20, 2011 12:01 PM by yasser zairi

    activate a Modalpanel with commandbutton

    yasser zairi Newbie

      Hi,

      i want to activate a modalPanel from a Commandbutton but it seem that is sth wrong .

      _______________________________________________________________________________________

      here is the code of the ModalPanel with the commandbutton ::

       

      <a4j:commandButton value="Modifier" ajaxSingle="true" id="editlink"

                      oncomplete="#{rich:component('editPanel')}.show()" action="#{valeursMBean.viewDetail}" />

       

              <rich:modalPanel id="editPanel" autosized="true" width="450">

                  <f:facet name="header">

                      <h:outputText value="Modifier la valeur mobiliere actuelle :" />

                  </f:facet>

                  <f:facet name="controls">

                      <h:panelGroup>

                          <h:graphicImage value="../style/close.jpeg" id="hidelink"

                              styleClass="hidelink" />

                          <rich:componentControl for="editPanel" attachTo="hidelink"

                              operation="hide" event="onclick" />

                      </h:panelGroup>

                  </f:facet>

                  <h:form>

                      <rich:messages style="color:red;"></rich:messages>

                      <h:panelGrid columns="1">

                          <a4j:outputPanel ajaxRendered="true">

                              <h:panelGrid columns="2">

                                  <h:outputLabel value="CodeIsin" for="codeIsin" />

                                  <h:inputText id="codeIsin"

                                      value="#{valeursMBean.currentItem.codeIsin}" />

                                  <h:outputLabel value="Categorie" for="categorie" />

                                  <h:inputText id="categorie"

                                      value="#{valeursMBean.currentItem.categorie}" />

                                  <h:outputLabel value="Denomination" for="denomination" />

                                  <h:inputText id="denomination"

                                      value="#{valeursMBean.currentItem.denomination}" />

                                  <h:outputLabel value="Date Echeance" for="dateEcheance" />

                                  <h:inputText id="dateEcheance"

                                      value="#{valeursMBean.currentItem.dateEcheance}" />

                                  <h:outputLabel value="Etat" for="etat" />

                                  <h:inputText id="etat" value="#{valeursMBean.currentItem.etat}"/>

                              </h:panelGrid>

                              <rich:message showSummary="true" showDetail="false" for="etat" />

                          </a4j:outputPanel>

                          <a4j:commandButton value="Enregistrer"

                              action="#{valeursMBean.update}"

                              reRender="codeIsin, categorie, etat, denomination, dateEcheance"

                              oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();" />

                      </h:panelGrid>

                  </h:form>

              </rich:modalPanel>

      _______________________________________________________________________________________________

      and here is my Bean ::

       

      package cdvm.surv.web;

       

      import java.io.Serializable;

      import java.util.Iterator;

      import java.util.List;

       

      import javax.annotation.PostConstruct;

       

       

      import org.richfaces.component.html.HtmlScrollableDataTable;

      import org.richfaces.model.ScrollableTableDataModel.SimpleRowKey;

      import org.richfaces.model.selection.Selection;

      import org.springframework.beans.factory.annotation.Autowired;

      import org.springframework.context.annotation.Scope;

      import org.springframework.stereotype.Component;

       

       

      import cdvm.surv.model.ValeurRef;

      import cdvm.surv.service.ValeurRefService;

       

      @Component("valeursMBean")

      @Scope("session")

      public class ValeursMBean implements Serializable {

       

          @Autowired

          private transient ValeurRefService valeurefService;

          private transient HtmlScrollableDataTable valeurTable;

       

       

          private List<ValeurRef> valeurefList;

          private ValeurRef currentItem;

       

       

          @PostConstruct

          public void init(){

              valeurefList = valeurefService.find();

          }

       

          public String update(){

              valeurefService.save(currentItem);

              init();

       

              return null;

          }

       

          public void viewDetail(){

              List<ValeurRef> valueList=(List<ValeurRef>) valeurTable.getValue();

              Selection sl = valeurTable.getSelection();

              Iterator<Object> keys= sl.getKeys();

       

              if(keys.hasNext()){

                  //SimpleRowKey ky = (SimpleRowKey)keys.next();

                  currentItem=valueList.get((Integer)keys.next());

                  System.out.println(currentItem.getCodeIsin());

              }

       

       

          }

       

          // Getter and Setter

       

          public ValeurRef getCurrentItem() {

              return currentItem;

          }

       

          public void setCurrentItem(ValeurRef currentItem) {

              this.currentItem = currentItem;

          }

          public HtmlScrollableDataTable getValeurTable() {

              return valeurTable;

          }

          public void setValeurTable(HtmlScrollableDataTable valeurTable) {

              this.valeurTable = valeurTable;

          }

          public List<ValeurRef> getValeurefList() {

              return valeurefList;

          }

          public void setValeurefList(List<ValeurRef> valeurefList) {

              this.valeurefList = valeurefList;

          }

       

      }

      ________________________________________________________________________________

      the error that i get is ::

       

      cause mère

      javax.faces.FacesException: #{valeursMBean.viewDetail}: java.lang.NullPointerException
           com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:107)
           javax.faces.component.UICommand.broadcast(UICommand.java:383)
           org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
           org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
           org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
           org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
           org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474)
           com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
           com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
           com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

      cause mère

      javax.faces.el.EvaluationException: java.lang.NullPointerException
           javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
           com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
           javax.faces.component.UICommand.broadcast(UICommand.java:383)
           org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
           org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
           org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
           org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
           org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474)
           com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
           com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
           com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

      cause mère

      java.lang.NullPointerException
           cdvm.surv.web.ValeursMBean.viewDetail(ValeursMBean.java:49)
           sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
           sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
           java.lang.reflect.Method.invoke(Method.java:616)
           org.apache.el.parser.AstValue.invoke(AstValue.java:191)
           org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
           com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
           javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:71)
           com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
           javax.faces.component.UICommand.broadcast(UICommand.java:383)
           org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
           org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
           org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
           org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
           org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474)
           com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
           com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
           com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
           javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
           org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
           org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
           org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
           org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

       

       

      i'll be thankful for any suggestions

       

      thanks in advance