You need to sign in to do that
Don't have an account?
srinivas.pendli
Error/Exception in Visual force page ?
Hi,
In my visual force page i'm getting this error can any know about this
please help me
see below link :
https://success.salesforce.com/questionDetail?qid=a1X30000000fbzxEAA
Thanks
Can you please post the relevant code for page and controller?
VF Page :
<apex:page standardController="Book__c" extensions="ClsBook" showHeader="true">
<apex:form >
<apex:pageBlock title="Enter Information">
<apex:pageBlockSection title="Details for BOok One"></apex:pageBlockSection>
<apex:PageblockSection columns="2" >
<apex:inputField value="{!Book__c.Name}"/>
<apex:inputField value="{!Book__c.author__c}" id="au" />
<apex:inputField value="{!Book__c.Start_Date__c}" />
<apex:inputField value="{!Book__c.End_Date__c}" />
<apex:inputField value="{!Book__c.Test_Name__c}"/>
<apex:inputField value="{!Book__c.Approved_By__c}"/>
<apex:PageBlockSectionItem >
<apex:outputLabel value="Status"/>
<apex:actionRegion >
<apex:inputField value="{!Book__c.Status__c}">
<apex:actionSupport event="onchange" reRender="ajaxrequest" />
</apex:inputField>
</apex:actionRegion>
</apex:PageBlockSectionItem>
</apex:PageblockSection>
<apex:outputPanel id="ajaxrequest">
<apex:pageBlockSection rendered="{!Book__c.Status__c=='Pending'}" >
<apex:inputField value="{!Book__c.Edition__c}"/>
</apex:pageBlockSection>
</apex:outputPanel>
<apex:pageBlockSection >
<apex:PageBlockSectionItem >
<apex:outputLabel value="Type"/>
<apex:actionRegion >
<apex:inputField value="{!Book__c.Type__c}">
<apex:actionSupport event="onchange" reRender="ajaxrequest1" />
</apex:inputField>
</apex:actionRegion>
</apex:PageBlockSectionItem>
</apex:PageblockSection>
<apex:outputPanel id="ajaxrequest1">
<apex:pageBlockSection rendered="{!Book__c.Type__c=='Type One'}" >
<apex:inputField value="{!Book__c.obj_3_Name__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{!Book__c.Type__c=='Type Two'}" >
<apex:inputField value="{!Book__c.obj_1__c}"/>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
<apex:variable var="rowNum" value="{!0}" />
<apex:pageBlock id="membAdd" >
<apex:variable var="rowNum" value="{!0}" />
<apex:pageblockSection / >
<apex:pageBlockTable value="{!accts}" var="a" id="table" columns="5">
<apex:facet name="footer">
<apex:commandLink value="Add New Record" action="{!addRow}" reRender="membAdd"/>
</apex:facet>
<apex:column headerValue="No." style="width:20px; text-align:center;" headerClass="centertext">
<apex:outputText value="{0,number, ###}" style="text-align:center;">
<apex:param value="{!rowNum+1}" />
</apex:outputText>
</apex:column>
<apex:column headerValue="Example Name">
<apex:inputField value="{!a.Example__c}" >
<apex:actionSupport event="onchange" action="{!MyMethod}" reRender="membAdd"/>
</apex:inputField>
</apex:column>
<apex:column headerValue="Number">
<apex:inputField value="{!a.Number__c}" >
</apex:inputField>
</apex:column>
<apex:column headerValue="B2 Name">
<apex:inputField value="{!a.B2_Name__c}" >
</apex:inputField>
</apex:column>
<apex:column headerValue="Remove Record">
<apex:commandLink value="Remove Record" action="{!removerow}" reRender="membAdd,temp" rendered="{!rowNum>=0}">
<apex:param value="{!rowNum}" name="index" />
</apex:commandLink>
<apex:variable var="rowNum" value="{!rowNum+1}"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}" immediate="true"/>
<apex:commandButton value="Click to Save" action="{!Save1}" rendered="true"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
------------------------
Controller :
public with sharing class ClsBook {
public Book__c record;
public Test__c test1 = new Test__c();
//list<Book2__c> record1 = new list<Book2__c>();
list<Book2__c> record1 {get; set;}
//public integer count{get;set{count=1;}}
public Boolean checked {get;set;}
public Integer rowNum{get;set;}
public List<Book2__c> accts {get; set;}
//public integer counter=1;
//public static integer i=0;
public list<Example__c> exa {get;set;}
public ClsBook(ApexPages.StandardController controller) {
this.record = (Book__c)controller.getRecord();
//Auto populating values.......
record.Test_Name__c= ApexPages.currentPage().getParameters().get('oppId');
record.author__c='JAPAN/USA';
record.Name=record.Test_Name__r.Test_1__c;
record.Start_Date__c=DateTime.Now().Date();
record.End_Date__c=DateTime.Now().Date().AddMonths(10);
//if(record.Type__c=='Type One'){
//record.obj_3_Name__c= ApexPages.currentPage().getParameters().get('oppId');
//record.obj_3_Name__c=record.Test_Name__c;
//}
//accts.add(new Book2__c(Book__c = record.id));
accts = new List<Book2__c>();
Book2__c LitOrd = new Book2__c();
LitOrd.Book__c = record.id;
accts.add(LitOrd);
}
public void addrow(){
Book2__c LitOrd = new Book2__c();
LitOrd.Book__c = record.id;
accts.add(LitOrd);
//count++;
}
public void removerow(){
rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
accts.remove(rowNum);
//Integer i = accts.size();
//if(checked==true){
//accts.remove(i-1);
//}
}
public PageReference Save1(){
//PageReference pr=new PageReference('/'+record.id);
//Book__c rec = [SELECT id,Name FROM Book__c ORDER BY CreatedDate DESC limit 1];
//test1 = [select id,name from Test__c where id=:ApexPages.currentPage().getParameters().get('oppId')];
try{
//record.Test_Name__c=test1.id;
insert record;
Book__c rec = [SELECT id,Name FROM Book__c ORDER BY CreatedDate DESC limit 1];
//if(rec.Name=='Srinivas'){
for(Integer x=0;x<accts.size();x++){
accts[x].Book__c=rec.id;
//accts[x].Number__c=exa.IND_INR__c;
insert accts[x];
}
}
catch(exception e){
ApexPages.addMessages(e);
}
PageReference parrec = new PageReference('/'+record.id);
parrec.setRedirect(true);
return parrec;
}
public PageReference save(){
try{
insert record;
//record1.Number__c = record.Number1__c;
//record1.Name = record.Number1__c;
//record1.obj_1__c= record.obj_1__c;
//record1.Book__c=record.id;
insert record1;
}
catch(Exception e){
ApexPages.addMessages(e);
}
PageReference pageref= new PageReference('/'+record.id);
pageref.setRedirect(true);
return pageref;
}
private void setupEmp()
{
for(Integer i=0;i<accts.size();i++){
exa = [select id, Name,IND_INR__c,Ex_Name__c from Example__c where id=:accts[i].Example__c limit 1];
for(Example__c e : exa){
accts[i].Number__c= e.IND_INR__c;
accts[i].B2_Name__c= e.Ex_Name__c;
}
}}
public PageReference MyMethod(){
setupEmp();
//i++;
return null;
}
}