Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1097285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:24:35+00:00 2026-05-17T00:24:35+00:00

How do I convert the following example to use one of the wicket/IOC integration

  • 0

How do I convert the following example to use one of the wicket/IOC integration packages?

I want to learn and understand the DI/IOC pattern. I have read a lot about it, but I’ve found it a little hard to grasp without digging into a code example. I have an example of a complete, working Wicket panel, which I think I want to convert to using DI.

The panel is basically a web UI editor for a list. It takes an IPanelFactory as a constructor argument. The constructor creates a list (DefaultRefreshingView), and the panel factory knows how to create a ViewPanel for each row. The panelFactory also knows how to create an add form, for introducing a new item into the list.

I will cut out a lot of code to get to the heart of what I think is relevant:

public interface IPanelFactory<T extends DomainEntity, U extends DomainEntity>
        extends IDetachable {
    IAddItemPanel<T, U> newAddItemPanel(String id);

    Component newEditPanel(ViewPanel.ViewPanelParameters<T> parms);

    Component newListPanel(String id, IModel<Collection<T>> listModel);
}

public class ListEditorPanel2<T extends DomainEntity, U extends DomainEntity>
        extends Panel implements IHeaderContributor {
    private static final long serialVersionUID = 1L;

    private final IPanelFactory<T, U> panelFactory;

    public ListEditorPanel2(String id, IModel<Collection<T>> listModel,
            final IPanelFactory<T, U> panelFactory) {
        super(id, listModel);
        this.panelFactory = panelFactory;

        final AjaxCell listCell = new AjaxCell("listCell");
        DefaultRefreshingView<T> itemList = new DefaultRefreshingView<T>(
                "itemList", listModel) {
            @Override
            protected void populateItem(final Item<T> item) {
                Component editPanel = ListEditorPanel2.this.panelFactory
                        .newEditPanel(new ViewPanelParameters<T>("viewPanel",
                                item.getModel(), new EditPanelCallback(item)));
                item.add(editPanel);
            }
        };
        listCell.add(itemList);
        add(listCell);

        final IAddItemPanel<T, U> addItemPanel = panelFactory
                .newAddItemPanel("addItemForm");
        add((Component) addItemPanel);
        Form<T> form = addItemPanel.getForm();
    }
}

Each implementation of IPanelFactory provides different components for the View and Add sections. There can be multiple instances of ListEditorPanel2 that use different factory implementations in the same page hierarchy.

My thinking is that I want IPanelFactory to be an injected dependency. So…

  • Is this a good use case for DI/IOC, or does it not make sense to use it here?
  • How would I do this “by hand” without using an IOC container? (Am I doing it already?)
  • Which wicket-IOC integration should I use? I am using wicket 1.4.8 at present. I was going to try wicket-spring-annot, but it looks like that project is out of date.
  • How do I set up the IOC container to do this for my wicket components?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:24:35+00:00Added an answer on May 17, 2026 at 12:24 am

    I dont quite understand your use case but i will try to answer your question anyway.
    Wicket has great support for the 2 most popular DI containers namely Spring and Guice. Personally i prefer using guice since it i find it less bloated and easier to use. You need to understand how guice works and how guice modules are created. To intergrate you wicket application with guice, you do something like below on your wicket application init method:

    Injector injector = Guice.createInjector(new   AppModule(),PersistenceService.usingJpa().across(UnitOfWork.REQUEST).buildModule());
    addComponentInstantiationListener(new GuiceComponentInjector(this, injector));
    

    Here am instantiating a guice injector with 2 modules, namely appModule and Persistence module (ignore the persistenceModule details . am using warp persist for transactions)

    In a guice module, you bind all the components that you would like to be injecting. I mostly bind my Daos and my services. I can then inject the same to my panels, pages and any other wicket component. I can also bind panels and other custom components so that i can inject them to other components as neccessary. I have however not found a situation where i will need to bind and inject a user interface component.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problems when I want to use implicit methods to convert a
so I want to convert NSString to double. I found the following example: NSString
i want to read\write a binary file which has the following structure: The file
I would like to convert / form the following arrays as example: Array (
Good day. I could really use your help on this one. I have a
I'm trying to convert following java snippet to Xtend, but i couldn't able to
I am trying to convert following table data into nested array using PHP. I
Can anyone provide a working sample code to convert following Oracle DB table with
I am a java devloper and I wish to convert following code to java
How can I convert the following JSON response to a C# object? { "err_code":

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.