+ Start a Discussion
anitha20anitha20 

Apex code development structure

canany one tel me structure of apex code

ashiiashii

hi,

 

Check below link

 

http://sites.force.com/blogs/ideaView?id=08730000000BLgwAAG

 

Refer "Best Practices for writing Apex"

 

Thanks

ashii

Pradeep_NavatarPradeep_Navatar

Apex code structure is totally based on Object Oriented Programming concepts. In apex there is a controller that is similar to class. In Apex controller you can make constructor, method and properties to store the VF page variables.      Find below a sample code :

 

---------------- VF Page ---------------

                                    <apex:page controller="SaveController">

                                                <apex:form>

                                                            Enter your Company Name : <apex:inputText value="{!propAccName}" />

                                                            <apex:commandButton value="Submit" action="{!SubmitData}" />

                                                </apex:form>

                                    </apex:page>

 

 

------------- Controller code -----------

                                    public class SaveController

                                    { 

                                                public String  propAccName{ get; set; }

                                                public void SubmitData()

                                                {

                                                            Account acc = new Account(name=propAccName);

                                                            Insert acc;

                                                }

                                    }