自动填充inputText

时间:2017-01-06 07:55:19

标签: jsf html-input auto-populate

我想将从数据库中检索到的ResultSet检索到xhtml文件中的 inputText 。下面显示了我迄今为止尝试过的代码。

Profile.java

    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Date;
    import com.mpts.srv.DBConnection;

    public class Profile {
        public void info(){

        String name = null;
        String mykad = null;
        String contact = null;
        Date dob = null;
        String gender = null;
        String email = null;

        DBConnection dbconn = new DBConnection("com.mysql.jdbc.Driver", "jdbc:mysql://localhost", "root",
                "root");
        dbconn.query("SELECT * FROM Patient WHERE patient_uid = SessionUtils.getUid()");
        ResultSet rs = dbconn.getResultSet();

        try {

            while (rs.next()) {

                name = rs.getString("name");
                mykad = rs.getString("mykad");
                contact = rs.getString("contact");
                dob = rs.getDate("dob");
                gender = rs.getString("gender");
                email = rs.getString("email");

            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        dbconn.close();
        }
    }

profile.xhtml

<h:outputLabel value="Name:"></h:outputLabel>
<b:inputText span="8" value="#{profile.getString(Name)}"></b:inputText>

如何将name填充到inputText中?

0 个答案:

没有答案
相关问题