Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8371279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:07:30+00:00 2026-06-09T14:07:30+00:00

I use the Primefaces manual example for a wizard, and replace one of the

  • 0

I use the Primefaces manual example for a wizard, and replace one of the tabs by a simple file upload form. I have all the necessary libraries and filter in web-inf for the file upload to work. Running the project with Netbeans does not show any error (the wizard is displayed and the UI responds), but the file is not uploaded and I get no system message from my fileBean class. Any clue where I make a mistake? Is something wrong with my nested form in the index.html? Thx!

index.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">
    <h:head>
        <title>The rings of scholarship</title>
    </h:head>
    <h:body>
        <h:form>

            <p:growl id="growl" sticky="true" showDetail="true"/>

            <p:wizard widgetVar="wiz"
                      flowListener="#{userWizard.onFlowProcess}">

                <p:tab id="personal" title="Personal">

                    <p:panel header="Personal Details">

                        <h:messages errorClass="error"/>

                        <h:panelGrid columns="2" columnClasses="label, value" styleClass="grid">
                            <h:outputText value="Firstname: *" />
                            <p:inputText required="true" label="Firstname"
                                         value="#{userWizard.user.firstname}" />

                            <h:outputText value="Lastname: *" />
                            <p:inputText required="true" label="Lastname"
                                         value="#{userWizard.user.lastname}" />

                            <h:outputText value="Age: " />
                            <p:inputText value="#{userWizard.user.age}" />

                            <h:outputText value="Skip to last: " />
                            <h:selectBooleanCheckbox value="#{userWizard.skip}" />
                        </h:panelGrid>
                    </p:panel>
                </p:tab>

                <p:tab id="upload" title="File upload">
                    <p:panel header="File upload">

                        <h:messages errorClass="error"/>

                        <h:panelGrid columns="2" columnClasses="label, value">
                            <h:form enctype="multipart/form-data">
                                <p:fileUpload value="#{fileBean.file}" mode="simple" />
                                <p:commandButton value="Submit" action="#{fileBean.save}" ajax="false"/>
                            </h:form>
                        </h:panelGrid>
                        <h:outputText value="Skip to last: " />
                        <h:selectBooleanCheckbox value="#{userWizard.skip}" />
                    </p:panel>
                </p:tab>

                <p:tab id="contact" title="Contact">
                    <p:panel header="Contact Information">

                        <h:messages errorClass="error"/>

                        <h:panelGrid columns="2" columnClasses="label, value">
                            <h:outputText value="Email: *" />
                            <p:inputText required="true" label="Email"
                                         value="#{userWizard.user.email}" />

                            <h:outputText value="Phone: " />
                            <p:inputText value="#{userWizard.user.phone}"/>

                            <h:outputText value="Additional Info: " />
                            <p:inputText value="#{userWizard.user.info}"/>
                        </h:panelGrid>
                    </p:panel>
                </p:tab>

                <p:tab id="confirm" title="Confirmation">
                    <p:panel header="Confirmation">

                        <h:panelGrid id="confirmation" columns="6">
                            <h:outputText value="Firstname: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{userWizard.user.firstname}" />

                            <h:outputText value="Lastname: " />
                            <h:outputText  styleClass="outputLabel"
                                           value="#{userWizard.user.lastname}"/>

                            <h:outputText value="Age: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{userWizard.user.age}" />>

                            <h:outputText value="Email: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{userWizard.user.email}" />

                            <h:outputText value="Phone " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{userWizard.user.phone}"/>

                            <h:outputText value="Info: " />
                            <h:outputText styleClass="outputLabel"
                                          value="#{userWizard.user.info}" />

                            <h:outputText />
                            <h:outputText />
                        </h:panelGrid>

                        <p:commandButton value="Submit" update="growl" 
                                         actionListener="#{userWizard.save}"/>

                    </p:panel>
                </p:tab>

            </p:wizard>

        </h:form>

    </h:body>
</html>

fileBean:

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.ViewScoped;
import org.apache.commons.io.IOUtils;
import org.primefaces.model.UploadedFile;

@ManagedBean
@ViewScoped
public class FileBean implements Serializable{

    private UploadedFile file;
/**
 * Creates a new instance of FileBean
 */
public FileBean() {
}

public UploadedFile getFile() {
    System.out.println("we get file");
    return file;
}

public void setFile(UploadedFile file) throws FileNotFoundException, IOException {
    System.out.println("we set file");
    this.file = file;

}

public void save() throws IOException {
    System.out.println("we save file");
    IOUtils.copy(file.getInputstream(), new FileOutputStream("D:\\" + file.getFileName()));
    BufferedReader br = new BufferedReader(new InputStreamReader(file.getInputstream()));
    String currLine = br.readLine();
    Integer counterLines = 0;
    while (currLine != null && counterLines < 5) {
        System.out.println("currLine is: " + currLine);
        counterLines++;
    }

}

}

UserWizard:

import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.primefaces.event.FlowEvent;

@ManagedBean
@ViewScoped
public class UserWizard implements Serializable{

    private User user = new User();
    private boolean skip;
    private static final Logger logger = Logger.getLogger(UserWizard.class.getName());

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public void save(ActionEvent actionEvent) {
        //Persist user

        FacesMessage msg = new FacesMessage("Successful", "Welcome :" + user.getFirstname());
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }

    public boolean isSkip() {
        return skip;
    }

    public void setSkip(boolean skip) {
        this.skip = skip;
    }

    public String onFlowProcess(FlowEvent event) {
        logger.log(Level.INFO, "Current wizard step:{0}", event.getOldStep());
        logger.log(Level.INFO, "Next step:{0}", event.getNewStep());

        if (skip) {
            skip = false;   //reset in case user goes back
            return "confirm";
        } else {
            return event.getNewStep();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:07:31+00:00Added an answer on June 9, 2026 at 2:07 pm

    Start by getting rid of the nested forms… you got one surrounding the wizard and one inside the <p:tab id="upload" title="File upload">

    Try removing the inner form from the tab and wrap the wizard with <h:form enctype="multipart/form-data">

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the simple File upload of Primefaces in development with Netbeans. My test
First of all, I use Java EE, Hibernate with EntityManager and PrimeFaces. I have
I use primefaces with facelets and i have a quastion: for example i have
I'm trying to use the primefaces dataExporter to export some data and I have
use C#,want to upload excel file on google doc. bellow syntax use to upload
I'm using primefaces' accordion panel. Inside the tabs i have forms which are created
I use Primefaces 3.1, JSF 2.1.6 on Glassfish 3.1.1. I have loads of commandbuttons
I know how to do file upload using Primefaces or using Tomahawk, however, I
I want to use Primefaces to display a wizard pretty much similar to the
i have problem with load data from Database i use Primefaces (or other use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.