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

wrapper class and vf page editing
Hi,
I want to edit opportunity record and its related child record at the same page in vf; once I check the opportunity it should show its related child record and allow me to make changes to both opportunity and child record. Currently I can do it on two separate pages. below are the current lines of the code for apex and vf.. also, I should be able to manage the colums properly on my page so that i dont need to scroll the page..Please assist..
public class wrapperListOpportunity
{
public list<wrapperOpp> wrappOppList{get;set;}
public list<Opportunity> getOppList = new list<Opportunity>();
public list<Order_Intake_Forecast__c> oifList{get;set;}
Public list<Order_Intake_Forecast__c > oilist{get;set;}
Public list<opportunity> oplist{get;set;}
public boolean selectedCheck{get;set;}
public String strDQIDueDays{get;set;}
public List<SelectOption> getDQIDueDays(){
Schema.DescribeFieldResult F = Opportunity.DQI_Due_In_Days__c.getDescribe();
List<Schema.PicklistEntry> P = F.getPicklistValues();
List<SelectOption> options = new List<SelectOption>();
//options.add(new SelectOption('','--All--'));
for(Integer i = 0; i < P.size(); i++){
options.add(new SelectOption(P[i].getValue(), P[i].getLabel()));
}
return options;
}
public wrapperListOpportunity()
{ selectedCheck = false;
wrappOppList = new list<wrapperOpp>();
for(Opportunity op : [SELECT id,name, G2_Planned_Date__c,G3_Planned_Date__c, G4_Planned_Date__c, G5_Planned_Date__c, G6_Planned_Date__c, G2_Approval_Date__c, G3_Approval_Date__c, G4_Approval_Date__c, G5_Approval_Date__c, G6_Approval_Date__c from Opportunity
where ((G2_Planned_Date__c=:date.today() OR G2_Planned_Date__c=NEXT_N_DAYS:5) AND G2_Approval_Date__c = null AND DQI_Due_In_Days__c =: strDQIDueDays) OR
((G3_Planned_Date__c=:date.today() OR G3_Planned_Date__c=NEXT_N_DAYS:5) AND G3_Approval_Date__c = null AND DQI_Due_In_Days__c =: strDQIDueDays) OR
((G3_Planned_Date__c=:date.today() OR G3_Planned_Date__c=NEXT_N_DAYS:5) AND G3_Approval_Date__c = null AND DQI_Due_In_Days__c =: strDQIDueDays) OR
((G4_Planned_Date__c=:date.today() OR G4_Planned_Date__c=NEXT_N_DAYS:5) AND G4_Approval_Date__c = null AND DQI_Due_In_Days__c =: strDQIDueDays) OR
((G5_Planned_Date__c=:date.today() OR G5_Planned_Date__c=NEXT_N_DAYS:5) AND G5_Approval_Date__c = null AND DQI_Due_In_Days__c =: strDQIDueDays) ])
{
wrappOppList.add(new wrapperOpp(false,op));
}
}
public pagereference DisplayData()
{
selectedCheck = true;
oifList = new list<Order_Intake_Forecast__c>();
for(wrapperOpp op1 : wrappOppList)
{
if(op1.checked == true)
getOppList.add(op1.opty);
}
update getOppList;
for(Order_Intake_Forecast__c o : [SELECT id,Business_Group__c, Business_Unit__c, Exclude_Reason__c, Forecast_Category__c,
L4_Name__c, L5_Name__c, Close_Date__c,Opportunity__c from Order_Intake_Forecast__c where Opportunity__c IN :getOppList])
{
oifList.add(o);
}
update oifList;
// selectedCheck = false;
return null;
}
public pagereference SaveOpportunity(){
for(integer i=0;i<wrappOppList.size();i++){
if(wrappOppList[i].checked== true)
{
update wrappOppList[i].opty;
}
// update oifList;
}
pagereference ref = new pagereference('/apex/OpportunityOIFEdit');
ref.setredirect(true);
return ref;
}
public pagereference SaveOif(){
//update getOppList;
if(oiflist.size()>0){
update oiflist;
}
pagereference ref = new pagereference('/apex/OpportunityOIFEdit');
ref.setredirect(true);
return ref;
}
public class wrapperOpp
{
public Opportunity opty{get;set;}
public Boolean checked{get;set;}
Public wrapperOpp(Boolean bool,Opportunity aa)
{
opty = aa;
checked = bool;
}
}
}
VF
_______________
<apex:page controller="wrapperListOpportunity">
<apex:form >
<apex:outputPanel rendered="{!selectedCheck == false}">
<apex:pageBlock >
<apex:selectList size="1" id="DQIDuedays" value="{!strDQIDueDays}">
<apex:selectOptions value="{!DQIDueDays}"/>
</apex:selectList>
<apex:pageBlockTable value="{!wrappOppList}" var="w" id="test">
<apex:column headerValue="Checkbox">
<apex:inputCheckbox value="{!w.checked}" >
<apex:actionSupport event="onclick" reRender="test"/>
</apex:inputCheckbox>
</apex:column>
<apex:column headervalue="Name">
<apex:inputfield value="{!w.opty.Name}"/>
</apex:column>
<apex:column headerValue="G2 Planned date">
<apex:inputfield value="{!w.opty.G2_Planned_Date__c}"/>
</apex:column>
<apex:column headerValue="G3 Planned date">
<apex:inputfield value="{!w.opty.G3_Planned_Date__c}"/>
</apex:column>
<apex:column headerValue="G4 Planned date">
<apex:inputfield value="{!w.opty.G4_Planned_Date__c}"/>
</apex:column>
<apex:column headerValue="G5 Planned date">
<apex:inputfield value="{!w.opty.G5_Planned_Date__c}"/>
</apex:column>
<apex:column headerValue="G2 Approval_Date">
<apex:inputfield value="{!w.opty.G2_Approval_Date__c}"/>
</apex:column>
<apex:column headerValue="G3 Approval_Date">
<apex:inputfield value="{!w.opty.G3_Approval_Date__c}"/>
</apex:column>
<apex:column headerValue="G4 Approval_Date">
<apex:inputfield value="{!w.opty.G4_Approval_Date__c}"/>
</apex:column>
<apex:column headerValue="G5 Approval_Date">
<apex:inputfield value="{!w.opty.G5_Approval_Date__c}"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Display Record" action="{!DisplayData}"/>
<apex:commandButton value="Save Opportunity" action="{!SaveOpportunity}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:outputPanel>
<apex:outputPanel >
<apex:pageBlock rendered="{!selectedCheck == true}">
<apex:pageBlockTable value="{!oifList}" var="oif">
<apex:column headerValue="Opportunity Name">
<apex:inputfield value="{!oif.Opportunity__c}"/>
</apex:column>
<apex:column headerValue="Business Group">
<apex:inputfield value="{!oif.Business_Group__c}"/>
</apex:column>
<apex:column headerValue="Business Unit">
<apex:inputfield value="{!oif.Business_Unit__c}"/>
</apex:column>
<apex:column headerValue="Exclude Reason">
<apex:outputfield value="{!oif.Exclude_Reason__c}"/>
</apex:column>
<apex:column headerValue="Forecast Category">
<apex:inputfield value="{!oif.Forecast_Category__c}"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Save OIF" action="{!SaveOif}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>
I want to edit opportunity record and its related child record at the same page in vf; once I check the opportunity it should show its related child record and allow me to make changes to both opportunity and child record. Currently I can do it on two separate pages. below are the current lines of the code for apex and vf.. also, I should be able to manage the colums properly on my page so that i dont need to scroll the page..Please assist..
public class wrapperListOpportunity
{
public list<wrapperOpp> wrappOppList{get;set;}
public list<Opportunity> getOppList = new list<Opportunity>();
public list<Order_Intake_Forecast__c> oifList{get;set;}
Public list<Order_Intake_Forecast__c > oilist{get;set;}
Public list<opportunity> oplist{get;set;}
public boolean selectedCheck{get;set;}
public String strDQIDueDays{get;set;}
public List<SelectOption> getDQIDueDays(){
Schema.DescribeFieldResult F = Opportunity.DQI_Due_In_Days__c.getDescribe();
List<Schema.PicklistEntry> P = F.getPicklistValues();
List<SelectOption> options = new List<SelectOption>();
//options.add(new SelectOption('','--All--'));
for(Integer i = 0; i < P.size(); i++){
options.add(new SelectOption(P[i].getValue(), P[i].getLabel()));
}
return options;
}
public wrapperListOpportunity()
{ selectedCheck = false;
wrappOppList = new list<wrapperOpp>();
for(Opportunity op : [SELECT id,name, G2_Planned_Date__c,G3_Planned_Date__c, G4_Planned_Date__c, G5_Planned_Date__c, G6_Planned_Date__c, G2_Approval_Date__c, G3_Approval_Date__c, G4_Approval_Date__c, G5_Approval_Date__c, G6_Approval_Date__c from Opportunity
where ((G2_Planned_Date__c=:date.today() OR G2_Planned_Date__c=NEXT_N_DAYS:5) AND G2_Approval_Date__c = null AND DQI_Due_In_Days__c =: strDQIDueDays) OR
((G3_Planned_Date__c=:date.today() OR G3_Planned_Date__c=NEXT_N_DAYS:5) AND G3_Approval_Date__c = null AND DQI_Due_In_Days__c =: strDQIDueDays) OR
((G3_Planned_Date__c=:date.today() OR G3_Planned_Date__c=NEXT_N_DAYS:5) AND G3_Approval_Date__c = null AND DQI_Due_In_Days__c =: strDQIDueDays) OR
((G4_Planned_Date__c=:date.today() OR G4_Planned_Date__c=NEXT_N_DAYS:5) AND G4_Approval_Date__c = null AND DQI_Due_In_Days__c =: strDQIDueDays) OR
((G5_Planned_Date__c=:date.today() OR G5_Planned_Date__c=NEXT_N_DAYS:5) AND G5_Approval_Date__c = null AND DQI_Due_In_Days__c =: strDQIDueDays) ])
{
wrappOppList.add(new wrapperOpp(false,op));
}
}
public pagereference DisplayData()
{
selectedCheck = true;
oifList = new list<Order_Intake_Forecast__c>();
for(wrapperOpp op1 : wrappOppList)
{
if(op1.checked == true)
getOppList.add(op1.opty);
}
update getOppList;
for(Order_Intake_Forecast__c o : [SELECT id,Business_Group__c, Business_Unit__c, Exclude_Reason__c, Forecast_Category__c,
L4_Name__c, L5_Name__c, Close_Date__c,Opportunity__c from Order_Intake_Forecast__c where Opportunity__c IN :getOppList])
{
oifList.add(o);
}
update oifList;
// selectedCheck = false;
return null;
}
public pagereference SaveOpportunity(){
for(integer i=0;i<wrappOppList.size();i++){
if(wrappOppList[i].checked== true)
{
update wrappOppList[i].opty;
}
// update oifList;
}
pagereference ref = new pagereference('/apex/OpportunityOIFEdit');
ref.setredirect(true);
return ref;
}
public pagereference SaveOif(){
//update getOppList;
if(oiflist.size()>0){
update oiflist;
}
pagereference ref = new pagereference('/apex/OpportunityOIFEdit');
ref.setredirect(true);
return ref;
}
public class wrapperOpp
{
public Opportunity opty{get;set;}
public Boolean checked{get;set;}
Public wrapperOpp(Boolean bool,Opportunity aa)
{
opty = aa;
checked = bool;
}
}
}
VF
_______________
<apex:page controller="wrapperListOpportunity">
<apex:form >
<apex:outputPanel rendered="{!selectedCheck == false}">
<apex:pageBlock >
<apex:selectList size="1" id="DQIDuedays" value="{!strDQIDueDays}">
<apex:selectOptions value="{!DQIDueDays}"/>
</apex:selectList>
<apex:pageBlockTable value="{!wrappOppList}" var="w" id="test">
<apex:column headerValue="Checkbox">
<apex:inputCheckbox value="{!w.checked}" >
<apex:actionSupport event="onclick" reRender="test"/>
</apex:inputCheckbox>
</apex:column>
<apex:column headervalue="Name">
<apex:inputfield value="{!w.opty.Name}"/>
</apex:column>
<apex:column headerValue="G2 Planned date">
<apex:inputfield value="{!w.opty.G2_Planned_Date__c}"/>
</apex:column>
<apex:column headerValue="G3 Planned date">
<apex:inputfield value="{!w.opty.G3_Planned_Date__c}"/>
</apex:column>
<apex:column headerValue="G4 Planned date">
<apex:inputfield value="{!w.opty.G4_Planned_Date__c}"/>
</apex:column>
<apex:column headerValue="G5 Planned date">
<apex:inputfield value="{!w.opty.G5_Planned_Date__c}"/>
</apex:column>
<apex:column headerValue="G2 Approval_Date">
<apex:inputfield value="{!w.opty.G2_Approval_Date__c}"/>
</apex:column>
<apex:column headerValue="G3 Approval_Date">
<apex:inputfield value="{!w.opty.G3_Approval_Date__c}"/>
</apex:column>
<apex:column headerValue="G4 Approval_Date">
<apex:inputfield value="{!w.opty.G4_Approval_Date__c}"/>
</apex:column>
<apex:column headerValue="G5 Approval_Date">
<apex:inputfield value="{!w.opty.G5_Approval_Date__c}"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Display Record" action="{!DisplayData}"/>
<apex:commandButton value="Save Opportunity" action="{!SaveOpportunity}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:outputPanel>
<apex:outputPanel >
<apex:pageBlock rendered="{!selectedCheck == true}">
<apex:pageBlockTable value="{!oifList}" var="oif">
<apex:column headerValue="Opportunity Name">
<apex:inputfield value="{!oif.Opportunity__c}"/>
</apex:column>
<apex:column headerValue="Business Group">
<apex:inputfield value="{!oif.Business_Group__c}"/>
</apex:column>
<apex:column headerValue="Business Unit">
<apex:inputfield value="{!oif.Business_Unit__c}"/>
</apex:column>
<apex:column headerValue="Exclude Reason">
<apex:outputfield value="{!oif.Exclude_Reason__c}"/>
</apex:column>
<apex:column headerValue="Forecast Category">
<apex:inputfield value="{!oif.Forecast_Category__c}"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Save OIF" action="{!SaveOif}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>

Anything on the above request please...