5

There is any way to create an standard input field on VF without bind it to an SObject field ?

I was searching on G unsuccessfully.

My approach was something like this:

 <vapex:inputField label="My Input" required="true" >

But I got this error:

value for <apex:inputField> is not a dynamic binding! 

Also,I've tried to assign a controller variable:

//class
public string myVar{get;set;}

//vp page
 <apex:inputField value="{!myVar}" required="true" />

Error:

Error: Could not resolve the entity from <apex:inputField> value binding '{!myVar}'. <apex:inputField> can only be used with SObject fields.

I need to add some inputs in order to make a filter using javascript. It is hard to believe for me that VF has not the option to make a simple input (resolving styling, labeling, etc)

6

<apex:inputField /> when bound to an sObject uses the field type that it is bound to in order to determine what type of HTML to render, including the label. If you are not interested in adding an sObject to the controller in order to provide binding for an inputField tag, your next options are:

  • <apex:inputCheckbox />
  • <apex:inputFile />
  • <apex:inputHidden />
  • <apex:inputSecret />
  • <apex:inputText />
  • <apex:inputTextarea />

These can be bound in the way that you attempted in the question, with myVar. You would also need to use the <apex:outputLabel /> tag in order to render a label. The association between the label and the input are made through the for attribute on the label and the id attribute on the apex:input tag.

4

You can of course use apex:inputText to retrieve data, but you lose the styling. Alternatively, you can use a temporary SObject instance created in Apex solely for the purpose of having the automatic styling. Then when the user clicks Save or whatever, transfer the temporary SObject data to the member vars you want them to reside in.

0

You can use <apex:inputText>. In this case you will have to create a property in controller and have to bind this with that property.

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.