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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:52:32+00:00 2026-06-17T06:52:32+00:00

if I have an input wrapped in a div (together with other stuff), how

  • 0

if I have an input wrapped in a div (together with other stuff),
how can I pass to that input whatever beavior is added to the wrapper?

Example:
Component HTML goes like <div> <img> <input> ...
Then I’d like to add it like add( new MyComponent("foo", model).add( new AjaxEventBehavior("onupdate"){ ... } (but that doesn’t work since only FormComponent can receive (AjaxEventBehavior`s).

I assume I could move this behavior object from wrapper to input, but don’t know where – is there some “after construction” listener?
Or should I do it completely different, like passing the behavior as a parameter?
The reason to keep it like above is to make it transparent for the user of the component.

  • 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-17T06:52:33+00:00Added an answer on June 17, 2026 at 6:52 am

    You could override the MarkupContainer#add(Behavior... behaviors) method of the wrapping component. This would of course mean that the wrapping component could never receive any behaviors:

    public class MyWrappingComponent extends Panel {
        private TextField<?> field;
    
        // Constructors and stuff..
    
        @Override
        public Component add(Behavior... behaviors) {
            field.add(behaviors);
            return this;
        }
    }
    

    One option is to separate the wrapping component to be a Border, which can be used to surround components with content. This would, however, reduce the “transparency” of the wrapping element. (See the example on the Javadoc page).

    public class MyWrappingBorder extends Border {
        public MyWrappingBorder(String id) {
            // add the <img />
            // add the <div />
        }
        ...
     }
    
     // The markup
     <wicket:border>
         <div>
            <img />
            <wicket:body /> <!-- Will be replaced with the added content -->
         </div>
     </wicket:border>
    

    Then use it like this:

     add(new MyWrappingBorder("border")
         .add(new TextField<String>("input").add(/* the behaviors */)));
    

    With this kind of markup

     <div wicket:id="border">
         <input type="text" wicket:id="input" />
     </div>
    

    The Border approach would enable you to reuse the border component without the `TextField? component. E.g., if you want to add a drop-down:

     add(new MyWrappingBorder("border")
         .add(new DropDownChoice<String>("input", listOfChoices)));    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html form(ASP.Net MVC). The input textboxes are wrapped in a div
I have few form fields, each input and label is wrapped inside a div
I have some HTML like this: <div id=SomeID> <div class=Wrapper> <input type=checkbox class=SomeCheckboxClass> <input
I have some HTML like this: <div id=Myclass> <div class=Wrapper> <input type=checkbox class=SomeCheckboxClass> <input
I have the following html tag <input type=text id=txtColor /> <div id=wrapper> <div id=someDynamicElement></div>
I'm trying to write a wrapper for Winamp input plugins and have hit a
I have input text: <div><label wicket:for=name>Name</label><input type=text wicket:id=name /></div> Now I need to add
Currently I have Input: e.g., '123456789'.'+'.'987654321' Desired Pattern: Output: e.g., '123456789987654321' How can I
I have a div that contains many floated child items. Each child item is
I have a DIV that slideToggles no problem. It reveals some additional options to

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.