peetss
peetss

Reputation: 91

How to fix "Target Unreachable, identifier 'bean' resolved to null"?

I am using JSF 2.1.7 with Primefaces 3.2, CDI and Apache MyFaces CODI for access to @ViewScoped.

Everything has been working absolutely fine but when I pass a bean through to another page via a ui:param and then attempt to use that bean specifically with a p:ajax request, I get the message, "Target Unreachable, identifier 'bean' resolved to null"

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

Then on page.xhtml I attempt to do this.

<p:gmap zoom="15" type="HYBRID" model="#{bean.simpleModel}">
   <p:ajax event="markerDrag" listener="#{bean.onMarkerDrag}" />
</p:gmap>

The first call to bean.simpleModel resolves properly. The ajax call to bean.onMarkerDrag does not.

My declaration of formBean is @Named("formBean"), @ViewScoped.

Any ideas?

Upvotes: 1

Views: 4122

Answers (3)

Daniel Beer
Daniel Beer

Reputation: 1849

I just had the same problem. In my case I used a

<p:commandButton value="Edit" icon="ui-icon-pencil" actionListener="#{bean.edit}" />

inside a template included via <ui:include> and got the same error message.

Interestingly the following alternatives did work:

actionListener="#{bean.edit()}"
action="#{bean.edit}"
action="#{bean.edit()}"

Maybe you should try

<p:ajax event="markerDrag" listener="#{bean.onMarkerDrag()}" />

i.e. adding parentheses to your method expression.

Upvotes: 2

Dar Whi
Dar Whi

Reputation: 822

That can't work, because it's against the rules of @ViewScoped

Upvotes: 0

Karl Kild&#233;n
Karl Kild&#233;n

Reputation: 2435

@ViewScoped is tricky with CDI, it is not fully compatible. Consider trying with @SessionScoped.

If it works then try with @ViewAccessScoped (since you use Codi). That scope basically adapts ViewScope for CDI usage.

Still problems or already using that? Then try @SessionScope and report back what happened.

Upvotes: 0

Related Questions