0

For my current scenario I am populating a table with a list of Suppliers(Col1) and Count of Records(Col2) Assigned to them. For this I have used an aggregateresult and have created a new class Summary and have updated the table.

The problem now is I need to have another column in the table - that is editable - to enter the max no of records that could be assigned to him. For the editable column I tried to assign apex:InputField, but that doesnt work. I am getting an error "Could not resolve entity form apex:inputField value binding.

<apex:page controller="Sample" sidebar="false" action="{!show}">
<apex:pagemessages />
<apex:form >
    <apex:pageBlock >
        <apex:pageblockTable value="{!SummaryList}" var="r">            
            <apex:column headerValue="Supplier Name" value="{!r.SupplierName}"/>
            <apex:column headerValue="Number of Contacts" value="{!r.Total}"/>
            <apex:column headerValue="Percentage">
                <apex:inputField  value="{!r.percentage}"/>>
            </apex:column>
        </apex:pageblockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

The class in Apex Controller where the percentage field is initialized...

public class Summary {
    public Integer Total {get;set;}
    public String SupplierName{get;set;}
    public String Percentage{get;set;}

    public Summary(AggregateResult a, String Name) {
        Total =  (Integer)a.get('Total');
        SupplierName= Name;
    }
}

1 Answer 1

2
  1. Apex Input fields can't be used for non sObject types. And aggregate result and String aren't a proper sObject types.

An HTML input element for a value that corresponds to a field on a Salesforce object. - Doc apex:inputField

  1. Therefore you have to use <apex:inputText>

An HTML input element of type text. Use this component to get user input for a controller method that does not correspond to a field on a Salesforce object. - Doc apex:inputText

Besides from that please consider to use the constructor of your class instead of action methods.

The action method invoked when this page is requested by the server. Use expression language to reference an action method. For example, action="{!doAction}" references the doAction() method in the controller. If an action is not specified, the page loads as usual. If the action method returns null, the page simply refreshes. This method will be called before the page is rendered and allows you to optionally redirect the user to another page. This action should not be used for initialization. - Doc apex:pages

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .