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:
- changing the scope to @ViewScoped,
- removing the bulk of the fields displayed (bar one - the name),
- passing in the requestParam again (but I realised that i wasn't even picked up in the first place and it works fine.
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.