1 2 Previous Next 18 Replies Latest reply: Jan 24, 2013 6:08 AM by HeretoHelp:Prem RSS

    Issue on commitng the data

    user5425941
      Hi friends,

      i have an urgent issue -

      1) in my page i have field called rebate , added the PPR for rebate and doing validation in controller that user should not enter more than 100 in rebate field,
      2) in apply button am doing commit.


      The issue is Suppose user enters 101 in rebate field and tab out , then it is showing exception ..,that is ok.  this time when i press the apply button still my data is saving into database, means it should be stop the data to save when i press the apply if the the page having any exception.

      Thanks
        • 1. Re: Issue on commitng the data
          Sushant Sharma
          Hi,

          Can you share your code?
          Also, is this field 'rebate' inside a table region having multiple rows ?

          --Sushant                                                                                                                                                                                                                                               
          • 2. Re: Issue on commitng the data
            user5425941
            Hi Sushanth,

            this field is not in advtable region, this is only single field.

            if("Advrebate".equals(pageContext.getParameter(EVENT_PARAM)))
            {
            String advertisingrebate=pageContext.getParameter("Rebate");

            if(null!=advertisingrebate)
            {
            int iadvertisingrebate=Integer.parseInt(advertisingrebate);

            if(iadvertisingrebate<=0||iadvertisingrebate>=100)

            {

            throw new OAException("rebate should not be more than 100",OAException.ERROR);

            }
            }
            }


            if(pageContext.getParameter("Save")!=null)
            {


            am.getOADBTransaction().commit();
            throw new OAException("Customer Rebate has been created",OAException.CONFIRMATION);
            }

            Thanks
            • 3. Re: Issue on commitng the data
              Sushant Sharma
              Hi,

              Try using this:

              if("Advrebate".equals(pageContext.getParameter(EVENT_PARAM))) {
              String advertisingrebate=pageContext.getParameter("Rebate");

              if(!("".equals(advertisingrebate.trim()))) {
              int iadvertisingrebate=Integer.parseInt(advertisingrebate);

              if(iadvertisingrebate<=0||iadvertisingrebate>=100)
              {

              throw new OAException("rebate should not be more than 100",OAException.ERROR);
              }
              }
              }
              if(pageContext.getParameter("Save")!=null)
              {
              am.getOADBTransaction().commit();
              throw new OAException("Customer Rebate has been created",OAException.CONFIRMATION);
              }

              --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
              • 4. Re: Issue on commitng the data
                user5425941
                Hi Sushanth,

                the validation is working fine for rebate, it is showing as expected error.

                only my problem is below

                testcase:

                Suppose user enters 101 in rebate field and tab out , then it is showing exception ..,that is ok. this point of time when i press the apply button still my data is saving into database, means it should be stop the data to save when i press the apply if the the page having any exception, but it is not stoping.

                Thanks
                • 5. Re: Issue on commitng the data
                  Sushant Sharma
                  Hi,

                  It will save the data as there is no validation on apply button. You should add this validation on click on 'apply' button then it will not save the data.

                  --Sushant                                                                                                                                                                                                                                                                                                                                                           
                  • 6. Re: Issue on commitng the data
                    Reetesh Sharma
                    There will be a method like setRebate in your EO or VO write your validation there and it will work fine for all the scenarios.

                    Remove code from your controller and don't write any code for this validation in controller.

                    Regards,
                    Reetesh Sharma
                    • 7. Re: Issue on commitng the data
                      user5425941
                      Thanks sushanth

                      this validation user wanted, it should be on tab event means ppr..how to handle this, means it should not be in apply button
                      • 8. Re: Issue on commitng the data
                        924022
                        Hi,
                        You can use flag variable for your requirement. I hope thiis might give desired output.

                        int flag = 0;
                        if(iadvertisingrebate<=0||iadvertisingrebate>=100)
                        {
                        flag = 1;
                        throw new OAException("rebate should not be more than 100",OAException.ERROR);
                        }

                        if(pageContext.getParameter("Save")!=null)
                        {
                        if (flag ==0){
                        am.getOADBTransaction().commit();
                        throw new OAException("Customer Rebate has been created",OAException.CONFIRMATION);

                        }
                        else if(flag == 1)
                        {
                        throw new OAException("rebate should not be more than 100",OAException.ERROR);
                        }
                        }
                        • 9. Re: Issue on commitng the data
                          user5425941
                          Hi Niranjan,

                          thanks for the help, but am trying EO level, could not able to achieve with below code am getting exception.

                          public void setRebate(Number value)
                          {

                          if ((value != null) || (!("".equals(value))))
                          {
                          Number fdeduct = getRebate();

                          if(fdeduct.intValue()<0||fdeduct.intValue()>100)
                          {
                          throw new OAException("please select valid value",OAException.ERROR);
                          }
                          }
                          setAttributeInternal(REBATE, value);
                          }
                          am getting below exception

                          Rebate% - Set method for attribute \"Rebate\" in HccCusRebateAM.HccCustomerCreateRebateVO1 could not be resolved
                          • 10. Re: Issue on commitng the data
                            AjithGOracle
                            Hi,

                            Instead of having the statement, "Number fdeduct = getRebate();", can you try doing the validation with the parameter variable "value", which should have the data that the user has entered?

                            -Ajith
                            • 11. Re: Issue on commitng the data
                              924022
                              One observation from my side:

                              Number fdeduct = getRebate();

                              I hope you have to use :

                              Number fdeduct = value;

                              you are doing null check for value field and doing calculations in getRebate(). It might not be the issue. But try with using value instead of getRebate();

                              From this EO code , everything else looks fine. Once the error is thrown, it should not allow any action to happen in the page. Try this and let me know.

                              --
                              niranj
                              • 12. Re: Issue on commitng the data
                                user5425941
                                Hi Niranjan/Ajith,

                                i have done this below code.. this time error is coming when i tab out, that is ok, but value is clearing from the field.same time when i press the save it is saving the records. this should not be happend..

                                public void setRebate(Number value)
                                {

                                if ((value != null) || (!("".equals(value))))
                                {

                                if(value.intValue()<0||value.intValue()>100)
                                {
                                throw new OAException("please select valid value",OAException.ERROR);
                                }
                                }
                                setAttributeInternal(REBATE, value);
                                }

                                IN APPLY BUTTON

                                if(pageContext.getParameter("Apply")!=null)
                                {

                                am.getOADBTransaction().commit();
                                throw new OAException("Rebates has been created successfully",OAException.CONFIRMATION);

                                }


                                please modify the code where am doing misatke.
                                Thanks

                                Edited by: user5425941 on Jan 23, 2013 11:47 PM
                                • 13. Re: Issue on commitng the data
                                  Sushant Sharma
                                  Hi,

                                  As suggested by Reetesh, you should write the validation code inside EOImpl.java.

                                  --Sushant                                                                                                                                                                                                           
                                  • 14. Re: Issue on commitng the data
                                    user5425941
                                    Hi Sushanth,

                                    i have write the code in inside EOIMPLE Set method.. like below

                                    public void setRebate(Number value)
                                    {

                                    if ((value != null) || (!("".equals(value))))
                                    {

                                    if(value.intValue()<0||value.intValue()>100)
                                    {
                                    throw new OAException("please select valid value",OAException.ERROR);
                                    }
                                    }
                                    setAttributeInternal(REBATE, value);
                                    }

                                    and then am using the commit in apply button

                                    if(pageContext.getParameter("Apply")!=null)
                                    {

                                    am.getOADBTransaction().commit();
                                    throw new OAException("Rebates has been created successfully",OAException.CONFIRMATION);

                                    }

                                    please correct me where i am doing wrong..

                                    Thanks
                                    1 2 Previous Next