0

I have one vf page where in I am bringing value from controller and displaying on vf page using <apex:outputText>.But it is displaying nothing on the page.I have checked even the debug in that method and it is displaying over there. I have even gone through this post but still I am facing the issue

<apex:page sidebar="false" showHeader="false" controller="PolicyHolderDetails">
<script>
 function GetValues(){
 var Nominee=document.getElementById('input-id4').value;
 var PaymentMode=document.getElementById('input-id5').value;
 var PaymentOptions=document.getElementById('input-id6').value; 
 var PolicyCoverage=document.getElementById('input-id7').value; 
 var EnrollmentDate=document.getElementById('input-id8').value; 
 var Tenure=document.getElementById('input-id9').value; 
   PassValues(Nominee,PaymentMode,PaymentOptions,PolicyCoverage,Tenure);
   alert('Details submitted successfully');
 }

</script>
 <apex:slds />
  <apex:form >
 <center> <h1 style="font-size: 20px;">Registration Form</h1></center>
 <div class="slds-form-element slds-text-title_caps" >
  <label class="slds-form-element__label " for="input-unique-id1">Policy</label>
  <div class="slds-form-element__control " id="div1" style="width: 250px;">
    <apex:outputText id="output-id1" value="{!Insurance}" rendered="true"/><br/><br/>
  </div>
  <label class="slds-form-element__label" for="input-unique-id2">Policy Holder</label>
  <div class="slds-form-element__control" style="width: 200px;">
    <apex:outputText id="output-id2" value="{!Name}" rendered="true"/><br/><br/>
  </div>
   <label class="slds-form-element__label" for="input-unique-id3">Initial Premium</label>
  <div class="slds-form-element__control" style="width: 200px;">
    <apex:outputText value="{!InitialPremium}" style="slds-output" id="ouput-id3"><br/><br/>

      </apex:outputText>
  </div>
   <label class="slds-form-element__label" for="input-unique-id4">Nominee</label>
  <div class="slds-form-element__control" style="width: 200px;">
    <input type="text" id="input-id4" class="slds-input" /><br/><br/>
  </div>
 <label class="slds-form-element__label" for="input-unique-id5">Payment Mode</label>
  <div class="slds-form-element__control" style="width: 200px;">
 <select name="mode" id="input-id5">
  <option value="--NONE--">--NONE--</option>
  <option value="Net Banking">Net Banking</option>
  <option value="Cheque">Cheque</option>
  <option value="Demand Draft">Demand Draft</option>
  </select> <br/><br/>
    </div>
     <label class="slds-form-element__label" for="input-unique-id6">Payment Options</label>
  <div class="slds-form-element__control" style="width: 200px;">
 <select name="options" id="input-id6">
  <option value="--NONE--">--NONE--</option>
  <option value="One Time">One Time</option>
  <option value="Monthly">Monthly</option>
  <option value="Quarterly">Quarterly</option>
    <option value="Half yearly">Half yearly</option>
    <option value="Yearly">Yearly</option>
  </select> <br/><br/> 
    </div>
    <label class="slds-form-element__label" for="input-unique-id7">Policy Coverage</label>
  <div class="slds-form-element__control" style="width: 200px;">
 <select name="options" id="input-id7">
  <option value="--NONE--">--NONE--</option>
  <option value="Individual">Individual</option>
  <option value="Individual and Spouse">Individual and Spouse</option>
  <option value="Individual + Spouse + 1Child">Individual + Spouse + 1Child</option>
  </select>  <br/><br/>
    </div>
    <label class="slds-form-element__label" for="input-unique-id8">Enrollment Date</label>
  <div class="slds-form-element__control" style="width: 200px;">
  <input type="Date" id="input-id8" class="slds-input"/><br/><br/>
  </div>
    <label class="slds-form-element__label" for="input-unique-id9">Tenure</label>
  <div class="slds-form-element__control" style="width: 200px;">
 <select name="tenure" id="input-id9">
  <option value="--NONE--">--NONE--</option>
  <option value="One Year">One Year</option>
  <option value="Two Years">Two Years</option>
  <option value="Three Years">Three Years</option>
  <option value="Four Years">Four Years</option>
  <option value="Five Years">Five Years</option>
  <option value="Seven Years">Seven Years</option>
  <option value="Nine Years">Nine Years</option>
  <option value="Ten Years">Ten Years</option>
    </select>    
    </div>
  <center><button class="slds-button slds-button_brand" id="btn" Onclick="GetValues()">Submit</button></center>
  </div>
  <apex:actionFunction name="PassValues" action="{!SaveAgreement}" rerender="none">
  <apex:param name="param4" value="" assignTo="{!Nominee}" />
  <apex:param name="param5" value="" assignTo="{!PaymentMode}"/>
  <apex:param name="param6" value="" assignTo="{!PaymentOptions}"/>
  <apex:param name="param7" value="" assignTo="{!PolicyCoverage}"/>
 <!-- <apex:param name="param8" value="" assignTo="{!EnrollmentDate}"/>-->
  <apex:param name="param9" value="" assignTo="{!Tenure}"/>
  </apex:actionFunction>
 </apex:form>
  </apex:page>

