You need to sign in to do that
Don't have an account?
Melissa Howard
VF lookup field not working
I have an extended controller for the Contact object that is not being picked up by Visualforce.
The VF line that isn't working is the which I want to be a lookup field is:
<apex:inputField id="RequestedBy" value="{!contactSetting}" />
Error =
<apex:form >
<apex:pageBlock title="Foodbank of Santa Barbara County Volunteer Information">
<apex:pageBlockSection columns="1">
<!-- <b>Input Date :</b><apex:inputfield value="TODAY"/> This gives error, even if value="7/21/2014"
<apex:outputLabel value="Lookup Contact" for="ContactLookup"/
<apex:inputField id="RequestedBy" value="{!contactSetting}" />
The APEX is:
public with sharing class ContactExtendedController {
public Contact contactSetting{get;set;}
public ContactExtendedController(ApexPages.StandardController Contact) {
contactSetting=new Contact();
}
public ContactExtendedController() {
contactSetting = [SELECT Id, Name FROM Contact
WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
// if (contactSetting == null)
// System.debug('Contact Doesn't Exist. Contact the Foodbank.');
}
}
The VF line that isn't working is the which I want to be a lookup field is:
<apex:inputField id="RequestedBy" value="{!contactSetting}" />
Error =
Error: Could not resolve the entity from <apex:inputField> value binding '{!contactSetting}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable. |
<apex:form >
<apex:pageBlock title="Foodbank of Santa Barbara County Volunteer Information">
<apex:pageBlockSection columns="1">
<!-- <b>Input Date :</b><apex:inputfield value="TODAY"/> This gives error, even if value="7/21/2014"
<apex:outputLabel value="Lookup Contact" for="ContactLookup"/
<apex:inputField id="RequestedBy" value="{!contactSetting}" />
The APEX is:
public with sharing class ContactExtendedController {
public Contact contactSetting{get;set;}
public ContactExtendedController(ApexPages.StandardController Contact) {
contactSetting=new Contact();
}
public ContactExtendedController() {
contactSetting = [SELECT Id, Name FROM Contact
WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
// if (contactSetting == null)
// System.debug('Contact Doesn't Exist. Contact the Foodbank.');
}
}
You should use:
<apex:inputField id="RequestedBy" value="{!contactSetting.Name}" />
instead of
<apex:inputField id="RequestedBy" value="{!contactSetting}" />
Because "contactSetting" is returning object, not a field value.
try this...example...
<apex:page controller="custlookup">
<apex:form >
Account <apex:inputField value="{!c.CampaignID}"/>
</apex:form>
</apex:page>
public with sharing class custlookup {
public Oppourtunity c { get; set; }
public anand_custlookup(){
c = new Oppourtunity();
}
}
then only find out extact answer
Always remember that Inputfield tag can be used only when you are accessing the sObject Fields...
To do that first you need to create a handler of the type sObject and use this handler in Vf to access the fields...
check the following example...
<apex:page controller="Cust_cntrl">
<apex:form >
First Name<apex:inputField value="{!c.FirstName}"/>
</apex:form>
</apex:page>
public with sharing class Cust_cntrl{
public Lead c { get; set; }
public Cust_cntrl{
c = new Lead();
}
}
Thanks.