Call javascript function not managed bean

0

I'm using the JSF framework with primefaces 6.0 and as I'm new, I'm having trouble calling a javascript when finalizing a method with a @RequestScoped scope bean. How can I do this? Is there any other way using this scope?

I want to call a script to show a feedback notification of the result to the user.

Remembering that there may be some error when starting the page in @PostConstruct init, bean initializer method, so I need to call the script without the action of a button.

    
asked by anonymous 07.09.2016 / 17:14

1 answer

2

But is Javascript really necessary?

Since you use Primefaces, I think it would be ideal to have a p: messages or p: growl component on the screen and add your message to the bean at the end of the method using:

//... Seu código
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"Feedback para o usuário"));

I usually encapsulate this code in an addMessage () method of a superclass, but it's up to you.

    
09.09.2016 / 06:33