I have created a CMS in Wicket 1.3 and have run into a problem.

A CMS-page consits of multiple "articles". The articles are laid out on the page using a ListView. Normally, an article just displays title, text etc, so each article is represented by a simple Fragment that holds the fields etc. A simplified version of populateItem looks like:

item.add(new ArticleFragment("article", "articleFragment", item.getModel()));

Now I also need to support custom modules (Wicket Panels) as articles, so I created a field in my article object that can contain a fully qualified class name that should resolve to a Panel, and I do something like:

if(article.getArticleType().equals(Article.ARTICLE_TYPE_PANEL_CONTROLLER) && !Strings.isEmpty(article.getControlsPanel())) {
    Class panelClass = Class.forName(a.getControlsPanel());
    Constructor panelConstructor = panelClass.getConstructor(String.class);
    item.add((Panel) panelConstructor.newInstance("article"));
} else
item.add(new ArticleFragment("article", "articleFragment", item.getModel()));

This works great. The problem arise when I need to maintain state in a panel included this way. When the page rerenders because of a form submit, the panel is recreated because of the actions in the populateItem method of the page, and I'm screwed.

Any idea of how I could avoid this? I've started getting crazy ideas about getting the panel from the pagemap or something and adding it back via item.add(), but I don't know how to, or if that will blow up in my face :)

Anyone? :)

-- Edvin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to