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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:55:18+00:00 2026-05-21T09:55:18+00:00

When the page with the MessagePanel first renders, the message and the approve link

  • 0

When the page with the MessagePanel first renders, the message and the approve link render perfectly. When I click the approve link, all the business logic works as desired, the getNextMessage() method returns the appropriate object, but the message panel does not update on the page in the browser. That is, the message body Label does not update.

JPAEntityModel extends LoadableDetachableModel.

What am I missing? And how do I fix it?

public class MessagePanel(String id, IModel<Message> messageModel) extends Panel {
  super(id, messageModel);
  add(new Label("messageText", new PropertyModel<Message>(getModelObject(), Message.BODY_FIELD)));
  add(new IndicatingAjaxFallbackLink<User>("approveLink", new JPAEntityModel<User> (getActiveUser())) {
    @Override
    public void onClick(AjaxRequestTarget target) {
      Message nextMessage = getNextMessage();
      MessagePanel.this.setDefaultModel(new JPAEntityModel<Message>(nextMessage));
      target.add(MessagePanel.this);
    }
});
  setOutputMarkupId(true);
}
  • 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-21T09:55:19+00:00Added an answer on May 21, 2026 at 9:55 am

    It is because you’re not using the model properly.

    This line takes the value of the panel’s model object, as it is set during construction, and uses it to create the component model.

    add(new Label("messageText", new PropertyModel<Message>(getModelObject(), Message.BODY_FIELD)));
    

    To make matters worse, when you click the link, the panel is given a new model:

    MessagePanel.this.setDefaultModel(new JPAEntityModel<Message>(nextMessage));
    

    But this obviously doesn’t affect the model of the label, as it is already set to refer to the original value.

    So there are two things you need to change to make it work. First off, your label model should use your panel model directly:

    new Model<Message>() {
      @Override
      public Message getObject() {
        return MessagePanel.this.getModelObject().getMessage(); //or something similar
      }
    }
    

    (Note: the code above isn’t necessarily the best solution, but it is a working solution that demonstrates how models can be used dynamically.)

    And ideally you shouldn’t replace the model when you click the link, just change the model object. If you need a custom model class (JPAEntityModel), you shouldn’t be accepting a pre-constructed model in the panel constructor anyway, just the first message object. The reason being the current implementation doesn’t enforce the use of JPAEntityModel from the start, only after the first click of the link.

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

Sidebar

Related Questions

My page should contain a link that looks like <a href=/desired_path/1>Click to go</a> .
Page in question: http://phwsinc.com/our-work/one-rincon-hill.asp In IE6-8, when you click the left-most thumbnail in the
This page displays beautifully in firefox but i get all kinds of problems when
Each page lists all the coupons available for a specific retailer. I query the
page--node--edit.tpl.php works just fine when you want to create a specific template for editing
I'm using jQuery with the BlockUI plugin to block a page after a link
I Successfully created an user control for displaying Error message. now everything works fine
In Page 1 on button click I redirect the page to page 2 with
Page in question: http://meyers.ipalaces.org/sitemap/ The first <LI> should be z-index: 2; and should be
Page 146 of the jQuery mobile First look book mentions data-placeholder, but I don't

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.