我正在尝试使用单元格编辑器创建一个数据表。我有一个名为“组”的列,其中显示了组列表。单击单元格编辑器图标时,它会显示一个复选框菜单,用户可以在其中检查他们想要的任何组,然后单击提交。
我什至还没有我的 rowEditEvent 处理程序,并且我得到了一个集合不可修改的异常。我无法弄清楚我做错了什么,我得到了这个例外。
任何帮助表示赞赏。
group_admin.xhtml
<h:form>
<p:dataTable value="#{userBacking.users}" var="users" editable="true">
<p:column headerText="Groups">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{users.groups}" />
</f:facet>
<f:facet name="input">
<p:selectCheckboxMenu value="#{users.groups}" label="Groups">
<f:selectItems value="#{groupBacking.groupsAsSelectItems}" />
</p:selectCheckboxMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Actions">
<p:rowEditor />
</p:column>
</p:dataTable>
</h:form>
获取用户
public List<UserBean> getUsers() throws Exception {
ContentManager cm = null;
cm = getContentManager();
if(users == null) {
users = new ArrayList<UserBean>();
UserManager um = cm.getUserManager();
List<? extends Group> cmsGroups = um.getCmsDefinedGroups();
List<? extends User> allUsers = um.getAllUsers(0, Integer.MAX_VALUE);
// loop through each user
for(User u : allUsers) {
Set<? extends Group> groups = u.getGroups();
UserBean user = new UserBean();
user.setUserName(u.getUserName());
user.setGroups(groups); // THIS LINE CAUSES THE EXCEPTION
users.add(user);
}
}
return users;
}
用户Bean
public class UserBean implements User {
private String userName;
private String firstName;
private String lastName;
private Set<? extends Group> groups = null;
public UserBean() {}
public UserBean(String userName, String firstName, String lastName, Set<? extends Group> groups) {
this.userName = userName;
this.firstName = firstName;
this.lastName = lastName;
this.groups = groups;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return userName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Set<? extends Group> getGroups() {
return groups;
}
public void setGroups(Set<? extends Group> groups) {
this.groups = groups;
}
public void removeGroups() {
groups = null;
}
@Override
public boolean isDisabled() {
// TODO Auto-generated method stub
return false;
}
@Override
public UserProfile getProfile() {
// TODO Auto-generated method stub
return null;
}
}
堆栈跟踪
Oct 9, 2012 1:09:08 PM com.sun.faces.renderkit.html_basic.MenuRenderer createCollection
SEVERE: Unable to create new Collection instance for type java.util.Collections$UnmodifiableSet
java.lang.InstantiationException: java.util.Collections$UnmodifiableSet
at java.lang.Class.newInstance0(Class.java:340)
at java.lang.Class.newInstance(Class.java:308)
at com.sun.faces.renderkit.html_basic.MenuRenderer.createCollection(MenuRenderer.java:907)
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel(MenuRenderer.java:367)
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValue(MenuRenderer.java:129)
at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:315)
at org.primefaces.component.selectcheckboxmenu.SelectCheckboxMenuRenderer.getConvertedValue(SelectCheckboxMenuRenderer.java:34)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1028)
at javax.faces.component.UIInput.validate(UIInput.java:958)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1209)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1086)
at javax.faces.component.UIData.iterate(UIData.java:1501)
at javax.faces.component.UIData.processValidators(UIData.java:1026)
at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:485)
at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
at javax.faces.component.UIData.visitTree(UIData.java:1233)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1518)
at javax.faces.component.UIForm.visitTree(UIForm.java:335)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1518)
at org.primefaces.component.tabview.TabView.visitTree(TabView.java:400)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1518)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1518)
at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:366)
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:246)
at javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1163)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thre
广告.java:662)