Parameters in Static attribute

0

I have the following attributes in my class:

static String URL="jdbc:jtds:sqlserver://blablabla; databaseName=Pxx";    
static String usuario;  
static String password ;  
static String DRIVER="net.sourceforge.jtds.jdbc.Driver";

I would like to pass parameters to the user and password attribute through a screen with 2 inputs :

<label>&nbsp;&nbsp; Usuário: <h:inputText value ="#{sql_controle.parans.usuario}"/></label>
    <label>&nbsp;&nbsp; Password: <h:inputText value ="#{sql_controle.parans.password}"/></label>
    <br></br><br></br>
    <p:commandButton value="CRIAR CONEXÂO" class ="btnSalvar" 
    action="#{sql_controle.createParam()}" onclick="#"/>

Except that they are not getting the parameters any attribute of another class that uses this procedure not being static works. I would like to know how to do this in attributes of type static .

    
asked by anonymous 28.09.2016 / 19:46

1 answer

0

JSF uses the Controller getters and setters to transfer the information from the View to the Controller. We do not use getters and setters on static members (maybe getters .. hehe) That way, you should create some public method that passes the information to your static members. Try something like this:

public void passaValorUsuario(String usuario) {
    SuaClasse.usuario = usuario;
}

: -)

    
29.09.2016 / 18:33