+ Start a Discussion
vibrationvibration 

How to create interface in salesforce?

How to create interface in salesforce?

Best Answer chosen by Admin (Salesforce Developers) 
RArunrajRArunraj

Vfpage:

 

<apex:page controller="Sample">    

<apex:pageBlock>        

Value from Controller is : {!discount}        

<apex:form>            

Textbox Value from controller is: <apex:inputText value="{!discount}"/>        

</apex:form>    

</apex:pageBlock> 

</apex:page>

 

Interface:

 

public interface PurchaseOrder {    

Double getDiscount();

 }


ApexClass:

 

public class Sample implements PurchaseOrder {        

Double discount;  

public void setDiscount(Double disc) {        

discount = disc;      

 }  


public Double getDiscount() {                

return 1.22;        

}

}

 

Thanks,

Arunraj

All Answers

RArunrajRArunraj

Hi,

 

Interface

 

public interface PurchaseOrder {    

Double discount(); 

}

 

Class

 

public class Sample implements PurchaseOrder {
public Double discount(){        

return 1.22;    

}

}

 

 

Thanks,

R. Arunraj

vibrationvibration

Where to create a interface in salesforce?

RArunrajRArunraj

AppSetup --> Develop  --> Apex classes --> click new button --> copy and paste the interface code and save it.

 

 

Thanks,

Arunraj

komathipriyakomathipriya

How to get the return value in VS page??

 

RArunrajRArunraj

Apex class

 

public class SampleController {

 

public String getVFName() {

         return 'Arun';

}

 

}

 

Vfpage:

 

<apex:page controller="SampleController ">

Name is : {!vfName}

</apex:page>

 

 

Thanks,

Arunraj

vibrationvibration

i call discount value in textbox in pages.

komathipriyakomathipriya

i'm getting the error 

 Class must implement the public interface method: Double discount()  

if i add get to the discount.

 

RArunrajRArunraj

Vfpage:

 

<apex:page controller="Sample">    

<apex:pageBlock>        

Value from Controller is : {!discount}        

<apex:form>            

Textbox Value from controller is: <apex:inputText value="{!discount}"/>        

</apex:form>    

</apex:pageBlock> 

</apex:page>

 

Interface:

 

public interface PurchaseOrder {    

Double getDiscount();

 }


ApexClass:

 

public class Sample implements PurchaseOrder {        

Double discount;  

public void setDiscount(Double disc) {        

discount = disc;      

 }  


public Double getDiscount() {                

return 1.22;        

}

}

 

Thanks,

Arunraj

This was selected as the best answer
vibrationvibration

Thank u