Call warning window from code for java in jsf

I have a requirement to update a properties file based on the input provided by the user on the jsf page. After updating the file, the user session should be cleared, and the warning field should indicate that "the setting has been updated," and the page should go to the login page.

I do not know how to call a warning window from java code. I found this to be possible in asp.net. I searched google but got no possible solution.

How can I make this possible?

All possible solutions are welcome. Thanks in advance.

UPDATE @balusc thanks for your pointer. I am using JSF RI 1.2 and Richfaces 3.3.2

+3
source share
5 answers

I was able to solve this problem using the "oncomplete" attribute on the a4j command line. The oncomplete attribute is used to call the javascript function after the server-side process completes.

After completing the process on the server side, I called the javascript function, which called the warning window and using

document.location="../login.jsf";

I went to the login page.

Any suggestions regarding this solution are welcome.

Thanks to everyone for the answers and comments.

+2
source

You can use the PrimeFaces dialog.

PrimeFaces is an open source component that enhances GUI and development.

, , , , .

+1

bean:

JavascriptContext.addJavascriptCall(facesContext, "alert('Setting has been updated');");

:

HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
session.invalidate();
+1

rich:modalPanel showWhenRendered, boolean bean. .

:

<a4j:outputPanel id="modalParent">
   <rich:modalPanel showWhenRendered="#{bean.someBooleanValue}">

   </rich:modalPanel>
</a4j:outputPanel>

/ reRender="modalParent"

+1

- this

<%

ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
HttpSession session = (HttpSession)ectx.getSession(false);
session.invalidate(); 
%>
<script type="text/javascript">
alert('Setting has been updated');
location.replace('/index.jsp');
</script>
0

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


All Articles