JSF2表单提交“目标无法到达,标识符"myModel"仅在提交时解析为空 [英] JSF2 form submit " Target Unreachable, identifier 'myModel' resolved to null ONLY on submit

查看:116
本文介绍了JSF2表单提交“目标无法到达,标识符"myModel"仅在提交时解析为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常奇怪的问题,一个bean不能解析,但是只能在提交时才能解决.在查看时可以正常工作,但在提交时可以正常工作,它会错误地指出标识符为空

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

我的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>

Model类

@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:

根本的例外是:

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:

  • 将范围更改为@ViewScoped
  • 删除大部分显示的字段(第一个栏-名称),
  • 再次传递requestParam(但是我意识到我一开始没有被接住,而且效果很好.

我发现很多人的最终错误相同,但情况却不同.

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?

我正在JBoss 7.1.1.Final上使用Arquillian进行测试

I am testing using Arquillian on JBoss 7.1.1.Final

任何帮助表示赞赏.

推荐答案

事实证明-罪魁祸首是日食.在昨天浪费了整个下午之后,今天早上我尝试通过Maven运行测试,效果很好.

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.

:-/

这篇关于JSF2表单提交“目标无法到达,标识符"myModel"仅在提交时解析为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