java - Show FacesMessage and reload Page in JSF -


I am sending emails from the JSF application. I need that when I send an email, the FaceSmase is displayed, the action is confirmed and the browser is reloaded on the same page. I have shown this code but it does not reload the same page.

  Send Public String Email () {// Send Email Code ..... Transport.send (Message); FacesContext.getCurrentInstance (). AddMessage (empty, new FacesMessage (FacesMessage. SEVERITY_INFO, "Success \ n", "You've successfully sent an e-mail:" + e_mail + ". \ N" Thanks "); "E-mail redirect-true" return; }   

This is what I have tried, this code reloads the page, but FacesMessage is not shown.

  Send public string email () {// send email code ..... Transport.send (message); FacesContext.getCurrentInstance (). AddMessage (empty, new FacesMessage (FacesMessage. SEVERITY_INFO, "Success \ n", "You've successfully sent an e-mail:" + e_mail + ". \ N" Thanks "); FacesContext reference = FacesContext.getCurrentInstance (); HttpServletRequest origRequest = (HttpServletRequest) context.getExternalContext (). GetRequest (); String reference = rootRequest.getContextPath (); FacesContext.getCurrentInstance (). GetExternalContext (). Redirect (textText + "/faces/Email.xhtml"); "E-mail redirect-true" return; }   

and send my email to the email page here:

  & lt; h: form & gt; & Lt; P: Show the gurran id = "growl" dipet = "true" /> & lt; P: panel header = "send email" style = "width: 70%" & gt; & Lt; h: Panel Grid Column = "2" & gt; & Lt; H: Output Label Value = "E-Mail Address:" /> & Lt; H: Input Text = "# {mailing.e_mail}" style = "width: 400px" /> & Lt; h: outputtext value = "subject:" /> & Lt; H: Input text = "# {mailing.subject}" style = "width: 400px" /> & Lt; h: Output Text Value = "Message:" /> & Lt; H: InputTextraValue = "# {mailing.mess}" style = "height: 300px; width: 700px" /> & Lt; H: panelGroup / & gt; & Lt; p: command button value = "send mail" action = "# {mailing.sendEmail ()}" Ajax = "false" /> & Lt; / H: panelGrid & gt; & Lt; / P: Panel & gt; & Lt; / H: form & gt;   

Please

You should set the object if you have a A new opportunity introduced in JSF2 is flash and wants to preserve FacesMessages on the redirect. The scope (and the built-in EL object flash ) is for the storage of the "content" short term (which means that you want to keep it for some time).

Try the following line before redirecting:

  FacesContext.getCurrentInstance (). GetExternalContext (). GetFlash () SetKeepMessages (true);  

> / Ul>

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -