I was working with JSF, Hibernate & mySQL. Simplified concept and code like this. I have an entity class
@Entity
public class CountryReview{
public CountryReview(){}
@Id
@GeneratedValue
private int pageId;
private String countryName;
private String capital;
// setter and getters
}
A backing bean class
@ManagedBean
@SessionScoped
public class UserBean{
private List<CountryReview> review;
// setters & getters for review
privater HibernateUtil helper;
private Session session;
@PostConstruct
private void populateBean(){
session = helper.getSessionFactory().openSession();
session.beginTransaction();
review = session.createQuery("from CountryReview").list();
session.getTransaction().commit();
}
}
i want to use "review" object to populate a dataTable and want to navigate to another page based on dataTable's a column cell's data. Expected code like this
.
.
.
<h:body>
<h:form>
<h:dataTable value="#{userBean.review}" var="name">
<h:column>
#{name.capital}
</h:column>
<h:column>
#{name.countryName}
</h:column>
<h:column>
<h:commandButton value="Know More" action="#{name.countryName}"/>
</h:column>
</h:dataTable>
</h:form>
</h:body>
Is there any way to do this??