首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在adf中将绑定变量的值复制到Iterator?

问如何在adf中将绑定变量的值复制到Iterator?
EN

Stack Overflow用户
提问于 2019-03-14 19:13:14
回答 1查看 1.3K关注 0票数 0

我有一个包含多个列+的adf表,加上一个有按钮的列,它将打开一个弹出窗口来插入一个值。

代码语言:javascript
复制
<af:table value="#{bindings.BpmCrMilestoneUPView1.collectionModel}" var="row" rows="#{bindings.BpmCrMilestoneUPView1.rangeSize}" >
                <af:column id="c49" headerText="#{bindings.BpmCrMilestoneUPView1.hints.MilestoneSeq.label}" width="50" displayIndex="-1" minimumWidth="12">
                  <af:inputText value="#{row.bindings.MilestoneSeq.inputValue}" readOnly="true" id="it16">
 </af:inputText>
    </af:column>
                  <af:column>
                <af:inputText value="#{row.bindings.Oldmilesseq.inputValue}"  id="it15">
                </af:column>

    <af:column label="openPopUp" >

    <af:button  action = "#{pageFlowScope.CRInitaitiveBean.openCommentsPopUp}" >
     </af:button>
    </af:column>
    <af:table>

这是包含输入文本字段的弹出窗口

代码语言:javascript
复制
    <af:popup  binding="#{pageFlowScope.CRInitaitiveBean.commentsPopUp}" id="p2">


    <div class="form-group" id="d7">
        <af:outputLabel value="#{lang.previous_comments}" />
        <af:inputText  autoSubmit="true" simple="true" 
        value="#{bindings.newCommentValue.inputValue}" />


   </div>
   </div>

和指向绑定选项卡中的newCommentValue的BpmCrOutputUPView1Iterator。如果打开每一行的弹出并键入值,则所有值都将正确保存。

但是,当我尝试以编程方式循环迭代器时,类型化值为空。

这是密码

代码语言:javascript
复制
         RowSetIterator itr = ADFUtils.findIterator("BpmCrOutputUPView1Iterator").getRowSetIterator();
        while (itr.hasNext()) {
            Row row = itr.next();
            if (row != null) {
                System.out.println();
                System.out.println("Current OUTPUT Row Is Not Null");
                String newComment = (String) row.getAttribute("newCommentValue");
                System.out.println();
                System.out.println("new Comment is  -------------------> "+newComment); // it should print the typed value for that row

                but it's printed null 
EN

回答 1

Stack Overflow用户

发布于 2019-03-15 07:40:00

对于这个特定的用例来说,使用强烈推荐的resolveExpression开放源码类JSFUtils函数会更容易。

JSFUtils和ADFUtils是由3位ADF英雄邓肯·米尔斯、史蒂夫·门奇和里克·史密斯创造的两个实用的java类。你可以很容易地找到那些使用你最喜欢的搜索引擎。

一旦添加到项目中,您就可以获得Java 中EL表达式的值,如下所示:

代码语言:javascript
复制
String newCommentValue= (String)JSFUtils.resolveExpression("#{bindings.newCommentValue.inputValue}");

下面是您的信息的JSFUtils函数:

代码语言:javascript
复制
/**
 * Method for taking a reference to a JSF binding expression and returning
 * the matching object (or creating it).
 * @param expression EL expression
 * @return Managed object
 */
public static Object resolveExpression(String expression) {
    FacesContext facesContext = getFacesContext();
    Application app = facesContext.getApplication();
    ExpressionFactory elFactory = app.getExpressionFactory();
    ELContext elContext = facesContext.getELContext();
    ValueExpression valueExp = elFactory.createValueExpression(elContext, expression, Object.class);
    return valueExp.getValue(elContext);
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55170360

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档