1

Is it possible to create an apex tag like <apex:inputCheckBox> without binding to a column in the underlying object ?.

<!-- For this example to render properly, you must associate the Visualforce page 
with a valid opportunity record in the URL. 
For example, if 001D000000IRt53 is the opportunity ID, the resulting URL should be: 
https://Salesforce_instance/apex/myPage?id=001D000000IRt53
See the Visualforce Developer's Guide Quick Start Tutorial for more information. -->

<apex:page standardController="Opportunity" recordSetVar="opportunities" tabstyle="opportunity">
    <apex:form id="changePrivacyForm">
        <apex:pageBlock >
        <apex:pageMessages />
        <apex:pageBlockButtons>
            <apex:commandButton value="Save" action="{!save}"/>
        </apex:pageBlockButtons>

        <apex:pageBlockTable value="{!opportunities}" var="o">
        <apex:column value="{!o.name}"/>
        <apex:column value="{!o.account.name}"/>
        <apex:column headerValue="Private?">
            <apex:inputCheckbox value="{!o.isprivate}"/> //LINE 1
        </apex:column>
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

The above is an example from VF guide. As you can see from Line 1, the checkbox HTML element is tied to a field in the Opportunity object.

Is it possible to do just display this checkbox and bind it to a "variable" in Visualforce instead of having it to be bound to a field in the underlying object ?

My requirement is to obtain input via checkboxes from the user browsing this VF page and the UI selection that the user will be providing will be used only for page processing and need not be stored in the object. As such I want to know should I always to create fields in the object even for this purpose ?

1

You could use an HTML tag instead, and process the result with Javascript

<input type="checkbox" name="vehicle" value="Bike">

Or, you could create a boolean property in a custom controller and bind the input to that.

How are you intending to use the result in page processing? Your sample doesn't include a custom controller, nor does it include any javascript, so there don't appear to be any opportunities for custom page processing.

| improve this answer | |
  • "Or, you could create a boolean property in a custom controller and bind the input to that." This helped me..Tx – Varun Apr 18 '14 at 13:11

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.