Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyCustomController {
- public Merchandise__C merchandise { get; set; }
- public MyCustomController() {
- Id id = ApexPages.currentPage().getParameters().get('id');
- merchandise= (id == null) ? new Merchandise__C() :
- [SELECT Name, Description__C, Price__C,Total_Inventory__C FROM Merchandise__C WHERE Id = :id];
- }
- public PageReference save() {
- try{
- insert merchandise; //Database.insert
- return (new ApexPages.StandardController(Merchandise)).view();
- }catch(Exception ex){
- System.debug('Exception : ' + ex);
- }
- return null;
- }
- }
- <apex:page controller="MyCustomController" tabstyle="Merchandise__c">
- <apex:form >
- <apex:pageBlock mode="edit">
- <apex:pageMessages />
- <apex:pageBlockSection >
- <apex:inputField value="{!Merchandise.name}"/>
- <apex:inputField value="{!Merchandise.Description__c}"/>
- <apex:inputField value="{!Merchandise.Price__c}"/>
- <apex:inputField value="{!Merchandise.Total_Inventory__c}"/>
- </apex:pageBlockSection>
- <apex:pageBlockButtons location="bottom">
- <apex:commandButton value="Save" action="{!save}"/>
- </apex:pageBlockButtons>
- </apex:pageBlock>
- </apex:form>
- </apex:page>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement