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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:30:16+00:00 2026-05-24T02:30:16+00:00

In Wicket, I’d like to subclass TextField form component to add additional markup around

  • 0

In Wicket, I’d like to subclass TextField form component to add additional markup around the tag.

Why I do not want to create a Panel:

1) I want the web page designer to use the input tag:
<input wicket:id="blah">

2) I don’t want the subclass to lose the FormField semantics in Java, e.g.:
field.setRequired(true);, etc.

I’m fine with hard-coding the wrapping markup in Java. But I’d like this to behave like a FormField in Java.

Any ideas? Looked around for examples, but stumped on this one

Edit:
I’m aware of Borders, but my issue with them is you have to add them in both the markup and in Java. For example:

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

—

FormComponent<Integer> field = new TextField<Integer>("field", new Model(1));
field.setRequired(true);
Border border = new MyBorder("border");
border.add(field);
form.add(border);

This makes the web page designer have to be aware of special markup, and the Java can’t be encapsulated (as a FormField subclass).

  • 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-24T02:30:18+00:00Added an answer on May 24, 2026 at 2:30 am

    Ah, this is what I wanted via IBehavior:

    My wrapper behavior (sorry for the Scala syntax):

    class FieldWrapper extends AbstractTransformerBehavior {
      def transform(component: Component, output: CharSequence): CharSequence = """
    <div class="blah">
      Blah blah blah  
      %s
    </div>
    """.format(output)
    }
    

    My subclass:

    class MyField[T](id: String, model: IModel[T]) extends TextField[T](id, model) {
      add(new FieldWrapper)
    }
    

    Original Markup:

    <input type="text" wicket:id="foobar"/>
    

    Generated markup:

    <div class="blah">
      Blah blah blah  
      <input type="text" value="" name="foobar" xmlns:wicket="http://wicket.apache.org">
    </div>
    

    Thanks S.O. for jumpstarting my mind 🙂

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

Sidebar

Related Questions

I'm using a ListMultipleChoice component in wicket and I want to get the selected
I am using Wicket and would like to create a grid of radio buttons
I have a wicket form which contains many TextField input components. There's a Validator
In Apache Wicket web framework every component returns false from getOuputMarkupId() by default .
Working on a Wicket application that adds markup to the DOM after onLoad via
I have a Wicket Web Page where I create a new Object of class
I'm using IntellIJ with Apache Wicket and IntelliJ is showing me that tags like
Apache Wicket ( http://wicket.apache.org/ ) and Apache Tapestry ( http://wicket.apache.org/ ) are both component
In wicket textfield how can I align text and cursor to right of the
am a newbie to wicket and am experimenting few things with it, like, I

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.