1
votes

I'm trying to display an authorization matrix in wicket.

I could come up with 2 solutions so far, but I can't find an advantage in either of them.

First one, which I'd prefer at the moment: DataTable
I'm thinking of creating a DataTable with custom rows and columns and then overriding the newCellItem method to place an AjaxCheckBox in every cell and read the information of column to row as value from it.

problem: I don't need a provider and as far as I know it's not possible to make a table without one.

2nd idea: ListView
It would be pretty easy to add them row by row with a static header row.

problem: I'd loose every advantage a table has.

Is there any "best practice" Wicket provides or should I go on with the DataTable? And if so: Is there no possibility to create a table without a Provider?

Because I get all information with my methods

getAllRoles() AND getAllDependencies();

which will return a Set.

4

4 Answers

1
votes

Usually we use near connection between Wicket repeaters (tables) and HTML in sense X-Y dimensions (HTML has 3x4, wicket has DataTable with 3 columns ant 4 objects in model etc ) , but this not required.

Wicket Repeater can write data in-line, simple one dimension Repeater break from Java code to html rows etc (emit extra tags as object or ordinary string).

Is possible to emit from Repeater in one sequence and break/format by CSS. I made such 1-2x in my wicket life, quite hard because I'm not good webdeveloper, but possible

Wicket DataTable may be not elegant solution when his Columns are not connected to real-life n-property row object. Provider for such DataTable must lie, not simulate real problem doimain.

0
votes

take a look at InMethod grid component from wicketstuff project: http://www.wicket-library.com/inmethod-grid/data-grid/editable-selection I think it goes into the right direction.

0
votes

I think DataTable should be a good basis. It is not very hard to write a provider. You can even use a pre-cooked one, the ListDataProvider

The 'hard' part is that almost all default Wicket repeaters are row-based, i.e. they use some pre-defined set of IColumns. As long as you do not dynamically change the columns, DataTable should be fine.

0
votes

My final solution was to create a ListView for the rows and one for the columns. In my row ListView I have a ListView for cells, which has the same amount of objects as "columns".

Edit: Since it has gone through many changes, I removed the code snippets. But still, nested ListViews are doing the job.
If you keep in mind how the structure in the .html should be, you can easily access it with mulitple ListViews.