I have a visualforce page that is currently iterating through the fieldsets within the OpportunityLineItems object. Everything is displaying correctly with the input fields where the user needs to type in the data. What I need it to do is when the person clicks the save button, I need to store those input values in my controller, so that I can later write them to the Product2 object for the particular OpportunityLineItem. I know how to do it with a single field and stuff like that, but I'm having trouble in terms of how I am supposed to do it with a dynamic fieldset.
Any help would be greatly appreciated. If there is any details that may be important that I left off, let me know. Thanks!
Controller
public without sharing class OliWizardExt
{
OpportunityLineItem oli;
Opportunity opp;
List<oliWrapper> digitalProducts;
List<oliWrapper> oliToScheduleList = new List<oliWrapper>();
Id thisOpportunityId;
List<pbeWrapper> selectedProducts;
List<OpportunityLineItem> saveOliList;
public Set<String> prodSet {get; set; }
public Map<String, List<Schema.FieldSetMember>> activeFieldsets {get; set;}
public List<String> currentProdNameList {get; set;}
public String currentProductName {get;set;}
public List<Schema.FieldSetMember> fsm {get;set;}
public OliWizardExt(ApexPages.StandardController con)
{
onLoad();
}
private void onLoad()
{
System.debug('OpportunityLineItem: ' + oli2);
//load opportunity
List<Opportunity> oppList = new List<Opportunity>();
thisOpportunityId = ApexPages.currentPage().getParameters().get('oppId');
if(thisOpportunityId!=null)
opp=[Select o.Pricebook2Id, o.Name, o.Id From Opportunity o where o.Id=:thisOpportunityId limit 1];
else
{
opp = new Opportunity();
opp.addError('Opportunity Id must be specified');
}
availableProducts = new List<pbeWrapper>();
buildQuery();
}
public void buildQuery()
{
if(opp.Pricebook2Id==null)
{
opp.addError('Pricebook must be specified');
return;
}
}
public List<pbeWrapper> getSelectedProducts()
{
return selectedProducts;
}
VisualForce Page
</script>
<apex:sectionHeader title="Opportunity Wizard" subtitle="Product Schedule Selection"/>
<apex:form >
<apex:messages />
<apex:PageBlock title="Confirmation" id="submitProducts">
<apex:pageBlockButtons >
<apex:commandButton action="{!saveShareOppSched}" value="Save"/>
<apex:commandButton action="{!cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/>
</apex:pageBlockButtons>
<apex:repeat value="{!prodSet}" var="f">
<apex:pageBlockSection title="{!f}" columns="1"> <!--title="Digital Display Product" -->
<apex:repeat value="{!selectedProducts}" var="prods">
<apex:pageBlockTable value="{!prods.pbe.Product2.Name}" var="indProd" rendered="{!IF(prods.pbe.Product2.IO_Family_Field_Set__c == f, true, false)}">
<!--<apex:repeat value="{!testProds[f]}" var="prods">
<apex:pageBlockTable value="{!prods}" var="indProd">-->
<apex:repeat value="{!$ObjectType.OpportunityLineItem.FieldSets.Opportunity_Product}" var="oppProd">
<apex:column headerValue="{!oppProd.Label}">
<apex:outputText value="{!indProd}"></apex:outputText>
</apex:column>
</apex:repeat>
<apex:repeat value="{!activeFieldsets[f]}" var="fieldValue">
<apex:column headerValue="{!fieldValue.label}">
********<apex:inputField value="{!OpportunityLineItem[fieldValue.fieldpath]}"></apex:inputField>*******
</apex:column>
</apex:repeat>
</apex:pageBlockTable>
</apex:repeat>
</apex:pageBlockSection>
</apex:repeat>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:PageBlock>
</apex:form>
</apex:page>