Reputation: 1155
I have a very strange problem where a bean is not resolved but ONLY on submit. It works fine on view but on submit, it errors out saying that the identifier is null
My JSF
<h:form id="edit" styleClass="form">
<rich:panel>
<f:facet name="header">
<h:outputText value="Edit Data" />
</f:facet>
<rich:graphValidator value="#{myModel}" id="gv">
<rich:messages for="gv" />
<rich:messages id="goal-messages" globalOnly="true" />
<!-- form fields that reference #{myModel.fields} -->
<h:commandButton id="save" value="Save"
action="#{myModel.save}" />
</rich:graphValidator>
</rich:panel>
</h:form>
The Model class
@Named("myModel")
@RequestScoped
public class MyModelImpl implements Model {
@Inject
@RequestParam("objectId")
private Long objectId;
// Getters & Setters for the various fields
public void save() {
// does nothing just now
}
}
I know that I should move the save operation into a controller which I will once I have it working. I have another instance of this working without issues (in another but related module). In fact, I copied the code to start with and modified as necessary.
The main difference in this module is that I name it differently from the class.
The view loads up ok without any issues, but on submit, I get the following:
The root exception is:
Caused by: javax.el.PropertyNotFoundException: /edit.xhtml @26,71 value="#{myModel.name}": Target Unreachable, identifier 'myModel' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:133) [jsf-impl-2.1.7-jbossorg-2.jar:]
at org.richfaces.el.ValueExpressionAnalayserImpl$SetValueCommand.resolve(ValueExpressionAnalayserImpl.java:42) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
at org.richfaces.el.ValueExpressionAnalayserImpl.resolveValue(ValueExpressionAnalayserImpl.java:64) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
at org.richfaces.el.ValueExpressionAnalayserImpl.updateValueAndGetPropertyDescriptor(ValueExpressionAnalayserImpl.java:90) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
at org.richfaces.validator.BeanValidatorServiceImpl.validateExpression(BeanValidatorServiceImpl.java:157) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]
... 41 more
Bearing in mind that it works on viewing the page, I am at a real loss as to why it doesn't work on submit.
I have tried various things including:
I have found lots of different people with the same final error but not the same circumstances .
all with no joy. Anybody have any thoughts on what might be the issue?
I am testing using Arquillian on JBoss 7.1.1.Final
Any help appreciated.
Upvotes: 0
Views: 5595
Reputation: 33
Check that your faces-config.xml is in the META-INF directory in the root directory of your web application.
http://docs.oracle.com/javaee/7/api/javax/faces/webapp/FacesServlet.html
Upvotes: 0
Reputation: 1155
As it turns out - the culprit was eclipse. After wasting a whole afternoon yesterday, I tried running the tests through maven this morning and it worked fine.
I had tried cleaning the projects in eclipse but that seemed to not have any effect yesterday. Doing it again today seemed to clear the issue.
In fact, the issue cropped up again which I was again able to fix by cleaning the project.
:-/
Upvotes: 2
Reputation: 1128
May be try @ManagedBean?:
@ManagedBean(name="myModel")
@RequestScoped
public class MyModelImpl implements Model {
@Inject
@RequestParam("objectId")
private Long objectId;
// Getters & Setters for the various fields
//should save return some outcome?
public String save() {
return "index.xhtml";
}
public String getName() {
retrun "Your error shows that somewhere in your xhtml this property is called";
}
}
Upvotes: 0