【发布时间】:2015-05-31 11:43:40
【问题描述】:
这会将数据提交给author.setFindwithid():
<h:form>
<h:outputLabel value="Id of to Be Edited record"></h:outputLabel>
<h:inputText value="#{author.id}"></h:inputText>
<h:commandButton value="submit" action="#{author.setFindwithid()}"/>
</h:form>
这是author.setFindwithid()的定义
public String setFindwithid() throws SQLException{
String query = "SELECT * FROM authors WHERE id=?";
PreparedStatement ps = con.prepareStatement(query);
ps.setInt(1, this.getId());
ResultSet rs = ps.executeQuery();
while (rs.next()) {
Author tmp = new Author();
tmp.setId(rs.getInt("id"));
tmp.setName(rs.getString("name123"));
list.add(tmp);
}
return "UpdateAuthor.xhtml";
}
可以看出我有一个list,我也重定向到UpdateAuthor.xhtml。我想让这个list 在UpdateAuthor.xhtml 的范围内可用,以便list 的值可以显示在视图中。我该怎么做?
【问题讨论】:
-
问题已通过this解决
-
该问题涉及不同的问题。您可以在与目标页面关联的 bean 中加载列表。