victor.martinez
1 Sep 2008, 3:04 AM
Hi all!
This is my first post..., i'm trying to add dynamic a item in to FormPanel but someting is wrong because the item added is not render. The idea is the next, the user press a button and some procedure is call in server side, trought mvc architecture (dispacher, controller, server side code, blablabla...) and when the process is over a new label is added into FormPanel.
this is the all code of the class :
package com.safelayer.foafmanager.client.mvc;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.KeyListener;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.mvc.View;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.safelayer.foafmanager.client.AppEvents;
public class ImportSocialNetworksView extends View {
private static final String text1 = "http://socialnetwork.com/users/";
private FormPanel panel ;
private LayoutContainer container1;
private Viewport v ;
public ImportSocialNetworksView(Controller controller) {
super(controller);
}
protected void handleEvent(AppEvent event) {
switch (event.type) {
case AppEvents.InitImport:
InitUI();
break;
case AppEvents.getFoafFromNet:
if ((Boolean) event.getData("ok")) {
Info.display("Message", "data where loading", "");
}
else {
Info.display("Error","data where not loading, check your username", "");}
}
}
private void InitUI() {
final LabelField oklabel = new LabelField();
oklabel.setText(text1);
//Matrix Layout
//Viewport v = new Viewport();
v = new Viewport();
v.setLayout(new RowLayout(Orientation.HORIZONTAL));
//LayoutContainer container1 = new LayoutContainer();
container1 = new LayoutContainer();
container1.setLayout(new RowLayout(Orientation.VERTICAL));
LayoutContainer container2 = new LayoutContainer();
container2.setLayout(new RowLayout(Orientation.VERTICAL));
panel = new FormPanel();
final LabelField label = new LabelField();
label.setText(text1);
panel.add(label);
//panel.render(panel.getItem(0).getElement());
final TextField text = new TextField();
text.setFieldLabel("User name");
text.setEmptyText("Enter your user name");
text.addKeyListener(new KeyListener(){
public void componentKeyUp(ComponentEvent ce){
String txt = text.getRawValue();
label.setText(text1 + txt);
}
});
panel.add(text);
Button b = new Button("add",
new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
Dispatcher.forwardEvent(AppEvents.getFoafFromNet);
panel.add(oklabel);
//HERE I TRY TO ADD A LABEL IN TO A PANEL
}
});
panel.addButton(b);
FormPanel panel2 = new FormPanel();
panel.setHeading("explode.us");
LabelField label2 = new LabelField();
label2.setText("http://Explode.us./cvbcvbc");
panel2.add(label2);
TextField text2 = new TextField();
text2.setFieldLabel("User name");
text2.setEmptyText("Enter your user name");
panel2.add(text2);
FormPanel panel3 = new FormPanel();
panel3.setHeading("Vox");
LabelField label3 = new LabelField();
label3.setText("http://Explode.us./cvbcvbc");
panel3.add(label3);
TextField text3 = new TextField();
text3.setFieldLabel("User name");
text3.setEmptyText("Enter your user name");
panel3.add(text3);
FormPanel panel4 = new FormPanel();
panel4.setHeading("livejournal");
LabelField label4 = new LabelField();
label4.setText("http://Explode.us./cvbcvbc");
panel4.add(label4);
TextField text4 = new TextField();
text4.setFieldLabel("User name");
text4.setEmptyText("Enter your user name");
panel4.add(text4);
FormPanel panel5 = new FormPanel();
panel5.setHeading("hi5");
LabelField label5 = new LabelField();
label5.setText("http://Explode.us./cvbcvbc");
panel5.add(label5);
TextField text5 = new TextField();
text5.setFieldLabel("User name");
text5.setEmptyText("Enter your user name");
panel5.add(text5);
FormPanel panel6 = new FormPanel();
panel6.setHeading("crazylive");
LabelField label6 = new LabelField();
label6.setText("http://Explode.us./cvbcvbc");
panel6.add(label6);
TextField text6 = new TextField();
text6.setFieldLabel("User name");
text6.setEmptyText("Enter your user name");
panel6.add(text6);
container1.add(panel, new RowData(1,0.33,new Margins(10)));
container1.add(panel2, new RowData(1,0.33,new Margins(10)));
container1.add(panel3, new RowData(1,0.33,new Margins(10)));
container2.add(panel4, new RowData(1,0.33,new Margins(10)));
container2.add(panel5, new RowData(1,0.33,new Margins(10)));
container2.add(panel6, new RowData(1,0.33,new Margins(10)));
v.add(container1,new RowData(0.5,1,new Margins(10)));
v.add(container2,new RowData(0.5,1,new Margins(10)));
RootPanel.get().add(v);
}
}
Thanks,
This is my first post..., i'm trying to add dynamic a item in to FormPanel but someting is wrong because the item added is not render. The idea is the next, the user press a button and some procedure is call in server side, trought mvc architecture (dispacher, controller, server side code, blablabla...) and when the process is over a new label is added into FormPanel.
this is the all code of the class :
package com.safelayer.foafmanager.client.mvc;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.KeyListener;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.mvc.View;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.safelayer.foafmanager.client.AppEvents;
public class ImportSocialNetworksView extends View {
private static final String text1 = "http://socialnetwork.com/users/";
private FormPanel panel ;
private LayoutContainer container1;
private Viewport v ;
public ImportSocialNetworksView(Controller controller) {
super(controller);
}
protected void handleEvent(AppEvent event) {
switch (event.type) {
case AppEvents.InitImport:
InitUI();
break;
case AppEvents.getFoafFromNet:
if ((Boolean) event.getData("ok")) {
Info.display("Message", "data where loading", "");
}
else {
Info.display("Error","data where not loading, check your username", "");}
}
}
private void InitUI() {
final LabelField oklabel = new LabelField();
oklabel.setText(text1);
//Matrix Layout
//Viewport v = new Viewport();
v = new Viewport();
v.setLayout(new RowLayout(Orientation.HORIZONTAL));
//LayoutContainer container1 = new LayoutContainer();
container1 = new LayoutContainer();
container1.setLayout(new RowLayout(Orientation.VERTICAL));
LayoutContainer container2 = new LayoutContainer();
container2.setLayout(new RowLayout(Orientation.VERTICAL));
panel = new FormPanel();
final LabelField label = new LabelField();
label.setText(text1);
panel.add(label);
//panel.render(panel.getItem(0).getElement());
final TextField text = new TextField();
text.setFieldLabel("User name");
text.setEmptyText("Enter your user name");
text.addKeyListener(new KeyListener(){
public void componentKeyUp(ComponentEvent ce){
String txt = text.getRawValue();
label.setText(text1 + txt);
}
});
panel.add(text);
Button b = new Button("add",
new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
Dispatcher.forwardEvent(AppEvents.getFoafFromNet);
panel.add(oklabel);
//HERE I TRY TO ADD A LABEL IN TO A PANEL
}
});
panel.addButton(b);
FormPanel panel2 = new FormPanel();
panel.setHeading("explode.us");
LabelField label2 = new LabelField();
label2.setText("http://Explode.us./cvbcvbc");
panel2.add(label2);
TextField text2 = new TextField();
text2.setFieldLabel("User name");
text2.setEmptyText("Enter your user name");
panel2.add(text2);
FormPanel panel3 = new FormPanel();
panel3.setHeading("Vox");
LabelField label3 = new LabelField();
label3.setText("http://Explode.us./cvbcvbc");
panel3.add(label3);
TextField text3 = new TextField();
text3.setFieldLabel("User name");
text3.setEmptyText("Enter your user name");
panel3.add(text3);
FormPanel panel4 = new FormPanel();
panel4.setHeading("livejournal");
LabelField label4 = new LabelField();
label4.setText("http://Explode.us./cvbcvbc");
panel4.add(label4);
TextField text4 = new TextField();
text4.setFieldLabel("User name");
text4.setEmptyText("Enter your user name");
panel4.add(text4);
FormPanel panel5 = new FormPanel();
panel5.setHeading("hi5");
LabelField label5 = new LabelField();
label5.setText("http://Explode.us./cvbcvbc");
panel5.add(label5);
TextField text5 = new TextField();
text5.setFieldLabel("User name");
text5.setEmptyText("Enter your user name");
panel5.add(text5);
FormPanel panel6 = new FormPanel();
panel6.setHeading("crazylive");
LabelField label6 = new LabelField();
label6.setText("http://Explode.us./cvbcvbc");
panel6.add(label6);
TextField text6 = new TextField();
text6.setFieldLabel("User name");
text6.setEmptyText("Enter your user name");
panel6.add(text6);
container1.add(panel, new RowData(1,0.33,new Margins(10)));
container1.add(panel2, new RowData(1,0.33,new Margins(10)));
container1.add(panel3, new RowData(1,0.33,new Margins(10)));
container2.add(panel4, new RowData(1,0.33,new Margins(10)));
container2.add(panel5, new RowData(1,0.33,new Margins(10)));
container2.add(panel6, new RowData(1,0.33,new Margins(10)));
v.add(container1,new RowData(0.5,1,new Margins(10)));
v.add(container2,new RowData(0.5,1,new Margins(10)));
RootPanel.get().add(v);
}
}
Thanks,