You need to sign in to do that
Don't have an account?

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
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
Yes i've added pageMessages,,