-1

I keep getting this message when trying to run the code below. It is supposed to show the test from the document to be uploaded. This is a Java Server Faces program. Why am I getting this message:Unable to find matching navigation case with from-view-id '/upload.xhtml' for action 'vidClass2.upload' with outcome 'vidClass2.upload'

<?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://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body >
        <h:form id="form" enctype="multipart/form-data" prependId="false">
            <p><h:inputFile id="file" value="#{vidClass2.vidData}"> 
                </h:inputFile>
            </p>
            <br/>
            <h:commandButton id="button" value ="upload" action ="vidClass2.upload">

            </h:commandButton>
            <p id="textOutput">Text: #{vidClass2.vidName}</p>
        </h:form>

    </h:body>
</html>


import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
import javax.servlet.http.Part;

/**
 *
 * @author David Jennings
 */
@ManagedBean(name = "vidClass2")
@RequestScoped
public class VidClass {

    private String userName;
    private String vidName;
    private Part vidData;

    /**
     * Creates a new instance of VidClass
     */
    public VidClass() {
    }

    /**
     * @return the userName
     */
    public String getUserName() {
        return userName;
    }

    /**
     * @param userName the userName to set
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }

    /**
     * @return the vidName
     */
    public String getVidName() {
        return vidName;
    }

    /**
     * @param vidName the vidName to set
     */
    public void setVidName(String vidName) {
        this.vidName = vidName;
    }

    /**
     * @return the vidData
     */
    public Part getVidData() {
        return vidData;
    }

    /**
     * @param vidData the vidData to set
     */
    public void setVidData(Part vidData) {
        this.vidData = vidData;
    }

    public void upload() {

        if (null != vidData) {
            try {
                InputStream is = vidData.getInputStream();
                vidName = new Scanner(is).useDelimiter("\\A").next();
            } catch (IOException ex) {
            }
        }
    }

}

enter image description here

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
jillian
  • 52
  • 6

1 Answers1

1

in case you are using JavaBeans components on yours page you should use expression #{bean.method} in action.

<h:commandButton id="button" value ="upload" action ="#{vidClass2.upload}"/>
delovepr
  • 71
  • 1
  • 6