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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:13:51+00:00 2026-05-27T09:13:51+00:00

I have a simple, mysterious problem with a label and using ajax to show

  • 0

I have a simple, mysterious problem with a label and using ajax to show it.

public class ChecklistTemplateForm extends Form{
    private static final long serialVersionUID = 1L;
    private Label cantSaveLabel;
    public ChecklistTemplateForm(String id) {
        super(id);
        cantSaveLabel = new Label("cantSaveLabel", "Name is not unique, enter another name and try saving again.");
        cantSaveLabel.setVisible(false);
        cantSaveLabel.setOutputMarkupId(true);
        add(cantSaveLabel);
        add(new AjaxButton("saveButton") {
            private static final long serialVersionUID = 1L;
            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                target.addComponent(cantSaveLabel);
                //here i do some stuff to decide if canSave is true or false
                if (canSave){
                    setResponsePage(AdminCheckListPage.class);
                }
                else if (!canSave){
                    cantSaveLabel.setVisible(true);
                    System.out.println(canSave);
                }
            }
        }); 
    }

}

The funny thing is, is canSave is false, the System.out.print works but the cansavelabel never becomes visible. What am I missing?

  • 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-27T09:13:52+00:00Added an answer on May 27, 2026 at 9:13 am

    You can not update the Label via Ajax as it is not in the rendered page. The

    cantSaveLabel.setVisible(false); 
    

    makes it so that the Label is not in the HTML. You would need to surround the Label with another component (WebMarkupContainer), call setOutputMarkupId(true) on this and add this container to the AjaxRequestTarget instaed of the label.

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

Sidebar

Related Questions

I have simple static lib in xcode with the only class test.h: @interface TestClass
I have simple login form I am using SQLite database which has fields like
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have simple WinForms application where modifying Windows Registry. The problem is that in
A familiar problem using VisualStudio is the mysterious calling of property getters. If these
I have simple jQuery Mobile site created using asp.net mvc 2 and uses basic
i have simple QStandardItemModel that holds the date to show in QTreeview when i
I have simple chat program using WCF service. One service use for server and
I have simple scenario in which i hide and show a signle MenuItem in
I have simple text file, and i have to print it using WPF. How

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.