This submits data to 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>
Here is definition of 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";
}
As it can be seen I have a list
and I am also redirecting to UpdateAuthor.xhtml
. I want to make this list
available in the scope of UpdateAuthor.xhtml
so that values of list
can been shown in view. How can I do that?