N
N
Natalia Tsarkevich2014-02-07 02:04:10
Java
Natalia Tsarkevich, 2014-02-07 02:04:10

How to write value to hidden field in jsf?

On the page, you need to create a hidden field where you want to write data, but when you try to create such a field

<h:inputHidden value="#{informationController.token}" id="hide"/>

gives an error that there is no such field, although there is a field:
private String token;
and a getter:
public String getToken(){
        this.token = OAuth.getToken();
        return token;
}

If I try to write
<h:inputHidden value="#{informationController.getToken}" id="hide"/>

then he scolds me that there is no such function - but what's wrong? After all, everything is there - why can't they see each other?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DiLighteR, 2014-02-07
@DiLighteR

to write the value, jsf looks for the set Token method and doesn't find it. create a setter. and in value pass the field itself, not its getter, so the first option is correct

<h:inputHidden value="#{informationController.token}" id="hide"/>

R
Ruslan Lopatin, 2014-02-08
@lorus

This is a bug, it seems. Maybe in PrimeFaces. Googling your error gives this link with a suggestion to bypass it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question