function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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;

                                                }

                                    }