我为我的项目创建日期小部件。
N为对象的setProperty和getProperty使用相同的小部件。
public TextBox getTimeTxtbx() {
// TODO Auto-generated method stub
timebx =new TextBox();
timebx.setReadOnly(true);
final PopupPanel popupPanel=new PopupPanel(true);
final DatePicker datePicker=new DatePicker();
datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
public void onValueChange(ValueChangeEvent<Date> event) {
// TODO Auto-generated method stub
Date date=event.getValue();
timebx.setText(DateTimeFormat.getFormat("EEE MMM dd HH:mm:ss z yyyy").format(date));
popupPanel.hide();
}
});
popupPanel.setWidget(datePicker);
timebx.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
String strDate = timebx.getText();
System.out.println(" strDate " +strDate);
DateTimeFormat format = DateTimeFormat.getFormat("[EEE MMM dd HH:mm:ss z yyyy]");
try {
Date selDate = (Date)format.parse(strDate);
datePicker.setValue(selDate, true);
} catch(Exception pe){
// setting current date
System.out.println("error" +pe);
datePicker.setValue(new Date(), true);
}
int x=timebx.getAbsoluteLeft();
int y=timebx.getAbsoluteTop();
popupPanel.setPopupPosition(x, y+20);
popupPanel.show();
}
});
return timebx;
}
public void setTimebx(String string) {
// TODO Auto-generated method stub
timebx.setText(string);
}我在不同gui类中的flexTable中添加了这个小部件
flexTable.setWidget(i, j,textBoxDisplay.getTimeTxtbx());
textBoxDisplay.setTimebx(customProperty.getValues().toString());在flexTable中,上述代码位于iterator中,名为两次。

就像在图像中一样: testDate接收到了。
当我单击testDate时,接收到的on的值将被更改。
编辑过的
public ListBox getBooleanBox() {
// TODO Auto-generated method stub
selectBoolean = new ListBox(false);
//selectBoolean.setName(title);
selectBoolean.setStyleName("cmis-Customproperties-TextBox");
selectBoolean.setSize("150px", "20px");
selectBoolean.addItem("True","True");
selectBoolean.addItem("False", "False");
return selectBoolean;
}
public void setBooleanBox(String value){
int itemCount = selectBoolean.getItemCount();
for(int i = 0 ;i < itemCount;i++){
if(selectBoolean.getItemText(i).equalsIgnoreCase(value)){
selectBoolean.setSelectedIndex(i);
}
}
}添加flexTable
customPropertyTabel.setWidget(i, j,textBoxDisplay.getBooleanBox());
textBoxDisplay.setBooleanBox(removeSymbol(customProperty.getValues().toString()));一切都很顺利。我得到了正确的值。
发布于 2012-07-24 09:51:28
这是实现中的一个参考问题。
在getTimeTxtbx的第二次迭代中(在textbox上创建接收),您已经将textBoxDisplay实例中的局部变量timebx设置为一个新的引用,即textbox上接收的引用。datePicker的onValueChange实现在timebx上设置文本,因此在第二次迭代中设置textbox而不是testingDate textbox。
尝试在迭代期间使用TextBoxDisplay的一个新实例。
TextBoxDisplay textBoxDisplay = new TextBoxDisplay();
flexTable.setWidget(i, j,textBoxDisplay.getTimeTxtbx());
textBoxDisplay.setTimebx(customProperty.getValues().toString());发布于 2012-07-24 09:47:28
在我看来,textBoxDisplay是testingDate和receivedOn的同一个小部件实例。这意味着如果添加了receivedOn,它就会覆盖testingDate,因此当您单击testingDate的图标时就会得到弹出窗口。所以您需要一个textBoxDisplay,用于testingDate和receivedOn,比如:textBoxDisplayTestingDate和textBoxDisplayReceivedOn
https://stackoverflow.com/questions/11627386
复制相似问题