【问题标题】:Why is "cc" null inside a commandButton's action in my Facelets composite component?为什么我的 Facelets 复合组件中的 commandButton 操作中的“cc”为空?
【发布时间】:2012-05-29 06:11:07
【问题描述】:

我有一个 Facelets Composite 组件,其中包括一个命令按钮:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<ui:component xmlns="http://www.w3.org/1999/xhtml" 
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:cc="http://java.sun.com/jsf/composite" 
          xmlns:ice="http://www.icesoft.com/icefaces/component"
          xmlns:nc="http://compositecomps.sss.evla.nrao.edu/jsf"
          xmlns:opt="http://java.sun.com/jsf/composite/components/opt"
          xmlns:undo="http://undo.sss.evla.nrao.edu/jsf"
          xmlns:n="http://sss.evla.nrao.edu/jsf"
          xmlns:f="http://java.sun.com/jsf/core">
<cc:interface>
  <cc:attribute name="value" type="edu.nrao.sss.tools.obsprep.bulkedit.BulkEditor"                      required="true"/>
  <cc:attribute name="loop"  type="edu.nrao.sss.tools.obsprep.uiactions.project.scan.ScanLoopUIActions" required="true"/>
</cc:interface>

<cc:implementation>
  <ui:param name="loop" value="#{cc.attrs.loop}"/>
  <ui:param name="val"  value="#{cc.attrs.value}"/>

  <ice:panelGroup id="wizStep1"
                  rendered="#{val.readyToSelect}">
    <nc:header value="select fields to filter on"/>
    <ice:commandButton value="#{val.nameField.value}" action="#{val.select}"/>
    <table cellpadding="5">
      <thead>
        <tr>
          <th></th><th>Field</th><th>Search For</th><th></th>
        </tr>
      </thead>
      <tbody>
        <opt:bulkEditField value="#{val.nameField}">
          <f:facet name="summary">
            <ice:inputText value="#{val.nameField.value}"/>
          </f:facet>
        </opt:bulkEditField>
      </tbody>
    </table>
    <ice:commandButton value="Select" action="#{val.select}"/>
  </ice:panelGroup>
</cc:implementation>
</ui:component>

我已更改代码以使用val.nameField.value 作为第一个命令按钮的标签来演示问题。

当我在页面中使用此组件时,它会呈现按钮和其下方的可搜索字段列表。如果我更改名称字段的值,按钮标签会更改。

但是,如果我单击该按钮,则会收到目标无法访问的异​​常:

Caused by: javax.el.PropertyNotFoundException: /resources/components /opt/bulkEdit.xhtml @25,79 action="#{val.select}": Target Unreachable, identifier 'val' resolved to null

我觉得我一定错过了这些复合组件如何工作的基础知识。这在 facelets/JSF 1.2 下作为标记文件工作得很好。在升级到 JSF 2.0 的过程中,我想继续使用复合组件,这样我就可以有一个定义好的接口。

如果我停止使用&lt;ui:param/&gt; 并直接输入cc.attrs.value,它会告诉我cc 为空。

我认为这可能是 icefaces 中的一个错误,但切换到普通的 &lt;h:commandButton/&gt; 会做同样的事情。

感谢您的任何建议。

【问题讨论】:

    标签: facelets composite-component


    【解决方案1】:

    这是 ICEfaces 2.0 中的一个错误。您有一个包含复合组件的 UISeries(panelTabSet 或 dataTable)。见http://jira.icesoft.org/browse/ICE-7142。它已在 3.0 中修复。

    【讨论】:

      猜你喜欢
      • 2014-12-18
      • 2010-11-01
      • 2013-10-14
      • 1970-01-01
      • 2019-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多