That's exactly it. -Igor
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Andrew Berman > Sent: Thursday, October 06, 2005 11:55 AM > To: [email protected] > Subject: RE: [Wicket-user] Dynamic HTML Element Creation > > Igor, > > So basically you are saying to do something like this (in > pseudocode): > > if (CHECKBOX) > add(new CheckboxPanel("formPanel")); else if (SELECT) > add(new SelectPanel("formPanel")); > ... > > and then in the HTML: > > <form...> > <span wicket:id="formPanel"/> > </form> > > Is this correct? > > Thanks! > > Andrew > > > > --- Igor Vaynberg <[EMAIL PROTECTED]> wrote: > > > If you take this approach you have to add all possible > element to the > > listitem and mark them as hidden. In my opinion, a better approach > > would be to create a panel for each question type and only add the > > proper panel. This approach will avoid the problem you are > currently > > having. It also makes it very easy to add other question > types since > > all you would have to do is provide a different panel as opposed to > > editing an existing template to add the new html. > > > > -Igor > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] > > On Behalf Of > > > Andrew Berman > > > Sent: Thursday, October 06, 2005 11:26 AM > > > To: [email protected] > > > Subject: [Wicket-user] Dynamic HTML Element > > Creation > > > > > > My application allows users to set up questions > > and valid > > > responses for those questions, which are > > subequently saved ot > > > the db. Along with the question is the ability to > > state what > > > type of HTML element the responses should show as. > > For > > > example, if the question is designated as > > CHECKBOX, then the > > > responses should all show as checkboxes. > > > > > > When I display the questions that are in the > > database, I loop > > > through the questions and based on what type they > > are, build > > > the proper component. However, the issue comes in > > because in > > > the HTML, I have every type of HTML form element > > that the > > > question could be. So, let's say quesiton one is > > a CHECKBOX, > > > when it goes through the HTML, it also finds > > wicket ids of > > > multiSelect, select, etc., but these do not exist > > in the > > > current ListItem, only checkbox does, so Wicket > > throws an > > > exception. Basically, I need an "if this id > > exists, do this, > > > otherwise, skip it." Am I going to have to custom > > build > > > something to do this, or is there maybe something > > I'm missing > > > or some other way to accomplish this. > > > > > > Thanks for any help you can give, > > > > > > Andrew > > > > > > Here is some code that may help out with my > > explanation. In > > > the page code I do this: > > > > > > add(new ListView("categoryQuestions", > > > categoryQuestions) { > > > > > > @Override > > > protected void > > populateItem(ListItem > > > item) { > > > CategoryQuestion cq = > > > (CategoryQuestion) item > > > .getModelObject(); > > > > > > ResponseType type = cq.getResponseType(); > > > List<CategoryQuestionResponse> > > > > > cqResponses = new > > ArrayList<CategoryQuestionResponse>( > > > > > cq.getValidResponses()); > > > > > > > > > if > > > (type.equals(ResponseType.CHECKBOX)) { > > > item.add(new > > > CheckBoxMultipleChoice("checkbox", cqResponses, > > > new > > > ChoiceRenderer("response.text", "id"))); > > > } else if > > > (type.equals(ResponseType.DROPDOWN)) { > > > item.add(new DropDownChoice("dropdown", > > > cqResponses, > > > new > > > ChoiceRenderer("response.text", "id"))); > > > } else if > > > (type.equals(ResponseType.MULTI_SELECT)) { > > > item.add(new > > > ListMultipleChoice("multiSelect", cqResponses, > > > new > > > ChoiceRenderer("response.text", > > "id")).setMaxRows(5)); > > > } else if > > > (type.equals(ResponseType.RATING)) { > > > // > > > } > > > } > > > > > > Then in the HTML I do: > > > > > > <form wicket:id="questionForm"> > > > <span wicket:id="categoryQuestions"> > > > > > > <select wicket:id="dropdown"> > > > <option>Option 1</option> > > > </select> > > > <select wicket:id="multiSelect"> > > > <option>Option 1</option> > > > </select> > > > <input wicket:id="checkbox" > > > type="checkbox"/> > > > > > > </span> > > > </form> > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.Net email is sponsored by: > > > Power Architecture Resource Center: Free content, > > downloads, > > > discussions, and more. > > http://solutions.newsforge.com/ibmarch.tmpl > > > _______________________________________________ > > > Wicket-user mailing list > > > [email protected] > > > > > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: > > Power Architecture Resource Center: Free content, downloads, > > discussions, and more. > > http://solutions.newsforge.com/ibmarch.tmpl > > _______________________________________________ > > Wicket-user mailing list > > [email protected] > > > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, > discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > Wicket-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/wicket-user > > > ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
