0

I am trying to get an input field value to reference a standard controller extension property.

Here is my controller extension:

public class LicenseActivationController {
    private final Contact contact;

    public LicenseActivationController(ApexPages.StandardController controller) {
        contact = (Contact)controller.getRecord();
    }

    public String activationID { get; set; }

    public String computerID { get; set; }
}

Here is my VisualForce page:

<apex:page standardController="Contact" extensions="LicenseActivationController">
    <apex:form>
        <apex:pageBlock title="License Activation">
            <apex:pageBlockSection columns="1">
                <apex:inputField value="{!activationID}" />
                <apex:inputField value="{!computerID}" />
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Activate" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

As you can see, I am trying to use activationID and computerID properties in the corresponding inputField, but the error I get is:

Error: Could not resolve the entity from value binding '{!activationID}'. can only be used with SObjects, or objects that are Visualforce field component resolvable.

How can I achieve extending the Contact controller and using properties inside the extension class like I am trying to do here?

4

Since those are not fields on an sObject you will need to use

<apex:inputText value="{!activationID}" />

If those are an Id to another object a trick is to create a property in the controller as a dummy sObject

public contact con {get; set;}

Then in your page use

<apex:inputField value="{!con.AccountId}"/>

for example to get the account lookup. Then in the controller simply reference con.AccountId to put where you really need it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.