4

What does Visualforce field component resolvable mean?

I tried to bind columns editor to a list of custom Apex class instances, and naturally ran into this error. Rather than taking the workaround and breaking this up into inputXXX's I would prefer to modify the class to make it VF friendly. However, nobody seems to know what "Visualforce field component resolvable" means.

Do I need to decorate the class? Add specific metadata methods? Any ideas?

This is NOT a duplicate question. My question relates to the second part of the description provided by the error message, stating that inputfield needs SOQL objects OR Objects that are Visualforce field component resolvable, which is not covered by the other answer.

Example:

public class Item {
    public Boolean Selected { get; set; } 
}

public List<Item> Items;

VF

<apex:pageBlockTable value="{!Items}" var="item" >
    <apex:column headerValue="Select" >
        <apex:inputField value="{!item.Selected}" />
    </apex:column>
</apex:pageBlockTable>

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

To reiterate again, I know that inputField works with SOQL, what I want to know about is the meaning and implementation of the second part of the error message. How can one go about making a custom class VF inputField friendly.

  • 2
    The docs state that apex:inputField is only used for Salesforce object fields. Is there any reason you cant use apex:input instead? – battery.cord Aug 15 '16 at 14:41
  • @battery.cord, among other things, I would prefer to use the inputField because of the richness of editors. If I can make this class work, I can also make one with the Date field work and show a proper date selection input. – mmix Aug 15 '16 at 15:19
  • Also, apex:input, and generally HTML5 client side validation, doesn't work very well with apex:actionRegions. – mmix Aug 15 '16 at 15:21
3

See @batterycord - inputfield can only be bound to SObject fields. Same with outputField

However, to exploit the user interface controls supplied by VF, you can consider using proxy sobjects

public class Item {
   public User u;   // the proxy object to provide a checkbox control
}


<apex:pageBlockTable value="{!Items}" var="item" >
   <apex:column headerValue="Select">
    <apex:inputField value="{!item.u.IsActive}" />
   </apex:column>
</apex:pageBlockTable>
| improve this answer | |
  • That's exactly what we are doing now, we actually have a specialized SOQL object that is only used to house fields for apex:inputField. See here. That's why I generally asked this question, dropping this fake SOQL object for an Apex class would be a win-win. – mmix Aug 15 '16 at 17:10
  • mmix - I don't know of any other solution; rather than the fake sobject, I've used Opportunity.CloseDate for proxy dates, Opportunity.Amount for proxy currencies, etc. – cropredy Aug 15 '16 at 17:34
0

I can't find offical documentation for this right now but it seems apex:inputField needs metadata to function correctly. And normal apex variables does not has this metadata. If you want to use inputField you can wrap an sObject then use it in inputField. (As being only method and the one you already use.)

| improve this answer | |
0

We've only seen two things in the wild that are "Visualforce field component resolvable":

  1. Schema.SObjectField
  2. Schema.FieldSetMember

The FieldSetMember has to be used to dereference a specific field off a specific related SObject :(

| improve this answer | |

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.