Well, there's one (partial) solution like this

Html:
       <table>
            <tr>
                <span wicket:id="freeServices">
                    <td valign="top" width="10%">
                        <span wicket:id="cols">
                            <input type="checkbox"
wicket:id="checks"/><span wicket:id="labels">Dummy Item</span><br/>
                        </span>
                    </td>
                </span>
            </tr>
        </table>
Java:
            int colSize = 10;
            List checkboxes = new ArrayList(), column = new ArrayList();
            for (int i = 0; i < services.size(); i++) {
                column.add((Service) services.get(i));
                if ((i+1) % colSize == 0) {
                    checkboxes.add(column);
                    column = new ArrayList();
                }
            }
            if (!column.isEmpty()) {
                checkboxes.add(column);
            }

            add(new ListView("freeServices", checkboxes) {
                public void populateItem(final ListItem col) {
                    List column = (List) col.getModelObject();
                    col.add(new ListView("cols", column) {
                        protected void populateItem(final ListItem item) {
                            Service service = (Service) item.getModelObject();
                            item.add(new Label("labels", service.getName()));
                            item.add(new CheckBox("checks", new
Model(String.valueOf(service.isFree()))));
                        }
                    });
                }
            });

But there are still a number of issues such as the way I have to(?)
use both a CheckBox and a Label (html "value" attribute should be
available, making the Label unneeded) and the way (which I've not yet
confirmed but suspect) that I'll need to deal with the results
individually, rather than en-masse, even before my own issues such as
the hard-coded HTML "10%" needing making dynamic.

All of this suggests to me that there's an area of form support that
could do with a closer look, in that it looks to me as if there's some
core functionality missing with regards to CheckBoxes used in groups,
rather than individually.

(I don't know if I can come up with anything, but it'll at least give
me a purpose in trying to understand the internals of what's happening
in forms...)

/Gwyn

On 16/08/05, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> <td>
> item1<br> item2<br>
> </td>
> 
> could be done just with a listview too:
> 
> <td>
> <span wicket:id="list"><span wicket:id="label" /><br></span>
> </td>
> 
> those spans shouldn't be in your way, and you could even set the
> rendering of the tags off.
> 
> And you can nest listview as deep as you want.
> 
> But I probably don't understand what you mean? :)
> 
> Eelco
> 
> Gwyn Evans wrote:
> 
> >I don't think so, or at least it's the step beyond that that I'm not
> >seeing.  My tries with a  ListView gave me a repeated set of
> ><td>item</td> blocks, (using a Label for the item), but I can't see
> >how I can generate something like:-
> ><td>
> >item1<br>
> >item2<br>
> >..
> >item10<br>
> ></td><td>
> >item11<br>
> >item12<br>
> >..
> ></td>
> >
> >I think that if the original 1-row format isn't kept, I might be able
> >to do something similar, where the key might be to explicitly re-map
> >the input list into a list of 'horizontal' lists, then use a series of
> ><tr>'s enclosing <td>'s, each enclosing a single item, but that didn't
> >seem to be all that simple/clean and I wondered if I was missing
> >something obvious...  (Maybe I need to investigate extending
> >ListMultipleChoice or it's parent, and see where that gets me.)
> >
> >/Gwyn
> >
> >On 16/08/05, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
> >
> >
> >>First a Form. The a ListView. And for each row a Label and a CheckBox
> >>component? As the checkboxes paths are unique for each row, you should
> >>have no problems there.
> >>
> >>Doesn't that work for you?
> >>
> >>Eelco
> >>
> >>Gwyn Evans wrote:
> >>
> >>
> >>
> >>>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
> >>>
> >>>
> >>
> >>
> >>-------------------------------------------------------
> >>SF.Net email is Sponsored by the Better Software Conference & EXPO
> >>September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> >>Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> >>Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> >>_______________________________________________
> >>Wicket-user mailing list
> >>[email protected]
> >>https://lists.sourceforge.net/lists/listinfo/wicket-user
> >>
> >>
> >>
> >
> >
> >-------------------------------------------------------
> >SF.Net email is Sponsored by the Better Software Conference & EXPO
> >September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> >Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> >Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> >_______________________________________________
> >Wicket-user mailing list
> >[email protected]
> >https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
> >
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to