500 Server error
500 Server error

Reputation: 644

Bean resolved to null inside p:ajax in a datatable

I'm having a strange case of Target Unreachable identifier 'bean' resolved to null.

I have a XHTML main web page containing the definition of a datatable like follows:

<c:set var="bean" value="#{mainSearchBean}" />

<h:form id="form">

    <p:datatable selectionMode="#{bean.selectionMode}" rendered="#{bean.isTableRendered}" ...>
        #{bean}

        <p:ajax event="onSelect" listener="#{bean.onSelect}" />

        <ui:include src="columns.xhtml">
            <ui:param name="bean" value="#{bean}" />
        </ui:include>

    </p:datatable>

</form>

I have a controller that produces my mainSearchBean as SessionScoped. And as soon as the bean mainSearchBean is called the producer method (@Produces) is called and creates normally my bean. In fact if I go and print the bean in the page, as illustrated above in the code before the p:ajax component, I get the same signature as the bean created in the producer method.

The Target Unreachable error is generated because of the bean in the <p:ajax> listener attribute.

I'm having the error on Glassfish 3.1 with JSF 2.1.26.

Upvotes: 0

Views: 239

Answers (1)

JanPl
JanPl

Reputation: 804

Aside from being a little sloppy with tag case sensitivity you set the variable bean to the string literal "mainSearchBean". You probably want to use an EL expression (#{...})

 <c:set var="bean" value="#{mainSearchBean}" />

Upvotes: 1

Related Questions