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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:57:11+00:00 2026-06-13T14:57:11+00:00

I’ve struck a problem with Java and Apache Wicket 1.5 where the identity of

  • 0

I’ve struck a problem with Java and Apache Wicket 1.5 where the identity of the enclosing Java object for two anonymous classes has changed!

Within one Wicket modal window I want to create a second modal window (for getting a text string prompt) and then update the original modal window with an AJAX refresh of the model (a list of string-integer pairs).

Basically I have two anonymous classes created in the same method but the ‘this’ pointer for the enclosing instance is different between one anonymous class and the other.

This does not seem like normal expected JVM behavior to me but I haven’t been able to find any specifics of how this works in the Java Specification either.

public class DropDownChoiceModal extends WebPage {

    public String newTermResponse;

    private void addAddTermModal() {
        addTermModal = new ModalWindow("add_term_modal");
        addTermModal.setPageCreator(new ModalWindow.PageCreator() {
            public Page createPage() {
                PropertyModel pm = new PropertyModel<String>(DropDownChoiceModal.this, "newTermResponse"); 
                System.out.println ("propModel: " + System.identityHashCode(DropDownChoiceModal.this)); 
                return new TextInputModal(addTermModal, "What is the new term you wish to add?", pm);
            }
        });

        addTermModal.setWindowClosedCallback(new WindowClosedCallback() {
        public void onClose(AjaxRequestTarget target) {

            System.out.println ("propModel: " + System.identityHashCode(DropDownChoiceModal.this)); 
            System.out.println ("newTermResponse: " + DropDownChoiceModal.this.newTermResponse);

            // If the value is set then use it 
            if (newTermAvailable()) {

                // Add the new term to the model
                model.add(new StringIntegerPair (newTermResponse, 0));

                System.out.println ("Update view: " + model.size());

                // Update the view
                target.add(wmc);
            }
            System.out.println ("No new term");
        }

        private boolean newTermAvailable() {
            return (newTermResponse != null) && !newTermResponse.isEmpty();
        }
    });

    add(addTermModal);
    }

For the TextInputModal class:

public class TextInputModal extends WebPage {

public TextInputModal(final ModalWindow modal, String requestString, final IModel<?> model) {
    Form<String> form = new Form<String>("form") {
        public void onSubmit() {
            System.out.println ("Submitted: " + System.identityHashCode(((PropertyModel)model).getTarget()) + "; " + model.getObject());
        }
    };

    // Add the buttons
    form.add(new AjaxButton("ok") {
        public void onAfterSubmit(AjaxRequestTarget target, Form<?> form) {
            System.out.println ("Submitted 2: " + System.identityHashCode(((PropertyModel)model).getTarget()) + "; " + model.getObject());
            modal.close(target);
        }
    });

    // Add the form
    add(form);
}
}

The output I get:

propModel: 698650686
Submitted: 698650686; fdsfds
Submitted 2: 698650686; fdsfds
propModel: 1447892364
newTermResponse: null
No new term

Any ideas why the identity of the enclosing instance (DropDownChoiceModal.this) has changed between anonymous class 1 ( new ModalWindow.PageCreator() {} ) and anonymous class 2 ( new WindowClosedCallback() {} ) when they are created in the same method ( addAddTermModal() )?

Thanks in advance…

Nigel

  • 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-13T14:57:12+00:00Added an answer on June 13, 2026 at 2:57 pm

    Big thanks to biziclop in the comments above… it looks like Wicket was clobbering the object when it was getting serialized – the contents of the “newTermResponse” String were getting lost somewhere during this serialization.

    I went back to the example of nested ModalWindow’s here:

    http://www.wicket-library.com/wicket-examples/ajax/modal-window

    Using getPageReference() as shown in the example instead of PropertyModel solved my issue.

    Cheers,

    Nigel

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters
I have an array which has BIG numbers and small numbers in it. I
i got an object with contents of html markup in it, for example: string

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.