Hi Isomorphic,
please see this BuiltInDS-based testcase (v10.1p_2016-01-10/PowerEdition Deployment), closely related to the original issue in this thread.
BuiltInDS.java:
animals.ds.xml:
Please change the value in lifeSpan and click Validate.
In the Developer Console you'll see that the VALIDATE-Request failed:
The only way to not have this happen is to include HiddenItems for every required items as well (here HiddenItem commonNameNameHidden = new HiddenItem("commonName"))like it was necessary for the primaryKey in the other thread.
This is of course possible, but requires very much boilerplate code if you have many member forms and many required fields in the DataSource. So perhaps this is more of an enhancement and not a bug report.
Best regards
Blama
please see this BuiltInDS-based testcase (v10.1p_2016-01-10/PowerEdition Deployment), closely related to the original issue in this thread.
BuiltInDS.java:
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.core.KeyIdentifier; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.util.Page; import com.smartgwt.client.util.PageKeyHandler; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.ValuesManager; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.HiddenItem; import com.smartgwt.client.widgets.layout.VLayout; public class BuiltInDS implements EntryPoint { private VLayout mainLayout; private IButton recreateBtn; public void onModuleLoad() { KeyIdentifier debugKey = new KeyIdentifier(); debugKey.setCtrlKey(true); debugKey.setKeyName("D"); Page.registerKey(debugKey, new PageKeyHandler() { public void execute(String keyName) { SC.showConsole(); } }); mainLayout = new VLayout(20); mainLayout.setWidth100(); mainLayout.setHeight100(); recreateBtn = new IButton("Recreate"); recreateBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { recreate(); } }); mainLayout.addMember(recreateBtn); recreate(); mainLayout.draw(); } private void recreate() { Window w = new Window(); w.setWidth("95%"); w.setHeight("95%"); w.setMembersMargin(0); w.setModalMaskOpacity(70); w.setTitle("Sorting by other fields when grouping"); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); DataSource animalsDS = DataSource.get("animals"); final ValuesManager vM = new ValuesManager(); vM.setDataSource(animalsDS); DynamicForm df1 = new DynamicForm(); df1.setIsGroup(true); df1.setGroupTitle("group1"); df1.setDataSource(animalsDS); df1.setValuesManager(vM); FormItem scientificName = new FormItem("scientificName"); FormItem commonName = new FormItem("commonName"); df1.setFields(scientificName, commonName); DynamicForm df2 = new DynamicForm(); df2.setIsGroup(true); df2.setGroupTitle("group2"); df2.setDataSource(animalsDS); df2.setValuesManager(vM); HiddenItem scientificNameHidden = new HiddenItem("scientificName"); FormItem lifeSpan = new FormItem("lifeSpan"); df2.setFields(scientificNameHidden, lifeSpan); IButton validateBtn = new IButton("Validate", new ClickHandler() { @Override public void onClick(ClickEvent event) { vM.validate(); } }); IButton saveBtn = new IButton("Save", new ClickHandler() { @Override public void onClick(ClickEvent event) { vM.saveData(); } }); w.addItem(df1); w.addItem(df2); w.addItem(validateBtn); w.addItem(saveBtn); w.show(); vM.fetchData(new Criteria("scientificName", "Allligator mississippiensis")); } }[B][/B]
animals.ds.xml:
Code:
<DataSource ID="animals" serverType="sql" tableName="animals" testFileName="animals.data.xml"> <fields> <field name="commonName" title="Animal" type="text" required="true" /> <field name="scientificName" title="Scientific Name" type="text" primaryKey="true" required="true" /> <field name="lifeSpan" title="Life Span" type="integer" required="true"> <validators> <validator type="isUnique" serverOnly="true" /> </validators> </field> <field name="status" title="Endangered Status" type="text"> <valueMap> <value>Threatened</value> <value>Endangered</value> <value>Not Endangered</value> <value>Not currently listed</value> <value>May become threatened</value> <value>Protected</value> </valueMap> </field> <field name="diet" title="Diet" type="text" /> <field name="information" title="Interesting Facts" type="text" length="1000" /> <field name="picture" title="Picture" type="image" detail="true" imageURLPrefix="/isomorphic/system/reference/inlineExamples/tiles/images/" /> </fields> </DataSource>[B][/B]
Please change the value in lifeSpan and click Validate.
In the Developer Console you'll see that the VALIDATE-Request failed:
Code:
{ affectedRows:0, errors:[ { commonName:{ errorMessage:"Field is required" } } ], invalidateCache:false, isDSResponse:true, operationType:"validate", queueStatus:-1, status:-4, data:null }
This is of course possible, but requires very much boilerplate code if you have many member forms and many required fields in the DataSource. So perhaps this is more of an enhancement and not a bug report.
Best regards
Blama
Comment