Instance classes and execute java methods from jsf

1

I'm doing a webservice, and I have several JSF Managed Bean methods, and I need to instigate the class and invoke the methods by sending parameters type String from a JSF page that is of .xhtml extension.

I do not need it to invoke from a button, but when I open the form it does it automatically. What label can I use and where?

Thank you very much

    
asked by alejoecheverri444 08.03.2017 в 18:51
source

1 answer

0

It is very simple, what you have to do once you have defined your Bean is to create a method with the @PostConstruct annotation, this indicates the method that should be executed after the construction of the bean.

@ManagedBean(name = "beanEjemplo") 
@SessionScoped
public class Bean{
   private String nombre;

   @PostConstruct
   public void iniciaMensaje(){
      nombre = "Este mensaje se muestra en la vista"
   }

   public void getNombre(){
     return nombre;
   }
   public String setNombre(String nombre){
      this.nombre = nombre;
   }
}

and nothing else you have to call in your sight. I hope I have helped

    
answered by 31.05.2018 в 20:53