1

I have a VF page that has pageblock table on it which displays data from a list. I am trying to add a field from that list as a input field but I get the below error for the quantity field. How can I use a field from a list of non sObject as input field ?

<apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.

Code : Controller

public class TestController_NWL{
public class OrderProduct{
    public String materialNumber {get; set;}
    public Integer quantity {get; set;}
}
Public List<OrderProduct> orderProductsList {get; set;}
}

VF Page :

<apex:page controller="TestController_NWL">
<apex:pageBlockSection title="Products" columns="1">
    <apex:pageBlockTable value="{!orderProductsList}" var="op" title="Products">
        <apex:column headerValue="Material Number">
            <apex:outputLink onclick="alert('Success');">
                {!HTMLENCODE(op.materialNumber)}
            </apex:outputLink>
        </apex:column>
        <apex:column headerValue="Material Number">
            <apex:inputField value="{!op.quantity}" />
        </apex:column>                  
    </apex:pageBlockTable>
</apex:pageBlockSection>

2
  • I think , You can't use wrapper class variable in inputfield. <apex:inputfield> values must be a field from sobject. You can initiate a sobject in wrapper class if you want to use its in <apex:input> field. Hope it helps. Oct 6, 2014 at 22:21
  • Unfortunately i don't have a sObject in this case. I can create a dummy object with all these fields but it will be a waste as it would never have any data.
    – HSG
    Oct 6, 2014 at 22:27

1 Answer 1

4

If it's not an sObject field, you have to use one of the typed input tags. In your case, you would use <apex:inputText>.

Additional options include <apex:inputcheckbox and <apex:inputTextArea> to handle other data types.

2
  • That's what I needed. Thanks for the quick response : )
    – HSG
    Oct 6, 2014 at 22:45
  • Note that inputtext will always transmit a string value of zero length to the controller even if the user left the field empty on the form. This contrasts to inputField wherein no entry by the user sends null to the sobject field in the controller.
    – cropredy
    Oct 7, 2014 at 4:26

You must log in to answer this question.

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