zodixman
14 Apr 2009, 7:24 AM
- JDK 6u10
- GXT 1.2.3
- GWT 1.5.3
- Eclipse 3.4.1
First, sorry if my English is not perfect :(.
I'm new to GXT. And i have trouble with my application.
I have a view that contains several components, in parallel, using a simple ADD.
The view is a ViewPort with a Fitlayout.
I have several FormPanel distributed in all components son (LayoutContainer) of ViewPort.
Consider a FormPanel which contains a set of TextField, ComboBox and others ...
So, my questions:
- Knowing that the viewport does not accept the ScrollBar. How can I use it even when I have a lower resolution. Should I (for example), put a set of component (LayoutContainer) in a layout that's active ScrollBar? If all this is simply impossible. Is there an alternative to the ViewPort ?
- How do I get a FormPanel in another FormPanel. I can not because it generates an exception ?
Other problems:
Codes in my ViewPort: (for example)
// ApplicationView.java
public class ApplicationView extends View {
public ApplicationView(Controller controller) {
super(controller) ;
}
public void initialize() {
Viewport viewport = new Viewport();
viewport.setLayout(new FitLayout());
viewport.setStyleAttribute("margin", "4px 0 0 0");
ContentPanel contentPanel = new ContentPanel();
contentPanel.setLayout(new FitLayout());
contentPanel.setFrame(false);
contentPanel.setBorders(false);
contentPanel.setHeaderVisible(false);
establishmentComponent = new EstablishmentComponent();
contentPanel.add(establishmentComponent, new FitData(4));
viewport.add(contentPanel, new FitData(Format.ApplicationView.VIEWPORT_MARGIN));
RootPanel.get().add(viewport);
}
}
// EstablishmentComponent.java
public class EstablishmentComponent extends LayoutContainer{
private EstablishmentPanel establishmentPanel ;
private CompanyPanel companyPanel ;
public EstablishmentComponent() {
setLayout(new FitLayout());
TabPanel panel = new TabPanel();
TabItem establishmentTab = new TabItem(locale.ESTABLISHMENT());
establishmentPanel = new EstablishmentPanel();
establishmentTab.add(establishmentPanel);
establishmentTab.getHeader().setStyleAttribute("width", "130px");
panel.add(establishmentTab);
TabItem companyTab = new TabItem(locale.COMPANY());
companyPanel = new CompanyPanel();
companyTab.add(companyPanel);
companyTab.getHeader().setStyleAttribute("width", "130px");
panel.add(companyTab);
add(panel);
}
}
// EstablishmentPanel .java
public class EstablishmentPanel extends LayoutContainer {
private EstablishmentSearchCriteria establishmentSearchCriteria ;
private EstablishmentSearchResult establishmentSearchResult ;
public EstablishmentPanel() {
setLayout(new RowLayout(Orientation.VERTICAL));
establishmentSearchCriteria = new EstablishmentSearchCriteria();
add(establishmentSearchCriteria);
establishmentSearchResult = new EstablishmentSearchResult();
add(establishmentSearchResult);
}
}
// EstablishmentSearchCriteria
public class EstablishmentSearchCriteria extends LayoutContainer {
private FormPanel formPanel ;
private Button searchButton ;
private Button cleanButton;
private TextField<String> textFieldCommercialName ;
private TextField<String> textFieldName ;
private ComboBox<BeanModel> comboBoxCompanyName ;
private ComboBox<BeanModel> comboBoxCompanySiren ;
private ColumnData columnData;
@SuppressWarnings("unchecked")
protected void onResize(int width, int height) {
super.onResize(width, height);
String fieldsSize = "96%";
double layoutSize = .20;
columnData.setWidth(layoutSize);
formPanel.setAutoWidth(true);
List<Field> fields = formPanel.getFields();
for (int i = 0; i < fields.size(); i++) {
fields.get(i).setWidth(fieldsSize);
}
layout();
}
public EstablishmentSearchCriteria() {
setLayout(new FitLayout());
setHeight(110);
columnData = new ColumnData(.20);
cleanButton = new Button(locale.CLEAN_BUTTON(), new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
formPanel.reset();
}
});
searchButton = new Button(locale.SEARCH_BUTTON(), new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent event) {
if (formPanel.isValid()) {
onSearchSubmit();
}
}
});
formPanel = createForm();
add(formPanel);
}
private FormPanel createForm() {
FormPanel formPanel = new FormPanel() ;
formPanel.setHeading(locale.ESTABLISHMENT_SEARCH_CRITERIA());
formPanel.setBorders(false);
formPanel.setBodyBorder(false);
LayoutContainer col1 = new LayoutContainer(new FormLayout(LabelAlign.TOP)) ;
LayoutContainer col2 = new LayoutContainer(new FormLayout(LabelAlign.TOP)) ;
LayoutContainer col3 = new LayoutContainer(new FormLayout(LabelAlign.TOP)) ;
LayoutContainer col4 = new LayoutContainer(new FormLayout(LabelAlign.TOP)) ;
LayoutContainer col5 = new LayoutContainer(new FormLayout(LabelAlign.TOP)) ;
textFieldCommercialName = new TextField<String>() ;
textFieldCommercialName.setName("commercialName") ;
textFieldCommercialName.setMaxLength(80) ;
col1.add(textFieldCommercialName) ;
textFieldName = new TextField<String>() ;
textFieldName.setName("name") ;
textFieldName.setMaxLength(80) ;
col2.add(textFieldName) ;
comboBoxCompanyName = new ComboBox<BeanModel>() ;
comboBoxCompanyName.setFieldLabel(locale.COMPANY()) ;
comboBoxCompanyName.setDisplayField("name") ;
comboBoxCompanyName.setSimpleTemplate("{name} - {siren}") ;
comboBoxCompanyName.setStore(getAsyncCompanyStore()) ;
comboBoxCompanyName.setTypeAhead(true) ;
comboBoxCompanyName.setMinChars(2) ;
comboBoxCompanyName.setPageSize(10) ;
comboBoxCompanyName.setForceSelection(true) ;
col4.add(comboBoxCompanyName) ;
comboBoxCompanySiren = new ComboBox<BeanModel>() ;
comboBoxCompanySiren.setFieldLabel(locale.COMPANY_SIREN()) ;
comboBoxCompanySiren.setDisplayField("siren") ;
comboBoxCompanySiren.setSimpleTemplate("{siren} - {name}") ;
comboBoxCompanySiren.setStore(getAsyncCompanyStore()) ;
comboBoxCompanySiren.setTypeAhead(true) ;
comboBoxCompanySiren.setMinChars(2) ;
comboBoxCompanySiren.setPageSize(10) ;
comboBoxCompanySiren.setForceSelection(true) ;
col5.add(comboBoxCompanySiren) ;
formPanel.setLayout(new ColumnLayout()) ;
formPanel.add(col1, columnData);
formPanel.add(col2, columnData);
formPanel.add(col3, columnData);
formPanel.add(col4, columnData);
formPanel.add(col5, columnData);
formPanel.setButtonAlign(HorizontalAlignment.LEFT) ;
formPanel.addButton(searchButton) ;
formPanel.addButton(cleanButton);
return formPanel ;
}
}
As you can see, I resize manualy the Fields at the time when resizing the window (onResize Event). It's ok, but this does not fully satisfy me. Because the result is unlikely. How can I solve this problem? I imagine that there is another easier solution to do that?
Thanks for answer me !?
- GXT 1.2.3
- GWT 1.5.3
- Eclipse 3.4.1
First, sorry if my English is not perfect :(.
I'm new to GXT. And i have trouble with my application.
I have a view that contains several components, in parallel, using a simple ADD.
The view is a ViewPort with a Fitlayout.
I have several FormPanel distributed in all components son (LayoutContainer) of ViewPort.
Consider a FormPanel which contains a set of TextField, ComboBox and others ...
So, my questions:
- Knowing that the viewport does not accept the ScrollBar. How can I use it even when I have a lower resolution. Should I (for example), put a set of component (LayoutContainer) in a layout that's active ScrollBar? If all this is simply impossible. Is there an alternative to the ViewPort ?
- How do I get a FormPanel in another FormPanel. I can not because it generates an exception ?
Other problems:
Codes in my ViewPort: (for example)
// ApplicationView.java
public class ApplicationView extends View {
public ApplicationView(Controller controller) {
super(controller) ;
}
public void initialize() {
Viewport viewport = new Viewport();
viewport.setLayout(new FitLayout());
viewport.setStyleAttribute("margin", "4px 0 0 0");
ContentPanel contentPanel = new ContentPanel();
contentPanel.setLayout(new FitLayout());
contentPanel.setFrame(false);
contentPanel.setBorders(false);
contentPanel.setHeaderVisible(false);
establishmentComponent = new EstablishmentComponent();
contentPanel.add(establishmentComponent, new FitData(4));
viewport.add(contentPanel, new FitData(Format.ApplicationView.VIEWPORT_MARGIN));
RootPanel.get().add(viewport);
}
}
// EstablishmentComponent.java
public class EstablishmentComponent extends LayoutContainer{
private EstablishmentPanel establishmentPanel ;
private CompanyPanel companyPanel ;
public EstablishmentComponent() {
setLayout(new FitLayout());
TabPanel panel = new TabPanel();
TabItem establishmentTab = new TabItem(locale.ESTABLISHMENT());
establishmentPanel = new EstablishmentPanel();
establishmentTab.add(establishmentPanel);
establishmentTab.getHeader().setStyleAttribute("width", "130px");
panel.add(establishmentTab);
TabItem companyTab = new TabItem(locale.COMPANY());
companyPanel = new CompanyPanel();
companyTab.add(companyPanel);
companyTab.getHeader().setStyleAttribute("width", "130px");
panel.add(companyTab);
add(panel);
}
}
// EstablishmentPanel .java
public class EstablishmentPanel extends LayoutContainer {
private EstablishmentSearchCriteria establishmentSearchCriteria ;
private EstablishmentSearchResult establishmentSearchResult ;
public EstablishmentPanel() {
setLayout(new RowLayout(Orientation.VERTICAL));
establishmentSearchCriteria = new EstablishmentSearchCriteria();
add(establishmentSearchCriteria);
establishmentSearchResult = new EstablishmentSearchResult();
add(establishmentSearchResult);
}
}
// EstablishmentSearchCriteria
public class EstablishmentSearchCriteria extends LayoutContainer {
private FormPanel formPanel ;
private Button searchButton ;
private Button cleanButton;
private TextField<String> textFieldCommercialName ;
private TextField<String> textFieldName ;
private ComboBox<BeanModel> comboBoxCompanyName ;
private ComboBox<BeanModel> comboBoxCompanySiren ;
private ColumnData columnData;
@SuppressWarnings("unchecked")
protected void onResize(int width, int height) {
super.onResize(width, height);
String fieldsSize = "96%";
double layoutSize = .20;
columnData.setWidth(layoutSize);
formPanel.setAutoWidth(true);
List<Field> fields = formPanel.getFields();
for (int i = 0; i < fields.size(); i++) {
fields.get(i).setWidth(fieldsSize);
}
layout();
}
public EstablishmentSearchCriteria() {
setLayout(new FitLayout());
setHeight(110);
columnData = new ColumnData(.20);
cleanButton = new Button(locale.CLEAN_BUTTON(), new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent ce) {
formPanel.reset();
}
});
searchButton = new Button(locale.SEARCH_BUTTON(), new SelectionListener<ButtonEvent>() {
public void componentSelected(ButtonEvent event) {
if (formPanel.isValid()) {
onSearchSubmit();
}
}
});
formPanel = createForm();
add(formPanel);
}
private FormPanel createForm() {
FormPanel formPanel = new FormPanel() ;
formPanel.setHeading(locale.ESTABLISHMENT_SEARCH_CRITERIA());
formPanel.setBorders(false);
formPanel.setBodyBorder(false);
LayoutContainer col1 = new LayoutContainer(new FormLayout(LabelAlign.TOP)) ;
LayoutContainer col2 = new LayoutContainer(new FormLayout(LabelAlign.TOP)) ;
LayoutContainer col3 = new LayoutContainer(new FormLayout(LabelAlign.TOP)) ;
LayoutContainer col4 = new LayoutContainer(new FormLayout(LabelAlign.TOP)) ;
LayoutContainer col5 = new LayoutContainer(new FormLayout(LabelAlign.TOP)) ;
textFieldCommercialName = new TextField<String>() ;
textFieldCommercialName.setName("commercialName") ;
textFieldCommercialName.setMaxLength(80) ;
col1.add(textFieldCommercialName) ;
textFieldName = new TextField<String>() ;
textFieldName.setName("name") ;
textFieldName.setMaxLength(80) ;
col2.add(textFieldName) ;
comboBoxCompanyName = new ComboBox<BeanModel>() ;
comboBoxCompanyName.setFieldLabel(locale.COMPANY()) ;
comboBoxCompanyName.setDisplayField("name") ;
comboBoxCompanyName.setSimpleTemplate("{name} - {siren}") ;
comboBoxCompanyName.setStore(getAsyncCompanyStore()) ;
comboBoxCompanyName.setTypeAhead(true) ;
comboBoxCompanyName.setMinChars(2) ;
comboBoxCompanyName.setPageSize(10) ;
comboBoxCompanyName.setForceSelection(true) ;
col4.add(comboBoxCompanyName) ;
comboBoxCompanySiren = new ComboBox<BeanModel>() ;
comboBoxCompanySiren.setFieldLabel(locale.COMPANY_SIREN()) ;
comboBoxCompanySiren.setDisplayField("siren") ;
comboBoxCompanySiren.setSimpleTemplate("{siren} - {name}") ;
comboBoxCompanySiren.setStore(getAsyncCompanyStore()) ;
comboBoxCompanySiren.setTypeAhead(true) ;
comboBoxCompanySiren.setMinChars(2) ;
comboBoxCompanySiren.setPageSize(10) ;
comboBoxCompanySiren.setForceSelection(true) ;
col5.add(comboBoxCompanySiren) ;
formPanel.setLayout(new ColumnLayout()) ;
formPanel.add(col1, columnData);
formPanel.add(col2, columnData);
formPanel.add(col3, columnData);
formPanel.add(col4, columnData);
formPanel.add(col5, columnData);
formPanel.setButtonAlign(HorizontalAlignment.LEFT) ;
formPanel.addButton(searchButton) ;
formPanel.addButton(cleanButton);
return formPanel ;
}
}
As you can see, I resize manualy the Fields at the time when resizing the window (onResize Event). It's ok, but this does not fully satisfy me. Because the result is unlikely. How can I solve this problem? I imagine that there is another easier solution to do that?
Thanks for answer me !?