function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ThathulaThathula 

addError is not working as expected, VF page

Hi All

I've VF page, where we can keep adding PCs records. There is a add another button where we can add another pc, I need to check whether user has fill all required data for previous PC record , before user goes for adding new PC.

What i've done is i've a VF page as below

<apex:variable value="1" var="num"/>
       <apex:repeat value="{!PC_List}" var="pcs" id="thePCList">
       <apex:pageBlockSection id="pcPageBlockSection" title="PC {!num}" columns="1" collapsible="false">
        <apex:variable var="num" value="{!VALUE(num) + 1}"/>
        <apex:inputField value="{!pcs.CPU__c}"/>
        
   
     </apex:pageBlockSection>
    </apex:repeat>

<apex:commandButton reRender="pageBlock1" styleClass="styled-button1" action="{!AddRow}" value="Add Another PC" "/>

Controller class AddRow function as below

public void AddRow()
        {
     
         integer previousPC=PC_List.size()-1;
      
        V_PC__c newPC=new V_PC__c();
 
     
        boolean isErrors=false;
        if(V_cpu__c==''){ // Even i made this always true
      
           ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please enter signatory telephone '));
           isErrors=true;
      
        }
      
        if(!isErrors)
        PC_List.add(newPC);
     
     
     
       }

I render pageBlock1 when addRow is clicked
i FEEL code is ok, but i don't get any error message


Thank a lott
Arunkumar RArunkumar R
Did you added <apex:pageMessages> tag in your visualforce page? 
ThathulaThathula
Thanks for your reply,

Yes i've added pageMessages,,