I am getting the nickname from an inputField and updating a list of strings and displaying the list of strings on a table. The outputField displays the newly entered value, but the controller variable seems to store the previous value even when I use the same {!Object.nickName} as the value attribute in both cases.


1) when I enter "1": Output box: 1, List retrieved from controller: (nothing)

2) Enter "2": Output box: 2, List retrieved from controller: 1

What is the issue here? Why is the same {!Object.nickName} retrieving two different values when it is an outputField vs controller variable(system debug/pageblocktable)

Vf Page:

    function checkName() {
        updateNicknameList( $('input[id$=Name]').val());

<apex:form >

    <apex:actionFunction name="UpdateNicknameList" action="{!updateNicknameList}" immediate="true" rerender="nicknameDisplay">
        <apex:param name="Name" value=""/>
    <apex:inputField id="Name" value="{!Object.nickName}" onblur="checkName()"/>    
    <apex:outputField value="{!Object.nickName}"/>
    <apex:commandLink value="Add nickname" action="{!processLinkClick}">
        <apex:param name="nickName" value="{!Object.nickName}" assignTo="{!nickName}"/>
    <Code Displaying the nicknames as a table>
</apex:form >


//Defining standard controllers

//Constructor initializes data members

public void updateNicknameList() {
        String Name = '';
        if (ApexPages.currentPage().getParameters().get('Name') != null) {
            Name = ApexPages.currentPage().getParameters().get('Name');
            this.Object.nickName = Name;
public PageReference processLinkClick() {
        return null;

add a debug statement and check what your controller receives.

in addition see this Post in the DeveloperForce forum http://boards.developerforce.com/t5/Apex-Code-Development/How-do-I-pass-value-of-apex-inputField-to-Custom-Controller/td-p/532905

  • Yes I was checking values with debug statements, the issue seems to be with the way I was passing the input field in the script: updateNicknameList( $('input[id$=Name]').val()); – srdev_salesforce May 14 '13 at 15:16

I was checking values with debug statements and alerts, the issue seems to be with the way I was passing the input field in the script:

updateNicknameList( $('input[id$=Name]').val());
<apex:inputField id="Name" value="{!Object.nickName}" onblur="checkName()"/> 

When I tried the method used in the above link from Seb__Wagner, the issue is resolved:

updateNicknameList( document.getElementById(name).value );
<apex:inputField id="check" value="{!Object.nickName}" onchange="checkName('{!$Component.check}');"/>

Thanks Seb__Wagner, this issue had been eating my head yesterday.


I don't understand why you're using ActionFunction to post Object.nickName to controller, then in controller set the Object.nickName again. As you're using a bind variable for inputField, the controller will automatically update with a new value once you click on your commandLink.

Essentially your page will function with the following page code (with no additional javascript):

<apex:inputField id="Name" value="{!Object.nickName}" />    
<apex:outputField value="{!Object.nickName}"/>
<apex:commandLink value="Add nickname" action="{!processLinkClick}" reRender="nicknameTable" />
<Code Displaying the nicknames as a table>

and controller:

public PageReference processLinkClick() {

    return null;

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.