function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MellowRenMellowRen 

InputField just as a variable, possible?

Hi, I might be missing something very simple here.

 

Is it possible to use InputField, or an alternate tag, that is not connected to a field in the database? ie It is for entering a value that is passed to the controller but isn't stored once the record is saved. Essentially, I'd like the user interface to have a set of fields that the user can enter data in, the controller processes that data and populates a "real" field—a helping-to-ensure-the-quality-of-data thing.

 

I could simply create extra fields in the database but having storage set aside for data that has no value and will never be used ever again irks me a bit.

 

Or is this the only option?

 

Regards

MellowRen

Best Answer chosen by Admin (Salesforce Developers) 
DaveHDaveH

Sure, if the field is text you can use apex:inputText, apex:inputCheckbox for check boxes etc. There are also the corresponding output elements (outputText, outputCheckbox).

All Answers

DaveHDaveH

Sure, if the field is text you can use apex:inputText, apex:inputCheckbox for check boxes etc. There are also the corresponding output elements (outputText, outputCheckbox).

This was selected as the best answer
MellowRenMellowRen

Oh.

 

Thanks DaveH, I'll go and reread about those tags—I completely misinterpreted what they were for.

 

In most cases I guess will want the users to enter numbers but I guess I can use the InputText and have the Apex code validate and convert it as a value. Is that what most people would do?

DaveHDaveH
Yea for numbers just use the inputText element then convert them in your controller using Integer.valueOf().
MellowRenMellowRen

Nice, thank you very much.

 

PS: The first line of the InputText page in the manual says:

 

Use this component to get user input for a controller method that does not correspond to a field on a Salesforce object.

 Sigh :-/