On a regular basis, I utilize a particular method, but I encounter an issue. There is a functionality that involves deleting a certain entity, however, I wish to notify the user who triggers this action with a commandLink by calling a JavaScript function confirm(str). If the confirmation result is false, I do not want it to trigger an Ajax function. As a solution, I decided to use the jsf.ajax.request function. Here is a snippet of my code:
<h:commandLink value="ajax" onclick="return ask(this,event,null,'page');" actionListener="#{test.ajax}"/>
<h:inputText value="#{test.page}" id="page"/>
Below is my JavaScript code:
function ask(element,event,exec,target){
if(confirm("Are you sure you want to delete it?"))
{
try{
jsf.ajax.request(element,event,{execute:exec,render:target});
}catch(ex){
alert(ex);
return false;
}
}else
return false;
}
After implementing this code, the function can execute successfully. However, I noticed that it does not work as an Ajax request. Additionally, other values in the backing bean are being updated as well! If someone could provide me with insights on this matter, I would be greatly appreciative!