Reputation: 1
I have this problem with JSF rendering. I have this bean containing boolean type value ulogovan
.
@Named("sessionBean")
@SessionScoped
public class SessionBean implements Serializable{
private boolean ulogovan;
private Zaposleni ulogovanZaposleni;
public SessionBean() {
ulogovan = false;
ulogovanZaposleni = null;
}
public boolean getUlogovan() {
return ulogovan;
}
public void setUlogovan(boolean ulogovan) {
this.ulogovan = ulogovan;
}
I have to show a form depending on a value of ulogovan
. Here is the begining of the form:
<h:form id="form" rendered="#{sessionBean.ulogovan == true}">
Upvotes: 0
Views: 1121
Reputation: 51
You can include @PostConstruct annotation on init() method. So before rendering the page this method will be called first. You can set the condition in this you wish
@Named("sessionBean")
@SessionScoped
public class SessionBean implements Serializable{
private boolean ulogovan;
private Zaposleni ulogovanZaposleni;
@PostConstruct
public void init() {
setUlogovan(false);
ulogovanZaposleni = null;
}
public boolean getUlogovan() {
return ulogovan;
}
public void setUlogovan(boolean ulogovan) {
this.ulogovan = ulogovan;
}
This will work definately.
Upvotes: 0
Reputation: 5011
Because ulogovan = false;
so when you said #{sessionBean.ulogovan == true}
that mean false == true
which is false
. Thus, your form will not be rendered unless you set ulogovan
to be true
.
If you want your form to be rendered depending on the value of ulogovan
, just do it like this:
<h:form id="form" rendered="#{sessionBean.ulogovan}">
Upvotes: 1