我的问题是关于这个primefaces标签:
<p:selectManyMenu>
它根本不会呈现任何可见的输出(复选框)。从日志记录输出我知道&#39; sessionBean.getAllDatasourceGroups()&#39;在页面刷新期间甚至不调用一次方法。只有&#39; sessionBean.getDatasourcegroups()&#39; getter for the&quot; datasourceGroups&#39;财产被召唤一次。
我无法弄清问题是什么。我在同一页面上有<p:selectOneMenu>
和@ManagedBean
@SessionScoped
public class SessionBean implements Serializable {
private List<DatasourceGroup> datasourceGroups = new ArrayList<>();
public List<DatasourceGroup> getDatasourceGroups() {
return datasourceGroups;
}
public void setDatasourceGroups(List<DatasourceGroup> datasourceGroups) {
this.datasourceGroups = datasourceGroups;
}
public List<DatasourceGroup> getAllDatasourceGroups() {
List<DatasourceGroup> list = Arrays.asList(DatasourceGroup.values());
return list;
}
}
非常相似的用例,它们运行正常。所以我对它是如何工作的基本理解...或者我认为: - )
以下是代码的其他相关部分供参考:
的SessionBean:
public enum DatasourceGroup {
KUNDEN (Permission.ZugriffKunden),
INKASSO (Permission.ZugriffInkasso),
INTERESSENTEN (Permission.ZugriffInteressenten),
WARN (Permission.ZugriffWarnadressen);
private Permission permissionNeeded;
DatasourceGroup(Permission permission) {
this.permissionNeeded=permission;
}
public Permission getPermissionNeeded() {
return permissionNeeded;
}
}
DatasourceGroup Enum:
@FacesConverter("datasourceGroupConverter")
public class DatasourceGroupConverter implements Converter {
@Override
public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
if (Toolbox.isNullOrEmpty(value))
return null;
try {
return DatasourceGroup.valueOf(value);
} catch (IllegalArgumentException e) {
throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error:",
"'" + value + "' is not a valid datasource group name"));
}
}
@Override
public String getAsString(FacesContext fc, UIComponent uic, Object object) {
if(object != null && object instanceof DatasourceGroup) {
return ((DatasourceGroup)object).toString();
}
return null;
}
}
DatasourceGroupConverter:
c.setTime(new Date(new Date().getTime() + (1000 * 60 * 24)));
我顺便使用了primefaces 6.0。