我通过ListDataModel在JSF页面中接收数据.
我需要汇总列的所有值.
遵循JSF代码:
Run Code Online (Sandbox Code Playgroud)<p:dataTable id="table" value="#{ProductBean.listProduct}" var="item" style="font-size:"12px" > <p:column > <f:facet name="header"> <h:outputText value="NAME" /> </f:facet > <h:outputText value="#{item[0].name}" /> </p:column > <p:column > <f:facet name="header"> <h:outputText value="VALUE BUY" /> </f:facet > <h:outputText value="#{item[1].valuebuy}" /> </p:column > <p:column > <f:facet name="header"> <h:outputText value="VALUE SELL" /> </f:facet > <h:outputText value="#{item[2].valuesell}" /> </p:column > <p:columnGroup type="footer"> <p:row> <p:column footerText="Total" /> <p:column footerText="TotalBuy" /> <<<<--------- Sum All Values of item[1].valuebuy and show here <p:column footerText="TotalSell" /> <<<<--------- Sum All Values of item[2].valuesell …
我得到了一个<h:commandButton像:
<h:commandButton id="login"
actionListener="#{bean.login}" value="Login"
styleClass="btn btn-primary btn-sm">
<f:ajax execute="@form" render="@form"/>
</h:commandButton>
Run Code Online (Sandbox Code Playgroud)
和a
<p:blockUI id="block" block=":form" trigger="login" />
它不起作用.该块永远不会显示出来.
它确实适用于<p:commandButton>.
我怎样才能实现它<h:commandbutton>.如果那是不可能的:有没有解决方法?
我有一个<h:commandbutton>喜欢
<h:commandButton value="Neuer Abschnitt"
styleClass="btn btn-primary btn-info"
action="#{beitragBearbeitenBean.erstelleAbschnitt}" />
Run Code Online (Sandbox Code Playgroud)
好吧,我点击按钮,调用方法,然后页面跳到顶部(证明你不在顶部!)
有趣的是,一个
<f:ajax execute="@form" />
Run Code Online (Sandbox Code Playgroud)
确实有点跳跃.
一般来说,我怎样才能避免跳跃?
private boolean hasDuplicates(Recipe recipe) {
List<Recipe> currentRecipes = new ArrayList<>();
Stream.of(this.breakfast, this.lunch, this.dinner).forEach(meal -> {
currentRecipes.add(meal.getRecipe());
currentRecipes.add(meal.getSnack());
});
currentRecipes.add(this.snack);
return currentRecipes.contains(recipe);
};
}
Run Code Online (Sandbox Code Playgroud)
// 想象一下所有字段的 getter 和 setter。
public class Menuplan {
private Meal breakfast;
private Meal lunch;
private Meal dinner;
private Recipe snack;
}
public class Meal {
private Recipe recipe;
private Reicpe snack;
}
Run Code Online (Sandbox Code Playgroud)
如果 Menuplan 已经分配了给定的食谱(作为零食或食谱),我使用上述方法进行测试。
我想知道是否有更优雅/更短的方法来编写函数。
我从一个普通的 Java EE 应用程序转移到 quarkus.io。在 Java EE 中,我有一个属性文件,
version=${project.version}并在 JAX RS 端点中读取此文件。这非常有效。
@GET
public Response getVersion() throws IOException {
InputStream in = getClass().getClassLoader().getResourceAsStream("buildInfo.properties");
if (in == null) {
return Response.noContent().build();
}
Properties props = new Properties();
props.load(in);
JsonObjectBuilder propertiesBuilder = Json.createObjectBuilder();
props.forEach((key, value) -> propertiesBuilder.add(key.toString(), value.toString()));
return Response.ok(propertiesBuilder.build()).build();
}
Run Code Online (Sandbox Code Playgroud)
现在我在用quarkus和MicroProfile,不知道有没有更好的方法。
我使用 MicroProfile 的 ConfigProperty 设置进行了尝试。
@ConfigProperty(name = "version")
public String version;
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
Property project.version not found.
这是我的 pom 的构建部分。
<build>
<finalName>quarkus</finalName>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>1.0.0.CR2</version>
<executions>
<execution> …Run Code Online (Sandbox Code Playgroud) 我有一个要求,用户应该能够从日历中选择日期.我使用过<p:calendar>PrimeFaces.
<p:calendar value="#{calendarBean.date1}" pattern="MM/dd/yyyy HH:mm" />
Run Code Online (Sandbox Code Playgroud)
问题是用户不应该选择分钟.他应该只能选择几个小时.
我可以通过命令行在Linux中发送电子邮件:
cat < x.txt | mail -s "SUBJECT" email@email.com
Run Code Online (Sandbox Code Playgroud)
这非常有效.注意:身体在x.txt.
现在,我想用Java执行这个命令.
Process p = Runtime.getRuntime().exec(
new String[] { "cat < x.txt", "|", "mail -s", "SUBJECT",
"email@email.com" });
p.waitFor();
BufferedReader buf = new BufferedReader(new InputStreamReader(
p.getInputStream()));
String line = "";
String output = "";
while ((line = buf.readLine()) != null) {
output += line + "\n";
}
System.out.println(output);
Run Code Online (Sandbox Code Playgroud)
好吧,它不工作,我得到跟随错误.
Exception in thread "main" java.io.IOException: Cannot run program "cat < x.txt |": error=2, Datei oder Verzeichnis nicht gefunden
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) …Run Code Online (Sandbox Code Playgroud)