Parameters in Static attribute

Asked

Viewed 86 times

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 attribute and password 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="#"/>

Only that they are not receiving the parameters any attribute of another class that uses this procedure is not static works. I would like to know how to do this in attributes like static.

1 answer

0

JSF uses Controller getters and setters to transfer information from View to Controller. We don’t use getters and setters on statics (maybe getters.. hehe) This way, you should create some public method that passes the information to your state members. Try something like this:

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

:-)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.