You need to sign in to do that
Don't have an account?
Becky Miller 15
New Coder Help - Adding Multiple Lines in Code
I am getting a couple of errors with the Controller which then gives me an error in Visualforce page.
I am trying to let the user add multiple rows of information from one screen. I am trying to allow the user to hit Add in the table so that we can get more information. I will need another table with the same capability to be able to add another row. Most of the time we won't need to add a row but I would rather do it right the first time. I am just learning how to do this so any guidance would be great.
Apex Class
public class MultiAdd
{
//will hold the Endora records to be saved
public List<Endora_Information__c> lstEndora = new List<Endora_Information__c>();
//list of the inner class
public List<innerClass> lstInner
{ get;set; }
//will indicate the row to be deleted
public String selectedRowIndex
{get;set;}
//no. of rows added/records in the inner class list
public Integer count = 1;
//{get;set;}
////save the records by adding the elements in the inner class list to lstinner,return to the same page
public PageReference Save()
{
PageReference pr = new PageReference('/apex/MultiAdd');
for(Integer j = 0;j<lstEndoras.size();j++)
{
lstInner.add(lstEndora[j].endora__c); (error)
}
insert lstInner;
pr.setRedirect(True);
return pr;
}
//add one more row
public void Add()
{
count = count+1;
addMore();
}
/*Begin addMore*/
public void addMore()
{
//call to the iner class constructor
innerClass objInnerClass = new innerClass(count);
//add the record to the inner class list
lstInner.add(objInnerClass);
system.debug('lstInner---->'+lstInner);
}/* end addMore*/
/* begin delete */
public void Del()
{
system.debug('selected row index---->'+selectedRowIndex);
lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
count = count - 1;
}/*End del*/
/*Constructor*/
public MultiAdd(ApexPages.StandardController ctlr)
{
lstInner = new List<innerClass>();
addMore();
selectedRowIndex = '0';
}/*End Constructor*/
/*Endora Class*/
public class innerClass
{
/*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
public String recCount
{get;set;}
public Endora_Information__c endora
{get;set;}
/*Inner Class Constructor*/
public innerClass(Integer intCount)
{
recCount = String.valueOf(intCount);
/*create a new endora record*/
endora = new Endora_Information__c();
}/*End Inner class Constructor*/
}
}
/*End inner Class*/
Error: Incompatible element type Decimal for collection of MultiAdd.innerClass
Visual Force page (everything works that is bolded)
Error: Line 1 Previous load of class failed: MultiAdd: line 28, column 13: Incompatible element type Decimal for collection of MultiAdd.innerClass
<apex:page standardController="Opportunity" extensions="MultiAdd" id="thePage">
<apex:relatedList list="Endora_Information__c"/>
<apex:form >
<style type="text/css">
.pbTitle {
white-space: nowrap
}
</style>
<apex:pageBlock title="Procedure Rooms: Quote 1 kiosk or 1 workflow software unit per procedure room.">
How many total procedure rooms?
<apex:inputText value="{!Opportunity.Total_Procedure_Rooms__c}"/><p/>
<b>PROCEDURE ROOM/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.PR_Qty_Kiosks__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.PR_Qty_WF_SF_Only__c}"/><p/>
</apex:pageBlock>
<apex:pageBlock title="Travel Carts">
How many travel carts will track endoscopes?
<apex:inputText value="{!Opportunity.qty_travel_carts__c}"/><p/>
<b>TRAVEL CARTS/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.tc_qty_endora__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.tc_wf_sf_only__c}"/><p/>
</apex:pageBlock>
<apex:pageBlock title="Kiosk Mounts">
Kiosk mount total by type for procedure rooms:? <p/>
<b>KIOSK MOUNTS/QTY</b><p/>
Flush Wall Mount #72233-847
<apex:inputText value="{!Opportunity.Qty_flush_wall_mount__c}"/><p/>
Flush Tilt Wall Mount #72233-849
<apex:inputText value="{!Opportunity.qty_tilt_wall_mount__c}"/><p/>
Arm Wall Mount #72233-848
<apex:inputText value="{!Opportunity.qty_arm_wall_mount__c}"/><p/>
Floor Stand #72233-850
<apex:inputText value="{!Opportunity.qty_floor_stand__c}"/><p/>
</apex:pageBlock>
<apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
<apex:commandbutton value="Save" action="{!Save}"/>
apex:pageblock id="pb1">
<apex:repeat value="{!lstInner}" var="e1" id="therepeat">
<apex:panelGrid columns="5">
<apex:panelGrid headerClass="Endora">
<apex:facet name="header">Del</apex:facet>
<apex:commandButton value="X" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
</apex:commandButton>
</apex:panelGrid>
<apex:panelGrid title="Cleaning SINKS: Quote 1 kiosk and 1 kiosk mount per solution " >
<apex:facet name="header">Department</apex:facet>
<apex:inputfield value="{!e1.acct.ShippingCountry}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Floor/Room#</apex:facet>
<apex:inputfield value="{!e1.acct.Active__c}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Kiosk Quantity</apex:facet>
<apex:inputfield value="{!e1.acct.Name}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Mount Type</apex:facet>
<apex:inputfield value="{!e1.acct.Name}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Kiosk Quantity</apex:facet>
<apex:inputfield value="{!e1.acct.Name}"/>
</apex:panelGrid>
</apex:panelgrid>
</apex:repeat>
</apex:form>
</apex:page>
I am trying to let the user add multiple rows of information from one screen. I am trying to allow the user to hit Add in the table so that we can get more information. I will need another table with the same capability to be able to add another row. Most of the time we won't need to add a row but I would rather do it right the first time. I am just learning how to do this so any guidance would be great.
Apex Class
public class MultiAdd
{
//will hold the Endora records to be saved
public List<Endora_Information__c> lstEndora = new List<Endora_Information__c>();
//list of the inner class
public List<innerClass> lstInner
{ get;set; }
//will indicate the row to be deleted
public String selectedRowIndex
{get;set;}
//no. of rows added/records in the inner class list
public Integer count = 1;
//{get;set;}
////save the records by adding the elements in the inner class list to lstinner,return to the same page
public PageReference Save()
{
PageReference pr = new PageReference('/apex/MultiAdd');
for(Integer j = 0;j<lstEndoras.size();j++)
{
lstInner.add(lstEndora[j].endora__c); (error)
}
insert lstInner;
pr.setRedirect(True);
return pr;
}
//add one more row
public void Add()
{
count = count+1;
addMore();
}
/*Begin addMore*/
public void addMore()
{
//call to the iner class constructor
innerClass objInnerClass = new innerClass(count);
//add the record to the inner class list
lstInner.add(objInnerClass);
system.debug('lstInner---->'+lstInner);
}/* end addMore*/
/* begin delete */
public void Del()
{
system.debug('selected row index---->'+selectedRowIndex);
lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
count = count - 1;
}/*End del*/
/*Constructor*/
public MultiAdd(ApexPages.StandardController ctlr)
{
lstInner = new List<innerClass>();
addMore();
selectedRowIndex = '0';
}/*End Constructor*/
/*Endora Class*/
public class innerClass
{
/*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
public String recCount
{get;set;}
public Endora_Information__c endora
{get;set;}
/*Inner Class Constructor*/
public innerClass(Integer intCount)
{
recCount = String.valueOf(intCount);
/*create a new endora record*/
endora = new Endora_Information__c();
}/*End Inner class Constructor*/
}
}
/*End inner Class*/
Error: Incompatible element type Decimal for collection of MultiAdd.innerClass
Visual Force page (everything works that is bolded)
Error: Line 1 Previous load of class failed: MultiAdd: line 28, column 13: Incompatible element type Decimal for collection of MultiAdd.innerClass
<apex:page standardController="Opportunity" extensions="MultiAdd" id="thePage">
<apex:relatedList list="Endora_Information__c"/>
<apex:form >
<style type="text/css">
.pbTitle {
white-space: nowrap
}
</style>
<apex:pageBlock title="Procedure Rooms: Quote 1 kiosk or 1 workflow software unit per procedure room.">
How many total procedure rooms?
<apex:inputText value="{!Opportunity.Total_Procedure_Rooms__c}"/><p/>
<b>PROCEDURE ROOM/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.PR_Qty_Kiosks__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.PR_Qty_WF_SF_Only__c}"/><p/>
</apex:pageBlock>
<apex:pageBlock title="Travel Carts">
How many travel carts will track endoscopes?
<apex:inputText value="{!Opportunity.qty_travel_carts__c}"/><p/>
<b>TRAVEL CARTS/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.tc_qty_endora__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.tc_wf_sf_only__c}"/><p/>
</apex:pageBlock>
<apex:pageBlock title="Kiosk Mounts">
Kiosk mount total by type for procedure rooms:? <p/>
<b>KIOSK MOUNTS/QTY</b><p/>
Flush Wall Mount #72233-847
<apex:inputText value="{!Opportunity.Qty_flush_wall_mount__c}"/><p/>
Flush Tilt Wall Mount #72233-849
<apex:inputText value="{!Opportunity.qty_tilt_wall_mount__c}"/><p/>
Arm Wall Mount #72233-848
<apex:inputText value="{!Opportunity.qty_arm_wall_mount__c}"/><p/>
Floor Stand #72233-850
<apex:inputText value="{!Opportunity.qty_floor_stand__c}"/><p/>
</apex:pageBlock>
<apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
<apex:commandbutton value="Save" action="{!Save}"/>
apex:pageblock id="pb1">
<apex:repeat value="{!lstInner}" var="e1" id="therepeat">
<apex:panelGrid columns="5">
<apex:panelGrid headerClass="Endora">
<apex:facet name="header">Del</apex:facet>
<apex:commandButton value="X" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
</apex:commandButton>
</apex:panelGrid>
<apex:panelGrid title="Cleaning SINKS: Quote 1 kiosk and 1 kiosk mount per solution " >
<apex:facet name="header">Department</apex:facet>
<apex:inputfield value="{!e1.acct.ShippingCountry}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Floor/Room#</apex:facet>
<apex:inputfield value="{!e1.acct.Active__c}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Kiosk Quantity</apex:facet>
<apex:inputfield value="{!e1.acct.Name}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Mount Type</apex:facet>
<apex:inputfield value="{!e1.acct.Name}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Kiosk Quantity</apex:facet>
<apex:inputfield value="{!e1.acct.Name}"/>
</apex:panelGrid>
</apex:panelgrid>
</apex:repeat>
</apex:form>
</apex:page>
public class MultiAdd
{
//will hold the account records to be saved
public List<Endora_Information__c> lstAcct{
get {
if(lstAcct == null)
return new List<Endora_Information__c>();
else
return lstAcct ;
}
set;
}
//list of the inner class
public List<innerClass> lstInner
{get;set;}
//will indicate the row to be deleted
public String selectedRowIndex
{get;set;}
//no. of rows added/records in the inner class list
public Integer count = 1;
//{get;set;}
////save the records by adding the elements in the inner class list to lstAcct,return to the same page
public PageReference Save()
{
PageReference pr = new PageReference('/apex/MultiAdd');
for(Integer j = 0;j<lstInner.size();j++)
{
lstAcct.add(lstInner[j].endora);
}
insert lstAcct;
pr.setRedirect(True);
return pr;
}
//add one more row
public void Add()
{
count = count+1;
addMore();
}
/*Begin addMore*/
public void addMore()
{
//call to the iner class constructor
innerClass objInnerClass = new innerClass(count);
//add the record to the inner class list
lstInner.add(objInnerClass);
system.debug('lstInner---->'+lstInner);
}/* end addMore*/
/* begin delete */
public void Del()
{
system.debug('selected row index---->'+selectedRowIndex);
lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
count = count - 1;
}/*End del*/
/*Constructor*/
public MultiAdd(ApexPages.StandardController ctlr)
{
lstInner = new List<innerClass>();
addMore();
selectedRowIndex = '0';
}/*End Constructor*/
/*Inner Class*/
public class innerClass
{
/*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
public String recCount
{get;set;}
public Endora_Information__c endora
{get;set;}
/*Inner Class Constructor*/
public innerClass(Integer intCount)
{
recCount = String.valueOf(intCount);
/*create a new account*/
endora = new Endora_Information__c();
}/*End Inner class Constructor*/
}
}
/*End inner Class*/
All Answers
public class MultiAdd
{
//will hold the Endora records to be saved
public List<Endora_Information__c> lstEndora = new List<Endora_Information__c>();
//list of the inner class
public List<innerClass> lstInner
{ get;set; }
//will indicate the row to be deleted
public Double selectedRowIndex
{get;set;}
//no. of rows added/records in the inner class list
public Double count = 1;
//{get;set;}
////save the records by adding the elements in the inner class list to lstinner,return to the same page
public PageReference Save()
{
PageReference pr = new PageReference('/apex/MultiAdd');
for(Double j = 0;j<lstEndoras.size();j++)
{
lstInner.add(lstEndora[j].endora__c);
}
insert lstInner;
pr.setRedirect(True);
return pr;
}
//add one more row
public void Add()
{
count = count+1;
addMore();
}
/*Begin addMore*/
public void addMore()
{
//call to the iner class constructor
innerClass objInnerClass = new innerClass(count);
//add the record to the inner class list
lstInner.add(objInnerClass);
system.debug('lstInner---->'+lstInner);
}/* end addMore*/
/* begin delete */
public void Del()
{
system.debug('selected row index---->'+selectedRowIndex);
lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
count = count - 1;
}/*End del*/
/*Constructor*/
public MultiAdd(ApexPages.StandardController ctlr)
{
lstInner = new List<innerClass>();
addMore();
selectedRowIndex = '0';
}/*End Constructor*/
/*Endora Class*/
public class innerClass
{
/*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
public String recCount
{get;set;}
public Endora_Information__c endora
{get;set;}
/*Inner Class Constructor*/
public innerClass(Double intCount)
{
recCount = Double.valueOf(intCount);
/*create a new endora record*/
endora = new Endora_Information__c();
}/*End Inner class Constructor*/
}
}
/*End inner Class*/
and new error is because, we cannot use double for accessing the list index. Please change your data type to previous stage and check you page if you are assigning the value for field to variable or vice correctly.
Here "lstInner" list is of type "InnerClass" and we cannot add just a cutom object fields to it. you need to convert it "inner class" type and then add it to list. Field "endora__c" is from salesforce object, "Endora_Information__c". Type of both varibles are not matching.
public static InnerClass createInnerClass (Endora_Information__c p_EI){
InnerClass v_inCls = new InnerClass();
v_inCls.Endora_Information__c = p_EI;
return v_inCls ;
}
then update error line as :
lstInner.add(createInnerClass(lstEndora[j]));
it should work.
public class MultiAdd
{
//will hold the Endora records to be saved
public List<Endora_Information__c> lstEndora = new List<Endora_Information__c>();
public static InnerClass createInnerClass (Endora_Information__c p_EI){
InnerClass v_inCls = new InnerClass();
v_inCls.Endora_Information__c = p_EI;
return v_inCls ;
}
//list of the inner class
public List<innerClass> lstEndoras
{ get;set; }
//will indicate the row to be deleted
public String selectedRowIndex
{get;set;}
//no. of rows added/records in the inner class list
public Integer count = 1;
//{get;set;}
////save the records by adding the elements in the inner class list to lstEndora,return to the same page
public PageReference Save()
{
PageReference pr = new PageReference('/apex/MultiAdd');
for(Double j = 0;j<lstEndoras.size();j++)
{
lstInner.add(createInnerClass(lstEndora[j]));
}
insert lstEndoras;
pr.setRedirect(True);
return pr;
}
//add one more row
public void Add()
{
count = count+1;
addMore();
}
/*Begin addMore*/
public void addMore()
{
//call to the iner class constructor
innerClass objInnerClass = new innerClass(count);
//add the record to the inner class list
lstEndoras.add(objInnerClass);
system.debug('lstEndoras---->'+lstEndoras);
}/* end addMore*/
/* begin delete */
public void Del()
{
system.debug('selected row index---->'+selectedRowIndex);
lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
count = count - 1;
}/*End del*/
/*Constructor*/
public MultiAdd(ApexPages.StandardController ctlr)
{
lstEndoras = new List<innerClass>();
addMore();
selectedRowIndex = '0';
}/*End Constructor*/
/*Endora Class*/
public class innerClass
{
/*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
public String recCount
{get;set;}
public Endora_Information__c endora
{get;set;}
/*Inner Class Constructor*/
public innerClass(Integer intCount)
{
recCount = String.valueOf(intCount);
/*create a new endora record*/
endora = new Endora_Information__c();
}/*End Inner class Constructor*/
}
}
/*End inner Class*/
PageReference pr = new PageReference('/apex/MultiAdd');
for(Double j = 0;j<lstEndoras.size();j++)
{
lstInner.add(createInnerClass(lstEndora[j]));
}
insert lstEndoras;
pr.setRedirect(True);
return pr;
as for(integer j = 0;j<lstEndoras.size();j++)
it should fix it.
<apex:page standardController="Opportunity" extensions="MultiAdd" id="thePage">
<apex:relatedList list="Endora_Information__c"/>
<apex:form >
<style type="text/css">
.pbTitle {
white-space: nowrap
}
</style>
<apex:pageBlock title="Procedure Rooms: Quote 1 kiosk or 1 workflow software unit per procedure room.">
How many total procedure rooms?
<apex:inputText value="{!Opportunity.Total_Procedure_Rooms__c}"/><p/>
<b>PROCEDURE ROOM/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.PR_Qty_Kiosks__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.PR_Qty_WF_SF_Only__c}"/><p/>
</apex:pageBlock>
This is no attribute called "acc" on class "innerClass", that's why this error is coming.
<apex:repeat value="{!lstInner}" var="e1" id="therepeat">
<apex:panelGrid columns="5">
<apex:panelGrid headerClass="Endora">
<apex:facet name="header">Del</apex:facet>
<apex:commandButton value="X" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
</apex:commandButton>
</apex:panelGrid>
<apex:panelGrid title="Cleaning SINKS: Quote 1 kiosk and 1 kiosk mount per solution " >
<apex:facet name="header">Department</apex:facet>
<apex:inputfield value="{!e1.acct.ShippingCountry}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Floor/Room#</apex:facet>
<apex:inputfield value="{!e1.acct.Active__c}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Kiosk Quantity</apex:facet>
<apex:inputfield value="{!e1.acct.Name}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Mount Type</apex:facet>
<apex:inputfield value="{!e1.acct.Name}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Kiosk Quantity</apex:facet>
<apex:inputfield value="{!e1.acct.Name}"/>
</apex:panelGrid>
</apex:panelgrid>
</apex:repeat>
<apex:page standardController="Opportunity" extensions="MultiAdd" id="thePage">
<apex:relatedList list="Endora_Information__r"/>
<apex:form >
<style type="text/css">
.pbTitle {
white-space: nowrap
}
</style>
<apex:pageBlock title="Procedure Rooms: Quote 1 kiosk or 1 workflow software unit per procedure room.">
How many total procedure rooms?
<apex:inputText value="{!Opportunity.Total_Procedure_Rooms__c}"/><p/>
<b>PROCEDURE ROOM/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.PR_Qty_Kiosks__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.PR_Qty_WF_SF_Only__c}"/><p/>
</apex:pageBlock>
<apex:pageBlock title="Travel Carts">
How many travel carts will track endoscopes?
<apex:inputText value="{!Opportunity.qty_travel_carts__c}"/><p/>
<b>TRAVEL CARTS/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.tc_qty_endora__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.tc_wf_sf_only__c}"/><p/>
</apex:pageBlock>
<apex:pageBlock title="Kiosk Mounts">
Kiosk mount total by type for procedure rooms:? <p/>
<b>KIOSK MOUNTS/QTY</b><p/>
Flush Wall Mount #72233-847
<apex:inputText value="{!Opportunity.Qty_flush_wall_mount__c}"/><p/>
Flush Tilt Wall Mount #72233-849
<apex:inputText value="{!Opportunity.qty_tilt_wall_mount__c}"/><p/>
Arm Wall Mount #72233-848
<apex:inputText value="{!Opportunity.qty_arm_wall_mount__c}"/><p/>
Floor Stand #72233-850
<apex:inputText value="{!Opportunity.qty_floor_stand__c}"/><p/>
</apex:pageBlock>
<apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
<apex:commandbutton value="Save" action="{!Save}"/>
apex:pageblock id="pb1">
<apex:repeat value="{!lstInner}" var="e1" id="therepeat">
<apex:panelGrid columns="5">
<apex:panelGrid headerClass="Endora">
<apex:facet name="header">Del</apex:facet>
<apex:commandButton value="X" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
</apex:commandButton>
</apex:panelGrid>
<apex:panelGrid title="Cleaning SINKS: Quote 1 kiosk and 1 kiosk mount per solution " >
<apex:facet name="header">Department</apex:facet>
<apex:selectList value="{!Endora_Information__r.Account_Dept__c}" multiselect="false" size="1" required="true">
<apex:inputfield value="{!Endora_Information__r.Account_Dept__c}"/>
</apex:selectList>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Floor/Room#</apex:facet>
<apex:inputfield value="{!Endora_Information__r.Floor_Room__c}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Kiosk Quantity</apex:facet>
<apex:inputfield value="{!Endora_Information__r.Kiosk_Qty__c}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Mount Type</apex:facet>
<apex:selectList value="{!Endora_Information__r.Mount_Type__c}" multiselect="false" size="1" required="true">
<apex:inputfield value="{!Endora_Information__r.Mount_Type__c}"/>
</apex:selectList>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Mount Quantity</apex:facet>
<apex:inputfield value="{!Endora_Information__r.Mount_Qty__c}"/>
</apex:panelGrid>
</apex:panelgrid>
</apex:repeat>
</apex:form>
</apex:page>
Check if opportunity has child relationship with Object "Endora_Information__C"? if yes what is correct child relationship name.
Child relationship name exists on lookup field.Use the correct name in above error line list variable.
<apex:page standardController="Opportunity" extensions="MultiAdd" id="thePage">
<apex:relatedList list="!Opportunity.Opportunity_Endora_Information__c"/>
<apex:form >
<style type="text/css">
.pbTitle {
white-space: nowrap
}
</style>
<apex:pageBlock title="Procedure Rooms: Quote 1 kiosk or 1 workflow software unit per procedure room.">
How many total procedure rooms?
<apex:inputText value="{!Opportunity.Total_Procedure_Rooms__c}"/><p/>
<b>PROCEDURE ROOM/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.PR_Qty_Kiosks__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.PR_Qty_WF_SF_Only__c}"/><p/>
</apex:pageBlock>
<apex:pageBlock title="Travel Carts">
How many travel carts will track endoscopes?
<apex:inputText value="{!Opportunity.qty_travel_carts__c}"/><p/>
<b>TRAVEL CARTS/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.tc_qty_endora__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.tc_wf_sf_only__c}"/><p/>
</apex:pageBlock>
<apex:pageBlock title="Kiosk Mounts">
Kiosk mount total by type for procedure rooms:? <p/>
<b>KIOSK MOUNTS/QTY</b><p/>
Flush Wall Mount #72233-847
<apex:inputText value="{!Opportunity.Qty_flush_wall_mount__c}"/><p/>
Flush Tilt Wall Mount #72233-849
<apex:inputText value="{!Opportunity.qty_tilt_wall_mount__c}"/><p/>
Arm Wall Mount #72233-848
<apex:inputText value="{!Opportunity.qty_arm_wall_mount__c}"/><p/>
Floor Stand #72233-850
<apex:inputText value="{!Opportunity.qty_floor_stand__c}"/><p/>
</apex:pageBlock>
<apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
<apex:commandbutton value="Save" action="{!Save}"/>
<apex:repeat value="{!Endora_Information__c}" var="e1" id="therepeat">
<apex:panelGrid columns="5">
<apex:panelGrid headerClass="Endora">
<apex:facet name="header">Del</apex:facet>
<apex:commandButton value="X" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
</apex:commandButton>
</apex:panelGrid>
<apex:panelGrid title="Cleaning SINKS: Quote 1 kiosk and 1 kiosk mount per solution " >
<apex:facet name="header">Department</apex:facet>
<apex:selectList value="{!e1.Opportunity_Name__c.Account_Dept__c}" multiselect="false" size="1" required="true">
<apex:inputfield value="{!e1.Account_Dept__c}"/>
</apex:selectList>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Floor/Room#</apex:facet>
<apex:inputfield value="{!e1.Floor_Room__c}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Kiosk Quantity</apex:facet>
<apex:inputfield value="{!e1.Kiosk_Qty__c}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Mount Type</apex:facet>
<apex:selectList value="{!e1.Mount_Type__c}" multiselect="false" size="1" required="true">
<apex:inputfield value="{!e1.Mount_Type__c}"/>
</apex:selectList>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Mount Quantity</apex:facet>
<apex:inputfield value="{!e1.Mount_Qty__c}"/>
</apex:panelGrid>
</apex:panelgrid>
</apex:repeat>
</apex:form>
</apex:page>
Check below example, it has child relationship name for Contacts , on Account object. field is on Contact.
<apex:page standardController="Account" extensions="SomeExtensionController">
<apex:relatedlist list="Contacts"/>
</apex:page>
Simlar, way you need to find child relationship name from "Endora information" object, lookup field to Opportunity and use its name in page.
<apex:relatedList list="Opportunities"/>
<apex:form >
<style type="text/css">
.pbTitle {
white-space: nowrap
}
</style>
I think the issue is here now;
<apex:repeat value="{!Endora_Information__c}" var="e1" id="therepeat">
<apex:panelGrid columns="5">
<apex:panelGrid headerClass="Endora">
<apex:facet name="header">Del</apex:facet>
<apex:commandButton value="X" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
</apex:commandButton>
</apex:panelGrid>
<apex:panelGrid title="Cleaning SINKS: Quote 1 kiosk and 1 kiosk mount per solution " >
<apex:facet name="header">Department</apex:facet>
<apex:selectList value="{!e1.Opportunity_Name__c.Account_Dept__c}" multiselect="false" size="1" required="true">
<apex:inputfield value="{!e1.Account_Dept__c}"/>
</apex:selectList>
</apex:panelGrid>
Modify line as :
<apex:repeat value="{!lstEndora }" var="e1" id="therepeat">
apex:repeat uses list/Map type variable.
Error:Unknown property 'OpportunityStandardController.lstEndora'
<apex:page standardController="Opportunity" extensions="MultiAdd" id="thePage">
<apex:relatedList list="Opportunities"/>
<apex:form >
<style type="text/css">
.pbTitle {
white-space: nowrap
}
</style>
<apex:pageBlock title="Procedure Rooms: Quote 1 kiosk or 1 workflow software unit per procedure room.">
How many total procedure rooms?
<apex:inputText value="{!Opportunity.Total_Procedure_Rooms__c}"/><p/>
<b>PROCEDURE ROOM/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.PR_Qty_Kiosks__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.PR_Qty_WF_SF_Only__c}"/><p/>
</apex:pageBlock>
<apex:pageBlock title="Travel Carts">
How many travel carts will track endoscopes?
<apex:inputText value="{!Opportunity.qty_travel_carts__c}"/><p/>
<b>TRAVEL CARTS/QTY</b><p/>
ENDORA kiosks #45040-73
<apex:inputText value="{!Opportunity.tc_qty_endora__c}"/><p/>
Workflow Software only (customer provides hardware) #ENDO-777
<apex:inputText value="{!Opportunity.tc_wf_sf_only__c}"/><p/>
</apex:pageBlock>
<apex:pageBlock title="Kiosk Mounts">
Kiosk mount total by type for procedure rooms:? <p/>
<b>KIOSK MOUNTS/QTY</b><p/>
Flush Wall Mount #72233-847
<apex:inputText value="{!Opportunity.Qty_flush_wall_mount__c}"/><p/>
Flush Tilt Wall Mount #72233-849
<apex:inputText value="{!Opportunity.qty_tilt_wall_mount__c}"/><p/>
Arm Wall Mount #72233-848
<apex:inputText value="{!Opportunity.qty_arm_wall_mount__c}"/><p/>
Floor Stand #72233-850
<apex:inputText value="{!Opportunity.qty_floor_stand__c}"/><p/>
</apex:pageBlock>
<apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
<apex:commandbutton value="Save" action="{!Save}"/>
<apex:repeat value="{!lstEndora}" var="e1" id="therepeat">
<apex:panelGrid columns="5">
<apex:panelGrid headerClass="Endora">
<apex:facet name="header">Del</apex:facet>
<apex:commandButton value="X" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
</apex:commandButton>
</apex:panelGrid>
<apex:panelGrid title="Cleaning SINKS: Quote 1 kiosk and 1 kiosk mount per solution " >
<apex:facet name="header">Department</apex:facet>
<apex:selectList value="{!e1.Opportunity_Name__c.Account_Dept__c}" multiselect="false" size="1" required="true">
<apex:inputfield value="{!e1.Account_Dept__c}"/>
</apex:selectList>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Floor/Room#</apex:facet>
<apex:inputfield value="{!e1.Floor_Room__c}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Kiosk Quantity</apex:facet>
<apex:inputfield value="{!e1.Kiosk_Qty__c}"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Mount Type</apex:facet>
<apex:selectList value="{!e1.Mount_Type__c}" multiselect="false" size="1" required="true">
<apex:inputfield value="{!e1.Mount_Type__c}"/>
</apex:selectList>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Mount Quantity</apex:facet>
<apex:inputfield value="{!e1.Mount_Qty__c}"/>
</apex:panelGrid>
</apex:panelgrid>
</apex:repeat>
</apex:form>
</apex:page>
Class:
public class MultiAdd
{
//will hold the account records to be saved
public List<Endora_Information__c> lstAcct = new List<Endora_Information__c>();
//list of the inner class
public List<innerClass> lstInner
{get;set;}
//will indicate the row to be deleted
public String selectedRowIndex
{get;set;}
//no. of rows added/records in the inner class list
public Integer count = 1;
//{get;set;}
////save the records by adding the elements in the inner class list to lstAcct,return to the same page
public PageReference Save()
{
PageReference pr = new PageReference('/apex/MultiAdd');
for(Integer j = 0;j<lstInner.size();j++)
{
lstAcct.add(lstInner[j].endora);
}
insert lstAcct;
pr.setRedirect(True);
return pr;
}
//add one more row
public void Add()
{
count = count+1;
addMore();
}
/*Begin addMore*/
public void addMore()
{
//call to the iner class constructor
innerClass objInnerClass = new innerClass(count);
//add the record to the inner class list
lstInner.add(objInnerClass);
system.debug('lstInner---->'+lstInner);
}/* end addMore*/
/* begin delete */
public void Del()
{
system.debug('selected row index---->'+selectedRowIndex);
lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
count = count - 1;
}/*End del*/
/*Constructor*/
public MultiAdd(ApexPages.StandardController ctlr)
{
lstInner = new List<innerClass>();
addMore();
selectedRowIndex = '0';
}/*End Constructor*/
/*Inner Class*/
public class innerClass
{
/*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
public String recCount
{get;set;}
public Endora_Information__c endora
{get;set;}
/*Inner Class Constructor*/
public innerClass(Integer intCount)
{
recCount = String.valueOf(intCount);
/*create a new account*/
endora = new Endora_Information__c();
}/*End Inner class Constructor*/
}
}
/*End inner Class*/
needs to be changed as :
<apex:repeat value="{!lstAcct }" var="e1" id="therepeat">
Variable Name for "Endora Information" object list is "lstAcct" in controller.
This should fix it.
Unknown property 'OpportunityStandardController.lstAcct'
I did change it prior to asking you. I see why it would be that because in the Controller I have documented the new Custom Object.
public List<Endora_Information__c> lstAcct = new List<Endora_Information__c>();
as
public List<Endora_Information__c> lstAcct{
get {
if(lstAcct == null)
return new List<Endora_Information__c>();
else
return lstAcct ;
}
set;
}
Page Dosen't have access to List Variable.
public class MultiAdd
{
//will hold the account records to be saved
public List<Endora_Information__c> lstAcct{
get {
if(lstAcct == null)
return new List<Endora_Information__c>();
else
return lstAcct ;
}
set;
}
//list of the inner class
public List<innerClass> lstInner
{get;set;}
//will indicate the row to be deleted
public String selectedRowIndex
{get;set;}
//no. of rows added/records in the inner class list
public Integer count = 1;
//{get;set;}
////save the records by adding the elements in the inner class list to lstAcct,return to the same page
public PageReference Save()
{
PageReference pr = new PageReference('/apex/MultiAdd');
for(Integer j = 0;j<lstInner.size();j++)
{
lstAcct.add(lstInner[j].endora);
}
insert lstAcct;
pr.setRedirect(True);
return pr;
}
//add one more row
public void Add()
{
count = count+1;
addMore();
}
/*Begin addMore*/
public void addMore()
{
//call to the iner class constructor
innerClass objInnerClass = new innerClass(count);
//add the record to the inner class list
lstInner.add(objInnerClass);
system.debug('lstInner---->'+lstInner);
}/* end addMore*/
/* begin delete */
public void Del()
{
system.debug('selected row index---->'+selectedRowIndex);
lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
count = count - 1;
}/*End del*/
/*Constructor*/
public MultiAdd(ApexPages.StandardController ctlr)
{
lstInner = new List<innerClass>();
addMore();
selectedRowIndex = '0';
}/*End Constructor*/
/*Inner Class*/
public class innerClass
{
/*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
public String recCount
{get;set;}
public Endora_Information__c endora
{get;set;}
/*Inner Class Constructor*/
public innerClass(Integer intCount)
{
recCount = String.valueOf(intCount);
/*create a new account*/
endora = new Endora_Information__c();
}/*End Inner class Constructor*/
}
}
/*End inner Class*/