PDA

View Full Version : Problem FieldSet



alissonvla
21 Dec 2010, 8:08 AM
2391323914hi everyone,
I'm having a problem with FieldSet, when it's rendered. See the images.

Source


FieldSet fieldSet = new FieldSet();
fieldSet.setAutoHeight(true);
fieldSet.setAutoWidth(true);
fieldSet.setHeading(model.getLabel());
if(model.isIscollapsed()){
fieldSet.collapse();
}else{
fieldSet.expand();
}
fieldSet.setCollapsible(model.isIscollapsible());
thanks.

sven
21 Dec 2010, 8:12 AM
autoHeight and autoWidth are not supported on complex components. You should define a real width at least. Depending on the layout you use, you also need to define a height.

alissonvla
21 Dec 2010, 8:16 AM
I set the height and the width manually and continue same thing.
thanks.

sven
21 Dec 2010, 8:18 AM
You need to give as more informations. Anybody other than you know your code. Can you please post a fully working testcase implementing EntryPoint?

alissonvla
21 Dec 2010, 8:32 AM
follow:



private static LayoutContainer criarTextField(SIArteWindowModel window, SIArteFieldModel campo, Map<EventType, Listener<FieldEvent>> listaListener) {
LayoutContainer layoutContainer = criarLabel(campo);

TextField<String> textField = new TextField<String>();
textField.setId("id_" + campo.getCodigoTabela() + "_" + campo.getCodigoColuna());
textField.setMaxLength(campo.getTamanho());
textField.setWidth(campo.getMaxlength() * 10);
textField.setValue(campo.getValor());
textField.setEnabled(campo.isReadOnly());
textField.setAllowBlank(campo.isRequired());

if (listaListener != null && !listaListener.isEmpty()) {
for (EventType evento : listaListener.keySet()) {
textField.addListener(evento, listaListener.get(evento));
}
}

layoutContainer.add(textField, new HBoxLayoutData(new Margins(0, 2, 0, 0)));

return layoutContainer;
}




private static LayoutContainer criarLabel(SIArteFieldModel campo) {
LayoutContainer layoutContainer = new LayoutContainer();
layoutContainer.setWidth(930);
layoutContainer.setId(campo.getNome() + "-lc");

HBoxLayout layout = new HBoxLayout();
layout.setPadding(new Padding(2));
layoutContainer.setLayout(layout);


Label labelCampo = new Label(campo.getLabel());
labelCampo.setId("lbl"+campo.getNome());
labelCampo.setStyleAttribute("font-weight", "bold");
labelCampo.setStyleAttribute("text-align", "right");
labelCampo.setWidth(150);
layoutContainer.add(labelCampo, new HBoxLayoutData(new Margins(3, 2, 0, 0)));


return layoutContainer;
}


these are code, of the components into FieldSet.
I'm sorry, but my english isn't very good.

sven
21 Dec 2010, 8:34 AM
That is not a fully working testcase that implements EntryPoint. The problem is that you use an HBoxLayout in a non visible (collapsed FieldSet). Is there any reason you use HBoxLayout (i dont see it)?

alissonvla
21 Dec 2010, 8:41 AM
then, my application is dynamic and very complex, I would have to send all my source code.

sven
21 Dec 2010, 8:43 AM
then, my application is dynamic and very complex, I would have to send all my source code.

Or you take the time and recreate it in a simple, standalone testcase. But i already pointed out what probably is the problem in my previous reply.

alissonvla
21 Dec 2010, 8:54 AM
follow


package br.com.arteinfo.client.view;

import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.util.Padding;
import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.HBoxLayout;
import com.extjs.gxt.ui.client.widget.layout.HBoxLayoutData;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

/**
* Classe que implementa o Entry Point da aplicação. Desta classe é montado
* o layout inicial da aplicação.
*
* @author Alexandre.Soares
*
*/
public class ArterhLayoutEntryPoint implements EntryPoint {

@Override
public void onModuleLoad() {
LayoutContainer container = new LayoutContainer();

FieldSet fieldSet = new FieldSet();
fieldSet.setHeight(200);
fieldSet.setWidth(500);
fieldSet.setHeading("TESTE");
fieldSet.collapse();
fieldSet.setCollapsible(true);

LayoutContainer layoutContainer = new LayoutContainer();
layoutContainer.setWidth(930);
layoutContainer.setId("Teste-lc");

HBoxLayout layout = new HBoxLayout();
layout.setPadding(new Padding(2));
layoutContainer.setLayout(layout);

Label labelCampo = new Label("Nome");
labelCampo.setId("lblNome");
labelCampo.setStyleAttribute("font-weight", "bold");
labelCampo.setStyleAttribute("text-align", "right");
labelCampo.setWidth(150);
layoutContainer.add(labelCampo, new HBoxLayoutData(new Margins(3, 2, 0, 0)));

TextField<String> textField = new TextField<String>();
textField.setId("id_NOME");
textField.setMaxLength(10);
textField.setWidth(150);
textField.setValue("");
textField.setEnabled(false);
textField.setAllowBlank(true);

layoutContainer.add(textField, new HBoxLayoutData(new Margins(0, 2, 0, 0)));

fieldSet.add(layoutContainer);

container.add(fieldSet);

RootPanel.get().add(container);
}
}



thanks

sven
21 Dec 2010, 9:01 AM
Why are you using a HboxLayout there, a FormLayout fits much better for your needs:

class ArterhLayoutEntryPoint implements EntryPoint {

public void onModuleLoad() {
LayoutContainer container = new LayoutContainer();

FieldSet fieldSet = new FieldSet();
fieldSet.setHeight(200);
fieldSet.setWidth(500);
fieldSet.setHeading("TESTE");
fieldSet.collapse();
fieldSet.setCollapsible(true);

LayoutContainer layoutContainer = new LayoutContainer();
layoutContainer.setWidth(930);
layoutContainer.setId("Teste-lc");

FormLayout l = new FormLayout();
l.setLabelAlign(LabelAlign.RIGHT);
l.setLabelWidth(150);
layoutContainer.setLayout(l);

TextField<String> textField = new TextField<String>();
textField.setId("id_NOME");
textField.setMaxLength(10);
textField.setFieldLabel("Nome");
textField.setWidth(150);
textField.setValue("");
textField.setEnabled(false);
textField.setAllowBlank(true);

layoutContainer.add(textField);

fieldSet.add(layoutContainer);
fieldSet.setLayout(new FitLayout());
container.add(fieldSet);

RootPanel.get().add(container);
}
}

alissonvla
21 Dec 2010, 9:18 AM
It solved my problem.
Thanks, very much.