Formpanel can be used in this way, an example on the API:
Copy Code code as follows:
var panel=ext.create (' Ext.form.Panel ', {
Title: ' Simple Form ',
Bodypadding:5,
WIDTH:350,
will be submitted to this URL via an AJAX request
URL: ' save-form.php ',
form field Fields will be arranged vertically, filling the entire width
Layout: ' Anchor ',
Defaults: {
Anchor: ' 100% '
},
The fields
DefaultType: ' TextField ',
Items: [{
Fieldlabel: ' Name ',
Name: ' I ',
Allowblank:false
},{
Fieldlabel: ' Last Name ',
Name: ' Last ',
Allowblank:false
}],
Reset and Save buttons.
Buttons: [{
Text: ' Reset ',
Handler:function () {
This.up (' form '). GetForm (). reset ();
}
}, {
Text: ' Save ',
Formbind:true,//only enabled once the form is valid
Disabled:true,
Handler:function () {
var form = this.up (' form '). GetForm ();
if (Form.isvalid ()) {
Form.submit ({
Success:function (form, action) {
Ext.Msg.alert (' Save Success ', action.result.msg);
},
Failure:function (form, action) {
Ext.Msg.alert (' Operation failure ', action.result.msg);
}
});
}
}
}],
RenderTo:Ext.getBody ()
);
Then look at the Api,formpanel has no URL configuration, nor get the API function. Think of it as a parameter to the parent class of Formpanel ...
Later went to look at the Ext.form.basic, there is a URL configuration items.
The Formpanel in ext does not save the form data, where the data is saved by Basicform, and when submitting the form you need to get the basicform in the current Formpanel to commit.
Form submission can be done after getting the Basicform object
Because there are 2 components to be used in the project, the only difference between the 2 components is that the URL is not the same, so I don't define the URL when I define the component
You can then also give the different URLs to the components when they are added to the different containers, and take the example above
where it's needed.
Copy Code code as follows:
Panel.getform (). Url= '. /logselectservlet ';//in different places you can assign different URLs like this
This approach is a good way to reuse components.