3

I am using JSF 2.1 and primefaces 3.5. Let's say I have a following code:

<!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>

When I press next on the wizard, and validation fails (application name is blank) then all inplaces included on the page are toggled to editor mode. I think that they shouldn't be toggled since validation for each input is performed when you accept editor for this input.

screenshot

It looks awful, especially that I have a lot of inplaces.

I would like to disable toggling of each inplace editor when validation fails. Does anyone have an idea of how to solve this problem?

4

1 に答える 1

1

これは、p: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のショーケースから完全な例を確認できます。

于 2013-03-22T22:13:53.550 に答える