How to decide whether FeedbackPanel is visible or not after IModel.load()?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to decide whether FeedbackPanel is visible or not after IModel.load()?

I've a ContentPanel with a FeedbackPanel and a table (DataView). The ContentPanel pulls the model in the constructor. If an error occurs durring the service call an error message is written in the ContentPanels feedbackMessageModel. Dependent whether an error occurs or not the FeedbackPanel (and border) will or won't be visible. The corresponding code is displayed below.

My problem is that the onConfigure-method of the FeedbackPanel is processed before the load-method of the ComponentAwareModel is called. When the onConfigure-method decides whether the FeedbackPanel is visible or not, there are no errors. Only after this the model-load-method is called and errorhandling happens.

Is there a way to keep the model within the DataView and decide nevertheless in the onConfigure-method about the Feedback-Panels visibility?

public class UserOverviewPanel{
  private UserService userService;
  IModel model = new ComponentAwareModel<List<UserHeaderDto>>(this) {
    protected List<UserHeaderDto> loadService() {
      return userService.getAllUsersForHeaderView();
  DataView<UserHeaderDto> dataView = new DataView<UserHeaderDto>("userRow", new
    ModelDataProvider<UserHeaderDto>(model)) {
    public void populateItem(final Item<UserHeaderDto> item) {
      UserHeaderDto user = item.getModelObject();
      item.setModel(new CompoundPropertyModel<UserHeaderDto>(user));
      item.add(new Label("id"));
  add(new FeedbackPanel(){
    protected void onConfigure() {
      List<FeedbackMessage> feedbackMsgs = feedback.getFeedbackMessagesModel().getObject();
      if (feedbackMsgs != null && feedbackMsgs.size() > 0) {
      } else {

public class ComponentAwareModel<T> extends LoadableDetachableModel<T> {
  private Component comp;
  public ComponentAwareModel(Component comp) {
    this.comp = comp;
  protected T load() {
      return callService();
    catch(Exception ex){
      return null;