On 4/19/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
int cols=5;
int rows=5;
final String[][] values=new String[rows][cols];
form.add(new Loop("rows", rows) {
populateitem(Item item) {
final int row=item.getindex ();
item.add(new Loop("cols", cols) {
populateitem(Item item) {
final int col=item.getindex();
IModel model=new Model() {
setobject(Component c, Object o) {
values[row][col]=o;
}
Object getObject(Component c) {
return values[row][col];
}};
item.add(new TextField("cell", model));
});
<table>
<tr wicket:id="rows"><td wicket:id="cols"><input type="text" wicket:id="cell"/></td></tr>
</table>
-Igor
On 4/19/06, Ayodeji Aladejebi <[EMAIL PROTECTED] > wrote:I am developing a web based solution for a client that prefers to enter records into the system like it is done in Excel so that in a single click of Submit , several rows in the database can be updated at once. Now i want to build a multi dimensional array of Textfields that maps to multiple rows in a database. I built this once in Servlet and JSP where a loop wipes accross the request.getParameterMap() and updates each corresponding row/column in the database.Now looking at Wicket, what will be the neatest way to get this done. I could create so many textfields like//Column 1TextField A1 = new TextField("A1");TextField A2 = new TextField("A2");...TextField An = new TextField("An");//Column 2TextField B1 = new TextField("B1");TextField B2 = new TextField("B2");...TextField Bn = new TextField("Bn");Now my Bean Model will have to contain a field each for all these textfields. is it?Except its not neccesary, but for these kind of problem, is it possible to have a feature like this: ,maybe,TextField[][] fields = FormComponentUtilities.createGrid(row,column,fieldsModel); //model must be 2D arrayform.add(fields);then in my model object, I have,private String[][] fieldsModel;When I submit the grid, i cant simply work the 2D array to update the backend.If this feature will not be neccessary, what better way can i go about it?thanks
