[jboss-user] [JBoss Seam] - how to use DataModelSelectionIndex correctly ?(newbie questi
guiltyxsin
do-not-reply at jboss.com
Mon Aug 27 08:57:58 EDT 2007
Hi,
Trying to use the DataModelSelectionIndex to pick up particular row of data and use it to do another query from other Action.java. I am not sure if I have done it right or not. I just can't get the data from the database.
this is what I have done. Have been stuck on it for a while. Appreciate any help.
| @DataModel
| private List<Customer > customers;
| @DataModelSelectionIndex
| private int customerIndex;
|
| @Out(required=false)
| private Customer customer;
|
| @Factory("customers")
| public void findCustomers()
| {
| customers = em.createQuery("select c from customer c").getResultList();
| }
|
| public String selectcustomer()
| {
| setcustomer();
| return("selected");
| }
|
| public void setcustomer()
| {
| customer= customers.get(customerIndex);
| }
|
And I inject customer on the other Action.java and use it to query for related data. but it doesn't work. Am I doing it wrong?
Here's the code for second Action.java
| @In
| private Customer customer;
|
| @DataModel
| private List<Result> results;
|
| public void getResult()
| {
|
| results = em.createQuery("select r from Result r where r.subscription_id = :SID")
| .setParameter("SID", patient.getId())
| .getResultList();
|
| }
|
build and deploy successfully but just not returning anything from getResult, a blank page. I have no idea why.
Regards,
Andy
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078333#4078333
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4078333
More information about the jboss-user
mailing list