Joyce
2018-08-20 05:42:33 UTC
Hello everybody,
I build my own GWT App which shows mainly a FlexTable (*campaignTable*)
with campaign objects in it. The campaign objects are saved in an array in
my main class. To change the data of the campaign, I have a button (
*editButton*) which opens with its clickhandler a popup. In that popup I
can change the data of the corresponding object. Has anyone an idea on how
I get the changed data in my main flexTable?
Thank you!
The corresponding source code of the main class is:
public class MyCampaign implements EntryPoint {
private VerticalPanel mainPanel = new VerticalPanel();
private FlexTable campaignTable = new FlexTable();
private HorizontalPanel addPanel = new HorizontalPanel();
private TextBox campaignName = new TextBox();
private TextBox spendenziel = new TextBox();
private TextBox spendenbetrag = new TextBox();
private TextBox spenderName = new TextBox();
private TextBox iban = new TextBox();
private TextBox bankName = new TextBox();
private Button saveButton = new Button("Speichern");
private Button cancelButton = new Button("Abbrechen");
private FlexTable addTable = new FlexTable();
private FlowPanel main = new FlowPanel();
private FlowPanel header = new FlowPanel();
private DisclosurePanel disPanel = new DisclosurePanel();
private Campaign campaign;
private ArrayList<Campaign> campaignArray = new ArrayList<Campaign>();
public void onModuleLoad() {
FlexCellFormatter cellFormatter = campaignTable.getFlexCellFormatter();
campaignTable.addStyleName("campaignTable");
campaignTable.setCellSpacing(5);
campaignTable.setCellPadding(3);
campaignTable.getRowFormatter().addStyleName(0, "campaignListHeader");
campaignTable.setText(0, 0, "Name");
campaignTable.setText(0, 1, "Spendenziel");
campaignTable.setText(0, 2, "bisher gespendet");
campaignTable.setText(0, 3, "");
campaignTable.setText(0, 4, "");
campaignTable.setText(0, 5, "");
campaignTable.setText(0, 6, "");
loadData();
// Disclosure Panel
main.add(header);
main.add(disPanel);
Button add = new Button();
add.setText("Aktion hinzufÃŒgen");
add.setTitle("Aktion hinzufÃŒgen");
header.add(add);
disPanel.setWidth("100%");
addTable.getRowFormatter().addStyleName(0, "ueberschriftAdd");
addTable.setText(0, 0, "Allgemein");
addTable.setText(1,0, "Name");
addTable.setWidget(1,1, campaignName);
addTable.setText(2,0, "Spendenziel");
addTable.setWidget(2,1, spendenziel);
addTable.setText(3,0, "Spendenbetrag");
addTable.setWidget(3,1, spendenbetrag);
addTable.getRowFormatter().addStyleName(4, "ueberschriftAdd");
addTable.setText(4, 0, "Bankverbindung");
addTable.setText(5,0, "Name");
addTable.setWidget(5,1, spenderName);
addTable.setText(6,0, "IBAN");
addTable.setWidget(6,1, iban);
addTable.setText(7,0, "Name der Bank");
addTable.setWidget(7,1, bankName);
addTable.setWidget(8, 0, saveButton);
addTable.setWidget(8,1, cancelButton);
disPanel.setContent(addTable);
add.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
disPanel.setOpen(!disPanel.isOpen());
campaignName.setFocus(true);
}
});
// Widgets zu MainPanel hinzufÃŒgen
mainPanel.add(campaignTable);
mainPanel.add(addPanel);
mainPanel.add(main);
//HTML-VerknÃŒpfung
RootPanel.get("mycampaign").add(mainPanel);
//Aktion speichern
saveButton.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
addAction();
}
});
}
private void addAction() {
String campaignName = this.campaignName.getText();
String spendenziel = this.spendenziel.getText();
String spendenbetrag = this.spendenbetrag.getText();
String spenderName = this.spenderName.getText();
String iban = this.iban.getText();
String bankName = this.bankName.getText();
if(!campaignName.matches("^[A-Za-z\\.]{4,30}$")) {
Window.alert("Der Name einer Aktion muss mind. 4 und darf max. 30 Zeichen
lang sein.");
this.campaignName.selectAll();
return;
}
if(!spendenziel.matches("^[0-9\\.]{2,30}$")) {
Window.alert("Das Spendenziel fÃŒr die Aktion muss mind. 10 Euro sein.");
this.spendenziel.selectAll();
return;
}
if(!spendenbetrag.matches("^[0-9\\.]{1,30}$")) {
Window.alert("Der Spendenbetrag muss mind. 1 Euro sein.");
this.spendenbetrag.selectAll();
return;
}
if(!spenderName.matches("^[A-Za-z\\.]{4,30}$")) {
Window.alert("Der Name muss mind. 4 und darf max. 30 Zeichen lang sein.");
this.spenderName.selectAll();
return;
}
if(!iban.matches("^[0-9A-Z\\.]{22,22}$")) {
Window.alert("Die IBAN Nr. muss 22 Zeichen lang sein.");
this.iban.selectAll();
return;
}
if(!bankName.matches("^[A-Za-z\\.]{4,30}$")) {
Window.alert("Der Bankname einer Aktion muss mind. 4 und darf max. 30
Zeichen lang sein");
this.bankName.selectAll();
return;
}
Account account = new Account(spenderName, bankName, iban);
Donation donation = new Donation(spenderName,spendenbetrag, account, true);
ArrayList<Donation> donList = new ArrayList<Donation>();
donList.add(donation);
campaign = new Campaign(campaignName, spendenziel, donList, account);
campaign.setAmountDonationSoFar(spendenbetrag);
this.campaignName.setText("");
this.spendenziel.setText("");
this.spendenbetrag.setText("");
this.spenderName.setText("");
this.iban.setText("");
this.bankName.setText("");
int row = campaignTable.getRowCount();
campaignArray.add(campaign);
campaignTable.setText(row, 0, campaign.getName());
campaignTable.setText(row, 1, campaign.getTargetAmount());
campaignTable.setText(row, 2, campaign.getAmountDonationSoFar());
//Buttons
Button editButton = new Button("Editieren");
editButton.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
EditCampaign doEditCampaign = new EditCampaign();
doEditCampaign.editCampaign(campaign);
doEditCampaign.show();
}
});
campaignTable.setWidget(row, 3, editButton);
Button spendenListeButton = new Button("Spendenliste");
spendenListeButton.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
DonationList2 donationList2 = new DonationList2();
donationList2.listDonation(campaign);
donationList2.show();
}
});
campaignTable.setWidget(row, 4, spendenListeButton);
Button formButton = new Button("Forumlar");
formButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
Formular formular = new Formular();
formular.show();
}
});
campaignTable.setWidget(row, 5, formButton);
Button spendenButton = new Button("Geld spenden");
spendenButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
DonateMoney doDonateMoney = new DonateMoney();
doDonateMoney.donateMoney(campaign);
doDonateMoney.show();
}
});
campaignTable.setWidget(row, 6, spendenButton);
Button removeButton = new Button("X");
removeButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
int removeIndex = campaignArray.indexOf(campaign);
campaignArray.remove(removeIndex);
campaignTable.removeRow(removeIndex +1);
}
});
campaignTable.setWidget(row, 7, removeButton);
}
...
The source code of the Edit Campaign class is the following:
class EditCampaign extends DialogBox {
private static FlexTable editTable = new FlexTable();
private TextBox campaignName = new TextBox();
private TextBox spendenziel = new TextBox();
private TextBox spendenbetrag = new TextBox();
private TextBox spenderName = new TextBox();
private TextBox iban = new TextBox();
private TextBox bankName = new TextBox();
private Button saveButton = new Button("Speichern");
private Button cancelButton = new Button("Abbrechen");
private Campaign campaign;
public EditCampaign() {
}
public Campaign editCampaign(Campaign campaignAktuell) {
this.campaign = campaignAktuell;
setText("Aktion editieren");
setAnimationEnabled(true);
setGlassEnabled(true);
center();
editTable.getRowFormatter().addStyleName(0, "ueberschriftAdd");
editTable.setText(0, 0, "Allgemein");
editTable.setText(1,0, "Name");
editTable.setWidget(1,1, campaignName);
editTable.setText(2,0, "Spendenziel");
editTable.setWidget(2,1, spendenziel);
editTable.setText(3,0, "Spendenbetrag");
editTable.setWidget(3,1, spendenbetrag);
editTable.getRowFormatter().addStyleName(4, "ueberschriftAdd");
editTable.setText(4, 0, "Bankverbindung");
editTable.setText(5,0, "Name");
editTable.setWidget(5,1, spenderName);
editTable.setText(6,0, "IBAN");
editTable.setWidget(6,1, iban);
editTable.setText(7,0, "Name der Bank");
editTable.setWidget(7,1, bankName);
editTable.setWidget(8, 0, saveButton);
editTable.setWidget(8,1, cancelButton);
campaignName.setText(campaign.getName());
spendenziel.setText(campaign.getTargetAmount());
spendenbetrag.setText(campaign.getAmountDonationSoFar());
spenderName.setText(campaign.getAccount().getName());
iban.setText(campaign.getAccount().getiban());
bankName.setText(campaign.getAccount().getNameOfBank());
cancelButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
EditCampaign.this.hide();
}
});
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
campaign.setName(campaignName.getText());
campaign.setTargetAmount(spendenziel.getText());
campaign.setAmountDonationSoFar(spendenbetrag.getText());
campaign.getAccount().setName(spenderName.getText());
campaign.getAccount().setIban(iban.getText());
campaign.getAccount().setNameOfBank(bankName.getText());
EditCampaign.this.hide();
}
});
setWidget(editTable);
return campaign;
}
}
I build my own GWT App which shows mainly a FlexTable (*campaignTable*)
with campaign objects in it. The campaign objects are saved in an array in
my main class. To change the data of the campaign, I have a button (
*editButton*) which opens with its clickhandler a popup. In that popup I
can change the data of the corresponding object. Has anyone an idea on how
I get the changed data in my main flexTable?
Thank you!
The corresponding source code of the main class is:
public class MyCampaign implements EntryPoint {
private VerticalPanel mainPanel = new VerticalPanel();
private FlexTable campaignTable = new FlexTable();
private HorizontalPanel addPanel = new HorizontalPanel();
private TextBox campaignName = new TextBox();
private TextBox spendenziel = new TextBox();
private TextBox spendenbetrag = new TextBox();
private TextBox spenderName = new TextBox();
private TextBox iban = new TextBox();
private TextBox bankName = new TextBox();
private Button saveButton = new Button("Speichern");
private Button cancelButton = new Button("Abbrechen");
private FlexTable addTable = new FlexTable();
private FlowPanel main = new FlowPanel();
private FlowPanel header = new FlowPanel();
private DisclosurePanel disPanel = new DisclosurePanel();
private Campaign campaign;
private ArrayList<Campaign> campaignArray = new ArrayList<Campaign>();
public void onModuleLoad() {
FlexCellFormatter cellFormatter = campaignTable.getFlexCellFormatter();
campaignTable.addStyleName("campaignTable");
campaignTable.setCellSpacing(5);
campaignTable.setCellPadding(3);
campaignTable.getRowFormatter().addStyleName(0, "campaignListHeader");
campaignTable.setText(0, 0, "Name");
campaignTable.setText(0, 1, "Spendenziel");
campaignTable.setText(0, 2, "bisher gespendet");
campaignTable.setText(0, 3, "");
campaignTable.setText(0, 4, "");
campaignTable.setText(0, 5, "");
campaignTable.setText(0, 6, "");
loadData();
// Disclosure Panel
main.add(header);
main.add(disPanel);
Button add = new Button();
add.setText("Aktion hinzufÃŒgen");
add.setTitle("Aktion hinzufÃŒgen");
header.add(add);
disPanel.setWidth("100%");
addTable.getRowFormatter().addStyleName(0, "ueberschriftAdd");
addTable.setText(0, 0, "Allgemein");
addTable.setText(1,0, "Name");
addTable.setWidget(1,1, campaignName);
addTable.setText(2,0, "Spendenziel");
addTable.setWidget(2,1, spendenziel);
addTable.setText(3,0, "Spendenbetrag");
addTable.setWidget(3,1, spendenbetrag);
addTable.getRowFormatter().addStyleName(4, "ueberschriftAdd");
addTable.setText(4, 0, "Bankverbindung");
addTable.setText(5,0, "Name");
addTable.setWidget(5,1, spenderName);
addTable.setText(6,0, "IBAN");
addTable.setWidget(6,1, iban);
addTable.setText(7,0, "Name der Bank");
addTable.setWidget(7,1, bankName);
addTable.setWidget(8, 0, saveButton);
addTable.setWidget(8,1, cancelButton);
disPanel.setContent(addTable);
add.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
disPanel.setOpen(!disPanel.isOpen());
campaignName.setFocus(true);
}
});
// Widgets zu MainPanel hinzufÃŒgen
mainPanel.add(campaignTable);
mainPanel.add(addPanel);
mainPanel.add(main);
//HTML-VerknÃŒpfung
RootPanel.get("mycampaign").add(mainPanel);
//Aktion speichern
saveButton.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
addAction();
}
});
}
private void addAction() {
String campaignName = this.campaignName.getText();
String spendenziel = this.spendenziel.getText();
String spendenbetrag = this.spendenbetrag.getText();
String spenderName = this.spenderName.getText();
String iban = this.iban.getText();
String bankName = this.bankName.getText();
if(!campaignName.matches("^[A-Za-z\\.]{4,30}$")) {
Window.alert("Der Name einer Aktion muss mind. 4 und darf max. 30 Zeichen
lang sein.");
this.campaignName.selectAll();
return;
}
if(!spendenziel.matches("^[0-9\\.]{2,30}$")) {
Window.alert("Das Spendenziel fÃŒr die Aktion muss mind. 10 Euro sein.");
this.spendenziel.selectAll();
return;
}
if(!spendenbetrag.matches("^[0-9\\.]{1,30}$")) {
Window.alert("Der Spendenbetrag muss mind. 1 Euro sein.");
this.spendenbetrag.selectAll();
return;
}
if(!spenderName.matches("^[A-Za-z\\.]{4,30}$")) {
Window.alert("Der Name muss mind. 4 und darf max. 30 Zeichen lang sein.");
this.spenderName.selectAll();
return;
}
if(!iban.matches("^[0-9A-Z\\.]{22,22}$")) {
Window.alert("Die IBAN Nr. muss 22 Zeichen lang sein.");
this.iban.selectAll();
return;
}
if(!bankName.matches("^[A-Za-z\\.]{4,30}$")) {
Window.alert("Der Bankname einer Aktion muss mind. 4 und darf max. 30
Zeichen lang sein");
this.bankName.selectAll();
return;
}
Account account = new Account(spenderName, bankName, iban);
Donation donation = new Donation(spenderName,spendenbetrag, account, true);
ArrayList<Donation> donList = new ArrayList<Donation>();
donList.add(donation);
campaign = new Campaign(campaignName, spendenziel, donList, account);
campaign.setAmountDonationSoFar(spendenbetrag);
this.campaignName.setText("");
this.spendenziel.setText("");
this.spendenbetrag.setText("");
this.spenderName.setText("");
this.iban.setText("");
this.bankName.setText("");
int row = campaignTable.getRowCount();
campaignArray.add(campaign);
campaignTable.setText(row, 0, campaign.getName());
campaignTable.setText(row, 1, campaign.getTargetAmount());
campaignTable.setText(row, 2, campaign.getAmountDonationSoFar());
//Buttons
Button editButton = new Button("Editieren");
editButton.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
EditCampaign doEditCampaign = new EditCampaign();
doEditCampaign.editCampaign(campaign);
doEditCampaign.show();
}
});
campaignTable.setWidget(row, 3, editButton);
Button spendenListeButton = new Button("Spendenliste");
spendenListeButton.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
DonationList2 donationList2 = new DonationList2();
donationList2.listDonation(campaign);
donationList2.show();
}
});
campaignTable.setWidget(row, 4, spendenListeButton);
Button formButton = new Button("Forumlar");
formButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
Formular formular = new Formular();
formular.show();
}
});
campaignTable.setWidget(row, 5, formButton);
Button spendenButton = new Button("Geld spenden");
spendenButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
DonateMoney doDonateMoney = new DonateMoney();
doDonateMoney.donateMoney(campaign);
doDonateMoney.show();
}
});
campaignTable.setWidget(row, 6, spendenButton);
Button removeButton = new Button("X");
removeButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
int removeIndex = campaignArray.indexOf(campaign);
campaignArray.remove(removeIndex);
campaignTable.removeRow(removeIndex +1);
}
});
campaignTable.setWidget(row, 7, removeButton);
}
...
The source code of the Edit Campaign class is the following:
class EditCampaign extends DialogBox {
private static FlexTable editTable = new FlexTable();
private TextBox campaignName = new TextBox();
private TextBox spendenziel = new TextBox();
private TextBox spendenbetrag = new TextBox();
private TextBox spenderName = new TextBox();
private TextBox iban = new TextBox();
private TextBox bankName = new TextBox();
private Button saveButton = new Button("Speichern");
private Button cancelButton = new Button("Abbrechen");
private Campaign campaign;
public EditCampaign() {
}
public Campaign editCampaign(Campaign campaignAktuell) {
this.campaign = campaignAktuell;
setText("Aktion editieren");
setAnimationEnabled(true);
setGlassEnabled(true);
center();
editTable.getRowFormatter().addStyleName(0, "ueberschriftAdd");
editTable.setText(0, 0, "Allgemein");
editTable.setText(1,0, "Name");
editTable.setWidget(1,1, campaignName);
editTable.setText(2,0, "Spendenziel");
editTable.setWidget(2,1, spendenziel);
editTable.setText(3,0, "Spendenbetrag");
editTable.setWidget(3,1, spendenbetrag);
editTable.getRowFormatter().addStyleName(4, "ueberschriftAdd");
editTable.setText(4, 0, "Bankverbindung");
editTable.setText(5,0, "Name");
editTable.setWidget(5,1, spenderName);
editTable.setText(6,0, "IBAN");
editTable.setWidget(6,1, iban);
editTable.setText(7,0, "Name der Bank");
editTable.setWidget(7,1, bankName);
editTable.setWidget(8, 0, saveButton);
editTable.setWidget(8,1, cancelButton);
campaignName.setText(campaign.getName());
spendenziel.setText(campaign.getTargetAmount());
spendenbetrag.setText(campaign.getAmountDonationSoFar());
spenderName.setText(campaign.getAccount().getName());
iban.setText(campaign.getAccount().getiban());
bankName.setText(campaign.getAccount().getNameOfBank());
cancelButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
EditCampaign.this.hide();
}
});
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
campaign.setName(campaignName.getText());
campaign.setTargetAmount(spendenziel.getText());
campaign.setAmountDonationSoFar(spendenbetrag.getText());
campaign.getAccount().setName(spenderName.getText());
campaign.getAccount().setIban(iban.getText());
campaign.getAccount().setNameOfBank(bankName.getText());
EditCampaign.this.hide();
}
});
setWidget(editTable);
return campaign;
}
}
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.