Hi, I have a tabView layout that looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition 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></h:head> <h:body> <p:messages /> <h:form id="form"> <p:tabView dynamic="true"> <p:tab title="Tab"> <p:inputText required="true" value="value"></p:inputText> </p:tab> <p:tab title="Select"> <p:selectOneMenu value="#{dummyController.selectedValue}" id="select" required="true" requiredMessage="Select is required"> <f:selectItem itemValue="1" itemLabel="asd"></f:selectItem> <f:selectItem itemValue="2" itemLabel="qwe"></f:selectItem> <f:selectItem itemValue="3" itemLabel="zc"></f:selectItem> </p:selectOneMenu> <p:message for="select" /> </p:tab> <p:tab title="Tab"> <p:inputText required="true" value="value"></p:inputText> </p:tab> </p:tabView> <h:commandButton action="#{dummyController.submit}" /> </h:form> </h:body> </ui:composition>
and its controller
import java.io.Serializable; import javax.faces.bean.ManagedBean; import javax.faces.bean.ViewScoped; @ManagedBean @ViewScoped public class DummyController implements Serializable { private static final long serialVersionUID = 1L; private int selectedValue; public void submit() { } public int getSelectedValue() { return selectedValue; } public void setSelectedValue(int selectedValue) { this.selectedValue = selectedValue; } }
it has weird behavior, follow tp playback instructions:
- open the tab "Selection"
- open another tab
- click send twice
the first press nothing happens as regular, the next press brings up the required message for selection, although it always matters
Tell me if something is missing or there are any solutions.
source share