Hi,
SQLResultRow is a type I made up. I didn't know what type you received
from your SQL query, so I used that. I assumed that your result set is
composed of rows where each row can be used as a "map" with key=column
name and value=column value.
With that in hand, you could iterate over the keys to build the list of
datatable columns. Each column would hold its key value and would use it
to access the proper column value from a result row.
On 23/07/2011 10:12 AM, davut uysal wrote:
Hi Bertrand,
What is SQLResultRow, is it a Wicket Type? Or should I create a custom class
named "SQLResultRow"?
The problem is, I can't create a custom "SQLResultRow" because I can't be
sure of its member fields.
User can run any SQL, so the type must be compatible with any result. For
example:
1) select firstname, lastname from employees; => Returns<Employee>
2) select locationcode, locationname from locations; => Returns<Location>
... (any SQL can return any unpredictable object)
So it is impossible to create a custom "SQLResultRow"
Anyway, I have solved the problem in the complex, hard way which is about to
use 2 nested repeaters (ListView). 1 for table column names loop, 1 for
table rows loop.
And, I got the answer: There is no easy way in wicket to do that kind of
dynamic thing.
Thanks,
On 22 July 2011 18:03, Bertrand Guay-Paquet<[email protected]> wrote:
Hi,
Here is the outline of a possible implementation :
Execute SQL String
Create a List<IColumn<SQLResultRow>>
for each SQL result column:
add a column to the list that displays one column of a SQLResultRow
Create a very simple ISortableDataProvider that returns the SQL result from
above
(make it more complex to implement sorting)
Create a DataTable using the column list and the data provider
On 22/07/2011 2:05 AM, davut uysal wrote:
Someone in another forum advised me this:
***
Maybe in latest Wicket something changed but in 1.4.16 you can't change
Columns in DataTable. So it's immutable in some sense.
But you may replace whole DataTable component instead when your sql
statement changes:
form.add(new Button("sqlSubmit") {
void onSubmit() {
String sql = ...;
form.replace(createDataTable("**myDataTable", sql));
}
})
form.add(createDataTable("**myDataTable", null));
Where createDataTable() creates DataTable using provided id and sql
string.
Also there is a convenient method Component.replaceWith(). Maybe it'll fit
better to your coding style.
***
I think this is what I need, but I dont know how to do. Can someone please
help me to create below method?
*createDataTable("wicketId", "SQL")*
Thanks,
On 21 July 2011 21:05, Andrew
Fielden<andrew.fielden@power-**oasis.com<[email protected]>
wrote:
I see your problem Davut, but I really don't think Wicket can solve it in
the
way you want it to. As Martin said, you need an<entity> to populate the
models used by the various Wicket components.
Could you somehow parse the SQL statement to extract the table name, and
find its meta data?
--
View this message in context:
http://apache-wicket.1842946.**n4.nabble.com/dynamic-**
DataTable-tp3683514p3684513.**html<http://apache-wicket.1842946.n4.nabble.com/dynamic-DataTable-tp3683514p3684513.html>
Sent from the Users forum mailing list archive at Nabble.com.
------------------------------**------------------------------**
---------
To unsubscribe, e-mail:
users-unsubscribe@wicket.**apache.org<[email protected]>
For additional commands, e-mail: [email protected]
------------------------------**------------------------------**---------
To unsubscribe, e-mail:
users-unsubscribe@wicket.**apache.org<[email protected]>
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]