You need to sign in to do that
Don't have an account?
Wraper class object List Rerendering Multiple times on VF Page
Hello there,
I have a inline edit VF page that is by using Wraper class. When ever i hit the command link Edit, The page block table again ReRendering and finally resulting, The same Page block table Repeats with same records. This is happening when i hit cancel button also.
Any one Please Help me, Thanks in advance
Here is my Snippet,
Page
----------------------------------------------------
<apex:page controller="OppDisplay2" >
<apex:form >
<apex:pageBlock id="pb" > <!--rerender="pb"-->
<apex:outputLabel >Opportunity Details</apex:outputLabel>
<apex:pageBlockTable value="{!Records}" var="o" id="pbt">
<apex:column headervalue="Action">
<apex:commandLink value="Edit" action="{!Edit}" rendered="{!Not(o.ren)}" > <!--rerender="pb"-->
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:commandLink>
<apex:commandlink value="Delete" action="{!Delete1}" rerender="pbt" >
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:commandlink>
<apex:commandLink value="Save" action="{!Save}" rerender="pb" rendered="{!o.ren}"> <!--rerender="pbt"-->
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:commandLink>
<apex:CommandLink value="Cancel" action="{!Cancel}" rerender="pbt" rendered="{!o.ren}" immediate="true">
<apex:param value="{!o.rowindex}" name="rowindex1" assignto="{!rowindex1}"/>
</apex:CommandLink>
</apex:column>
<apex:column headervalue="Opportunity Name">
<apex:outputField value="{!o.opp.name}" rendered="{!Not(o.ren)}"/>
<apex:inputField value="{!o.opp.name}" rendered="{!o.ren}"/>
</apex:column>
<apex:column headervalue="Close Date">
<apex:outputfield value="{!o.opp.CloseDate}" rendered="{!Not(o.ren)}"/>
<apex:inputfield value="{!o.opp.CloseDate}" rendered="{!o.ren}"/>
</apex:column>
<apex:column headervalue="Stage Name">
<apex:outputfield value="{!o.opp.StageName}" rendered="{!Not(o.ren)}"/>
<apex:inputfield value="{!o.opp.StageName}" rendered="{!o.ren}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
--------------------------------------------------------------
/* Controller */
----------------------------------------------------------------
public class OppDisplay2 {
// Param object for selected row index
public integer rowindex1{get;set;}
public Id id1{get;set;}
public List<Opportunity> lstopp = new list<Opportunity>();
public List<Wraper> lstwrap=new List<Wraper>();
wraper wrapobj;
public OppDisplay2()
{
}
public class wraper
{
public Opportunity opp{get;set;}
public integer rowindex{get;set;}
public boolean ren{get;set;}
}
public List<wraper> getRecords()
{
lstopp= [select id,name,CloseDate, StageName from Opportunity limit 6];
for(integer i=0;i<lstopp.size();i++){
wrapobj=new wraper();
wrapobj.opp=lstopp[i];
wrapobj.rowindex=i;
wrapobj.ren=false;
lstwrap.add(wrapobj);
}
return lstwrap;
}
public pagereference Save(){
if(rowindex1<lstwrap.size()){
// Updating List with Specified rowindex value
update lstwrap[rowindex1].opp;
lstwrap[rowindex1].ren=false;
}
return null;
}
public pagereference Cancel(){
id1=wrapobj.opp.id;
Opportunity oppobj=[select name,CloseDate,StageName from Opportunity where id=:id1];
if(rowindex1<lstwrap.size()){
wrapobj.opp.Name=oppobj.Name;
wrapobj.opp.CloseDate=oppobj.CloseDate;
wrapobj.opp.StageName=oppobj.StageName;
lstwrap[rowindex1].ren=false;
}
return null;
}
public pageReference Edit(){
if(rowindex1<lstwrap.size()){
lstwrap[rowindex1].ren=true;
}
return null;
}
public pagereference Delete1(){
if(rowindex1<lstwrap.size()){
//Deleting in the Object
Delete lstwrap[rowindex1].opp;
//Deleting in the List
lstwrap.remove(rowIndex1);
}
return null;
}
}
Can you please change the return type of both Edit and Cancel button to void instead of pagereference and then try?
Hi Pankaj,
I have changed Pagereferences into Void methods, But No change. Its again same.
Have a look at these,