Reusable DropDownChoice in Wicket Form -


I have more than 50 forms in my project, and they are very similar to each other and similar DropDownChoice I use the component to create a separate panel , where I define my DropDownChoice , and after that I will use that panel < / Code> will use? Otherwise, how can I apply that situation?

For example

form1 has the following fields:
Name (< Code> text field
) alias ( TextField )
city ( DropDownChoice )

form2 has the following fields:
Code ( TextField )
Amount ( TextField )
City (Again same dropdown choice )

I want to have a beautiful solution for that approach .

DropDownChoice with its predefined parameter is better to enhance, and not With the panel real dropdown choice .

This approach has at least two advantages:

  1. You do not need to create a separate markup file, because it comes with panel Is -approach
  2. You can directly use the DropDownChoice methods Otherwise, you should forward such methods as methods of the panel , or for DDC Gator's method should be implemented. Therefore, something better would be done:

      public class City Dopdown Choice DropDownChoice and lt; City & gt; // Use your own generic (define only one constructor, but you can apply another * / public ciudraPDown Chice (last string id) {super}; in this ();} / * your According to the desire to create a DDC * Private / Private * init () {setChoices (/ * Your Cities' List of Cities or Cities, Anywhere / /) SetChoiceRenderer (/ * You can define the default options renderer Are * /); SetOutputMark UpId (true); / * Add some Ajax behavior / / (New Ajax EVAVicTechter ("change") {@Override Events on Secure Zero (Last AjaxRequestTarget Goal) {On Change};}}}}} / * In forms you can override this method to do something when the option changes * / protected void onChange (the last AjaxRequestTarget target) {// override to something}}  

    and Only use it in your form:

      form form = ...; Form.add (new Ciudadroop Down Choice ("Cities"));  

    Think this approach will be tailored to your needs.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -