1

データベースからポイントを取得してオーバーレイに追加するマネージド Bean があります。同じマネージド Bean で、データベースから関連データを取得し、ユーザーが任意のマーカーをクリックするとそれらを表示します。

ここまでは問題ありません。私の管理対象 Bean は@SessionScoped. ただし、プロジェクトをシステムに追加しようとすると、追加されますが、以前のバージョンのデータが表示されます。@ViewScoped要求に応じてデータを取得するように変更すると、基本的に最後に更新された状態でデータを取得します。

ここに私の豆があります:

@ManagedBean
@SessionScoped
public class MapBean implements Serializable{

    private static final long serialVersionUID = 1L;

    private MapModel simpleModel;
    private Marker marker;
    //genel
    private String projectName, projectExp, projectCoordLong, projectCoordLat, district, sector, workStatus, assistant, bidName, company, bidCost, costPaid;


    //getters and setters ...

    //süre bilgileri
    private String processTime = "0", startDate, endDate;
    //teknik bilgiler
    private String parcel, planStatus, roadLength, roadWidth, totalArea, extraInfo;
    //genel devam
    private String unitOffer, approxCost, projectCost, fileNu;
    //idare kontrol teşk.
    private String chef, arch, strEng, landArch, elecEng, geoEng, machEng, mapEng, planEng;
    //ihale önce takip
    private String assistantBefore, engArch;
    //uygulamacı birim kontrol teşkilatı
    private String mudYard, mim, ins, peyz, elek;
    //fima iletişim bilgileri
    private String compResp, compResJob, compTel, compAddress, compMail,total;

    public String getTotal() {
        return total;
    }

    public void setTotal(String total) {
        this.total = total;
    }

    public MapModel getSimpleModel() {
        return simpleModel;
    }
    //con to db
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/projetakip?useUnicode=true&characterEncoding=utf-8", "root", "");
    Statement stmt = con.createStatement();
    String SQL;
    ResultSet rs;



    public MapBean() throws Exception {
        SQL = "select * from projects";
        rs = stmt.executeQuery(SQL);
        simpleModel = new DefaultMapModel();
        LatLng coord1;

        //add markers to map
        while (rs.next()) {
            coord1 = new LatLng(Double.valueOf(rs.getString("projectCoordLat")), Double.valueOf(rs.getString("projectCoordLon")));
            simpleModel.addOverlay(new Marker(coord1, rs.getString("id"), "", "http://maps.google.com/mapfiles/ms/micons/red-dot.png"));
        }

    }

    public void onMarkerSelect(OverlaySelectEvent event) throws Exception {
        marker = (Marker) event.getOverlay();

        Statement stmt2= con.createStatement();
        String markerSQL = "select * from projects where id=" + marker.getTitle();
        ResultSet markerRs = stmt.executeQuery(markerSQL);

        while (markerRs.next()) {

            //proje bilgisi
            projectName = markerRs.getString("projectName");
            startDate = markerRs.getString("startDate");
            endDate = markerRs.getString("endDate");
            company = markerRs.getString("company");
            bidCost = markerRs.getString("biddCost");
            sector = markerRs.getString("sector");
            workStatus = markerRs.getString("workStatus");
            projectExp = markerRs.getString("projectExp");
            projectCoordLat = markerRs.getString("projectCoordLat");
            projectCoordLong = markerRs.getString("projectCoordLon");
            district = markerRs.getString("district");
            assistant = markerRs.getString("assistant");
            bidName = markerRs.getString("bidName");
            costPaid = markerRs.getString("costPaid");
            processTime = markerRs.getString("processTime");

            //teknik bilgiler
            parcel = markerRs.getString("parcel");
            planStatus = markerRs.getString("planStatus");
            roadWidth = markerRs.getString("roadWidth");
            roadLength = markerRs.getString("roadLength");
            totalArea = markerRs.getString("totalArea");
            extraInfo = markerRs.getString("extraInfo");
            unitOffer = markerRs.getString("unitOffer");
            approxCost = markerRs.getString("approxCost");
            projectCost = markerRs.getString("projectCost");
            fileNu = markerRs.getString("fileNu");

            //idare kontrol teşkilatı
            chef = markerRs.getString("chef");
            arch = markerRs.getString("arch");
            strEng = markerRs.getString("strEng");
            landArch = markerRs.getString("landArch");
            elecEng = markerRs.getString("elecEng");
            geoEng = markerRs.getString("geoEng");
            machEng = markerRs.getString("machEng");
            mapEng = markerRs.getString("mapEng");
            planEng = markerRs.getString("planEng");

            //uyg birim teşk
            mudYard = markerRs.getString("mdYard");
            mim = markerRs.getString("mim");
            ins = markerRs.getString("ins");
            peyz = markerRs.getString("peyz");
            elek = markerRs.getString("elek");

            assistantBefore = markerRs.getString("assistantBefore");
            engArch = markerRs.getString("engArch");

            //firma iletişim
            compResp = markerRs.getString("compRes");
            compResJob = markerRs.getString("compResJob");
            compTel = markerRs.getString("compTel");
            compAddress = markerRs.getString("compAddress");
            compMail = markerRs.getString("compMail");


        }

        //addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Seçilen proje:", marker.getTitle()));

    }

