You need to sign in to do that
Don't have an account?
Ethan West
Error: Unknown property 'VisualforceArrayList.Name'
Hi,
I've got a requirement for a button that mass creates assignments against the list view.
I've got a controller set but can't seem to get the VF page I have set out to save with the controller active.
Any chance anyone can advise as to what I'm doing wrong & how to resolve?
Error:
Error: Unknown property 'VisualforceArrayList.Name'
Apex:
public class AddmultipleAssignmentController { public pse__Assignment__c del; public List<pse__Assignment__c> TC {get; set;} public List<pse__Assignment__c> delTCList {get; set;} public List<pse__Assignment__c> listAssignment {get; set;} public Integer rowIndex {get; set;} public AddmultipleAssignmentController(ApexPages.StandardSetController controller) { pse__Assignment__c a = new pse__Assignment__c(); listAssignment = new List<pse__Assignment__c>(); listAssignment.add(a); delTCList = new List<pse__Assignment__c>(); TC = new List<pse__Assignment__c>(); } public void addRow(){ pse__Assignment__c a = new pse__Assignment__c(); listAssignment.add(a); } public PageReference save(){ for(pse__Assignment__c s2 : listAssignment){ TC.add(s2); return Page.Allassignmentsaved; } insert TC; listAssignment.clear(); addRow(); return null; } public void deleteRow(){ rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex')); del = listAssignment.remove(rowIndex); delTCList.add(del); } }
VF Page:
<apex:page standardController="pse__Assignment__c" recordSetVar="unused" extensions="AddmultipleAssignmentController" > <apex:enhancedList type="pse__Assignment__c" height="300" rowsPerPage="10" id="ListViewID"/> <apex:form> <apex:pageBlock title="Assignments" id="pb"> <apex:variable var="rowNumber" value="{!0}"/> <apex:pageblockSection columns="1"> <apex:pageBlockTable title="Assignments" value="{!listAssignment}" var="TC"> <apex:column headerValue="No." style="width:20px; text-align:center;" headerClass="centertext"> <apex:outputText value="{0}" style="text-align:center;"> <apex:param value="{!rowNumber+1}"/> </apex:outputText> </apex:column> <apex:column headerValue="Assignment Name"> <apex:inputField value="{!TC.Name}"/> </apex:column> <apex:column headerValue="Resource"> <apex:inputField value="{!TC.pse__Resource__c}"/> </apex:column> <apex:column headerValue="Project"> <apex:inputField value="{!TC.pse__Project__c}"/> </apex:column> <apex:column headerValue="Candidate"> <apex:inputField value="{!TC.Candidate__c}"/> </apex:column> <apex:column headerValue="Bill Rate"> <apex:inputField value="{!TC.pse__Bill_Rate__c}"/> </apex:column> <apex:column headerValue="Start Date"> <apex:inputField value="{!TC.Start_Date__c}"/> </apex:column> <apex:column headerValue="End Date"> <apex:inputField value="{!TC.End_Date__c}"/> </apex:column> <apex:column headerValue="Monday Hours"> <apex:inputField value="{!TC.Monday_Hours__c}"/> </apex:column> <apex:column headerValue="Tuesday Hours"> <apex:inputField value="{!TC.Tuesday_Hours__c}"/> </apex:column> <apex:column headerValue="Wednesday Hours"> <apex:inputField value="{!TC.Wednesday_Hours__c}"/> </apex:column> <apex:column headerValue="Thursday Hours"> <apex:inputField value="{!TC.Thursday_Hours__c}"/> </apex:column> <apex:column headerValue="Friday Hours"> <apex:inputField value="{!TC.Friday_Hours__c}"/> </apex:column> <apex:column headerValue="Saturday Hours"> <apex:inputField value="{!TC.Saturday_Hours__c}"/> </apex:column> <apex:column headerValue="Sunday Hours"> <apex:inputField value="{!TC.Sunday_Hours__c}"/> </apex:column> <apex:column headerValue="Action"> <apex:commandButton value="Delete Row" action="{!deleteRow}" reRender="pb"/> <apex:param name="rowIndex" value="{!rowNumber+1}"/> </apex:column> </apex:pageBlockTable> <apex:commandButton action="{!addRow}" value="Add Assignment" rerender="pb"/> </apex:pageblockSection> <apex:pageBlockButtons> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Greetings to you!
You need to change the name of variable of pageBlockTable as you are using TC in controller.
var- The name of the variable that represents one element in the collection of data specified by the value attribute. You can then use this variable to display the element itself in the body of the pageBlockTable component tag.
Use below code:
Visualforce:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Hi Khan,
Thank you! That fixed the current issue, however, with the functionality of adding a row working when I tested to save the record it takes me to the Page.Allassignmentsaved (thank you for pointing out that was missing), but doesn't seem to be actually saving the record at all.
I had this functionality working prior to making amendments as I've saved a test record in the past - so I'm not sure what's going on now.
Many thanks,
Ethan
Also, as an addition onto this - when I try to delete a row I also get the error:
"Argument cannot be null.
Error is in expression '{!deleteRow}' in component <apex:commandButton> in page mass_create_assignment: Class.AddmultipleAssignmentController.deleteRow: line 38, column 1"
Which is odd as I can't see anywhere within the Apex Class code that references the case as null - other than potentially the +1, do you happen to see the issue at all?
Many thanks,
Ethan
Visualforce:
Controller:
Hi Khan,
Thank you for this it's all working now thanks to youra! Sorry for the delayed response in getting back to you - turns out there was a schedule record which was bugging out the process that I had to use the DataLoader for to delete the record.
Out of curiosity within your Apex code it creates the functionality to show one line of a record to fill prior to pressing any additional "Add Assignment" buttons, see below:
Do you mind explaining which line within the Apex code this is as I'd like to use that function for a similar piece I have.
Many thanks,
Ethan
You are getting this functionality because you are using below lines of code in constructor.
pse__Assignment__c a = new pse__Assignment__c(); listAssignment.add(a);
The constructor is the initializer of a class. A constructor can only be called once for each object, which is during initialization time.