I'm using a ValuesManager to bind together a few different forms. To create a new record I use ValuesManager.editNewRecord(initialValuesMap) and provide a Map with initial values for various fields. The add request that gets sent to the server includes both values() and oldValues() and the fields are split between the two maps. Why would there be "oldValues" on an add request and what is it that determines which fields show up in oldValues and which in values?
Announcement
Collapse
No announcement yet.
X
-
Some are only in "oldValues", some are in both "values" and "oldValues" and some are in neither. I'm also seeing ERRORs like this when calling saveData on the ValuesManager. The field in the example HOCR is on the form and does have a value (set in the initial values map) and that value does actually get sent to the server on the add request. But still the error shows up.
Code:17:10:07.575 [ERROR] [ipgui] 17:10:07.574:MUP2:WARN:ValuesManager:isc_ValuesManager_0:Member Form: [DynamicForm ID:isc_PoHeaderCanvas$16_3] has explicitly specified value for field[s] 'HOCR', but has no item associated with this fieldName. Ignoring this value. Values may be set for fields with no associated form item directly on the valuesManager via valuesManager.setValues(), but not on member forms. See ValuesManager documentation for more info.
Comment
-
I'm afraid I'm mixing two unrelated problems together. Back to the original issue with oldValues on an add request. One thing to note is that when I use ValuesManager.saveData() I'm passing a DSRequest where I have setOperationId() to a custom value I need server side. See this issue for why.
The request I receive on the server is correctly configured as type:"add" and my custom ID shows up as the "operation", but the values are mixed between values and oldValues, with some fields showing up in both.
Code:=== 2010-08-21 15:31:16,667 [0-18] DEBUG RPCManager - Request #1 (DSRequest) payload: { values:{ HBLK:"JFTEST", HVEN:521, HODI:new Date(1282366800000), HSDI:new Date(1282366800000), HADI:new Date(1282366800000), HCDI:new Date(1282366800000), HFPH:null, HCUR:null, HVIA:null, HEADR:"AYING@ISLANDPACIFIC.COM", HEML:true, HPRT:true, HFAX:false, HEDI:false, HOP2:false, HPTK:false, HTRM:null, HTCD:null, HFTC:null, HCMD:null, HTC1:null, HTC2:null, HTC3:null, HTC4:null, HBC1:null, HBC2:null, HBC3:null, HFNM:"ANDREW'S VENDOR", HFA1:null, HFA2:null, HFCT:null, HFST:null, HFZP:null, HFCN:null, HFOB:null, HTI1:null, HTI2:null, HTI3:null, HTI4:null, HTI5:null, HEXP:false, HPED:false, HCRT:1, "H##3":"TEMP1", HSTR:1, HDPT:1 }, operationConfig:{ dataSource:"PoHeader", operationType:"add" }, componentId:"isc_ValuesManager_0", appID:"builtinApplication", operation:"member(F002)", oldValues:{ HUSR:"JF", "HUA#":false, HRNO:0, HAEX:true, HBYR:"AY", HFGP:2, HNU1:"JFISHER", HDRP:"N", HPSP:"N", OrderType:"B", HODI:null, HSDI:null, HADI:null, HCDI:null, HCUT:"H", HLCI:null, HLCE:null, HPRF:"L", HOCR:"O" }, criteria:{ } }
Comment
-
I've eliminated the error about "form explicitly specified value for field[s], but has no item associated with this fieldName." I had tried using defaultValue for those fields in the ds.xml and removing that removed the error. I've now confirmed that the fields which show up in oldValues are the ones that are in the Map passed to ValuesManager.editNewRecord(initialValuesMap).
Here is a simple test case showing the problem, starting with the datasource.
Code:<DataSource ID="IPPURUN" dataFormat="iscServer" serverType="sql" dbName="as400" sparseUpdates="true" tableName="IPPURUN" serverConstructor="com.islandpacific.gui.server.customDataSource.IpDataSource"> <fields> <field name="PUCD" title="Code" type="text" length="2" required="true" primaryKey="true"/> <field name="PUVL" title="Value" type="integer" length="5" required="true"> <validators> <validator type="integerRange" min="1" max="99999" errorMessage="Please enter a positive number between 1 and 99999" /> </validators> </field> <field name="PUDS" title="Descriptor" type="text" length="10" required="true"/> </fields> </DataSource>
Code:public class PoHeaderCanvasTest extends Canvas { // Constructor public PoHeaderCanvasTest() { ValuesManager vm = new ValuesManager(); vm.setDataSource(DataSource.get("IPPURUN")); DynamicForm myForm = new DynamicForm(); myForm.setDataSource(DataSource.get("IPPURUN")); myForm.setValuesManager(vm); myForm.setFields(new TextItem("PUCD"), new IntegerItem("PUVL"), new TextItem("PUDS"), new SubmitItem("Submit")); Map initMap = new HashMap(); initMap.put("PUDS", "testing"); vm.editNewRecord(initMap); this.addChild(myForm); } }
Code:=== 2010-08-22 11:16:14,800 [l0-4] DEBUG RPCManager - Request #1 (DSRequest) payload: { values:{ PUCD:"xx", PUVL:5 }, operationConfig:{ dataSource:"IPPURUN", operationType:"add" }, componentId:"isc_ValuesManager_0", appID:"builtinApplication", operation:"IPPURUN_add", oldValues:{ PUDS:"testing" }, criteria:{ } }
The same thing happens without using the ValuesManager. The only difference there is that in that case the initial value "testing" disappears from the form after clicking submit. When I use the ValuesManager it stays on the form but in both cases it is flagged with the error saying it is required.
Comment
-
I've tried the 8/23 nightly and I'm seeing many more fields show up in the values list, but still not all of them consistently. It seems like the only ones that are not always being included in the values list are HiddenItems that have their values set by code.
For example, I have a HiddenItem for a boolean field. The value for that field is switched between true and false by clicking on another TextItem's FormItemIcon. It's initial value is false. If I click the icon to change it to true and click submit the true value does show up correctly in values(). That first submit results in a validation error. So I click the icon a second time to change the boolean field back to false and click submit again. On the second submit the correct "false" value shows up in oldValues() and there is no value for that field in values().
There is another HiddenItem whose initial value is included in the Map passed to ValuesManager.editNewRecord(initialValuesMap) and never changed. That value does not show up in values() in either the first or second (after the validation error) "add" request.
Comment
-
Hi Jay
We're not reproducing this one.
Here's my test case:
Code:public void onModuleLoad() { DataSource testDS = new DataSource(); testDS.setDataFormat(DSDataFormat.ISCSERVER); testDS.setSparseUpdates(true); testDS.setFields( new DataSourceField("PUCD", FieldType.TEXT) {{ setPrimaryKey(true); }}, new DataSourceField("PUVL", FieldType.TEXT), new DataSourceField("FOO", FieldType.TEXT), new DataSourceField("FOO2", FieldType.BOOLEAN) ); ValuesManager vm = new ValuesManager(); vm.setDataSource(testDS); final DynamicForm myForm = new DynamicForm(); myForm.setDataSource(testDS); myForm.setValuesManager(vm); myForm.setFields(new TextItem("PUCD"), new TextItem("PUVL"), new HiddenItem("FOO"), new HiddenItem("FOO2"), new SubmitItem("Submit")); Map initMap = new HashMap(); initMap.put("PUVL", "testing"); initMap.put("FOO", "test2"); initMap.put("FOO2", false); vm.editNewRecord(initMap); Button setFoo2 = new Button ("click to set hidden field val"); setFoo2.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // set foo 2 programmatically myForm.setValue("FOO2",true); } }); setFoo2.setLeft(300); setFoo2.draw(); myForm.draw(); }
The code above has a hidden item "FOO2", which is initially set to false, but has a button to set to true.
If you hit submit without clicking the button to set the foo2 field value, the submitted request has a values object like this:
Code:"data":{ "values":{ "FOO2":false, "PUVL":"testing", "FOO":"test2" }, ...
After hitting the button to modify FOO2, hitting submit gives me a request with the FOO2 value updated in the values block:
Code:"data":{ "values":{ "FOO2":true, "PUVL":"testing", "FOO":"test2" }, ...
See if you can modify the above code to reproduce your problem and show us what's special about your form so we can figure this out!
Thanks
Isomorphic Software
Comment
Comment