    public Marker getMarker() {
        return marker;
    }
}

そして、ここに私のjsfスニペットがあります:

<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
            <p:growl id="growl" showDetail="true"/>
            <p:gmap center="41.067445,29.047749" zoom="11" type="HYBRID"  model="#{mapBean.simpleModel}" style="width:100%;height:100%" streetView="true"> 
                <p:ajax event="overlaySelect" listener="#{mapBean.onMarkerSelect}" update="growl"/>
                <p:gmapInfoWindow rendered="true">  

                    <h:form id="form">  

                        <p:tabView id="tabView" dynamic="true" cache="true"  orientation="top" effect="blind" style="font-size: 10px;font-weight: bold;"> 

                            <p:tab id="tab1" title="Proje Bilgileri" >

                                <h:panelGrid columns="2" cellpadding="3">  
                                    <h:outputText value="Proje Adı: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.projectName}" style="font-weight: bold; font-size: 13px;"/>  

                                    <h:outputText value="Proje Detayı: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.projectExp}" style="font-weight: bold; font-size: 13px;"/>  

                                    <h:outputText value="Proje Koordinatları: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.projectCoordLat}, #{mapBean.projectCoordLong}" style="font-weight: bold; font-size: 13px;"/>  

                                    <h:outputText value="İlçe: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.district}" style="font-weight: bold; font-size: 13px;"/>  

                                    <h:outputText value="Sektör: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.sector}" style="font-weight: bold; font-size: 13px;"/>       

                                    <h:outputText value="İş Durumu: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.workStatus}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Sorumlu Müd. Yard.: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.assistant}" style="font-weight: bold; font-size: 13px;"/>      

                                    <h:outputText value="İhale Adı: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.bidName}" style="font-weight: bold; font-size: 13px;"/>      

                                    <h:outputText value="Firma: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.company}" style="font-weight: bold; font-size: 13px;"/>  

                                    <h:outputText value="İhale Bedeli: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.bidCost}" style="font-weight: bold; font-size: 13px;"/>  

                                    <h:outputText value="Ödenen Hak Ediş Tutarı: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.costPaid}" style="font-weight: bold; font-size: 13px;"/>   

                                    <h:outputText value="SÜRE BİLGİSİ" style="font-weight: bold; font-size: 13px; float: right; font-style: italic"/><p:separator />

                                    <h:outputText value="Başlangıç Tarihi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.startDate}" style="font-weight: bold; font-size: 13px;"/>  

                                    <h:outputText value="İşin Süresi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.processTime}" style="font-weight: bold; font-size: 13px;"/>     

                                    <h:outputText value="Bitiş Tarihi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.endDate}" style="font-weight: bold; font-size: 13px;"/> 
                                </h:panelGrid>
                            </p:tab>  

                            <p:tab id="tab2" title="Teknik Bilgiler">  
                                <h:panelGrid columns="2" cellpadding="3">  
                                    <h:outputText value="Ada/Parsel: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.parcel}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Plan Durumu: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.planStatus}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Yolun Genişliği: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.roadWidth}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Yolun Uzunluğu: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.roadLength}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Toplam Alan: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.totalArea}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="İlave Bilgi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.extraInfo}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Teklif Birim Fiyat: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.unitOffer}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Yapım Yaklaşık Maliyeti: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.approxCost}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Proje Maliyeti: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.projectCost}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Dosya Kodu: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.fileNu}" style="font-weight: bold; font-size: 13px;"/> 

                                </h:panelGrid>  
                            </p:tab>  

                            <p:tab id="tab3" title="Proje Teşkilatı">  
                                <h:panelGrid columns="2" cellpadding="3">  

                                    <h:outputText value="Şef: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.chef}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Mimar: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.arch}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="İnşaat Mühendisi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.strEng}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Peyzaj Mimarı: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.landArch}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Elektrik Mühendisi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.elecEng}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Jeoloji Mühendisi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.geoEng}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Makine Mühendisi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.machEng}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Harita Mühendisi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.mapEng}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Şehir Plancısı: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.planEng}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="İHALE ÖNCESİ TAKİP" style="font-weight: bold; font-size: 13px; float: right; font-style: italic"/><p:separator />

                                    <h:outputText value="Sorumlu Müd. Yard.: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.assistantBefore}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Sorumlu Müh./Mimar: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.engArch}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="UYGULAMACI KONTROL TEŞKİLATI" style="font-weight: bold; font-size: 13px; float: right; font-style: italic"/><p:separator />

                                    <h:outputText value="Müdür Yard.: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.mudYard}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Mimar: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.mim}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="İnşaat Mühendisi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.ins}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Peyzaj Mimarı: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.peyz}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Elektrik Mühendisi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.elek}" style="font-weight: bold; font-size: 13px;"/> 


                                </h:panelGrid>
                            </p:tab>  

                            <p:tab id="tab4" title="Firma Bilgisi">  
                                <h:panelGrid columns="2" cellpadding="3">  

                                    <h:outputText value="Yetkili Kişi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.compResp}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Görevi: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.compResJob}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Telefon: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.compTel}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="Adres: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.compAddress}" style="font-weight: bold; font-size: 13px;"/> 

                                    <h:outputText value="E-Posta: " style="font-size: 13px;"/>  
                                    <h:outputText value="#{mapBean.compMail}" style="font-weight: bold; font-size: 13px;"/>     

                                </h:panelGrid>  
                            </p:tab>  


                            <p:tab title="Yorumlar">  
                                <h:panelGrid columns="2" cellpadding="10">  
                                    <p:graphicImage value="/images/pdf.png" />  
                                    <h:outputText value=""/>
                                </h:panelGrid>  
                            </p:tab> 

                            <p:tab title="Dosyalar">  
                                <h:panelGrid columns="2" cellpadding="10">  
                                    <p:graphicImage value="/images/pdf.png" />  
                                    <h:outputText value=""/>
                                </h:panelGrid>  
                            </p:tab> 

                            <p:tab title="Resimler">  
                                <h:panelGrid columns="2" cellpadding="10">  
                                    <p:graphicImage value="/images/pdf.png" />  
                                    <h:outputText value=""/>
                                </h:panelGrid>  
                            </p:tab> 

                        </p:tabView>
                        <br />
                        <center>
                            <h:outputText value="Toplam Proje Sayısı: #{mapBean.total}" style="font-size: 13px;"/>  
                        </center>
                    </h:form>

                </p:gmapInfoWindow>
            </p:gmap>

ご覧のとおり、マーカーをクリックすると、データがタブに表示されます。使用する@SessionBeanとすべてのタブがいっぱいになりますが、現在のセッションでデータベースから最後の更新を取得しません。

使用する@ViewScopedと、最後の更新が認識されますが、最初のタブしか表示されません。他は空です。

どうすればこれを達成できますか?どんな助けでも大いに感謝します。

4

0 に答える 0