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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:37:14+00:00 2026-06-12T12:37:14+00:00

I have the question, how to reload add method after the button click? for

  • 0

I have the question, how to “reload” add method after the button click? for example:

ArrayList list = new ArrayList();
DataView dataView = new DataView("listview", new ListDataProvider(list)) {
    public void populateItem(final Item item) {
            final DBUser user = (DBUser) item.getModelObject();
            item.add(new Label("id", String.valueOf(user.getid())));
     }
};
final Load load = new Load(dataView);
    Form<?> form2 = new Form<Void>("form2") {
        @Override
        protected void onSubmit() {

            load.tick();
        }
};
add(dataView);

Now the load class:

public class Load {
private DataView dataView;

public Load(DataView dataView)
{
    this.dataView = dataView;
}

public DataView tick()
{
    Session session = HibernateUtil.getSessionFactory().openSession();//getCurrentSession();
    session.beginTransaction();
    Query query = session.createQuery(
            "from DBUser");
    ArrayList list = new ArrayList();
    for (Iterator it=query.iterate();it.hasNext();) {
        DBUser row = (DBUser) it.next();
        DBUser dbuser = new DBUser(row.getid());
        list.add(dbuser);
    }

    dataView = new DataView("listview", new ListDataProvider(list)) {
        public void populateItem(final Item item) {
            final DBUser user = (DBUser) item.getModelObject();
            item.add(new Label("id", String.valueOf(user.getid())));
        }
    };
    session.close();
    return dataView;
}

}

Right now add(line) method was called just once, how to call it after every button click?

here is my .html

<table frame="below" border=1>
    <tr wicket:id="listview">
         <td align="center" width="40"><span wicket:id="id"></span></td>
     </tr>
 </table>
  • 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-06-12T12:37:15+00:00Added an answer on June 12, 2026 at 12:37 pm

    I think, you could reload your DataView in such a way:

    Form<?> form2 = new Form<Void>("form2") {
    
        @Override
        protected void onSubmit() {
            StartPage.this.replace( load.tick() );
            // or you can use 
            // StartPage.this.addOrReplace( load.tick() ) 
            // instead
        }
    };
    

    But your code also needs serious refactoring! As for me I would write it like so to improve readability:

    final Load load = new Load();
    
    Form<?> form2 = new Form<Void>("form2") {
        @Override
        protected void onSubmit() {
            StartPage.this.replace( createDataView( load.tick() ) );
        }
    };
    add(form2);
    
    add( createDataView( new ArrayList() ) );
    

    Implementation of the createDataView(list) method:

    private DataView createDataView(List list) {
        return new DataView("listview", new ListDataProvider(list)) {
            public void populateItem(final Item item) {
                final DBUser user = (DBUser) item.getModelObject();
                item.add(new Label("id", String.valueOf(user.getid())));
            }
        };
    }
    

    Implementation of the Load class:

    public class Load {
    
        public List tick() {
            List result = new ArrayList();
            // ...
            // populate list from database
            // ...
            return result;
        }
    }
    

    Hope this helps.

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

Sidebar

Related Questions

I have been trying to add a button after a parser ( on a
I have question regarding the SQLAlchemy. How can I add into my mapped class
I have question about parsing in Html helper : I have sth like: @foreach
I have question. I have some app on facebook and getting this error Fatal
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have question about XSLT1.0. The task is to write out in HTML all
I have Question and QuestionTypes. In Question table there is a foreign key that
I have question i.e how can i select a previous div CODE:- if($i >
I have question regarding the use of function parameters. In the past I have
I have question concerning a function I created. I would like to show the

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.