9 Replies Latest reply on Sep 14, 2009 9:26 PM by sadasd asdsad

    problem when trying to save data with a4j:commandButton

    sadasd asdsad Newbie

      hi i got a main page ==>

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xml:lang="en" lang="en">
      
      <body>
      
      <ui:composition template="../../index.xhtml">
      
      
       <ui:define name="content">
       <script type="text/javascript">
       function popUpPage() {
       jQuery("#dialog").dialog({
       autoOpen: true,
       title: 'Basic Dialog'
      
       });
       jQuery('#content\\:showTP\\:test').click(function() {
       jQuery("#dialog").dialog('open');
       });
      
      
      
       }
      </script>
      
       <h:form id="showTP">
       <rich:dataTable align="center" id="tarifGroup" value="#{showTariffGroupView.tariffGroupList}" var="tariffGroup" rows="10">
       <rich:column>
       <f:facet name="header">
       <f:verbatim>Tariff Group Name</f:verbatim>
       </f:facet>
       <h:outputText value="#{tariffGroup.tariffgroupname}" />
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <f:verbatim>Creation Date</f:verbatim>
       </f:facet>
       <h:outputText value="#{tariffGroup.creationdate}" />
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <f:verbatim>Lcr Type</f:verbatim>
       </f:facet>
       <h:outputText value="#{tariffGroup.lcrtype}" />
       </rich:column>
      
       </rich:dataTable>
      
       <a4j:commandButton id="test" value="test*****" onclick="popUpPage();" >
       <f:setPropertyActionListener value="Add" target="#{showTariffGroupView.action}" />
       </a4j:commandButton>
      
       <div id="dialog" style="display:none;" >
       <a4j:include viewId="addTP.jsp"></a4j:include>
       </div>
       <rich:datascroller align="left" for="tarifGroup" maxPages="20"/>
      </h:form>
      
      <rich:modalPanel top="50" id="editUserConf" autosized="true" width="450" >
      
       <f:facet name="header">
       <h:panelGroup>
       <h:outputText value="Modal Panel"></h:outputText>
       </h:panelGroup>
       </f:facet>
      
       <f:facet name="controls">
       <h:panelGroup>
       <h:graphicImage value="/images/delete.gif" styleClass="hidelink" id="hidelink"/>
       <rich:componentControl for="editUserConf" attachTo="hidelink" operation="hide" event="onclick"/>
       </h:panelGroup>
       </f:facet>
      
       <a4j:include viewId="addTP.jsp">
       </a4j:include>
      
       </rich:modalPanel>
      
       </ui:define>
      
      
       </ui:composition>
       </body>
       </html>
      



      which contain ass yu can see a <ui:include> addTP.jsp , which i popup using jquery

      here is my addTP.jsp


      <div xmlns="http://www.w3.org/1999/xhtml"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xml:lang="en" lang="en">
      
       <script type="text/javascript">
       function ajaxRequestContainsErrors() {
       return document.getElementById("maximumSeverity").value == "2";
       }
       function windowclose(){
       console.log("printed")
       jQuery("#dialog").dialog("close");
       };
       </script>
      
      
      
      <a4j:outputPanel id="tadaaaaaaaa" ajaxRendered="false">
      
       <table id="count">
      
       <tr colspan="3">
       <td>
       <h:messages styleClass="error" id="error_message" layout="table" infoClass="infoMessages" errorClasses="errorMessages" showDetail="true"></h:messages>
       </td>
       </tr>
      
      
       <tr>
       <td>
       <h:outputText value="Tarif Name: "></h:outputText>
       </td>
       <td>
       <h:inputText value="#{showTariffGroupView.currentItem.tariffgroupname}">
       <rich:beanValidator summary="Invalid name" />
       </h:inputText>
      
       </td>
      
       </tr>
      
       <tr>
       <td>
       <h:outputText value="LC TYPE: "></h:outputText>
       </td>
       <td>
       <h:selectOneMenu id="lcrtype" style="width:100%" value="#{showTariffGroupView.currentItem.lcrtype}" >
       <f:selectItem itemValue="**"/>
       <f:selectItem itemLabel="LCD: seller price" itemValue="0"/>
       <f:selectItem itemLabel="LCR: buyer price" itemValue="1"/>
      
       <!-- <f:selectItems value="#{showTariffGroupView.lcrList}"></f:selectItems> -->
       </h:selectOneMenu>
       </td>
       </tr>
      
       <tr>
       <td>
       <h:outputText value="Package: "></h:outputText>
       </td>
       <td>
       <h:selectOneMenu id="noPackage" style="width:100%" value="#{showTariffGroupView.currentItem.idPackageOffer}" >
      
       <f:selectItem itemValue="**"/>
      
       <f:selectItems id="pkGroupeLst" value="#{showTariffGroupView.packageGrou}"></f:selectItems>
       </h:selectOneMenu>
       </td>
       </tr>
      
       <tr>
       <td>
       <h:outputText value="Interprefix "></h:outputText>
       </td>
       <td>
       <h:selectOneRadio id="interprefix" value="#{showTariffGroupView.currentItem.removeinterprefix}">
       <f:selectItem id="item1" itemLabel="remove Prefix" itemValue="0" />
       <f:selectItem id="item2" itemLabel="Keep Prefix" itemValue="1" />
      
      
       </h:selectOneRadio>
      
       </td>
       </tr>
      
      
       </table>
      
      
       <table align="center">
       <tr>
       <td>
      
       <a4j:commandButton action="#{showTariffGroupControl.saveRow}" oncomplete="windowclose();" value="Save" reRender="tarifGroup">
      
       </a4j:commandButton>
      
       </td>
       <td>
       <a4j:commandButton onclick="windowclose();" value="Cancel" reRender="tarifGroup"></a4j:commandButton>
       </td>
       </tr>
       </table>
      
      </a4j:outputPanel>
      
      
       </div>
      
      


      the problem when i press the button save in the popued window , the backed bean receive null from the jsp ; here is my saveRow function:

      public void saveRow(){
       AddRow();
       System.out.println("*1*");
       if (view.action.compareTo("Edit") == 0){
       System.out.println("Edit");
       System.out.println("before add");
       foxManager.makePersistent(view.currentItem);
       System.out.println("after add");
      
       }
       else{
       if(view.action.compareTo("Add") == 0){
       System.out.println("Add");
       System.out.println("before add");
       view.currentItem.setIduser(0);
       view.currentItem.setIdPackageOffer(new Long(1));
       //view.currentItem.setLcrtype(1);
       //view.currentItem.setRemoveinterprefix(1);
       //view.currentItem.setTariffgroupname("sdsadd");
      
       System.out.println("debug***"+view.currentItem);
      
       System.out.println("debug"+view.currentItem.getTariffgroupname());
       System.out.println("debug"+view.currentItem.getLcrtype());
       System.out.println("debug"+view.currentItem.getIdPackageOffer());
       System.out.println("debug"+view.currentItem.getRemoveinterprefix());
      
      
       foxManager.makePersistent(view.currentItem);
      
       System.out.println("after add");
      
       }
       else System.out.println("none");
       }
      
      
       }
      
      
      
       public void AddRow(){
       System.out.println("-----AddRow------");
       view.currentItem = new TariffGroup();
       }
      
      



      when i press here is the output of the console :

      -----AddRow------
      *1*
      Add
      before add
      debug***com.foxManager.core.persistence.model.TariffGroup@268d15
      debugnull
      debugnull
      debug1
      debugnull
      


      for my faces-config:

      <managed-bean>
       <managed-bean-name>showTariffGroupControl</managed-bean-name>
       <managed-bean-class>com.foxManager.bean.control.ShowTariffGroupControl</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
       <managed-property>
       <property-name>view</property-name>
       <value>#{showTariffGroupView}</value>
       </managed-property>
       </managed-bean>
       <managed-bean>
       <managed-bean-name>showTariffGroupView</managed-bean-name>
       <managed-bean-class>com.foxManager.bean.view.ShowTariffGroupView</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
       </managed-bean>
      
      


      and thanks a lot