I have been struggling with this for a while now and need some help. Below I have table of orders being displayed using <apex:repeat>
. By doing this I can create a table for each order I want to display.
The problem I am having is in the <apex:form>
section. I have two fields "Teacher" and "Teacher Wage" that I want the user to fill in and then save. For the teacher field this is a list of values for them to select and for teacher wage it is input text field. Whenever I click Save I the values selected and inputted are not being past over to the controller.
I have added debug logs to my code and can see the only value I can take across to the controller is the order Id.
Any ideas?
Visualforce Code:
<apex:pageBlock title="Order Dan Testing" >
<apex:repeat value="{!aorders}" var="o" rows="100">
<table id="classes" class="ordertable">
<tr id="{!o.OrderNumber}" class="tableheaderRow" >
<th rowspan="2"><button class="tbutton" value="{!o.OrderNumber}">+</button></th>
<th> Class Id </th>
<th> Account Name </th>
<th> Programme </th>
<th> Programme Code </th>
<th> Class Start Date </th>
<th> Class End Date </th>
<th> Class Amount </th>
<th> Status </th>
<th> Teacher </th>
<th> </th>
<th> Teacher Wage </th>
<th> </th>
<th> </th>
</tr>
<tr class="tabledataRow" >
<td> <apex:outputLink value="/{!o.id}">{!o.OrderNumber}</apex:outputLink> </td>
<td> <apex:outputField value="{!o.AccountId}"/> </td>
<td> <apex:outputField value="{!o.Programme__r.Name}"/> </td>
<td> <apex:outputField value="{!o.Programme_Code__c}"/> </td>
<td> <apex:outputField value="{!o.EffectiveDate}"/> </td>
<td> <apex:outputField value="{!o.EndDate}"/> </td>
<td> <apex:outputField value="{!o.Total_Cost_Of_Class__c}"/> </td>
<td> <apex:outputField value="{!o.Status}"/> </td>
<td> <apex:outputField value="{!o.ClassTeacher__r.Name}"/> </td>
<apex:form >
<td> <apex:selectList value="{!selectedVal}" size="1">
<apex:selectOptions value="{!openPresentationOptions}" />
</apex:selectList></td>
<td>
<apex:inputText value="{!o.Teacher_Wages__c}"/> </td>
<td>
<apex:commandLink action="{!saveS}" value="saveS">
<apex:param name="saveOrder" value="{!o.id}"/>
</apex:commandLink>
</td>
</apex:form>
</tr>
</table>
APEX:
public String selectedVal{get;set;}
public List<SelectOption > getopenPresentationOptions(){
List<SelectOption> options = new List<SelectOption>();
options.add( new SelectOption('0000','Choose Teacher'));
for( Contact teacher : [ SELECT Id, Name FROM Contact WHERE Type__c = 'Teacher' order by Id desc] ) {
options.add( new SelectOption(teacher.Id,teacher.name));
}
return options;
}
public List<Order> aorders {
get{
aorders = [
SELECT Id, OrderNumber, AccountId, EffectiveDate , EndDate, Status, Total_Cost_Of_Class__c,
ClassTeacher__r.Name, Teacher_Wage__c, Programme__r.Name, Programme_Code__c, ClassTeacher__r.Id
FROM Order
order by OrderNumber desc];
return aorders;
}
set ;
}
public void saveS() {
string oid = ApexPages.currentpage().getParameters().get('saveOrder');
Order singleRec;
for (Order x: aorders) {
if (oid == x.id) {
singleRec = x;
break;
}
}
if (singleRec != null)
System.debug('order ' +singleRec);
System.debug('order number ' +singleRec.OrderNumber);
System.debug('TEACHER WAGE ' +singleRec.Teacher_Wage__c);
System.debug('TEACHER ' +singleRec.ClassTeacher__c);
}
For the teacher wage I have also tried changing the inputText value to use {!TeacherWageFromPage} and create a getter and setters in the controller but still when I check the debug log after run it shows as NULL.
public Decimal getTeacherWageFromPage() {
return teacherWage;
}
public void SetTeacherWageFromPage(Decimal s) {
teacherWage = s;
}
apex:form
inside each table row? Normal practice would be one apex:form surrounding entire table ; 2) yourgetOpenPresentationOptions()
returns an invariant list yet it will be called for every row. Build once if property is null, otherwise return the list