This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes valuechangelistener - oldvalue is always null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "valuechangelistener - oldvalue is always null" Watch "valuechangelistener - oldvalue is always null" New topic

valuechangelistener - oldvalue is always null


Joined: Aug 06, 2001
Posts: 8
We are using Xhtml, jSF and Tomahawk so the pages below ae in XHTML.

However, I have a valuechangelistener in sernario 1 that only returns an OLDVALUE of NULL when event.getOldValue() is called. The corresponding web page triggered this event by an onchange="submit"

Senario 1:
Listener Call :
public void processSelectedTemplate(ValueChangeEvent event)
PhaseId phase = event.getPhaseId();
PhaseId anyPhase = PhaseId.ANY_PHASE;
PhaseId toPost = PhaseId.UPDATE_MODEL_VALUES;

if (phase.equals(anyPhase) )
else if (event.getNewValue() != null)
// get the value of the chosen template
templateId = (Long)event.getNewValue();

if (templateId==null)
logger.warn("TemplateId null while processing Assignee change event");

etc............ do some mgt bean setting
// Remain in edit mode


Page Call:
<apm:selectOneMenu id="SelectedTemplate" style="width: 30%;"
<j:selectItem itemLabel="" itemValue="" />
<j:selectItems value="#{TemplateList.templatesForPractice}" />

Senario 2
I also have another valuechangelistener not triggered by an onchange="submit". Still does onyl returns NULL.

Page Call
<apm:selectOneMenu id="Task_assignedTo" value="#{WriteableTask.assignedTo.userId}" style="width: 30%;" valueChangeListener="#{TaskController.processAssigneeChange}">
<j:selectItem id="assigned1" itemValue="" itemLabel="Me" />
<j:selectItem id="assigned2" itemValue="rafiqr" itemLabel="Kevin Shock-Putter" />
<j:selectItem id="assigned3" itemValue="ellemen" itemLabel="Ray The Man" />
<j:selectItem id="assigned4" itemValue="siciliad" itemLabel="Tom Component-Man" />

Listener Call :
public void processAssigneeChange(ValueChangeEvent event)

// select the phase this should be executed in
PhaseId phase = event.getPhaseId();
if (!PhaseId.UPDATE_MODEL_VALUES.equals(phase) )

if (this.getTaskItem().getId()==null)
logger.warn("Task Id null while processing Assignee change event");

// load the task and check if old has changed - old value from hereis not working - allways null
TaskBase loadedTask = this.loadTask(this.getTaskItem().getId());
if(event.getNewValue()!=null && !event.getNewValue().equals(loadedTask.getAssignedTo().getUserId())
&& !"".equals(event.getNewValue()))


Note that even taking the code out of the listeners still returns NULL!

Any ideas would be much appreciated!!!

Consider Paul's rocket mass heater.
subject: valuechangelistener - oldvalue is always null
Similar Threads
JSF valuechangeListener not detecting a change for values entered manually in a text field.
JSF ValueChange problems and Default method where the form submits to
Display value of 'checked' radio button
[JSF 2] internationalization: UPDATE_MODEL_VALUES et INVOKE_APPLICATION phases are skipped
Make selection with h:selectOneMenu and redisplay the value in a h:outputText?