1

I have this URL:
https://localhost:8181/Platform2/faces/admin/applicationDetails.xhtml?applicantid=16&applicationid=5
When, i introduce this on browser, i have to login in order to go to see the content of this page. It should show the details of an applicant and an application (Applicant and Applications are entities of my Web maven project). The problem is that when i do this, the page do not retrieve anything. When i enter the URL again, is displays the desired content. My JSF web page is:

<?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>

My Backing bean is:

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;
    }

}

I put a breaking point in init method, to make debug, and at first time is not called. When I refresh, the bean is called and evertything works correctly. Why doesn´t result at first time?

Goldbones
  • 1,407
  • 3
  • 21
  • 55
  • And how do you perform that login?I guess you are not correctly redirecting from login method to your original URL. – Petr Mensik Jul 07 '14 at 09:31

0 Answers0