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

  • Home
  • SEARCH
  • 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 5996401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:05:52+00:00 2026-05-23T00:05:52+00:00

This the exception: java.lang.IllegalStateException: this kind of handler cannot be attached to multiple components;

  • 0

This the exception:

java.lang.IllegalStateException: this kind of handler cannot be attached to multiple components; it is already attached to component [MarkupContainer [Component id = textField1]], but component [MarkupContainer [Component id = textField2]] wants to be attached too
at org.apache.wicket.behavior.AbstractAjaxBehavior.bind(AbstractAjaxBehavior.java:70)
at org.apache.wicket.Component.add(Component.java:973)
at info.ems.wicket.page.HomePage.<init>(HomePage.java:23)

thrown by the following code:

public class HomePage extends MasterPage {

    public HomePage() {
        AjaxEventBehavior ajaxOnClickBehavior = new AjaxEventBehavior("onClick") {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onEvent(AjaxRequestTarget target) {
                // Same behavior of both the textField1 and textField2
            }
        };

        add(new TextField<String>("textField1", new Model<String>("Text Field 1")).add(ajaxOnClickBehavior));
        add(new TextField<String>("textField2", new Model<String>("Text Field 2")).add(ajaxOnClickBehavior));       
    }
}

But this is okay:

public class HomePage extends MasterPage {

    public HomePage() {
        add(new TextField<String>("textField1", new Model<String>("Text Field 1")).add(new AjaxEventBehavior("onClick") {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onEvent(AjaxRequestTarget target) {
                // Behavior of textField1, same as textField2
            }
        }));
        add(new TextField<String>("textField2", new Model<String>("Text Field 2")).add(new AjaxEventBehavior("onClick") {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onEvent(AjaxRequestTarget target) {
                // Behavior of textField2, same as textField1 
            }
        }));        
    }
}

Why?

Thank you.

Added:

public class HomePage extends MasterPage {

    public HomePage() {
        add(new TextField<String>("textField1", new Model<String>("Text Field 1")).add(new AjaxOnClickBehavior("onClick")));
        add(new TextField<String>("textField2", new Model<String>("Text Field 2")).add(new AjaxOnClickBehavior("onClick")));
    }

    private class AjaxOnClickBehavior extends AjaxEventBehavior {

        private static final long serialVersionUID = 1L;

        public AjaxOnClickBehavior(String event) {
            super(event);
        }

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            // Same behavior of both the textField1 and textField2
        }

    }
}
  • 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-23T00:05:53+00:00Added an answer on May 23, 2026 at 12:05 am

    Basically, you can’t assign the same instance of a Behavior to multiple components. If you want to improve readability and maintainability, you can use:

    public class HomePage extends MasterPage {
        public HomePage() {
            add(new TextField<String>("textField1", new Model<String>("Text Field 1")).add(newOnClickBehavior()));
            add(new TextField<String>("textField2", new Model<String>("Text Field 2")).add(newOnClickBehavior()));       
        }
    
        protected AjaxEventBehavior newOnClickBehavior() {
            return new AjaxEventBehavior("onClick") {
                private static final long serialVersionUID = 1L;
    
                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    // Same behavior of both the textField1 and textField2
                }
            };
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This exception peppers our production catalina logs on a simple 'getParameter()' call. WARNING: Parameters:
What is the cause of this exception in ASP.NET? Obviously it is a viewstate
My technical lead insists on this exception mechanism: try { DoSth(); } catch (OurException)
From what I understand of the SDK, this exception is raised when the bindings
I'm using ant to generate javadocs, but get this exception over and over -
Often, I found OutOfMemoryException on IBM Websphere Application Server. I think this exception occur
I'm new to Ruby, so I'm having some trouble understanding this weird exception problem
This is the exception that I'm getting when I'm trying to bind to a
This causes a compile-time exception: public sealed class ValidatesAttribute<T> : Attribute { } [Validates<string>]
This is about when a .NET remoting exception is thrown. If you take a

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.