1

我的项目中有一个 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)

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

4

1 回答 1

2

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

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

在这里,您出于某种原因eventName解决了问题并获得了NPE。它似乎与这个Primefaces 错误有关。null

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

于 2013-10-26T23:38:02.740 回答