Re: GWT save and modify in database(mysql)

2010-09-21 Thread nacho
I see lot of code but what is your trouble / question?

On 20 sep, 07:34, Buica Tatiana doggie...@yahoo.com wrote:
 So i had to do the following assignment in GWT:

 1.Implement a selection/de-selection component as described below:
 The selected item in the first list goes into the second list and is
 removed from the first list when the  button is pressed. The
 selected item in the second list goes into the first list and is
 removed from the second list when the  button is pressed. The latest
 selected item text is also displayed into the bottom text control with
 the label “Selection”.
 There also exists two checkboxes allowing the user to SAVE the content
 of the second list to a file or a database.

 After i searched a lot over the internet i came out with this program:

 This is the client side, meaning that this is what the user can see in
 the Web Browser. I made the whole GUI in the 'onModuleLoad()' section,
 including the action-listeners i needed for my application.
 I also had to communicate with the server side so i can connect to a
 database.
 'CInterfaceAsync inter = GWT.create(CInterface.class);' with this line
 i create a connection with the server-side trough an interface that
 should be created on the client side too. using inter.function allows
 me to access the methods from the server side.

 package gwt.hom.client;

 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;

 import com.google.gwt.core.client.EntryPoint;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.dom.client.ChangeEvent;
 import com.google.gwt.event.dom.client.ChangeHandler;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.user.client.Window;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.*;

 public class WebApp implements EntryPoint {

         private static final long serialVersionUID = 1L;

         CInterfaceAsync inter = GWT.create(CInterface.class);

         public static ListBox list1;
         public ListBox list2;
         public Button left, right, save;
         public Label label, file, db;
         ArrayListString list1Elems, list2Elems;
         public CheckBox toFile, toDB;
         public TextArea selected;
         public Panel panel, panel2, panel3;

         @Override
         public void onModuleLoad() {

                 list1 = new ListBox();
                 list1.setVisibleItemCount(4);
                 list1.addChangeHandler(new ChangeHandler() {

                         @Override
                         public void onChange(ChangeEvent event) {
                                 int selectedIntdex = list1.getSelectedIndex();
                                 String selectedString = 
 list1.getValue(selectedIntdex);
                                 selected.setText(selectedString);
                         }

                 });
                 inter.getInfo1(new AsyncCallbackArrayListString() {

                         @Override
                         public void onSuccess(ArrayListString result) {
                                 IteratorString it = result.iterator();
                                 while (it.hasNext())
                                         list1.addItem(it.next().toString());
                         }

                         @Override
                         public void onFailure(Throwable caught) {
                                 Window.alert(Error loading the Database! );
                         }
                 });

                 list2 = new ListBox();
                 list2.setVisibleItemCount(4);
                 list2.addChangeHandler(new ChangeHandler() {

                         @Override
                         public void onChange(ChangeEvent event) {
                                 int selectedIntdex = list2.getSelectedIndex();
                                 String selectedString = 
 list2.getValue(selectedIntdex);
                                 selected.setText(selectedString);
                         }

                 });
                 inter.getInfo2(new AsyncCallbackArrayListString() {

                         @Override
                         public void onSuccess(ArrayListString result) {
                                 IteratorString it = result.iterator();
                                 while (it.hasNext())
                                         list2.addItem(it.next().toString());
                         }

                         @Override
                         public void onFailure(Throwable caught) {
                                 Window.alert(Error loading the Database! );
                         }
                 });

                 left = new Button(  );
                 left.addClickHandler(new ClickHandler() {

                         public void onClick(ClickEvent event) {
                                 

GWT save and modify in database(mysql)

2010-09-20 Thread Buica Tatiana
So i had to do the following assignment in GWT:

1.Implement a selection/de-selection component as described below:
The selected item in the first list goes into the second list and is
removed from the first list when the  button is pressed. The
selected item in the second list goes into the first list and is
removed from the second list when the  button is pressed. The latest
selected item text is also displayed into the bottom text control with
the label “Selection”.
There also exists two checkboxes allowing the user to SAVE the content
of the second list to a file or a database.

After i searched a lot over the internet i came out with this program:

This is the client side, meaning that this is what the user can see in
the Web Browser. I made the whole GUI in the 'onModuleLoad()' section,
including the action-listeners i needed for my application.
I also had to communicate with the server side so i can connect to a
database.
'CInterfaceAsync inter = GWT.create(CInterface.class);' with this line
i create a connection with the server-side trough an interface that
should be created on the client side too. using inter.function allows
me to access the methods from the server side.

package gwt.hom.client;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.*;

public class WebApp implements EntryPoint {

private static final long serialVersionUID = 1L;

CInterfaceAsync inter = GWT.create(CInterface.class);

public static ListBox list1;
public ListBox list2;
public Button left, right, save;
public Label label, file, db;
ArrayListString list1Elems, list2Elems;
public CheckBox toFile, toDB;
public TextArea selected;
public Panel panel, panel2, panel3;


@Override
public void onModuleLoad() {


list1 = new ListBox();
list1.setVisibleItemCount(4);
list1.addChangeHandler(new ChangeHandler() {

@Override
public void onChange(ChangeEvent event) {
int selectedIntdex = list1.getSelectedIndex();
String selectedString = 
list1.getValue(selectedIntdex);
selected.setText(selectedString);
}

});
inter.getInfo1(new AsyncCallbackArrayListString() {

@Override
public void onSuccess(ArrayListString result) {
IteratorString it = result.iterator();
while (it.hasNext())
list1.addItem(it.next().toString());
}

@Override
public void onFailure(Throwable caught) {
Window.alert(Error loading the Database! );
}
});

list2 = new ListBox();
list2.setVisibleItemCount(4);
list2.addChangeHandler(new ChangeHandler() {

@Override
public void onChange(ChangeEvent event) {
int selectedIntdex = list2.getSelectedIndex();
String selectedString = 
list2.getValue(selectedIntdex);
selected.setText(selectedString);
}

});
inter.getInfo2(new AsyncCallbackArrayListString() {

@Override
public void onSuccess(ArrayListString result) {
IteratorString it = result.iterator();
while (it.hasNext())
list2.addItem(it.next().toString());
}

@Override
public void onFailure(Throwable caught) {
Window.alert(Error loading the Database! );
}
});

left = new Button(  );
left.addClickHandler(new ClickHandler() {

public void onClick(ClickEvent event) {
ArrayListObject buffer = new 
ArrayListObject();
int selectedEl = list2.getSelectedIndex();
String element = list2.getItemText(selectedEl);