class TestPage externds WebPage {
   private String sql;
  
   public String getSql() { return sql; }

   public TestPage() {
    ...
    add(new TextArea("foo", new PropertyModel(this, "sql")));
    ...
    IDataProvider dp=new IDataProvider() {
        Iterator iterator(...) {
            return database.query(sql).iterator();
        }
  
       ...
    }
}

what this does is make your textarea write its data into the page's sql property via a property model, the dataprovider does the reverse - pull the sql string out of the page's property

there are many ways to do this - but this one is good for a newbie, hope it gets you started
-Igor



On 6/28/06, itsliang < [EMAIL PROTECTED]> wrote:

Hi all,

I am having a page contains a Form component and a DataTable component.
There is only one TextArea component and one submit button within my Form.
Below that Form, there is my DataTable. The DataTable is primarily used to
show the data from database. The TextArea, of course, is used to get the sql
query string from the user. So once the user submit his query string, the
DataTable will show the query result to him.

The problem I have is: I don't know how to update the data of my DataTable.
How can I reload the data when user submit a new query?

The following code is my rough idea (hence it's incomplete). Can any one
give me an example or a hint? Thanks in advance!

Regards,
Chih-liang Chang

------------------------------------------------------------------------------------

public class TestPage extends WebPage {

        public TestPage() {
                String sql;
                Model sqlQuery = new Model(sql);
                super.add(new TestForm("form", sqlQuery));
                IDataProvider dataProvider = new DatabaseProvider(sqlQuery);
                super.add(new DataTable("table", column, dataProvider, 10));
        }

        private class TestForm extends Form {

                public TestForm(String id, IModel sqlQuery) {
                        super(id, sqlQuery);
                        super.add(new TextArea("text", sqlQuery);
                }

        }

        private class DatabaseProvider implements IDataProvider {

                public DatabaseProvider(IModel sqlQuery) {
                        ...
                }

        }

}
--
View this message in context: http://www.nabble.com/How-to-update-the-data-of-DataTable--tf1865371.html#a5096663
Sent from the Wicket - User forum at Nabble.com.


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to