Re: how to programmatically access the value of this widget

2012-04-14 Thread Alfredo Quiroga-Villamil
In CompositePanel expose a getter for your texbox and then invoke
getValue() on it?

Best regards,

Alfredo

On Sat, Apr 14, 2012 at 10:17 AM, tong123123 tong123...@gmail.com wrote:

 as shown in the attached image, if I want to access the value of the
 textbox with value value2 (the textbox in the second row after the add
 button), how to do it as seem there is no a specific name to access it.

 the code is as follow:

 package com.mycompany.project.client;

 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.user.client.ui.Button;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Widget;

 public class HATestPanel extends FlowPanel{

  Button btnAdd = new Button(Add);
  Button btnListWidget = new Button(List Widget);

  public void onLoad(){

   this.add(btnAdd);
   btnAdd.addClickHandler(new ClickHandler(){

@Override
public void onClick(ClickEvent event) {
 // TODO Auto-generated method stub
 CompositePanel compositePanel = new CompositePanel();
 ((HATestPanel)((Button)
 event.getSource()).getParent()).add(compositePanel);
}

   });

   }
 }


 and the implementation of  CompositePanel is as follow:

 package com.mycompany.project.client;

 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.ListBox;
 import com.google.gwt.user.client.ui.TextBox;

 public class CompositePanel  extends HorizontalPanel{

  protected void onLoad(){
   ListBox lb = new ListBox();
   TextBox txt2 = new TextBox();
   lb.addItem(field1);
   lb.addItem(field2);
   lb.addItem(field3);
   this.add(lb);
   this.add(txt2);
  }

 }


 maybe my design is poor, any better method suggested?
 in reality, the listbox is used for user select searc field, and the
 textbox is for user enter search value for that search field.





 --
 You received this message because you are subscribed to the Google Groups
 Google Web Toolkit group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/google-web-toolkit/-/Rc2QBu_9m6MJ.
 To post to this group, send email to google-web-toolkit@googlegroups.com.
 To unsubscribe from this group, send email to
 google-web-toolkit+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/google-web-toolkit?hl=en.




-- 
Alfredo Quiroga-Villamil

AOL/Yahoo/Gmail/MSN IM:  lawwton

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to programmatically access the value of this widget

2012-04-14 Thread Jens
Store your widgets in fields and add getter/setter methods so you can 
access their data.

Also in your ClickHandler instead of:

((HATestPanel)((Button) 
event.getSource()).getParent()).add(compositePanel);   

you can simply do

add(compositePanel) or HATextPanel.this.add(compositePanel) if you like.

-- J.

Am Samstag, 14. April 2012 16:17:36 UTC+2 schrieb tong123123:

 as shown in the attached image, if I want to access the value of the 
 textbox with value value2 (the textbox in the second row after the add 
 button), how to do it as seem there is no a specific name to access it.
  
 the code is as follow:

 package com.mycompany.project.client;

 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.user.client.ui.Button;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Widget;

 public class HATestPanel extends FlowPanel{
  
  Button btnAdd = new Button(Add);
  Button btnListWidget = new Button(List Widget);
  
  public void onLoad(){
   
   this.add(btnAdd);
   btnAdd.addClickHandler(new ClickHandler(){

@Override
public void onClick(ClickEvent event) {
 // TODO Auto-generated method stub
 CompositePanel compositePanel = new CompositePanel();
 ((HATestPanel)((Button) 
 event.getSource()).getParent()).add(compositePanel);
}

   });
   
   }
 }

  
 and the implementation of  CompositePanel is as follow:

 package com.mycompany.project.client;

 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.ListBox;
 import com.google.gwt.user.client.ui.TextBox;

 public class CompositePanel  extends HorizontalPanel{
  
  protected void onLoad(){
   ListBox lb = new ListBox();
   TextBox txt2 = new TextBox(); 
   lb.addItem(field1);
   lb.addItem(field2);
   lb.addItem(field3);
   this.add(lb);
   this.add(txt2);
  }

 }

  
 maybe my design is poor, any better method suggested?
 in reality, the listbox is used for user select searc field, and the 
 textbox is for user enter search value for that search field.
  
  
  
  


-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/XerPShAubfAJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to programmatically access the value of this widget

2012-04-14 Thread tong123123
I think you mean add a getter and setter in CompositePanel, but the problem 
is how to access it in HATestPanel?
as I don't know the variable name of each CompositePanel.
just like I click the button three times, then what is the variaible name 
of these 3 compositePanel? although in each click handler its name is 
compositePanel.
 

Jens於 2012年4月14日星期六UTC+8下午10時36分21秒寫道:

 Store your widgets in fields and add getter/setter methods so you can 
 access their data. 

 Also in your ClickHandler instead of:

 ((HATestPanel)((Button) 
 event.getSource()).getParent()).add(compositePanel);   

 you can simply do

 add(compositePanel) or HATextPanel.this.add(compositePanel) if you like.

 -- J.

 Am Samstag, 14. April 2012 16:17:36 UTC+2 schrieb tong123123: 

 as shown in the attached image, if I want to access the value of the 
 textbox with value value2 (the textbox in the second row after the add 
 button), how to do it as seem there is no a specific name to access it.
  
 the code is as follow:

 package com.mycompany.project.client;

 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.user.client.ui.Button;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Widget;

 public class HATestPanel extends FlowPanel{
  
  Button btnAdd = new Button(Add);
  Button btnListWidget = new Button(List Widget);
  
  public void onLoad(){
   
   this.add(btnAdd);
   btnAdd.addClickHandler(new ClickHandler(){

@Override
public void onClick(ClickEvent event) {
 // TODO Auto-generated method stub
 CompositePanel compositePanel = new CompositePanel();
 ((HATestPanel)((Button) 
 event.getSource()).getParent()).add(compositePanel);
}

   });
   
   }
 }

  
 and the implementation of  CompositePanel is as follow:

 package com.mycompany.project.client;

 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.ListBox;
 import com.google.gwt.user.client.ui.TextBox;

 public class CompositePanel  extends HorizontalPanel{
  
  protected void onLoad(){
   ListBox lb = new ListBox();
   TextBox txt2 = new TextBox(); 
   lb.addItem(field1);
   lb.addItem(field2);
   lb.addItem(field3);
   this.add(lb);
   this.add(txt2);
  }

 }

  
 maybe my design is poor, any better method suggested?
 in reality, the listbox is used for user select searc field, and the 
 textbox is for user enter search value for that search field.
  
  
  
  



-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/Y5Q62a-Fg_YJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to programmatically access the value of this widget

2012-04-14 Thread Jens
Store them in a separate list or iterate through all child widgets of your 
HATestPanel using FlowPanel.getWidgetCount() and FlowPanel.getWidget(int 
index). For each widget check if its a CompositePanel, cast it and call its 
getter to get the value.



Am Samstag, 14. April 2012 17:06:08 UTC+2 schrieb tong123123:

 I think you mean add a getter and setter in CompositePanel, but the 
 problem is how to access it in HATestPanel?
 as I don't know the variable name of each CompositePanel.
 just like I click the button three times, then what is the variaible name 
 of these 3 compositePanel? although in each click handler its name is 
 compositePanel.
  

 Jens於 2012年4月14日星期六UTC+8下午10時36分21秒寫道:

 Store your widgets in fields and add getter/setter methods so you can 
 access their data. 

 Also in your ClickHandler instead of:

 ((HATestPanel)((Button) 
 event.getSource()).getParent()).add(compositePanel);   

 you can simply do

 add(compositePanel) or HATextPanel.this.add(compositePanel) if you like.

 -- J.

 Am Samstag, 14. April 2012 16:17:36 UTC+2 schrieb tong123123: 

 as shown in the attached image, if I want to access the value of the 
 textbox with value value2 (the textbox in the second row after the add 
 button), how to do it as seem there is no a specific name to access it.
  
 the code is as follow:

 package com.mycompany.project.client;

 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.user.client.ui.Button;
 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.Widget;

 public class HATestPanel extends FlowPanel{
  
  Button btnAdd = new Button(Add);
  Button btnListWidget = new Button(List Widget);
  
  public void onLoad(){
   
   this.add(btnAdd);
   btnAdd.addClickHandler(new ClickHandler(){

@Override
public void onClick(ClickEvent event) {
 // TODO Auto-generated method stub
 CompositePanel compositePanel = new CompositePanel();
 ((HATestPanel)((Button) 
 event.getSource()).getParent()).add(compositePanel);
}

   });
   
   }
 }

  
 and the implementation of  CompositePanel is as follow:

 package com.mycompany.project.client;

 import com.google.gwt.user.client.ui.FlowPanel;
 import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.ListBox;
 import com.google.gwt.user.client.ui.TextBox;

 public class CompositePanel  extends HorizontalPanel{
  
  protected void onLoad(){
   ListBox lb = new ListBox();
   TextBox txt2 = new TextBox(); 
   lb.addItem(field1);
   lb.addItem(field2);
   lb.addItem(field3);
   this.add(lb);
   this.add(txt2);
  }

 }

  
 maybe my design is poor, any better method suggested?
 in reality, the listbox is used for user select searc field, and the 
 textbox is for user enter search value for that search field.
  
  
  
  



-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/kYzgE5sKoQIJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to programmatically access the value of this widget

2012-04-14 Thread Thomas Broyer


On Saturday, April 14, 2012 5:13:39 PM UTC+2, Jens wrote:

 Store them in a separate list or iterate through all child widgets of your 
 HATestPanel using FlowPanel.getWidgetCount() and FlowPanel.getWidget(int 
 index). For each widget check if its a CompositePanel, cast it and call its 
 getter to get the value.


In other words: variables are a mean to give name to things; fields are 
just variables with a distinct scope (object instance instead of local to a 
block or method). If you need/want names for things, it's up to you to give 
them such a name.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/LDu6maxvjOAJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to programmatically access the value of this widget

2012-04-14 Thread tong123123
Sorry, I cannot catch your idea, in my clickhandler, the variable name is 
compositePanel for each click, and then add to the flowpanel, but if I 
press the add button three time and then outside the add button, how to 
refer the name of these three compositePanel?
 

Thomas Broyer於 2012年4月14日星期六UTC+8下午11時18分18秒寫道:

 In other words: variables are a mean to give name to things; fields are 
 just variables with a distinct scope (object instance instead of local to a 
 block or method). If you need/want names for things, it's up to you to give 
 them such a name.


-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/eaqlisZI1l8J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to programmatically access the value of this widget

2012-04-14 Thread tong123123
thanks, now my implementation is 

 public class HATestPanel extends FlowPanel{
  
  Button btnAdd = new Button(Add);
  Button btnListWidget = new Button(submit);
  
  public void onLoad(){
   
   this.add(btnAdd);
   this.add(btnListWidget);
   btnAdd.addClickHandler(new ClickHandler(){

@Override
public void onClick(ClickEvent event) {
 // TODO Auto-generated method stub
 CompositePanel compositePanel = new CompositePanel();
 HATestPanel.this.add(compositePanel);
}

   });
   
   
   btnListWidget.addClickHandler(new ClickHandler(){

@Override
public void onClick(ClickEvent event) {
 // TODO Auto-generated method stub
 for (int i=0; iHATestPanel.this.getWidgetCount();i++){
  if (HATestPanel.this.getWidget(i) instanceof CompositePanel){
   ListBox lb =((CompositePanel)HATestPanel.this.getWidget(i)).getLb();
   TextBox txt = 
 ((CompositePanel)HATestPanel.this.getWidget(i)).getTxt2();
   if 
 (lb.getItemText(lb.getSelectedIndex()).equalsIgnoreCase(field1)){
System.out.println(txt.getText());
// validation txt
   }else if 
 (lb.getItemText(lb.getSelectedIndex()).equalsIgnoreCase(field2)){
System.out.println(txt.getText());
// validation txt
   }
  }
 }
}

   });
   
  }

 }

But there is still some problem, if I want to add a delete button after 
each row, is it very difficult? Or the easier method is add a checkbox 
before the listbox in class CompositePanel and then add a delete button 
(one and only one for the HATestPanel, not per row) to the HATestPanel?
 
I see this forum attachment page, it has a delete link after the browse 
button of each attachment row, but I have no idea how could this be 
implemented in my case?
 
 

Jens於 2012年4月14日星期六UTC+8下午11時13分39秒寫道:

 Store them in a separate list or iterate through all child widgets of your 
 HATestPanel using FlowPanel.getWidgetCount() and FlowPanel.getWidget(int 
 index). For each widget check if its a CompositePanel, cast it and call its 
 getter to get the value. 

  


-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/r8DOFF8Fy8gJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: how to programmatically access the value of this widget

2012-04-14 Thread Jens


 But there is still some problem, if I want to add a delete button after 
 each row, is it very difficult?Or the easier method is add a checkbox 
 before the listbox in class CompositePanel and then add a delete button 
 (one and only one for the HATestPanel, not per row) to the HATestPanel? 

If you add a Button to each composite panel you can call 
CompositePanel.removeFromParent() to delete itself from the view.
If you add a CheckBox in each composite panel and a single delete Button in 
HATestPanel you first have to find all composite panels (same loop as for 
your submit button) which are checked for deletion (implement a isChecked() 
method in CompositePanel) before calling removeFromParent() on them.

Its up to you.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/uUV6lQ19IOEJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.