wcx6298 / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

Datasource Length Validation Fails on Text Items #759

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Before your post : If you are not 100% sure that you've found an issue,
please post on the SmartGWT forums first. Upon confirmation you'll be
advised to create an issue.

    I am a 100% sure, I have posted this on the forum (http://forums.smartclient.com/showthread.php?t=32346&highlight=fanie1980) and received no assistance.

All issues require a minimal standalone test case with
an onModuleLoad() to be attached. You can modify an existing showcase
example if desired. Issues created without a standalone test case are
subject to being rejected after 7 days if no test case is present.

[CODE]

import com.smartgwt.client.data.AdvancedCriteria;
import com.smartgwt.client.data.Criterion;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.RequestTransformer;
import com.smartgwt.client.data.ResponseTransformer;
import com.smartgwt.client.types.OperatorId;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.layout.VLayout;

public class DataSourceValidation implements EntryPoint {  

    public void onModuleLoad() {  

        Validation validation = new Validation();
    }  

    class Validation extends VLayout {

        private DataSource ds;
        private DynamicForm form = new DynamicForm();

        public Validation(){
            super();
            setWidth100();
            setHeight100();
            setPadding(50);
            setBackgroundColor("#f5f5f5");
            setMembersMargin(20);
        }

        @Override
        protected void onInit(){
            createDataSource();
            createGrid();
            createForm();
        }

        private void createForm(){
            TextAreaItem crud = new TextAreaItem("Memo", "Memo");
            ButtonItem save = new ButtonItem("Save", "Save");
            save.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    form.validate();

                    if (!form.hasErrors())
                        form.saveData();
                }
            });

            form.setDataSource(ds);
            form.setBackgroundColor("#FFFFFF");
            form.setFields(crud, save);
            addMember(form);
        }

        private void createGrid(){
            ListGridTextAreaField Memo = new ListGridTextAreaField("Memo", "Memo", 3000);

            ListGrid grid = new ListGrid();
            grid.setCanEdit(true);
            grid.setDataSource(ds);
            grid.setAutoFetchData(true);
            grid.setFields(Memo);
            grid.setCriteria(new AdvancedCriteria(OperatorId.AND, new Criterion[] { new Criterion("IDMEMO", OperatorId.EQUALS, 46) }));
            grid.setWrapCells(true);  
            grid.setFixedRecordHeights(false);
            addMember(grid);        
        }

        private void createDataSource(){
            ds = DataSource.get("Memo", new RequestTransformer() {

                @Override
                protected Object transformRequest(DSRequest dsRequest) {
                    return dsRequest.getData();
                }
            }, new ResponseTransformer() {

                @Override
                protected void transformResponse(DSResponse response, DSRequest request,Object data) {
                    if ((response.getData() != null) && (response.getData().length > 0))
                        form.editRecord(response.getData()[0]);
                }
            }); 
        }

         class ListGridTextAreaField extends ListGridField {

                /**
                 * 
                 * @param name
                 * @param title
                 * @param length - Specifies the maximum number of characters allowed in the text area item
                 */
                public ListGridTextAreaField(String name, String title, int length) {
                    super(name, title);
                    setWidth("*");

                    LengthRangeValidator validator = new LengthRangeValidator(); // Created this validator to try and explicitly set the validation rules, only works for a while (than a new validation rule of max length 60 overrides all other rules)
                    validator.setMax(length);

                    TextAreaItem crud = new TextAreaItem(name, title);
                    //crud.setValidators(validator); // Only works for a while (than a new validation rule of max length 60 overrides all other rules)
                    crud.setEnforceLength(true);
                    setEditorProperties(crud);

                    //setValidators(validator); // Only works for a while (than a new validation rule of max length 60 overrides all other rules)
                }
            }
    }

}  
[/CODE]

Please test any issue against the latest available code (from
smartclient.com/builds) before filing, and indicate any release versions
that you know are also affected.

What steps will reproduce the problem?
1. I deploy to two tomcat instances (Apache Load Balancing). At first it works 
perfectly but after a few days all datasource text validation fails 
(ListGridField, TextItem, RichTextItem, TextAreaItem). I can redeploy my 
application with no code changes, it works perfectly again for a few days. I 
can recreate it this way every time.
2. I cannot create it on my development environment, so it makes it very hard 
to find the problem locally

What is the expected output? What do you see instead?
Text validation is expected to use the datasource to enforce length validation 
on types of "text", it does in the beggining but after two or three days it 
enforces it's own length validation rules.

The datasource defines the length as 1000, after a few days the validation rule 
on the same item is overridden to a different value. When validation is them 
checked I get the following error:

FireFox:
Must be no more than 60 characters

Chrome:
Must be no more than 60 characters
Must be no more than 1000 characters

