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.
Test:
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:
<script>
function checkName() {
updateNicknameList( $('input[id$=Name]').val());
}
}
</script>
<apex:form >
<apex:actionFunction name="UpdateNicknameList" action="{!updateNicknameList}" immediate="true" rerender="nicknameDisplay">
<apex:param name="Name" value=""/>
</apex:actionFunction>
<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}"/>
</apex:commandLink>
<Code Displaying the nicknames as a table>
</apex:form >
Controller:
//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;
this.nickNameList.add(Name);
}
public PageReference processLinkClick() {
this.nickNames.add(nickName);
return null;
}