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 7946921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:17:04+00:00 2026-06-04T01:17:04+00:00

I am trying to understand how Wicket LoadableDetachable model is working. What i understand

  • 0

I am trying to understand how Wicket LoadableDetachable model is working.
What i understand from the Wicket documentation is in a normal scenario , when the request completes the processing wicket will auto serialize the all components with associated model values. This one will consumes more memory . If we use the LoadableDetachable model at the time of serialization the model values will not get serialized. Is this right? . So it will detach the model object automatically . So For the next request the model value will be reload again automatically? See my below code.

public class ProductListPanel extends Column<Product> {

    @SpringBean
    private ProductService productService;
    private List productList;


    public ProductListPanel(String id) {
        super(id);
        class ProductModel extends LoadableDetachableModel {

            @Override
            public void detach() {
                // TODO Auto-generated method stub
                productList = null;
                System.out.print("Called Detach Object\n");
            }


            @Override
            protected Object load() {
                // TODO Auto-generated method stub
                productList = productService.findAll();
                System.out.print("Called Get Object\n");
                return productList;
            }

        }
        System.out.print("Before creating also calling\n");
        final ProductModel productModel = new ProductModel();

        ListView view = new ListView("list", productModel) {

            protected void populateItem(ListItem item) {
                System.out.print("\nBefore start also calling\n");
                System.out.print("Before this one is callling \n");
                Product result = (Product) item.getModelObject();
                item.add(new Label("code", result.getCode()));
                item.add(new Label("name", result.getName()));
                final Link deleteLink = new Link("remove", item.getModel()) {

                    @Override
                    public void onClick() {
                        Product product = (Product) getModelObject();
                        productService.delete(product);

                    }

                };
                item.add(deleteLink);

            }
        };

        add(view);
        Link addProductLink = new Link("addProduct") {

            @Override
            public void onClick() {
                // TODO Auto-generated method stub
                setResponsePage(new AddProduct());
            }

        };
        add(addProductLink);
        productModel.detach();
    }
}

In the above code i am listing all the products from the DB. and i am having Remove link for each product , when we are clicking that link i am removing the product from the DB. After clicking the Remove link the page is not getting refreshed means it still showing the deleted product . if i add this line productModel.detach(); then it is working properly . My question here is why i have to call productModel.detach(); manually? LoadableDetachableModel suppose do automatically right?

Please help me

  • 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-06-04T01:17:05+00:00Added an answer on June 4, 2026 at 1:17 am

    LoadableDetachableModel caches the retrieved object for the duration it is attached. When you load the data from the database, all items are there. Then you execute a query to delete a record, but don’t update the list. So either you have to change your onClick handler to also update the retrieved list, or just detach the model.

    There is no magic in LoadableDetachableModel. Take a look at the code below:

    List<Person> people = dao.getListOfPeopleAttendingParty();
    
    // assume that the number of people attending the party is 4
    assert people.size() == 4;
    
    Person guest = people.get(0);
    dao.delete(guest);
    
    // what is the number of people attending the party now?
    assert people.size() == ?;
    

    What do you think that people.size() is now?

    The execution of LoadableDetachableModel is not any different than the code snippet above:

    List<Person> people = peopleModel.getObject(); // is called by ListView
    
    // assume that the number of people attending the party is 4
    assert people.size() == 4;
    
    Person guest = people.get(0);
    dao.delete(guest);
    
    // what is the number of people attending the party now?
    assert people.size() == ?;
    

    So: no magic involved, just plain Java and ordinary logic.

    PS. The answer to both questions is 4 even though the database no longer holds the guest

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

Sidebar

Related Questions

I trying to understand Model to ViewModel relation and I keep bumping in the
I trying to understand if a isset is required during form processing when i
Trying to understand the relationship between UIView and CALayer. I read Apple documentation but
Im trying to understand when to call autorelease, and what this will actually do
Trying to understand why rownames = FALSE is not passed on from Test to
Am trying to understand jquery. Am a bit slow, maybe cause I come from
Trying to understand the Android framework model. I have an application that needs to
While trying to understand Rvalue references from here , I am unable to understand
Trying to understand upcasting in Java. Recently observed strange behavior. Example: public class A
Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults

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.