Hi,
  I'm currently trying to 'mirror' a quick & dirty JSP page in  Wicket & wondering how best do a particular thing...

  I've got a list of Services, with basically a String ('name') and a boolean attribute ('free').  There are 90-odd of these, and I need to display them as checkboxes in a set of columns.  The Q&D JSP method puts them in a table, with a set of checkboxes making up a column in a <td>...</td>, as below...

    String generateServiceTable(List services, int colSize, String listName) {
        int cols = (services.size() / colSize) + 1;
        StringBuffer sb = new StringBuffer();
        sb.append("<table ><tr>\n");
        int rows = 0;
        for (int i = 0, ; i < services.size(); i++) {
            Service service = (Service) services.get(i);
            if (rows == 0) {
                sb.append("<td valign=top width=\"" + 100 / cols + "%\">\n");
            }
            rows++;
            sb.append("<input type=\"checkbox\" name=\"" + listName + "\" value=\"");
            sb.append(service.getName());
            sb.append("\"");
            if (service.isFree()) {
                sb.append(" checked");
            }
            sb.append(">");
            sb.append(service.getName());
            sb.append("<br>\n");
            if (rows == colSize) {
                sb.append("</td>\n");
                rows = 0;
            }
        }
        sb.append("</tr>\n");
        sb.append("</table>\n");
        return sb.toString();
    }

so I get a

   a1[]   a11[]  a21[]  a31[] ...
   a2[]   a12[]  a22[]  a32[] ...
...
  a10[]   a20[]  a30[]  a40[] ...

effect, but I'm having difficulty working out a good/clean/simple way of achieving the same result with Wicket.
(Note that using the same name on the checkboxes results in them behaving in the same way as a multiple-choice list does, in terms of what the browser dispatches, at least.)

  I had this all working happily, using a ListMultipleChoice, so I've got the 'surrounding' form/model, etc, it's just how best to do this that's unclear...

/Gwyn

Reply via email to