Hi Ramazan,
I'm also very new to wicket, and I've came across a similar situation too.
I solved my situation by using different panels with the same markup
id. Something like (inside the populateItem method):
if (condition == true) {
item.add(new SomePanel("sameId"));
} else {
item.add(new AnotherPanel("sameId"));
}
In this way, in your markup you'd have something like
<div wicket:id="sameId"></div>
and you could have completely different panels.
Let me know if this helps or if you find a better way
> did not add the component to your page at all, or that the hierarchy
> does not match.
> .....Page.html
> <td wicket:id="categoryList">
>
> <select wicket:id="category"></select>
> </td>, index = 2, current = '<select
> wicket:id="category">' (line 16, column 18)]
> at
> org.apache.wicket.markup.MarkupStream.throwMarkupException(MarkupStream.java:536)
>
>
> This is form code:
>
> public class DynamicForm extends Form {
>
> private static final long serialVersionUID = 1L;
>
> final ListView<CategoryModel> listView;
>
> private List<CategoryModel> categories;
>
> public DynamicForm(String id) {
> super(id);
>
> categories = new ArrayList<CategoryModel>();
> categories.add(new CategoryModel(masterCategories));
>
> final WebMarkupContainer listContainer = new
> WebMarkupContainer("categoryContainer");
> listView = new ListView<CategoryModel>("categoryList", categories) {
>
> private static final long serialVersionUID = 1L;
>
> @Override
> protected void populateItem(final ListItem<CategoryModel> item) {
> final CategoryModel category = item.getModelObject();
> ListChoice<OmCategory> listChoice = new ListChoice<OmCategory>(
> "category",
> new PropertyModel<OmCategory>(category, "selectedCategory"),
> masterCategories,
> new IChoiceRenderer<OmCategory>() {
> private static final long serialVersionUID = 1L;
>
> public Object getDisplayValue(OmCategory omCategory) {
> return omCategory.getCategoryCode().getLocalized();
> }
>
> public String getIdValue(OmCategory omCategory, int index) {
> return omCategory.getRowId();
> }
> }
> );
> listChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
> private static final long serialVersionUID = 5417882427051940952L;
>
> @Override
> protected void onUpdate(AjaxRequestTarget target) {
> if(categories.size() > 1 && (categories.indexOf(category)
> + 1) != categories.size()) {
> categories = new
> ArrayList<CategoryModel>(categories.subList(0,
> (categories.indexOf(category) + 1)));
> }
> categories.add(new CategoryModel(masterCategories));
> target.add(listContainer);
> }
> });
> if(categories.indexOf(item.getModelObject()) != -1) {
> item.add(listChoice);
> } else {
> item.remove(listChoice);
> }
> }
> };
> listView.setOutputMarkupId(true);
> listContainer.add(listView);
> listContainer.setOutputMarkupId(true);
> add(listContainer);
> }
> }
>
>
> First time I am developing with wicket, and maybe I use wrongly. I'm
> new and any feedback is appreciated... Sorry for my english :)
>
> Br.
> Ramazan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
Rodrigo H M Bezerra
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]