My datasource loader loads:

if (window.isc == undefined || window.isc.DataSource == undefined){  
alert("Can't load DataSources - SmartClient runtime not loaded");}

...

isc.DataSource.create({
    allowAdvancedCriteria:true,
    serverType:"sql",
    generatedBy:"v8.2p_2012-09-17/EVAL Deployment 2012-09-17",
    tableCode:"4bfc8e0b4cc96be5e84e5b74f7658456",
    ID:"Memo",
    logActionHistory:"true",
    dataSourceVersion:1,
    fields:[
        {
            hidden:true,
            columnCode:"b338f6d675a1ce753b35867f41d784d9",
            primaryKey:true,
            name:"IDMEMO",
            type:"sequence"
        },
        {
            columnCode:"d504a5ea65b088497578bdd812714d51",
            name:"Memo",
            length:1000,
            type:"text",
            required:true
        }
    ]
})

...

What version of the product are you using? On what operating system?
SmartClient Version: v10.0p_2015-02-28/PowerEdition Deployment (built 
2015-02-28)
GWT 2.5.1

What browser(s) does this happen in?  Are there any browsers where the
issue does not occur?
Chrome: Version 32.0.1700.107
FF: 26.0
Seems to occur on all

Please provide any additional information below.
At this stage there is no integrity on my system, without any validation we are 
basically running blind. Customers are really getting anoid and have already 
cancelled because of this.

We have tried everything, we have played around with adding implicit validation 
rules, removing validation rules, implemented a cache filter, ensured our 
character encoding is correct. However, after a few days random validation 
rules are applied to the Text Items, we do not know who and how and by what 
they are set, but it clearly ignores the validation defined in the datasource.

We thought that it had something to do with the loading of the datasources but 
checking the datasource loader confirms that they are correct. We also thought 
that is could have had something to do with the load balancing but we have been 
unable to confirm this.

Here is the client logs, no server logs are recorded, this validation occurs in 
the browser first, so no requests are sent to the server.

Server Side Problem
No server-side problem as it does not get past validation, so no request is 
sent to the server

