PrimeFaces rule: wizard health check does not work

I have p:wizardwith some tabs. On the first tab, the user selects a value (t :selectOneRadio- I use Tomahawk). This is a necessary value.

If the user does not select a value, he will not go to the next tab, but a verification error will not be displayed. Hm.

If the user selects a value, goes to the next tab, returns to the first tab and selects another value, it will behave as if this time the value were not selected. (There is no validation error, but the second tab cannot be called).

And even worse: the user selects a value on the first tab, goes to the second tab, tries to call an action from there ... a verification message appears; it acts as if no value was selected in the first tab.

Is there any explanation for this?

UPDATE

The solution suggested on the PrimeFaces forum worked for me. (Adding a process = "@this" to commandButton.)

+5
source share
5 answers

UPDATE

The solution suggested on the PrimeFaces forum worked for me. (Addendum process="@this"to commandButton.) I do not know why!

+4
source

One more thing you might want to consider.

, , .

    public String onFlowProcess(FlowEvent event) {  
    //First perform check to see if the user is attempting to remove the last visitor
    if ("confirm".equals(event.getNewStep()) && (visitors == null || visitors.isEmpty())) {
        log.debug("Validation failed for empty visitors");
        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Visit must have at least one visitor.", null);
        FacesContext.getCurrentInstance().addMessage(null, msg);
        return event.getOldStep();
    }

    return event.getNewStep();  
}

.xhtml flowListener. , .

<p:wizard showNavBar="true" widgetVar="scheduler" flowListener="#{scheduleVisit.onFlowProcess}" showStepStatus="true">
+3

, . , , , , . , , .

2.2 Wizard:

AJAX - ajax, , ajax. , , , , , ajax. .

, bean, . .

, selectOneRadio , ""? , , .

+2
source

You just need to set the true attribute to your switch.

Example:

<p:selectOneRadio required="true" requiredMessage="you must put it">
    <f:selectItem itemLabel="Días Laborales" itemValue="diasLab" />
    <f:selectItem itemLabel="Días Ticados" itemValue="diasTic" />
</p:selectOneRadio>
+1
source

PrimeFaces authentication task: wizard

Step: 1 customerInformation.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!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:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">


 <p:wizard flowListener="#{customerForm.onFlowProcess}">  

       <p:tab id="information" title="Information">  
     <p:panel header="Customer Information"> 

        <h:outputLabel value="First Name" for="fName"/>
            <h:inputText id="fname" value="#{customer.fname}"/>                                                                                                                                             

            <h:outputLabel value="Last Name" for="lName"/>
            <h:inputText id="lname" value="#{customer.lname}"/>                                                             

         </panel>
       </p:tab>

         <p:tab id="details" title="Details">  
       <p:panel header="Customer Details">  

              <h:outputLabel value="Address Line 1" for="addressOne"/>
            <h:inputText id="addressOne" value="#{customer.addressOne}"/>                                                                                                                                               

            <h:outputLabel value="Address Line 2" for="addressTwo"/>
            <h:inputText id="addressTwo" value="#{customer.addressTwo}"/>   

           </panel>
       </p:tab>
  </p:wizard>
</html>

Step: 2 Create a bean class CustomerForm.java

public class CustomerForm implements Serializable {

    private static final long serialVersionUID = 1L;

    private String fName;
    private String lName;
    private String addressOne;
    private String addressTwo;

    private static Logger logger = Logger.getLogger(CustomerForm.class.getName());                                         

    /**
     * Call this method in p:wizard tag
     * 
     */  
    public String onFlowProcess(FlowEvent event) {  
    logger.info("Current wizard step:" + event.getOldStep());  
    logger.info("Next step:" + event.getNewStep());  
        return event.getNewStep();  
    }

    /**
     * @return the fName
     */
    public String getfName() {
        return fName;
    }
    /**
     * @param fName the fName to set
     */
    public void setfName(String fName) {
        this.fName = fName;
    }
    /**
     * @return the lName
     */
    public String getlName() {
        return lName;
    }
    /**
     * @param lName the lName to set
     */
    public void setlName(String lName) {
        this.lName = lName;
    }
    /**
     * @return the addressOne
     */
    public String getAddressOne() {
        return addressOne;
    }
    /**
     * @param addressOne the addressOne to set
     */
    public void setAddressOne(String addressOne) {
        this.addressOne = addressOne;
    }
    /**
     * @return the addressTwo
     */
    public String getAddressTwo() {
        return addressTwo;
    }
    /**
     * @param addressTwo the addressTwo to set
     */
    public void setAddressTwo(String addressTwo) {
        this.addressTwo = addressTwo;
    }

}

Note: do not put required = "true" in the xhtml file

-1
source

All Articles