Link to home
Start Free TrialLog in
Avatar of haileysdad
haileysdad

asked on

DefaultTableModel

Is there a possibility of using the DefaultTableModel in conjunction with JSF pages?  I am trying to add database field  to a table in JSF.  I don't want to use drop down lists and that seems to be the only info I can find.  Any help would be greatly appreciated.  I have code to look at if need be.
SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of haileysdad
haileysdad

ASKER

Can it be used with JSF?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
   I am trying to implement this code but it keeps telling me that it cannont find symbol.

    private void displayResults(List courseList){
        Vector<String> tableHeaders = new Vector<String>();
        Vector tableData = new Vector();
        tableHeaders.add("Course ID");
        tableHeaders.add("Course Name");
        tableHeaders.add("Section");
        tableHeaders.add("Instructor");
 
        for(Object o : courseList){
            Courses course = (Courses) o;
            Vector<Object> oneRow = new Vector<Object>();
            oneRow.add(course.getCourseId());
            oneRow.add(course.getCourseName());
            oneRow.add(course.getSectionId());
            oneRow.add(course.getInstructor());
            tableData.add(oneRow);
        }//end for
    resultsTable.setModel(new DefaultTableModel(tableData, tableHeaders));
    }//end displayResults

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
symbol: method setModel(javax.swing.table.DefaultTableModel)
location: class com.sun.webui.jsf.component.Table
I don't want it to use that location, but it seems as if there are no other choices as the design view only provides one type of table.
All my imports
import addressBookDB.Courses;
import addressBookDB.HibernateUtil;
import com.sun.data.provider.impl.CachedRowSetDataProvider;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.Label;
import com.sun.webui.jsf.component.Table;
import com.sun.webui.jsf.component.TextField;
import com.sun.webui.jsf.model.DefaultTableDataProvider;
import java.util.List;
import java.util.Vector;
import javax.faces.FacesException;
import javax.swing.table.DefaultTableModel;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
so I can't use it where ever I want.  Any ideas on how to get may data to the tables using buttons?
i don't siorry, we don't use jsf. All the examples I have seen just dealing with binding tables to databases

I've seen plenty of tutorials on using drop down lists, but it is hard to implement them for what I want to do.  Oh, well thanks for your time.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial