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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:36:38+00:00 2026-05-15T10:36:38+00:00

My gwt project have flexTable show data of image and button on each row

  • 0

My gwt project have flexTable show data of image and button on each row and coll.
But my button won’t work properly. this is my current code:

private Button[] b = new Button[]{new Button("a"),...,new Button("j")};
private int z=0;
...
public void UpdateTabelGallery(JsArray str){
    for(int i=0; i str.length(); i++){
    b[i].setText(str.gettitle());                               
    UpdateTabelGallery(str.get(i));                   
  }
}

public void UpdateTabelGallery(GalleryData str){
  Image img = new Image();  
  img.setUrl(str.getthumburl());  

  HTML himage= new HTML("a href="+str.geturl()+">"+ img +"/a>" + b[z] );                                                        
  TabelGaleri.setWidget(y, x, himage);

//is here th right place?
  b[z].addClickHandler(new ClickHandler(){
  @Override
    public void onClick(ClickEvent event) {
      Window.alert("I wan to show the clicked button text" + b[z].getText());               
    }                         
  });

  z++;
}

I’m still confuse where I should put my button handler. With this current code seems the clickhandler didn’t work inside a looping. And if I put it outside loop its not working because I need to know which button clicked. I need to get my index button.but how? Is there any option than array button?

thanks

  • 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-15T10:36:39+00:00Added an answer on May 15, 2026 at 10:36 am

    The problem is that you refer to ‘z’ in your click handler, but the value of z changes, so that when your click handler is actually called the value of z is wrong.

    You need a local final variable in UpdateTabelGallery which you assign the current value of z to to allow it to be captured by the handler you create. Even better, get rid of z entirely and pass i to UpdateTableGallery:

    public void updateTableGallery(GalleryData str, final int i){
      Image img = new Image();  
      img.setUrl(str.getthumburl());  
    
      HTML himage= new HTML("a href="+str.geturl()+">"+ img +"/a>" + b[i] );                                                        
      TabelGaleri.setWidget(y, x, himage);
    
    //is here th right place?
      b[i].addClickHandler(new ClickHandler(){
      @Override
        public void onClick(ClickEvent event) {
          Window.alert("I wan't to show the clicked button text" + b[i].getText());               
        }                         
      });
    
    }
    

    But what do you expect:

      HTML himage= new HTML("a href="+str.geturl()+">"+ img +"/a>" + b[i] );       
    

    to do? Aside from the incorrect HTML syntax, I don’t think adding ypur button to the string will work.

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

Sidebar

Related Questions

I have a maven gwt project, and I'm using ClientBundle to package my image
I have a gwt project that uses gwt-mosaic. Here is the error message I
I have a GWT project in which I need to manually specify currency, number
We have a large GWT project and many smaller GWT sub-projects basically the large
I have the following code from a GWT Project that is part of the
I'm playing with a GWT/GAE project which will have three different pages, although it
Do you have any suggestions of graphing libraries to use with a GWT project?
I have created a google project... went new web project with the gwt/gae plugin.
I have an Eclipse GWT project with two source folders: One for source code
I have this simple object in my GWT project. I cannot send it over

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.