Jsf can close browser tab with bean?

My application manages the software, and for the convenience of users, I want to allow them to open several tabs to change the settings of more than one record at a time. But, having finished everything that they do, the tabs remain open, and I received some complaints about this. So basically my question is:

If there is a way to close a browser tab that sends a request to a method in my bean support? eg:

JSF Page:

<h:commandButton value="Public score"
   action="#{assignmentBean.publicSelected()}">                        
</h:commandButton>

Bean Method:

public void publicSelected() {
    application.setAssignmentStatus(done);
    dataAccess.mergeEntity(application);
}

Is there a way to add something after merging the command and close the browser tab that activated the method? thanks for the help

FULL CODE FOR SOLUTION . I am poorly versed in JS and JSF, so for any of you who are also bad at this, I am posting the full code using the Tiago Vieira Dos Santos hint.

:

<h:commandButton value="Public score"
   action="#{myBean.doThings}">    
   <f:ajax execute="@this" onevent="pop"/>                    
</h:commandButton>

:

<script type="text/javascript">
    function pop(data){
        if(data.status == "success"){
            window.close();
        }
    }
</script>

, , , .

+4
2

, javascript Window.close(), oncomplete tag bean FacesContext.

?

+2

OutputLink Javascript

<h:outputLink onclick="window.open('popup.faces', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no'); return false;" value="#">
        <h:outputText value="open popup" />
</h:outputLink>

. , . , , .

, , .

<h:commandLink actionListener="#{bean.openPopupClicked}" value="open popup" />

public void openPopupClicked(ActionEvent event) {
    // code to open a new browser window goes here
}
+1

Source: https://habr.com/ru/post/1535564/


All Articles