Given the following enum
.
public enum Constants
{
PAGE_LINKS(10);
//Other constants as and when required.
private final int value;
private Constants(int value){
this.value = value;
}
public int getValue(){
value;
}
}
This enum
is placed under an application scoped bean like so,
@ManagedBean
@ApplicationScoped
public final class ConstantsBean
{
private Constants constants;
public ConstantsBean() {}
public Constants getConstants() {
return constants;
}
}
How to access the value of PAGE_LINKS
in EL?
<p:dataGrid pageLinks="#{}".../>
What should be written in #{}
? Is it possible?
EDIT:
Modifying the bean in the following way,
@ManagedBean
@ApplicationScoped
public final class ConstantsBean
{
public ConstantsBean() {}
public int getValue(Constants constants) {
return constants.getValue();
}
}
and then accessing in EL like so,
<p:dataGrid pageLinks="#{constantsBean.getValue('PAGE_LINKS')}".../>
somehow works but I don't believe in this ugly way.
#{constantsBean.constants.value}
should work for you. – Trundle