1

私はこの URL を持っています:
https://localhost:8181/Platform2/faces/admin/applicationDetails.xhtml?applicantid=16&applicationid=5
ブラウザでこれを紹介すると、このページのコンテンツを見るためにログインする必要があります。申請者と申請書の詳細を表示する必要があります (申請者と申請書は、私の Web Maven プロジェクトのエンティティです)。問題は、これを行うと、ページが何も取得しないことです。URLを再度入力すると、目的のコンテンツが表示されます。私のJSF Webページは次のとおりです。

<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <body>
        <ui:composition template="./mainadmin.xhtml"> 
            <ui:define name="content">

                <h:form> 

                    <h2 >Application details of #{applicationDetailsRequestBB.applicant.username}</h2>
                    <h:panelGrid columns="2"  >
                        <h:outputText value="First Name" />
                        <h:outputText value="#{applicationDetailsRequestBB.applicant.firstName}" />

                        <h:outputText value="Last Name:" />
                        <h:outputText value="#{applicationDetailsRequestBB.applicant.lastName}" />

                        <h:outputText value="CV" />
                        <h:link outcome="#{applicationDetailsRequestBB.cvPath}"  target="_blank" value="cv">
                        </h:link>

                        <h:outputText value="Cover Letter" />
                        <h:link outcome="#{applicationDetailsRequestBB.coverLetterPath}" target="_blank" value="cl">
                        </h:link>

                        <h:outputText value="Email:" />
                        <h:outputText value="#{applicationDetailsRequestBB.applicant.email}" />

                        <h:outputText value="Address:" />
                        <h:outputText value="#{applicationDetailsRequestBB.applicant.address}" />

                        <h:outputText value="City:" />
                        <h:outputText value="#{applicationDetailsRequestBB.applicant.city}" />

                        <h:outputText value="Phone:" />
                        <h:outputText value="#{applicationDetailsRequestBB.applicant.phone}" />

                        <h:outputText value="Mobile Phone:" />
                        <h:outputText value="#{applicationDetailsRequestBB.applicant.mobile}" />

                        <h:outputText value="Country:" />
                        <h:outputText value="#{applicationDetailsRequestBB.applicant.country}" />

                        <h:outputText value="Degree:" />
                        <h:outputText value="#{applicationDetailsRequestBB.applicant.degree}" />

                        <h:outputText value="School" />
                        <h:outputText value="#{applicationDetailsRequestBB.applicant.school}" />

                    </h:panelGrid>  



                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>

私のバッキングビーンは次のとおりです。

package pt.uc.dei.aor.finalproject.amj.platform.backingbeans;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.Serializable;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.component.html.HtmlForm;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import pt.uc.dei.aor.finalproject.amj.databasefinalproject.entities.Applicant;
import pt.uc.dei.aor.finalproject.amj.databasefinalproject.entities.Application;
import pt.uc.dei.aor.finalproject.amj.databasefinalproject.facades.ApplicantFacade;
import pt.uc.dei.aor.finalproject.amj.databasefinalproject.facades.ApplicationFacade;

import pt.uc.dei.aor.finalproject.amj.platform.application.StatefulApplication;

/**
 *
 * @author Alvaro
 */
@Named
@RequestScoped
public class ApplicationDetailsRequestBB implements Serializable {

    private String cvPath;
    private String coverLetterPath;
    private String imgPath;
    private Applicant applicant;
    private Application application;

    @EJB
    private ApplicantFacade applicantFacade;
    @EJB
    private ApplicationFacade applicationFacade;

    public ApplicationDetailsRequestBB() {
    }

    @PostConstruct
    public void init() {

        Map<String, String> mapList = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
        if (mapList.containsKey("applicantid") && mapList.containsKey("applicationid")) {
            Applicant a = applicantFacade.find(Long.parseLong(mapList.get("applicantid")));
            Application app = applicationFacade.find(Long.parseLong(mapList.get("applicationid")));
            if (a != null && app != null && app.getApplicant().equals(a)) {
                applicant = a;
                application = app;
                this.cvPath = "/CV/" + application.getCv();
                this.coverLetterPath = "/CL/" + application.getCoverLetter();
            }
        }

    }


    public String getCvPath() {
        return cvPath;
    }

    public void setCvPath(String cvPath) {
        this.cvPath = cvPath;
    }

    public String getCoverLetterPath() {
        return coverLetterPath;
    }

    public void setCoverLetterPath(String coverLetterPath) {
        this.coverLetterPath = coverLetterPath;
    }

    public String getImgPath() {
        return imgPath;
    }

    public void setImgPath(String imgPath) {
        this.imgPath = imgPath;
    }

    public Applicant getApplicant() {
        return applicant;
    }

    public void setApplicant(Applicant applicant) {
        this.applicant = applicant;
    }

    public ApplicantFacade getApplicantFacade() {
        return applicantFacade;
    }

    public void setApplicantFacade(ApplicantFacade applicantFacade) {
        this.applicantFacade = applicantFacade;
    }

    public Application getApplication() {
        return application;
    }

    public void setApplication(Application application) {
        this.application = application;
    }

    public ApplicationFacade getApplicationFacade() {
        return applicationFacade;
    }

    public void setApplicationFacade(ApplicationFacade applicationFacade) {
        this.applicationFacade = applicationFacade;
    }

}

デバッグするためにinitメソッドにブレークポイントを入れて、最初は呼び出されません。更新すると、Bean が呼び出され、すべてが正しく機能します。なぜ最初に結果が出ないのですか?

4

0 に答える 0