PDA

View Full Version : FormPanel readOnly



yopiyop
13 Jun 2008, 1:18 AM
Can you add setReadOnly(boolean readOnly) method on FormPanel (
to set all form fields to read only) ?

thx
David

yopiyop
18 Jun 2008, 1:49 AM
in Tab Form Panel example : FormPanel.getFields throws Exception (version beta 5):



java.lang.ClassCastException: com.extjs.gxt.ui.client.widget.TabPanel cannot be cast to com.extjs.gxt.ui.client.widget.LayoutContainer
at com.extjs.gxt.ui.client.widget.form.FormPanel.getChildFields(FormPanel.java:155)
at com.extjs.gxt.ui.client.widget.form.FormPanel.getFields(FormPanel.java:53)
in



FormPanel panel = new FormPanel();
panel.setFrame(false);
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
panel.setButtonAlign(HorizontalAlignment.CENTER);
panel.setLayout(new FitLayout());

TabPanel tabs = new TabPanel();

TabItem personal = new TabItem();
personal.setText("Personal Details");
personal.setLayout(new FormLayout());

TextField<String> name = new TextField<String>();
name.setFieldLabel("First Name");
name.setValue("Darrell");
personal.add(name);

TextField<String> last = new TextField<String>();
last.setFieldLabel("Last Name");
last.setValue("Meyer");
personal.add(last);

TextField<String> company = new TextField<String>();
company.setFieldLabel("Company");
personal.add(company);

TextField<String> email = new TextField<String>();
email.setFieldLabel("Email");
personal.add(email);

tabs.add(personal);

TabItem numbers = new TabItem();
numbers.setText("Phone Numbers");
numbers.setLayout(new FormLayout());

TextField<String> home = new TextField<String>();
home.setFieldLabel("Home");
home.setValue("800-555-1212");
numbers.add(home);

TextField<String> business = new TextField<String>();
business.setFieldLabel("Business");
numbers.add(business);

TextField<String> mobile = new TextField<String>();
mobile.setFieldLabel("Mobile");
numbers.add(mobile);

TextField<String> fax = new TextField<String>();
fax.setFieldLabel("Fax");
numbers.add(fax);

tabs.add(numbers);

panel.add(tabs);
panel.addButton(new Button("Cancel"));
panel.addButton(new Button("Submit"));

panel.setSize(340, 180);


//---------------
for (Field field : panel.getFields()) {
field.setReadOnly(true);
}
Viewport v = new Viewport();
v.add(panel);
RootPanel.get().add(v);

gslender
18 Jun 2008, 1:56 AM
The problem is that you are adding a TabPanel to the FormPanel - you can only add widgets that extend Field to a FormPanel.

What you want to do is add a formpanel to a contentpanel and add the tabpanel to the contentpanel... does that make sense?

yopiyop
18 Jun 2008, 4:39 AM
The problem is that you are adding a TabPanel to the FormPanel - you can only add widgets that extend Field to a FormPanel.

What you want to do is add a formpanel to a contentpanel and add the tabpanel to the contentpanel... does that make sense?

not really, look at source : http://extjs.com/explorer/#tabpanelform

gslender
18 Jun 2008, 12:22 PM
Ahhh, TabForms are new - there is a bug in the code and you'll need to repost or move this to Bugs

darrellmeyer
18 Jun 2008, 12:47 PM
The bug is fixed in SVN and I added setReadOnly to FormPanel.

mfettah
6 Aug 2008, 3:07 PM
Why i can t found the methode formPanel.getForm().getValues() in the class
com.extjs.gxt.ui.client.widget.form.FormPanel
RequestBuilder rb ;
....
rb.sendRequest(formPanel.getForm().getValues(), new RequestCallback()
{
public void onResponseReceived(Request req, Response res)
{
etc...

gslender
6 Aug 2008, 3:20 PM
you should really also post a new thread - don't jump on the back of another as it becomes confusing for future readers...

regarding your problem, you'll need to provide more details as RequestBuilder is a GWT class that is commonly used with GWT FormPanel... the GXT version is not the same nor is it based on the GWT FormPanel - so you won't be able to get/do the same things