Validation In User Entry via Wizard

UI Components for JSF
Post Reply
jameson_uk
Posts: 4
Joined: 14 Jul 2021, 16:21

26 Jul 2021, 18:12

In one step of my wizard component I want to provide the user with an input box where they can enter one or many users.
This is working fine and I am storing the results in a selectOneListbox but I cannot seem to trigger my custom validator

My tab view looks like

Code: Select all

<p:inputText id="users" value="#{myBean.users}" />

<p:commandButton value="->" action="#{myBean.onAddUsers}" update="users,userList" process="users @this" />

<p:selectOneListbox id="userList">
  <f:selectItems value="#{myBean.userList}" />
  <f:validator validatorId="my.package.UserValidator" />
</p:selectOneListbox>
The backing bean has

Code: Select all

  private String user;
  private List<String> users;

  public void onAddusers() {
    List<String usersToAdd = new ArrayList<>(Arrays.asList(users.split(";")));
    for (String u : userToAdd) {
      userList.add(u.trim());
    }
    users = null;
  }
which works fine and if the user enters one or more users and clicks the button then the list is set fine and I can process the data.
The problem is I have invalid usernames. In other places I am using the same validator to ensure I only process valid ones and it works fine.

How can I get this list of users validated? I did originally envisage this being validated when a user clicked next to move to the next step but I am not too fussed about how and where just as long as it works and is obvious. Any suggestions?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 25 guests