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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:33:55+00:00 2026-05-28T03:33:55+00:00

How does the Model work? I have a Registry Class like this: public class

  • 0

How does the Model work?

I have a Registry Class like this:

public class RegisterPanel extends Panel{

//empty user
public User user = new User();

protected ServiceClient client = ((WicketApplication) (WicketApplication.get())).getClient();

@SuppressWarnings({ "rawtypes" })
public RegisterPanel(String id) {
    super(id);
    //creates form with an empty user
    Form form = new RegisterForm("registerForm", user); 
    add(form); 
}

@SuppressWarnings({ "rawtypes" })
class RegisterForm extends Form {

    private String userId = "";
    private String email = "";
    private String password1 = "";
    private String password2 = "";

    private FormComponent formEmail;
    private FormComponent formPassword1;
    private FormComponent formPassword2;

  @SuppressWarnings("unchecked")
public RegisterForm(String id, User user) {

    super(id);
    add(new TextField("userId", new PropertyModel(this, "userId")).setRequired(true));
    formEmail = new TextField("email", new PropertyModel(this, "email")).setRequired(true);
    formPassword1 = new PasswordTextField("password1", new PropertyModel(this, "password1")).setRequired(true);
    formPassword2 = new PasswordTextField("password2", new PropertyModel(this, "password2")).setRequired(true);
    add(formEmail);
    add(formPassword1);
    add(formPassword2);
  }

  @Override
  public void onSubmit() {

      Result result = client.register(email, userId, password1);
      if(result.getStatus()) {

                      user.setEail(email);
                          user.setUserId(userId);
                          user.setPassword(password1);
                  client.postUser(user);
      }
  } 
}
 }

But how do I work with models? Now I just bound PropertyModels to my TextFields. I thought I can bind a model to my empty user and on the submit method I work on my model instead on my plain user. How does it work? Whats the advantage of working on models?

  • 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-28T03:33:55+00:00Added an answer on May 28, 2026 at 3:33 am

    Working with models has several advantages:

    public class RegisterPanel extends Panel{
    
    protected ServiceClient client = ...
    
    public RegisterPanel(String id) {
        super(id);
        //creates form with an empty user
        Form<Void> form = new RegisterForm<Void>("registerForm", new Model(new User())); 
        add(form); 
    }
    
    class RegisterForm extends Form<Void> {
    
        public RegisterForm(String id, IModel<User> user) {
            super(id);
    
            add(new TextField("userId", new PropertyModel(user, "userId")).setRequired(true));
            add(new TextField("email", new PropertyModel(user, "email")).setRequired(true);
            add(new PasswordTextField("password", new PropertyModel(user, "password")).setRequired(true);
            add(new PasswordTextField("password2", new Model("").setRequired(true);
    }
    
        @Override
        public void onSubmit() {
            try {
                client.registerAndPost(email, userId, password1);
            } catch (ServiceException ex) {
                ...
            }
        }
    }
    

    Note:

    • RegisterForm isn’t interested where the user is coming from
    • form fields write directly into the user
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model looking like this. class ProjectMembership(models.Model): member = models.ForeignKey(User, related_name='project_membership_member_set') Edit:
Does anybody have any example code on how this would work? Seems like it
So I have a method in a reservation model called add_equip. This method does
These urls work: /admin /admin/appname But this does not work for any model, including
Does jquery/javascript have any event model that you can attach to your objects? Basically
Why does SQL server express 2008 give me this error? CREATE TABLE model (
It looks like Django does not update last_login field in auth_user model when a
I see this in a stack trace: myorg.vignettemodules.customregistration.NewsCategoryVAPDAO.getEmailContentByID(I)Lmyorg/pushemail/model/EmailContent; What does the (I)L mean?
Does ASP.NET MVC offer any simple way to get model binding to work when
I have an app that starts 10 threads. Each thread does it's work and

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.