Stack Trace:
[CODE]
09:41:13.112:MDN6:INFO:EventHandler:Target Canvas for event 'mousedown': 
[ImgTab ID:isc_Tab_35]
09:41:13.222:MUP0:INFO:EventHandler:Target Canvas for event 'mouseup': [ImgTab 
ID:isc_Tab_35]
09:41:13.322:MUP0:INFO:ResultSet:isc_CrudListGrid_17:Creating new isc.ResultSet 
for operation 'DxMemo_fetch' with filterValues: {
"operator":"and", 
"criteria":[
{
"fieldName":"IDGROUP", 
"operator":"equals", 
"value":"207"
}, 
{
"fieldName":"IDEMPLOYEE", 
"operator":"equals", 
"value":"502"
}, 
{
"fieldName":"IDRESERVATION", 
"operator":"equals", 
"value":1034
}
], 
"_constructor":"AdvancedCriteria"
}
09:41:13.323:MUP0:INFO:ResultSet:isc_ResultSet_58 (dataSource: DxMemo, created 
by: isc_CrudListGrid_17):setCriteria: filter criteria changed, invalidating 
cache
09:41:13.323:MUP0:INFO:ResultSet:isc_ResultSet_58 (dataSource: DxMemo, created 
by: isc_CrudListGrid_17):Invalidating cache
09:41:13.324:MUP0:INFO:ResultSet:isc_ResultSet_58 (dataSource: DxMemo, created 
by: isc_CrudListGrid_17):getRange(0, 1) will fetch from 0 to 75
09:41:13.325:MUP0:INFO:ResultSet:isc_ResultSet_58 (dataSource: DxMemo, created 
by: isc_CrudListGrid_17):fetching rows 0,75 from server
09:41:13.345:MUP0:INFO:RPCManager:sendQueue[203]: 1 RPCRequest(s); transport: 
xmlHttpRequest; target: https://apps.hti-systems.com/nova/no...2-21&isc_xhr=1
09:41:13.446:MUP0[E1]:INFO:RPCManager:sendQueue[204]: 1 RPCRequest(s); 
transport: xmlHttpRequest; target: 
https://apps.hti-systems.com/nova/no...2-21&isc_xhr=1
09:41:13.584:XRP4:INFO:RPCManager:transaction 203 arrived after 229ms
09:41:13.589:XRP4:INFO:RPCManager:rpcResponse(DxMemo_fetch)[fetch]: result: 1 
records[status=0]
09:41:13.590:XRP4:INFO:xmlBinding:DxMemo:dsResponse is: {operationId: 
"DxMemo_fetch",
clientContext: undef,
internalClientContext: Obj,
context: Obj,
transactionNum: 203,
httpResponseCode: 200,
httpResponseText: "//isc_RPCResponseStart-->[{affectedRows:..."[416],
xmlHttpRequest: [object XMLHttpRequest],
transport: "xmlHttpRequest",
status: 0,
clientOnly: undef,
httpHeaders: Obj,
isStructured: true,
callbackArgs: null,
results: Obj,
affectedRows: 0,
data: Array[1],
endRow: 1,
invalidateCache: false,
isDSResponse: true,
operationType: "fetch",
queueStatus: 0,
serverTime: Date(02/19/2015),
startRow: 0,
totalRows: 1}
09:41:13.591:XRP4:INFO:ResultSet:isc_ResultSet_58 (dataSource: DxMemo, created 
by: isc_CrudListGrid_17):Received 1 records from server
09:41:13.591:XRP4:INFO:ResultSet:isc_ResultSet_58 (dataSource: DxMemo, created 
by: isc_CrudListGrid_17):Fetch request returned range 0,1 differs from 
requested range 0,75. Assuming client/server batch size mismatch and clearing 
loading markers greater than 1
09:41:13.591:XRP4:INFO:ResultSet:isc_ResultSet_58 (dataSource: DxMemo, created 
by: isc_CrudListGrid_17):cached 1 rows, from 0 to 1 (1 total rows, 1 cached)
09:41:13.592:XRP4:INFO:ResultSet:isc_ResultSet_58 (dataSource: DxMemo, created 
by: isc_CrudListGrid_17):Cache for current criteria complete
09:41:13.642:XRP6:INFO:RPCManager:transaction 204 arrived after 189ms
09:41:13.646:XRP6:INFO:RPCManager:rpcResponse(custom)[rpc]: result: 1 
records[status=0]
09:41:13.647:XRP6:INFO:xmlBinding:DxItinerary:dsResponse is: {operationId: 
"custom",
clientContext: undef,
internalClientContext: Obj,
context: Obj,
transactionNum: 204,
httpResponseCode: 200,
httpResponseText: "//isc_RPCResponseStart-->[{affectedRows:..."[431],
xmlHttpRequest: [object XMLHttpRequest],
transport: "xmlHttpRequest",
status: 0,
clientOnly: undef,
httpHeaders: Obj,
isStructured: true,
callbackArgs: null,
results: Obj,
affectedRows: 0,
data: Array[1],
endRow: 1,
invalidateCache: false,
isDSResponse: true,
operationType: "fetch",
queueStatus: 0,
serverTime: Date(02/19/2015),
startRow: 0,
totalRows: 1}
09:41:13.649:XRP6:INFO:ResultSet:isc_ResultSet_59 (dataSource: DxItinerary, 
created by: undefined):creating auto-operation for operationType: fetch
09:41:13.649:XRP6:INFO:ResultSet:isc_ResultSet_59 (dataSource: DxItinerary, 
created by: undefined):setCriteria: filter criteria changed, invalidating cache
09:41:13.649:XRP6:INFO:ResultSet:isc_ResultSet_59 (dataSource: DxItinerary, 
created by: undefined):Invalidating cache
09:41:37.939:MDN5:INFO:EventHandler:Target Canvas for event 'mousedown': 
[ToolStripButton ID:isc_ToolStripButton_1]
09:41:38.041:MUP0:INFO:EventHandler:Target Canvas for event 'mouseup': 
[ToolStripButton ID:isc_ToolStripButton_1]
09:41:38.065:MUP0:INFO:gridEdit:isc_CrudListGrid_17:Starting editing at row 1, 
colNum 0
09:41:38.076:MUP0:INFO:gridEdit:isc_CrudListGrid_17_body:redraw with editors 
showing, editForm.hasFocus: undefined
09:41:38.740:MDN7:INFO:EventHandler:Target Canvas for event 'mousedown': 
[DynamicForm ID:isc_DynamicForm_11]
09:41:38.866:MUP8:INFO:EventHandler:Target Canvas for event 'mouseup': 
[DynamicForm ID:isc_DynamicForm_11]
09:41:38.875:MUP8:INFO:EventHandler:isc_DynamicForm_11:Bubbling handleClick 
event for isc_TextAreaItem_0
09:41:38.876:MUP8:INFO:EventHandler:isc_DynamicForm_11:Bubbling handleCellClick 
event for isc_TextAreaItem_0
09:41:39.112:KDN0:INFO:EventHandler:keyDown event with Canvas target: 
[TextAreaItem ID:isc_TextAreaItem_0 name:Memo], native target: 
[TEXTAREAElement]{name:Memo}
09:41:39.218:INP1:INFO:RPCManager:sendQueue called with no current queue, 
ignoring
09:41:41.084:MDN4:INFO:EventHandler:Target Canvas for event 'mousedown': 
[GridBody ID:isc_CrudListGrid_17_body]
09:41:41.090:MDN4:INFO:gridEdit:isc_CrudListGrid_17:cellEditEnd: ending 
editing, completion event: click_outside
09:41:41.093:MDN4:WARN:ResultSet:isc_ResultSet_58 (dataSource: DxMemo, created 
by: isc_CrudListGrid_17):getRange(1, 2): start beyond end of rows, returning 
empty list
09:41:41.097:MDN4:INFO:gridEdit:isc_CrudListGrid_17:validateFieldValue, 
newValue: "
Now you have static variables and class variables (class variables only exists 
while you have an object of type horse, once you destroy the horse object, the 
variables dissapears with it). Static variables are created the first time you 
mention a Horse and does not dissapear if the object is destroyed. Lets say you 
have a static varable of type integer to count how many times the horse has 
eaten and a class variable doing the same:

