gpt4 book ai didi

jsf - Primefaces - 验证失败时切换所有就地

转载 作者:行者123 更新时间:2023-12-02 03:48:06 25 4
gpt4 key购买 nike

我使用的是 JSF 2.1 和 primefaces 3.5。假设我有以下代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Web application</title>
</h:head>
<h:body>
<h1>Editor</h1>
<h:form>
<p:wizard>
<p:tab title="Edit">
<h2>Edit:</h2>
<p:dataTable value="#{editorBean.applications}" var="app">
<p:column headerText="Id">
<p:inplace emptyLabel="Value not assigned" editor="true" effectSpeed="fast">
<p:inputText value="#{app.id}" />
</p:inplace>
</p:column>
<p:column headerText="Name">
<p:inplace emptyLabel="Value not assigned" editor="true" effectSpeed="fast">
<p:inputText value="#{app.name}" required="true" />
</p:inplace>
</p:column>
</p:dataTable>
</p:tab>
<p:tab title="Summary">
<h2>Summary:</h2>
<p:dataTable value="#{editorBean.applications}" var="app">
<p:column headerText="Id">#{app.id}</p:column>
<p:column headerText="Name">#{app.name}</p:column>
</p:dataTable>
</p:tab>
</p:wizard>
</h:form>
</h:body>
</html>

当我在向导中按下一步,验证失败(应用程序名称为空)时,页面上包含的所有 inplaces 都会切换到编辑器模式。我认为不应切换它们,因为当您接受此输入的编辑器时会执行每个输入的验证。

screenshot

看起来很糟糕,尤其是我有很多地方。

我想在验证失败时禁用每个就地编辑器的切换。有谁知道如何解决这个问题?

最佳答案

那是因为 p:inplace 组件不是为此目的而制作的。在像 inplace 这样的数据表中使用时,很少有其他组件会产生问题,但对于您的要求,这可能很有用:

<p:column headerText="Year" style="width:25%">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{car.year}" /></f:facet>
<f:facet name="input"><p:inputText value="#{car.year}" style="width:96%" label="Year"/></f:facet>
</p:cellEditor>
</p:column>

您可以从 primefaces showcase 查看完整示例.

关于jsf - Primefaces - 验证失败时切换所有就地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15580522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com