Eine Taste mehrere Aktionen

Habe ich zwei Bohnen genannt zu werden, und ich will einen Knopf um Sie zu rufen. Wie Sie dies tun?

Hier ist mein Versuch:

<h:form enctype="multipart/form-data">
    <p:inputTextarea rows="6" cols="33" autoResize="false"
                     value="#{uploadText.text}" maxlength="174" />
</h:form>

<h:form enctype="multipart/form-data">
    <p:messages showDetail="true" />
    <p:panelGrid columns="2" style=" width:30px;">
        <h:outputLabel id="image" value="Select Image: *" />
        <p:fileUpload value="#{uploadImage.file}" mode="simple"
                      allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
    </p:panelGrid>

    <h:commandButton action="#{uploadImage.upload}" value="Submit">
        <f:actionListener binding="#{uploadText.upload}" />
    </h:commandButton>
</h:form>

Aber es wirft diese Fehlermeldung:

/calendar.xhtml @109,55 binding="#{uploadText.upload}": The class 'textView.UploadText' does not have the property 'upload'.

Nur, denn ich bin mit Bindung hier :

<h:commandButton action="#{uploadImage.upload}" value="Submit">
    <f:actionListener binding="#{uploadText.upload}" />
</h:commandButton>

Sagt er Die Klasse textView.UploadText nicht die Eigenschaft haben 'upload' das ist nicht wahr! Ich habe versucht actionListner als gut, aber es funktioniert nicht.

Hier ist uploadtext Klasse:

public class UploadText implements Serializable {

    private static final long serialVersionUID = 1L;
    private String text;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public void upload() {

        if (text != null) {

            try {
                String f_username = JloginDAO.user;

                Connection con = DBconnection.getConnection();
                PreparedStatement pre = con.prepareStatement("insert into upload_text (text,user_idt) values(?, (SELECT id from users WHERE username = ?))");
                pre.setString(1, text);
                pre.setString(2, f_username);

                pre.executeUpdate();
                System.out.println("Inserting Successfully!");
                pre.close();
                FacesMessage msg = new FacesMessage("Succesful", text + " is uploaded.");
                FacesContext.getCurrentInstance().addMessage(null, msg);

            } catch (Exception e) {
                System.out.println("Exception-File Upload." + e.getMessage());
            }
        } else {
            FacesMessage msg = new FacesMessage("Please select image!!");
            FacesContext.getCurrentInstance().addMessage(null, msg);
        }
    }
}
  • Konnte Sie zeigen Sie der Klasse, wie gut?
  • Siehe editierten Beitrag oben @HoXa
  • Upload-Methode ist keine Eigenschaft, die Sie nicht Hinzugefügt haben, um die Klammer? action="#{uploadImage.upload()}"
  • Sollten Sie die type Attribut <f:actionListener> statt zu finden, um Ihre Durchführung ("fully qualified class name) ActionListner implementiert ist oder einfach nur die actionListener Attribut <h:commandButton>.
  • Möglich, Duplikat der Rufen mehrerer bean-Methode in primefaces gleichzeitig
InformationsquelleAutor sasuri | 2014-12-19
Schreibe einen Kommentar