You need to sign in to do that
Don't have an account?

Compile error:Invalid type: ApexPages.StandardController at line 4 ....
Hi ,
I have a custom object Purchase_Order__c which has a child object Purchase_order_line__c.
Now i have a page button on the Purchase_Order "Receive" which calls a visualforce page that displays the related purchase_order_lines as a table with the received quantity as input fields.There is also a "Save" Button.
But when i make changes and click on the save button the changes are not saved.
This is because the id passed to the page is the purchase_order id and nopt the related list.My code was as below:
<apex:page standardController="Purchase_Order__c">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Purchase_Order__c.Purchase_Order_Lines__r}" var="line" border="1">
<tr>
<td><apex:column value="{!line.name}" style="white-space:nowrap ;font-weight:bold"/></td>
</tr>
<apex:column />
<apex:column value="{!line.Product__c}"/>
<apex:column headerValue="Purchase Quantity">
<apex:outputField value="{!line.Quantity__c}"/>
</apex:column>
<apex:column headerValue="Received Quantity">
<apex:inputField value="{!line.Received_Quantity__c}"/>
</apex:column>
<apex:column headerValue="RMA Quantity">
<apex:inputField value="{!line.RMA_Quantity__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Now to resolve this i tried to write a controller extension for purchase_order to update the records when save is clicked:
public class receiveController {
// Constructor
public receiveController(ApexPages.StandardController controller) {
this.po = (Purchase_order__c)controller.getRecord();
this.pol = [ SELECT
d.Name, d.quantity__c
FROM
purchase_order_line__c d
WHERE
d.purchase_order__c = :po.id ];
}
// Action Method called from page button
public pagereference saveChanges() {
upsert this.pol;
return null;
}
// Action Method called from page link
public pagereference newRec() {
Purchase_order_line__c d = new Purchase_order_line__c();
d.Purchase_order__c =this.po.id;
pol.add( d );
return null;
}
// public Getter to provide table headers
public string[] getheaders() { return new string []
{'Name','Quantity__c'} ; }
// public Getter to list
public Purchase_order_line__c[] getRecs() {
return this.pol;
}
// class variables
Purchase_order__c po;
Purchase_order_line__c[] pol;
}
But i get a compile error:
Error: Compile Error: Invalid type: ApexPages.StandardController at line 4 column 27.
Can somebody please help me? iam really stuck here badly....