aspose file tools*
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
JavaRanch » Java Forums » Java » JSF
Bookmark "valuechangelistener - oldvalue is always null" Watch "valuechangelistener - oldvalue is always null" New topic
Author

valuechangelistener - oldvalue is always null

glenn
Greenhorn

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) )
{
event.setPhaseId(toPost);
event.queue();
return;
}
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");
return;
}

etc............ do some mgt bean setting
}
// Remain in edit mode
setEditMode(true);
}

}


Page Call:
<apm:selectOneMenu id="SelectedTemplate" style="width: 30%;"
onchange="submit();"
valueChangeListener="#{TaskController.processSelectedTemplate}"
value="#{TaskController.templateId}">
<j:selectItem itemLabel="" itemValue="" />
<j:selectItems value="#{TemplateList.templatesForPractice}" />
</apm:selectOneMenu>


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" />
</apm:selectOneMenu>

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) )
{
event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
event.queue();
return;
}

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

// 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()))
{
this.setNotificationRequired(true);
}

}



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

Any ideas would be much appreciated!!!

Thanks
 
Don't get me started about those stupid light bulbs.
 
subject: valuechangelistener - oldvalue is always null