1

我将 JSF 2 与 PrimeFaces 一起使用,并且我的 facelet 具有调用通过 ui:param 传入的 bean 上的方法的 commandLinks(或 commandButtons)。

我的 facelet xhtml 期望dialogBean作为ui:param

   <h:panelGroup>

       <p:commandButton
           value="#{msgs.ok}"
           actionListener="#{dialogBean.okClicked}"
           process="#{dialogId}"
           update="#{dialogId}, #{externalIdsToUpdateOnOk}"
           styleClass="dialogBottomBtn"
        />

        <p:commandButton
            value="#{msgs.cancel}"
            actionListener="#{dialogBean.close}"
            process="@this"
            update="#{dialogId}"
            styleClass="dialogBottomBtn"
        />

   </h:panelGroup>

facelet 是这样包含的:

<ui:include src="/faces/common/dialogButtons.xhtml">
    <ui:param name="dialogId" value="textBlockQuestionDialog" />
    <ui:param name="dialogBean" value="#{formEditor.textBlockQuestionDialog}" />
    <ui:param name="externalIdsToUpdateOnOk" value=":form:tree, :form:properties, :form:preview" />
</ui:include>

它失败并出现此错误:

javax.el.PropertyNotFoundException: Target Unreachable, 
   identifier 'dialogBean' resolved to null

我试过用定义为参数替换,没有任何 #{dialogBean.close}帮助#{dialogBean['close']}#{dialogBean[action]}action

dialogBean h:outputText与类似的输出一起使用时得到解决。此外,当我替换actionListeneraction.

有什么想法吗?

4

1 回答 1

0

I think I found the answer.

Double-check that your dialogBean object's actionListener methods (okClicked etc.) take an ActionEvent parameter.

It seems like this parameter is required for beans passed by ui:param, but not others.

I suspect what's going on is something like this:

  1. check dialogBean parameter for method okClicked(ActionEvent)
  2. if not found, look for bean named dialogBean with method okClicked(ActionEvent)
  3. if not found, look for bean named dialogBean with method okClicked()

where the no-argument method is only used when the bean name directly matches, not indirectly matches via ui:param reference.

于 2012-09-06T21:27:34.997 回答