Guys I am making this simple Addition function in Oracle ADF In which I am taking three input text fields first two for input numbers and third one for output and a button where i have written code for computing the addition operation.on a page after creating Adf Fusion Application in ADF This is the code for
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html>
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:document title="PageAdd.jsf" id="d1">
<af:form id="f1">
<af:inputText label="input1" id="it1" binding="#{Mbean.input1}" autoSubmit="true"/>
<af:inputText label="input2" id="it2" binding="#{Mbean.input2}" autoSubmit="true"/>
<af:inputText label="output" id="it3" binding="#{Mbean.output}" autoSubmit="true"/>
<af:button text="Submit" id="b1" action="#{Mbean.b1_action}"/>
<af:selectBooleanRadio text="selectBooleanRadio 1" label="Label 1" id="sbr1"/>
</af:form>
</af:document>
<!--oracle-jdev-comment:preferred-managed-bean-name:Mbean-->
</f:view>
As you can see the bindings. Mbean is the Managed Bean and the part after '.' is the property. In the Button I have created this method called b1_action. Below is the java code. package view;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import oracle.adf.view.rich.component.rich.input.RichInputText;
public class Addition {
private RichInputText input1;
private RichInputText input2;
private RichInputText output;
public Addition() {
}
public void setInput1(RichInputText input1) {
this.input1 = input1;
}
public RichInputText getInput1() {
return input1;
}
public void setInput2(RichInputText input2) {
this.input2 = input2;
}
public RichInputText getInput2() {
return input2;
}
public void setOutput(RichInputText output) {
this.output = output;
}
public RichInputText getOutput() {
return output;
}
public String b1_action() {
String s;
String x;
String v;
s = (String)input1.getValue();
x = (String)input2.getValue();
int r2=Integer.parseInt(x);
int r1= Integer.parseInt(s);
int d =r2+r1;
v =Integer.toString(d);
output.setValue(v);
System.out.println(output.getValue());
return null;
}
}
While my Application is able to take the values and even add together but not able to display it in the third input text field which i am not able to do I am new to this Tool and language Java kindly help me.
在您的“输出”组件上添加了部分触发器属性,如下所示:
<af:inputText label="output" id="it3" binding="#{Mbean.output}" autoSubmit=“true" partialTriggers=“ b1"/>
First Make Input 1 and Input 2 autoSubmit="True"
. Then Make partialTriggers="it1 it2"
for Output. Make the partialSubmit="True"
for the Button.
If nothing happend try to write this.output.setValue(V);
After output.setValue(v);
add this line of code AdfFacesContext.getCurrentInstance().addPartialTarget(output);
Then set property autoSubmit
to “true”
inside output in your page
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.