Hi Isomorphic,
I have the following use case: Three boolean fields, exactly one must be set to true. Fields are defined as follows:
Each field has this (definitely too complicated) validator:
On update velocity is called. But for some reason (I don't know if one (=you in your EE calls to velocity?) can configure it) velocity does not short-circuit-evaluate the expressions. At first, ALL the fetchById()-methods are called and the $dataSource.fetchById($record.ID).fieldX) is replaced with the result from the DS-fetch, then the result is given to the Parser.
So within very short time, 9 or 18 DS-fetches are issued, sometimes resulting in this error displayed in the client:
The error is OK for me, as this is probably bad design on my behalf, but I thought you might want to know this can happen.
I think I'll rewrite it using http://www.smartclient.com/smartgwte...l#serverObject as I suppose this is the correct way of doing it.
Best regards,
Blama
I have the following use case: Three boolean fields, exactly one must be set to true. Fields are defined as follows:
Code:
<field name="field1" length="1" type="boolean" sqlStorageStrategy="singleChar" sqlTrueValue="J" sqlFalseValue="N" required="true">...</field>
Code:
<validators> <validator type="serverCustom" errorMessage="Set exactly one field of 1/2/3!"> <serverCondition><![CDATA[ ( (("$!record.field1" == "" && $dataSource.fetchById($record.ID).field1) || ("$!record.field1" != "" && "$!record.field1" == "true")) && !(("$!record.field2" == "" && $dataSource.fetchById($record.ID).field2) || ("$!record.field2" != "" && "$!record.field2" == "true")) && !(("$!record.field3" == "" && $dataSource.fetchById($record.ID).field3) || ("$!record.field3" != "" && "$!record.field3" == "true")) ) || ( !(("$!record.field1" == "" && $dataSource.fetchById($record.ID).field1) || ("$!record.field1" != "" && "$!record.field1" == "true")) && (("$!record.field2" == "" && $dataSource.fetchById($record.ID).field2) || ("$!record.field2" != "" && "$!record.field2" == "true")) && !(("$!record.field3" == "" && $dataSource.fetchById($record.ID).field3) || ("$!record.field3" != "" && "$!record.field3" == "true")) ) || ( !(("$!record.field1" == "" && $dataSource.fetchById($record.ID).field1) || ("$!record.field1" != "" && "$!record.field1" == "true")) && !(("$!record.field2" == "" && $dataSource.fetchById($record.ID).field2) || ("$!record.field2" != "" && "$!record.field2" == "true")) && (("$!record.field3" == "" && $dataSource.fetchById($record.ID).field3) || ("$!record.field3" != "" && "$!record.field3" == "true")) ) ]]></serverCondition> </validator> </validators>
So within very short time, 9 or 18 DS-fetches are issued, sometimes resulting in this error displayed in the client:
Code:
Invocation of method 'fetchById' in class com.isomorphic.sql.SQLDataSource threw exception java.sql.SQLException: Listener refused the connection with the following error: ORA-12519, TNS:no appropriate service handler found The Connection descriptor used by the client was: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(PORT=1521)(HOST=localhost))(CONNECT_DATA=(SID=xe))) at CustomValidator[line 10, column 84]
I think I'll rewrite it using http://www.smartclient.com/smartgwte...l#serverObject as I suppose this is the correct way of doing it.
Best regards,
Blama
Comment