专家 我正在Oracle ADF中创建这个简单的Addition函数 我在其中输入三个输入文本字段,前两个用于输入数字,第三个用于输出,以及一个按钮,其中我编写了用于计算添加操作的代码。在ADF中创建Adf Fusion应用程序后的页面中 这是
的代码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;
}
}
正如你可以看到绑定。 Mbean是Managed Bean,是'。'之后的部分。是财产。 在Button中我创建了这个名为b1_action的方法。 下面是java代码。 包视图;
train.index <- 1:50000
test.index <- 50001:nrow(Data_clean)
#clean up
# remove grammar/punctuation
Data_clean$Raison.Reco.clean <- tolower(gsub('[[:punct:]0-9]', '', Data_clean$Raison.Reco))
train <- Data_clean[train.index, ]
test <- Data_clean[test.index, ]
word.freq <- function(document.vector, sparsity = .999)
{
temp.tf <- document.vector %>% tokens(ngrams = 1:3) %>% # generate tokens
dfm # generate dfm
freq.df <- colSums(temp.tf)
freq.df <- data.frame(word = names(freq.df), freq = freq.df)
rownames(freq.df) <- NULL
return(freq.df)
}
word.freq.pos <- word.freq(train$Raison.Reco.clean[train$Note.Reco == "10"])
word.freq.neg <- word.freq(train$Raison.Reco.clean[train$Note.Reco == "0"])
#merge les deux tables
freq.all <- merge(word.freq.pos, word.freq.neg, by ='word', all = T )
#clean'up
freq.all$freq.x[is.na(freq.all$freq.x)] <- 0
freq.all$freq.y[is.na(freq.all$freq.y)] <- 0
#calculer la difference
freq.all$diff <- abs(freq.all$freq.x - freq.all$freq.y)
head(freq.all[order(-freq.all$diff), ])
#NDSI
#smoothing term
alpha <- 30
#ndsi
freq.all$ndsi <- abs(freq.all$freq.x - freq.all$freq.y) / (freq.all$freq.x + freq.all$freq.y + 2*alpha)
head(freq.all[order(-freq.all$ndsi), ])
#number of feature in the matrix
num.features <- 500
#sort the values
freq.all <- freq.all[order(-freq.all$ndsi), ]
############################################## tf-idf ###################################################################################
#cast to a string
freq.all$word <- as.character(freq.all$word)
#construct the tf matrix
tf <- t(apply(t(train$Raison.Reco.clean), 2, function(x) str_count(x, freq.all$word[1:num.features])))
idf <- log(length(train.index)/colSums(sign(tf[train.index, ])))
idf[is.infinite(idf)] <- 0
tf.idf <- as.data.frame(t(apply(tf, 1, function(x) x * idf)))
colnames(tf.idf) <- freq.all$word[1:num.features]
##################################################################### Random forest #############################################
# train random forest classifier
ndsi.forest <- randomForest(tf.idf[train.index, ], as.factor(train$Note.Reco[train.index]), ntree = 100)
虽然我的应用程序能够获取值甚至加在一起但不能在第三个输入文本字段中显示它,我无法做到 我是这个工具的新手,Java语言帮助我。
答案 0 :(得分:0)
首先输入1和输入2 autoSubmit="True"
。
然后为输出设置partialTriggers="it1 it2"
。
为按钮设置partialSubmit="True"
。
如果没有发生任何事情,请尝试编写this.output.setValue(V);
答案 1 :(得分:0)
在output.setValue(v);
添加此行代码
AdfFacesContext.getCurrentInstance().addPartialTarget(output);
然后在页面的输出中将属性autoSubmit
设置为“true”