简体   繁体   中英

PropertyNotFoundException in SelectBooleanCheckbox

I have one checkbox per each node in TreeNode component of PrimeFaces 3.3.1 which is throwing a javax.el.PropertyNotFoundException inside its value attribute. Here's my code:

<p:tree value="#{CadBean.treeNode}" var="rec">  
<p:treeNode>
    <h:outputText value="#{rec.codigo}" />
</p:treeNode>

<p:treeNode type="Funcionality" icon="ui-icon16-weblibrary-folderopened">
    <p:selectBooleanCheckbox value="#{CadBean.alreadyAssociated(rec.id)}">
        <p:ajax event="click" listener="#{CadBean.onrecClicked(rec.id)}" />
    </p:selectBooleanCheckbox>
    <h:outputText value="#{rec.codigo}" />
</p:treeNode>

<p:treeNode type="Page" icon="ui-icon16-weblibrary-htmlpage">
    <p:selectBooleanCheckbox value="#{CadBean.alreadyAssociated(rec.id)}">
        <p:ajax event="click" listener="#{CadBean.onrecClicked(rec.id)}" />
    </p:selectBooleanCheckbox>
    <h:outputText value="#{rec.codigo}" />
</p:treeNode>

<p:treeNode type="System" icon="ui-icon16-weblibrary-computer">
    <h:outputText value="#{rec}" />
</p:treeNode>

The exception is thrown in value="#{CadBean.alreadyAssociated(rec.id)}" .

The boolean method is like this:

public boolean alreadyAssociated(int recId) {
for (Association a : associations) {
    if (a.getRec().getId() == recId) {
        return true;
    }
}
return false;
}

And here's the exception:

SEVERE: javax.el.PropertyNotFoundException: /s_ca/cadRec.xhtml @54,122 value="#{CadBean.alreadyAssociated(rec.id)}": Property 'alreadyAssociated' not found on type br.com.tsg.web.beans.CadBean

I'm using Mojarra 2.1.9 and can't use selectionMode="checkbox" in the TreeNode because I'll need two more components with the checkbox.

Thanks.

Solved. I just had to create a method like this:

public void setAlreadyAssociated(boolean b) {
}

Yeah, it's a bad workaround... but solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM