Your code looks fine...
One thing is change the ajax
event from KeyUp
to blur
.
KeyUp - Forces to call the listener method for every typing letter.
Blur - Forces to call the listener method when you left the text box after typing the content.
Here you need 'blur' event because you need to call the DB after entered the all empno
.
Make sure that the values are retrieved from DB, after changed the event
As for as my consern your DB value is not getting at workerNo()
when ajax listener forces.
JSF Code
<h:ouputText value="empno"/>
<p:inputText id="empno" value="#{bean.empno}">
<p:ajax event="blur" listener="#{bean.ajaxEvent}" update="empname"/>
</p:inputText>
<h:ouputText value="empname"/>
<p:inputText id="empname" value="#{bean.empname}">
Bean Code
//Setters and getters of empname,empno
public void ajaxEvent()
{
if(getEmpNo()==//DB empno)
{
setEmpName("DB empname"); //Here only your updating the name field
}
}