0

I searched a lot and I did not find any solution. I am using primefaces 5.2 version. Here is my code:

    <p:dialog header="#{msg['table.playlist.edit.caption']}" widgetVar="editPl" id="editPl" appendTo="@(body)" modal="true" minHeight="100">
            <h:form id="editForm">
                <h:panelGrid id="editPanel" columns="3" cellpadding="5">

                    <h:outputText for="fieldName" value="#{msg['table.playlist.column.header.name']}" />
                    <p:inputText id="fieldName" value="#{playlistModel.playlist.plName}" label="FieldName"/>
                    <p:message for="fieldName" style="color:red" />

                    <h:outputText value="#{msg['table.playlist.column.header.default']}" />
                    <h:selectBooleanCheckbox value="#{playlistModel.playlist.defaultPl}"/>

                </h:panelGrid>

                <p:commandButton value="#{msg['modal.button.save']}" ajax="true" validateClient="true" update=":editForm" action="#{playlistModel.addPlaylist}" oncomplete="if (args &amp;&amp; !args.validationFailed) PF('editPl').hide();"/>
                <p:commandButton value="#{msg['modal.button.cancel']}" onclick="PF('editPl').hide();"/>

            </h:form>   
    </p:dialog>

My class:

@ManagedBean(name="playlistModel")
@ViewScoped
public class PlaylistModel extends BaseModel implements Serializable{

    private E_CMS_PL playlist;
        .
        .
        .
}

My bean:

import javax.validation.constraints.Size;

@Entity
@Table(name="E_CMS_PL")
public class E_CMS_PL extends BaseEntity {

    /** Name of the playlist */
    @Column(name = "PL_NAME", unique=true ,length=64)
    @Size(min=2,max=5)
    private String plName;
    .
    .
    .
}

When I click on save it just enter in the addPlaylist method, I also try to test it with a simple button like this: <p:commandButton value="test" ajax="false" validateClient="true"/> but the input is still not validated. I did not understand why. Why is this not working?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
FAndrew
  • 248
  • 4
  • 22
  • 1
    http://stackoverflow.com/a/7548821/1391249 – Tiny Dec 02 '15 at 15:31
  • Based on your previously asked questions, you're indeed using Tomcat. So the abovelinked duplicate definitely applies. – BalusC Dec 02 '15 at 18:17
  • I checked the jars and I have: **validation-api-1.1.0.Final.jar, hibernate-validator-5.1.3.Final.jar, slf4j-api-1.7.12.jar**. Yes I am using **tomcat7**, and my project is configured with **maven**. I don`t have ** javax.faces.VALIDATE_EMPTY_FIELDS false ** in web.xml and I don`t have **** in my xhtml. I tried with **@Size,@NotNull,@NotEmpty,@NotBlank** and none of it are working. Still did not show the error message. Any idea what could I do? – FAndrew Dec 03 '15 at 08:05
  • This is the right duplicate: http://stackoverflow.com/questions/19637996/bean-validation-doesnt-work-with-mojarra-2-2-4 – BalusC Dec 04 '15 at 08:22

1 Answers1

0

I found my solution, I think it was not duplicate. I make a change in pom.xml

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-impl</artifactId>
    <version>2.2.4</version>
</dependency>

<dependency>
    <groupId>com.sun.faces</groupId>
    <artifactId>jsf-api</artifactId>
    <version>2.2.4</version>
</dependency>

from version 2.2.4 to 2.2.2 version and now it`s working the bean validation. I think probably it is a bug in 2.2.4 and 2.2.3 version.

FAndrew
  • 248
  • 4
  • 22