• pwkay
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi All,

 

I have standardcontroller and used controller extension.I have inputfield rejectionreason and I have a requirement in which user clicks on Reject button I should show alert message to the user to enter the rejection reason before rejecting record.

 

 

On the reject button I am calling the onclick event which calls javascript function.The vf code and controller code is as follows:

 

In the javascript variable I am not able to get the value that the user enetrs in the Rejection reason field.I think because onclick event is getting called before the action event and getter and setter methods are not executed.

 

Could you please let me know how this could be resolved and get the Rejection reason value what user enters  in javascript variable.

 

VF Page code:

 <apex:page  standardController="object1__c" extensions="ApproveorReject" >

<apex:form>

function func()

{

   var a='{!RejectionReason}';

    if(a=='')

    {

                     window.alert("Please enter the Rejection Reason before Rejecting the Invoice");

    }

}

<apex:inputField value="{!object1__c.Rejection_Reason__c}" id="rejectionid"/><br></br>

<apex:commandButton value="Reject"  action="{!reject}" onclick="func()"/>

</apex:form>

</apex:page>

 

 

 

 

 Controller code:

 

 

 

 

public with sharing class ApproveorReject {

public String Rejectionreason;

public final object1__c jc;

public void setRejectionReason()
{
    Rejectionreason=jc.Rejection_Reason__c;
}
   
      
      
              
public String getRejectionReason()
{
   return  Rejectionreason;
}    

 

  public ApproveorReject (ApexPages.StandardController controller)
{

    this.jc = (object1__c)Controller.getRecord();

}

 

public PageReference reject()

{

  //code

}

}