Public Class PolicyHolderDetails {
    Public String Name{get;set;}
    Public String PhoneNo{get;set;}
    Public string Website{get;set;}
    Public string Street{get;set;}
    Public string City{get;set;}
    Public string State{get;set;}
    Public String Zipcode{get;set;}
    Public string Fax{get;set;}
    Public String Industry{get;set;}

    Public String Insurance1{get;set;}
    Public String Insurance2{get;set;}
    Public String Insurance3{get;set;}
    Public String Insurance4{get;set;}

    Public String Insurance{get;set;}

    Public String Nominee{get;set;}
    Public  String PaymentMode{get;set;}
    Public  String PaymentOptions{get;set;}
    Public  String PolicyCoverage{get;set;}
    Public  String Tenure{get;set;}
    Public  decimal InitialPremium{get;set;}

    Public  ID PolicyHolderid{get;set;}
    Public  ID PolicyId{get;set;}

    Public PageReference CheckInsurance(){
        //Insurance=Apexpages.currentPage().getParameters().get('Param1');
        system.debug(Insurance);
        if(Insurance!=null && Insurance=='Health Insurance'){
            system.debug('HIHIH:::::::'+Insurance);
            Policy__c Pid=[select id,Initial_Premium__c from policy__c where Policy_Name__c='Health Insurance'][0];
            PolicyId=Pid.id;
            InitialPremium=Pid.Initial_Premium__c;
            system.debug('PolicyId='+PolicyId +InitialPremium);
        }
        if(Insurance!=null && Insurance=='Home Insurance'){
            system.debug('HIHIH:::::::'+Insurance);
            system.debug(Insurance);
            policy__c Pid=[select id,Initial_Premium__c from policy__c where Policy_Name__c='Home Insurance'][0];
            PolicyId=Pid.id;
            InitialPremium=Pid.Initial_Premium__c;
            system.debug('PolicyId='+PolicyId);
        }
        if(Insurance!=null && Insurance=='Life Insurance'){
            system.debug('HIHIH:::::::'+Insurance);
            policy__c Pid=[select id,Initial_Premium__c from policy__c where Policy_Name__c='Life Insurance'][0];
            PolicyId=Pid.id;
            InitialPremium=Pid.Initial_Premium__c;
            system.debug('PolicyId='+PolicyId);
        }
        if(Insurance!=null && Insurance=='Automobile Insurance'){
            system.debug('HIHIH:::::::'+Insurance);
            policy__c Pid=[select id,Initial_Premium__c from policy__c where Policy_Name__c='Automobile Insurance'][0];
            PolicyId=Pid.id;
            InitialPremium=Pid.Initial_Premium__c;
            system.debug('PolicyId='+PolicyId);
        }
          PageReference pgref=new PageReference('apex/AgreementRegistrationPage');
        pgref.setRedirect(true);
        return null;

    }
}
| improve this question | | | | |
  • you are redirecting to another page in the constructor? – AslamK Aug 23 '17 at 12:23
  • //Insurance=Apexpages.currentPage().getParameters().get('Param1'); this line is commented so Insurance will be none. Uncomment and test. and where are you calling CheckInsurance() – Tushar Sharma Aug 23 '17 at 12:39
0

In above code you are populating "InitialPremium" value in CheckInsurance() method but on page there is no reference of this method.

So if you want to populate InitialPremium on pageload then use getter method in class with run on page load. OR use ReRender if you want to populate after a button click.

| improve this answer | | | | |
0

You are not setting values for insurance, name properties except InitialPremium at controller Side. As you are setting the value to InitialPremium in CheckInsurance method, but this method is not called anywhere from Vf page, so as the method does not get called, all values will be null that's why the output text is not displaying anything.

Just to test assign any values to insurance, name & InitialPremium in constructor & then check values are coming or not.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.