java - 甲骨文 MAF : Reflect value into inputText based on multiple selectOneChoice selection

标签 java oracle-maf

我在 calc.amx 中创建了三个 selectOneChoice 组件,它会根据值的变化进行计算并得到一些输出。我需要将它附加到与 inputText(不可编辑的文本)相同的 amx 页面。以下是我的尝试,


Calc.amx:

所有这些 selectOneChoice 都会有 valueChangeListener 将值设置到 bean 中,

<amx:selectOneChoice value="valueOne" label="Value One" id="soc1" valueChangeListener="#{calcBean.setValueOne}">
    <amx:selectItems value="valueOne" id="si1"/>
</amx:selectOneChoice>

<amx:selectOneChoice value="valueTwo" label="Value Two" id="soc2" valueChangeListener="#{calcBean.setValueTwo}">
    <amx:selectItems value="valueTwo" id="si2"/>
</amx:selectOneChoice>

<amx:selectOneChoice value="valueThree" label="Value Three" id="soc3" valueChangeListener="#{calcBean.setValueThree}">
    <amx:selectItems value="valueThree" id="si3"/>
</amx:selectOneChoice>
<amx:inputText value="#{bindings.grantTotal.inputValue}" label="#{bindings.grantTotal.hints.label}" id="it4"/>

CalcBean.java:

private String firstValue;
private String secondValue;
private String thirdValue;
private String grantTotal;


public void setFirstValue(String firstValue) {
    String oldFirstValue = this.firstValue;
    this.firstValue = firstValue;
    propertyChangeSupport.firePropertyChange("firstValue", oldFirstValue, firstValue);
}

public String getFirstValue() {
    return firstValue;
}

public void setSecondValue(String secondValue) {
    String oldSecondValue = this.secondValue;
    this.secondValue = secondValue;
    propertyChangeSupport.firePropertyChange("secondValue", oldSecondValue, secondValue);
}

public String getSecondValue() {
    return secondValue;
}

public void setThirdValue(String thirdValue) {
    String oldThirdValue = this.thirdValue;
    this.thirdValue = thirdValue;
    propertyChangeSupport.firePropertyChange("thirdValue", oldThirdValue, thirdValue);
}

public String getThirdValue() {
    return thirdValue;
}

public void setGrantTotal(String grantTotal) {
    String oldGrantTotal = this.grantTotal;
    this.grantTotal = grantTotal;
    propertyChangeSupport.firePropertyChange("grantTotal", oldGrantTotal, grantTotal);
}

public String getGrantTotal() {
    return grantTotal;
}


public void addPropertyChangeListener(PropertyChangeListener l) {
    propertyChangeSupport.addPropertyChangeListener(l);
}

public void removePropertyChangeListener(PropertyChangeListener l) {
    propertyChangeSupport.removePropertyChangeListener(l);
}

public void setValueOne(ValueChangeEvent valueChangeEvent) {
    firstValue = valueChangeEvent.getNewValue().toString();
    doCalc(firstValue,secondValue,thirdValue);
}

public void setValueTwo(ValueChangeEvent valueChangeEvent) {
    secondValue = valueChangeEvent.getNewValue().toString();
    doCalc(firstValue,secondValue,thirdValue);
}

public void setValueThree(ValueChangeEvent valueChangeEvent) {
    thirdValue = valueChangeEvent.getNewValue().toString();
    doCalc(firstValue,secondValue,thirdValue);
}

public void doCalc(String firstValue, String secondValue, String thirdValue){
    if(firstValue!=null&&secondValue!=null&&thirdValue!=null){
        System.out.println(firstValue+secondValue+thirdValue);
        grantTotal = firstValue+secondValue+thirdValue;
        setGrantTotal(grantTotal);
        System.out.println("grantTotal : "+grantTotal);
    } else {
        grantTotal = "No Value";
        setGrantTotal(grantTotal);
        System.out.println("grantTotal : "+grantTotal);
    }

}

所以我能够根据 selectOneChoice 选择进行计算,并且能够在 sop 语句中打印计算输出。

现在,我如何根据每个 selectOneChoice 选择将 grantTotal 值反射(reflect)到 inputText 中的相同 amx 页面?

最佳答案

grandTotal 是您绑定(bind)中的一个属性值吗?如果是这样,您可以使用 EL 轻松设置该值。


示例:

 int myValue = 123; 
 AdfmfJavaUtilities.setELValue("#{bindings.GrandTotal.inputValue}", myValue); 

Click Here有关 setELValue() 的 Oracle 文档。

关于java - 甲骨文 MAF : Reflect value into inputText based on multiple selectOneChoice selection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33430324/

相关文章:

java - 如何在 ImageView 中显示视频缩略图?

java - 为什么我的 javamail 程序不通过 jdeveloper 运行?

java - 根据模型值隐藏 JTable 中的单个单元格

java - Java Servlet 中静态变量的使用(例如在 AppEngine 中)

java - 在 IPV6 网络上获取网络无法访问

java - 甲骨文 MAF : Supports for Web application?

javascript - 甲骨文 MAF : (Signature Capture) Calling a javascript function from Managed Bean

java - 用动态生成的类替换反射调用

java - 使用 firebase 实时数据库,我的条目约为 300 项。现在在 datasnapshot 中没有得到 firebase 的响应