如何正确更新表单中的组件

时间:2017-03-09 20:31:03

标签: ajax jsf primefaces

我的表格中有一堆面板显示图像,但是我只需点击一下按钮即可更新图像(加载下一组图像)。我已经尝试使用ajax="false"方法,但这会删除表单中的所有变量,例如(用于加载图像的网址)这是我的按钮:

<div style="position : absolute; right:400px; top:1500px" >
    <p:commandButton value="Confirm" id="Confirm"  actionListener="#{con.confirmButton}" oncomplete="PF('panelP').hide()" ajax="false" />
    </div> 

面板和确认按钮以如下形式存储:

<h:form id="form">


    <p:galleria id= "ISSimage" style="position : absolute; left:50px; top:550px" value="#{con.gallery}" var="image" panelWidth="500" panelHeight="313" showCaption="true">
    <p:graphicImage value="#{image}" alt="Image Description for #{image}" title="#{image}"/>
</p:galleria>

        <f:view contentType="text/html">
        <p:panel id="satImage"  style="position : absolute; right:50px; top:550px" panelWidth="500" panelHeight="400">
        <p:gmap id="satview" center="#{con.lati}, #{con.longi}" zoom="6" type="SATELLITE" style="width:600px;height:400px" model="#{con.simpleModel}"  />
    </p:panel>
    </f:view>

我尝试存储所有图像的列表         有没有办法在没有删除图像变量的情况下单击确认按钮正确加载下一组图像?

MY BEAN是300行,所以我只限于显示相关部分。这里是:   public void confirmButton(ActionEvent actionEvent){

    //setting Next Image

    //add the point depending on which panels are open then reset the panel booelan values
    gallery = new ArrayList<String>();
    candidates = new ArrayList<String>();
    Connection conn = null;
    PreparedStatement stmt = null;
    //Statement stmt1 = null;
    ResultSet rs = null;
    //gallery.clear();


    try{
        gallery = new ArrayList<String>();

        conn = DriverManager.getConnection(CONN_STRING,USERNAME,PASSWORD);

        stmt = conn.prepareStatement(op);
        //stmt.setString(1, oldconsole);
        //stmt.setString(2, oldconsole);
        stmt.setDouble(1, oldlati);
         stmt.executeUpdate();

        stmt = conn.prepareStatement("SELECT * FROM `ISS` WHERE taskinfo__citylat = (SELECT taskinfo__citylat FROM `ISS` LIMIT ?,1)");
        int rdmnum = randomise();
        stmt.setInt(1, rdmnum);
        rs = stmt.executeQuery();
        while(rs.next()){
            String issimg=rs.getString("taskinfo__link_small");
            gallery.add(issimg);
            //ADDS IMAGES TO GALLERIA
            excl_num = rs.getInt("rownum");
            excluded.add(excl_num);
            //ADDS ROWNUMBERS TO EXCLUDED ARRAY SO THEY DONT GET CALLED AGAIN.
            lati = rs.getFloat("taskinfo__citylat");
            longi = rs.getFloat("taskinfo__citylon");
            oldlati=lati;

            }
catch(SQLException e){
            System.err.println(e);
        }
public float getLati(){
    return lati;
}
public float getLongi(){
    return longi;
}

public double getOldlati(){
    return oldlati;
}
public double getOldlongi(){
    return oldlongi;
}

0 个答案:

没有答案