private int howManyTimesEaten;
private static int staticHowManyTimesEaten;

Every time you call the horse.eat() method both gets incremented by one:

Horse horse = new Horse();
horse.eat(); //howManyTimesEaten = 1, staticHowManyTimesEaten = 1
horse.eat(); //howManyTimesEaten = 2, staticHowManyTimesEaten = 2
horse = null;
Horse donkey = new Horse();
donkey.eat(); //howManyTimesEaten = 1, staticHowManyTimesEaten = 3", passed 
validation: false, resultingValue: null
09:41:41.098:MDN4:INFO:gridEdit:isc_CrudListGrid_17:validateFieldValue, 
newValue: undef, passed validation: true, resultingValue: null
09:41:41.098:MDN4:INFO:gridEdit:isc_CrudListGrid_17:validateFieldValue, 
newValue: undef, passed validation: true, resultingValue: null
09:41:41.099:MDN4:INFO:gridEdit:isc_CrudListGrid_17:validateFieldValue, 
newValue: undef, passed validation: true, resultingValue: null
09:41:41.100:MDN4:INFO:gridEdit:isc_CrudListGrid_17:validateFieldValue, 
newValue: undef, passed validation: true, resultingValue: null
09:41:41.101:MDN4:INFO:gridEdit:isc_CrudListGrid_17:validateFieldValue, 
newValue: undef, passed validation: true, resultingValue: null
09:41:41.102:MDN4:INFO:gridEdit:isc_CrudListGrid_17:validateFieldValue, 
newValue: undef, passed validation: true, resultingValue: null
09:41:41.103:MDN4:INFO:RPCManager:sendQueue called with no current queue, 
ignoring
09:41:41.211:MUP2:INFO:EventHandler:Target Canvas for event 'mouseup': 
[GridBody ID:isc_CrudListGrid_17_body]
[/CODE]

Original issue reported on code.google.com by fa...@hti-systems.co.za on 4 Mar 2015 at 6:53

Attachments:

GoogleCodeExporter commented 9 years ago
My Datasource:

[CODE]
<!-- Auto-generated from database table DxMemo -->

<DataSource 
    schema="dbo"
    dbName="Nova"
    tableName="DxMemo"
    ID="Memo"
    dataSourceVersion="1"
    generatedBy="v8.2p_2012-09-17/EVAL Deployment 2012-09-17"
    serverType="sql"
    requiresAuthentication="true"
    logActionHistory="true"
>
    <fields>
        <field primaryKey="true" name="IDMEMO" type="sequence" hidden="true"></field>
        <field name="Memo" length="1000" type="text" required="true"></field>
    </fields>
</DataSource>
[/CODE]

Original comment by fa...@hti-systems.co.za on 4 Mar 2015 at 6:55

GoogleCodeExporter commented 9 years ago
You've posted a lot of information, which is generally good, but you have not 
posted anything that suggests a framework bug.  The fact that the problem 
suddenly starts happening after multiple days of deployment strongly suggests a 
deployment issue.  If you are loading the same SmartGWT client-side resources 
there is no way for them to suddenly change behavior for newly loaded pages, so 
you should look at how your server's responses differ when the problem begins, 
especially the DataSourceLoader responses.  You may ultimately discover an 
issue such as your load balancing system serving stale or corrupted versions of 
files.

Aside from the above, also please realize you are the only person reporting 
this issue out of many, many users with SmartGWT-based applications 
continuously available to millions of users - this makes it even less likely to 
be a framework bug.

Until you've isolated a reproducible bug in SmartGWT (and you are not close to 
this) you should continue to discuss this on the forums.  If you would like 
some assistance in troubleshooting from Isomorphic Support, you can purchase a 
support plan starting here:

   http://www.smartclient.com/services/index.jsp#support

Original comment by smartgwt...@gmail.com on 4 Mar 2015 at 7:28