I have two objects - Object1 & Object2
Object1 has a list of Products say Product1, Product2, Product3 Object2 has a accessories say acc1, acc2, acc3
- and One Text Field.
User has to select applicable accessories for all those products
Product Acc1 Acc2 Acc3 Product1 True False True Product2 True False True Product3 False True False
I am storing all products in one object - Object1 And all Accessories in Object2
- On Save
I will be saving Object2 with Text field filled with Product Name from Object1 and the rest of the checkboxes with filled values - checkbox1, checkbox2, checkbox3
So far I have written the following code, But getting an error as
public class PrdAccSelection{
public List<Object1__c> lstPrd{get;set;}
public Object2__c chk = new Object1__c();
public List<Object2__c> lstchk{get;set;}
public PrdAccSelection(){
lstPrd = [select id, Name, Prd_Description__c from Object1__c];
for(Object1__c l : lstPrd){
chk.Question_Description__c = l.Prd_Description__c;
system.debug('chk'+chk);
lstchk.add(chk);
}
system.debug('lstchk'+lstchk);
}}
VF Page:
<apex:page controller="PrdAccSelection" >
<apex:form >
<apex:pageBlock title="Product Accessory Selection">
<apex:pageBlockTable value="{!lstchk}" var="c">
<apex:column value="{!c.Prd_Description__c}"/>
<apex:column value="{!c.acc1__c}"/>
<apex:column value="{!c.acc2__c}"/>
<apex:column value="{!c.acc3__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Visualforce Error Help for this Page
System.NullPointerException: Attempt to de-reference a null object Class.Feedback.: line 10, column 1