0

我在 ADF Faces 中的 js 函数有问题af:interatoraf:iterator我在( af:ouputText, af:inputText, )中有 3 个控件af:selectBooleanCheckBox,我想在复选框上有一个 js 函数,这样在选中复选框时,文本outputText将被复制到inputText.

这里的问题是af:iterator,ADF 将生成自己的 id 或为 id 附加一个奇怪的数字,我不确定是否应该依赖这些生成的 id 来编写我的 js 函数。我知道我应该为此使用 PPR,但我不能。

4

2 回答 2

1

为什么不能使用 PPR?根本不应该依赖 js ID,当假设您决定将任务流放在区域或 portlet 中时,它们会发生变化。

字段值应基于 VO 属性,如果它们不是 DB 支持的,您可以创建临时 VO。然后更新 VO 上的值并调用

AdfFacesContext.getCurrentInstance().addPartialTarget(JSFUtils.findComponent("<comp_id of parent component>"));
于 2010-11-02T22:50:45.897 回答
1

您可以结合使用<af:clientAttribute/> and <af:clientListener/>和一些 javascript 来实现此行为。

您还需要在<af:inputText/>.

这适用于我的测试程序。

<af:document id="d1">
  <af:resource type="javascript">
    function copyFromTo(evt) {
        fromValue = evt.getSource().getProperty('fromValue');
        fromIndex = evt.getSource().getProperty('fromIndex');
        // iterator ID, then fromIndex, then inputText ID 
        id = 'i1:'+fromIndex+':it1'; 
        inputComponent = AdfPage.PAGE.findComponentByAbsoluteId(id);
        inputComponent.setValue(fromValue);
    }
  </af:resource>
  <af:form id="f1">
    <af:panelStretchLayout id="psl1">
      <f:facet name="center">
        <af:iterator id="i1" value="#{PageBean.outputTextValues}" var="row" varStatus="rowStatus">
          <af:panelGroupLayout id="pgl1" layout="horizontal">
            <af:selectBooleanCheckbox label="Copy" id="sbc1">
              <af:clientAttribute name="fromValue" value="#{row}"/>
              <af:clientAttribute name="fromIndex" value="#{rowStatus.index}"/>
              <af:clientListener method="copyFromTo" type="click"/>
            </af:selectBooleanCheckbox>
            <af:spacer width="10" height="10" id="s1"/>
            <af:outputText value="#{row}" id="ot1"/>
            <af:spacer width="10" height="10" id="s2"/>
            <af:inputText label="Label 1" id="it1" value="none" clientComponent="true"/>
          </af:panelGroupLayout>
        </af:iterator>
        <!-- id="af_one_column_stretched"   -->
      </f:facet>
    </af:panelStretchLayout>
  </af:form>
</af:document>
于 2010-11-03T19:11:12.923 回答