gpt4 book ai didi

java - Primefaces : Select Check Box menu : NullPointerException

转载 作者:行者123 更新时间:2023-11-30 04:10:57 24 4
gpt4 key购买 nike

我的项目中有一个 selectCheckBoxMenu 的实现。我的 xhtml 文件中的部分代码是:-

<p:row >
<p:column style=" width: 497px; text-align: right;">
<h:outputText for="toMails" value="To : " />
</p:column>
<p:column style=" width: 497px; text-align: left;">
<p:selectCheckboxMenu id="toMails" value="#{schedule.selectedEmailIds}" label="Mail Recipients" filter="true"
filterText="Filter" filterMatchMode="startsWith" panelStyle="width:220px">
<f:selectItems value="#{schedule.users}" />
</p:selectCheckboxMenu>
</p:column>
</p:row>

我的 Bean 类有代码:-

private String[] selectedEmailIds;  

private Map<String,String> users;

//Getters and Setters

//Value Loader Method
public void loadWorkFlowServices()
{
try
{
Map<String, String> tmpUsers = new HashMap<String, String>();
tmpUsers.put("Scarface", "Scarface");
tmpUsers.put("Goodfellas", "Goodfellas");
tmpUsers.put("Godfather", "Godfather");
tmpUsers.put("Carlito's Way", "Carlito's Way");
tmpUsers.put("Rang De Basanti", "Rang De Basanti");
tmpUsers.put("Despicable Me", "Despicable Me");
tmpUsers.put("The Dark Knight", "The Dark Knight");
setUsers(tmpUsers);
}
catch (Exception e)
{
LOGGER.error("Error while loading the workflow services.", e);
}
}

当我从下拉列表中选择任何值并提交时。我遇到异常 -

Error occurred while doing security check on URL hit
java.lang.NullPointerException
at org.primefaces.component.selectcheckboxmenu.SelectCheckboxMenu.queueEvent(SelectCheckboxMenu.java:199)
at javax.faces.component.UIInput.validate(UIInput.java:976)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)

我在网上找不到太多帮助。请提出我所缺少的内容。

最佳答案

查看您的错误,我一直在浏览 Primefaces 的 SelectCheckboxMenu 类,并找到了这段代码(Primefaces 3.5 SelectCheckboxMenu:199):

if(event instanceof AjaxBehaviorEvent && eventName.equals("toggleSelect"))

这里您的 eventName 由于某种原因解析为 null 并且您得到 NPE 。好像和这个有关Primefaces bug .

无论如何,您提供的代码在 4.0 版本中就像一个魅力,所以如果可以的话,您应该考虑升级。

关于java - Primefaces : Select Check Box menu : NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19608120/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com