0

I am writing a VF page where my requirement is that I have a input picklist field. When I change the picklist value it is calling to controller method. And when in controller I have written a page message. This message should show in the page. My controller method is working fine and it is also throwing the error when I see ij the Debug log. But page message is not showing on the page. Please look into my code.

 <apex:actionFunction name="PassingParameter1" action="{!PassingParameter}" reRender="test">
                <apex:param value="" name="recordId"/>
            </apex:actionFunction> `<apex:inputField id="check" styleClass="slds-input" style="max-width:325px" value="{!subtaskwrp.subt.Status__c}" >
       <apex:actionSupport event="onchange" reRender="test" oncomplete="doSomething('{!subtaskwrp.subt.Id},{!subtaskwrp.subt.Status__c}');"/> 
  </apex:inputField>

<script>
        function doSomething(test) { 
            PassingParameter1(test);
            // lkfield.value now has the selected ID value
        } 

My controller code is :

public void PassingParameter(){


   String recordstaId = ApexPages.currentPage().getParameters().get('recordId');

   String status = recordstaId.substringAfter(',');

   Id RecordId = recordstaId.substringBefore(','); 

   system.debug('*****'+recordstaId);

   for(Sub_Task__c st : [Select Id, name, Order__c,Priority__c, Due_Date__c,  Status__c,  Assigned_Date__c , Main_Task__c
                                                    from Sub_Task__c
                                                    Where Id =: recordId]){ 


        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Warning,'You can not change Status to Completed. You need to complete the previous Task first.'));

    }
}

The above page message I am not getting on the page. But getting in Debug Log. I tried with pagereference method too.

  • I hope you have included <apex:pageMessages /> within your VF page – Vijay Ganji Aug 30 '19 at 11:43
  • Yes, I have added <apex:pageMessages /> before <apex:form> tag. – RAHUL SRIVASTAVA Aug 30 '19 at 12:15
  • the rerender= needs to include the id of the pageMessage (or the id of a component that wraps pageMessage – cropredy Aug 30 '19 at 19:03

Your Answer

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

Browse other questions tagged or ask your own question.