PrimeFaces“组件标识符的第一个字符必须是字母或下划线”?

时间:2013-10-22 13:46:13

标签: jsf jsf-2 primefaces

我已从PrimeFaces 3.5切换到4.0。

我收到“tieredMenu”的错误:

java.lang.IllegalArgumentException: component identifier's first character must be a letter or an underscore ('_')! But it is "0"

我已将此跟踪到“BaseMenuModel.class”,方法是“generateUniqueIds”:

public void generateUniqueIds() 
{
    this.generateUniqueIds(getElements(), null);
}
 private void generateUniqueIds(List<MenuElement> elements, String seed) {
        if(elements == null || elements.isEmpty()) {
            return;
        }

        int counter = 0;

        for(MenuElement element : elements) {
            String id = (seed == null) ? String.valueOf(counter++) : seed + "_" + counter++;
            element.setId(id);

            if(element instanceof MenuGroup) {                
                generateUniqueIds(((MenuGroup) element).getElements(), id);
            }
        }
    }

似乎它会生成以数字开头的ID,因为seednull

这是预期的吗?

编辑1: Bean代码:

public String initActionMenus() throws Exception
{
    ExpressionFactory factory =   FacesContext.getCurrentInstance().getApplication().getExpressionFactory();
    MethodExpression methodsExpressionDelete = factory.createMethodExpression(FacesContext.getCurrentInstance().getELContext(), "#{UserGroupMgmtBean.menuDeleteAction}", null, new Class[]{ActionEvent.class});
    MethodExpressionActionListener actionListenerDelete = new MethodExpressionActionListener(methodsExpressionDelete);

    model = new DynamicMenuModel();
    UISubmenu smAction = new UISubmenu();       
    smAction.setLabel("Action");

    UIMenuItem itemDelete = new UIMenuItem();
    itemDelete.setValue("Delete");
    itemDelete.setUpdate(UPDATE_AREA_ID);
    itemDelete.setAjax(true);
    itemDelete.addActionListener(actionListenerDelete);
    smAction.getChildren().add(itemDelete);

    model.addElement(smAction);
    return "OK";
}

xthml代码:

<p:tieredMenu model="#{UserGroupMgmtBean.model}" id="userGroupMenu"/>

0 个答案:

没有答案