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

Passing custom object fields to controller through visualforce page
Hi All,
I am new to salesforce developemnt.
I want to know, how I can access fields from custom objects to my apex controller through visualforce page.
To be more detail about my question -
- I have a custom object 'shipment' and some fields created for that object (Fileds are like dropdown, multiselect, long text etc)
- I have visual force page and I am not able to show fields like drop down list with values defined in my custom object (values are predefined in object fields with type as picklist) Anyone knows how I can do that ?
- and after that I want to send those values to my controller from my visualforce page where I can write my actual business logic and process that data.
Let me know if I am not clear. Thanks is advance.
Best Regards,
Abhishek
I am new to salesforce developemnt.
I want to know, how I can access fields from custom objects to my apex controller through visualforce page.
To be more detail about my question -
- I have a custom object 'shipment' and some fields created for that object (Fileds are like dropdown, multiselect, long text etc)
- I have visual force page and I am not able to show fields like drop down list with values defined in my custom object (values are predefined in object fields with type as picklist) Anyone knows how I can do that ?
- and after that I want to send those values to my controller from my visualforce page where I can write my actual business logic and process that data.
Let me know if I am not clear. Thanks is advance.
Best Regards,
Abhishek
In MVC stucture you have difined the a object called Shipment so you have difiend the Model Layer.
Now you need to show the value on page so you need a controller(your apex class) and page (view).
Suppose you have a object "Shipement". In object schema you will find the API name of this object like "Shippment__C". And suppose you have dified two fields X and Y and the api name wil be X__c and Y__c respectly.
Your apex class will be
your page code
This link will hepl you.
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_custom.htm
if it helps you then please mark as solution
I was trying the code u pasted above. I am not getting data from anywhere as of now.
So my constructor is empty and not like the one you mentioned above. I just initialized the variables x and y to 0 value.
and when I hit on save button which I created on my visualforce page, I m calling save method from my controller. There I am just trying to print the value of x and y and I am getting error as :
10:41:12.037 (37287047)|EXCEPTION_THROWN|[14]|System.NullPointerException: Attempt to de-reference a null object
10:41:12.037 (37466224)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object
Any idea about this ?
Thanks,
Abhishek
public class Sushi {
public Sushi__c sushiObj{get;set;}
public Sushi() {
sushiObj.Name__c = '';
}
public PageReference save() {
//String strX = ApexPages.currentPage().getParameters().get('X');
System.Debug('This is : ' + sushiObj.Name__c);
return null;
}
}
Visualforce :
<apex:page standardController="Sushi__c(**this is object api name**)" extensions="Sushi (** this is controller name**)">
:
:
<apex:pageBlockSection title="Basic Information" columns="2">
<apex:inputText label="Customized E-mail Text" value="{!sushiObj.Name__c}"/>
</apex:pageBlockSection>
Thanks,
Abhishek