Sunday, June 15, 2014

How to use apex:inputField in Visualforce Page?

How to use <apex:inputField>  in Visualforce Page?

<apex:inputField >:
This tag helps to display fields of any standard or custom object (Any Sales force Object) on the visualforce page. The <apex:inputField > component respects the attributes of the associated field, including whether the field is required or unique, and the user interface widget to display to get input from the user. For example, if the specified < apex:inputField > component is a date field, a calendar input widget is displayed. The above behaviour is shown only when the tag is used inside a pageblocksection component.

When used in an < apex:pageBlockSection >, < apex:inputField > tags always display with their corresponding output label.

This tag supports following attributes:
Attribute
Description
id
An identifier that allows the inputField component to be referenced by other components in the page.
label
A text value that allows you to override the default label that is displayed for the field. You can set label to an empty string to hide the label on forms. Setting it to null is an error.
onblur
The JavaScript invoked if the onblur event occurs that is, if the focus moves off of the field.
onchange
The JavaScript invoked if the onchange event occurs that is, if the user changes the content of the field.
onclick
The JavaScript invoked if the onclick event occurs that is, if the user clicks the field.
ondblclick
The JavaScript invoked if the ondblclick event occurs that is, if the user clicks the field twice.
onfocus
The JavaScript invoked if the onfocus event occurs that is, if the focus is on the field.
onkeydown
The JavaScript invoked if the onkeydown event occurs that is, if the user presses a keyboard key.
onkeypress
The JavaScript invoked if the onkeypress event occurs that is, if the user presses or holds down a keyboard key.
onkeyup
The JavaScript invoked if the onkeyup event occurs that is, if the user releases a keyboard key.
onmousedown
The JavaScript invoked if the onmousedown event occurs that is, if the user clicks a mouse button.
onmousemove
The JavaScript invoked if the onmousemove event occurs that is, if the user moves the mouse pointer.
onmouseout
The JavaScript invoked if the onmouseout event occurs that is, if the user moves the mouse pointer away from the field.
onmouseover
The JavaScript invoked if the onmouseover event occurs that is, if the user moves the mouse pointer over the field.
onmouseup
The JavaScript invoked if the onmouseup event occurs that is, if the user releases the mouse button.
onselect
The JavaScript invoked if the onselect event occurs that is, if the user selects a checkbox associated with this field.
rendered
A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true.
required
A Boolean value that specifies whether this inputField is a required field. If set to true, the user must specify a value for this field. If not selected, this value defaults to false. Note that if this input field displays a custom object name its value can be set to nil and will not be required unless you set this attribute to true. The same does not apply to standard object names, which are always required regardless of this attribute.
style
The CSS style used to display the inputField component. This attribute may not work for all values. If your text requires a class name, use a wrapping span tag.
styleClass
The CSS style class used to display the inputField component. This attribute may not work for all values. If your text requires a class name, use a wrapping span tag.
taborderhint
A hint to indicate the relative order in which this field is selected compared to other page components when a user presses the Tab key repeatedly. This value must be an integer between 1 and 3276, with component 1 being the first component that is selected when a user presses the Tab key.
value
A merge field that references the Salesforce field that is associated with this inputField. For example, if you want to display an input field for an account's name field, use value="{!account.name}". You cannot associate this inputField with a formula merge field of type currency if your organization is using dated exchange rates.


Visualforce Eample:

<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.site}"/>
                <apex:inputField value="{!account.type}"/>
                <apex:inputField value="{!account.accountNumber}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
   </apex:form>
</apex:page>


save image





0 comments:

Post a Comment

 
| ,