Quantcast
Channel: SmartClient Forums
Viewing all 4756 articles
Browse latest View live

DataSource operationBindings not respecting responseDataSchema with JSON results

$
0
0
Hi,

I have a DataSource that returns JSON objects where the request fields are not the same as the response schema. OperationBindings.responseDataSchema exists for my purpose but does not appear to work for JSON result sets.

I traced the problem to the validateJSONRecord() method always calling 'this.getFieldNames()' on the requesting DataSource and not considering whether responseDataSchema has been set.

Please find below an enhancement that means responseDataSchema is respected with JSON results. Please feel welcome to incorporate the changes into the mainline of your codebase.


_handleJSONReply in ISC_DataBinding.js was modified with the call to the recordsFromObjects method being replaced as follows:
Code:

var responseDataSchema = this.getOperationBinding(dsRequest).responseDataSchema;
data = this.recordsFromObjects(data, responseDataSchema);

The following functions were replaced in ISC_DataBinding.js:
Code:

    recordsFromObjects : function (data, schema) {

        // normalize to Array and apply schema
        if (!isc.isAn.Array(data)) data = [data];

        // skipping validation means eg date values specified as Strings won't become Dates,
        // valueXPath and dropExtraFields won't apply, etc.  But for large data volumes where
        // these features aren't required, this is faster.  Undocumented for now.
        if (this.skipJSONValidation) return data;

        for (var i = 0; i < data.length; i++) {
            data[i] = this.validateJSONRecord(data[i], null, schema);
        }
        return data;
    },

    validateJSONRecord : function (record, disableXPath, schema) {
        // If no record was given, return null.
        if (!record) {
            return null;
        }
        if ( schema == null ) {
            schema = this;
        }
       
        var fieldNames = schema.getFieldNames(),
            result = {};
        for (var i = 0; i < fieldNames.length; i++) {
            var fieldName = fieldNames[i],
                field = schema.getField(fieldName),
                fieldValue;

            if (field.valueXPath && !disableXPath) {
                fieldValue = isc.xml.selectObjects(record, field.valueXPath, true);
            } else {
                fieldValue = record[fieldName];
            }

            if (field.getFieldValue) {
                if (!isc.isA.Function(field.getFieldValue)) {
                    isc.Func.replaceWithMethod(field, "getFieldValue",
                                                    "record,value,field,fieldName");
                }
                fieldValue = field.getFieldValue(record, fieldValue, field, fieldName);
            }

            var undef;
            if (fieldValue !== undef) {
                // validation fieldValue, if it is complex type
                var fieldDS = isc.DS.get(field.type);
                if (fieldDS && !(fieldDS.skipJSONValidation)) {
                    if (!(isc.isAn.Array(fieldValue))) {
                        fieldValue = fieldDS.validateJSONRecord(fieldValue);
                    } else {
                        for (var j = 0; j < fieldValue.length; j++) {
                            fieldValue[j] = fieldDS.validateJSONRecord(fieldValue[j]);
                        }
                    }
                }

                //this.logWarn("validating value: " + fieldValue +
                //            " of field: " + this.echo(field));
                result[fieldName] = schema.validateFieldValue(field, fieldValue);
            }
        }

        if (schema.dropExtraFields) return result;


        for (var i = 0; i < fieldNames.length; i++) {
            var fieldName = fieldNames[i];
            record[fieldName] = result[fieldName]
        }
        return record;
    }


Img from DrawPane

$
0
0
Hi,

I am trying to get an Img from my DrawPane but I am getting a blank image. Can you please tell me what I am doing wrong.

I am using SmartGwt 5.0p Pro. I tried this on IE 11 and ff.

Code:

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.drawing.DrawPane;
import com.smartgwt.client.widgets.drawing.DrawRect;

public class DrawPaneTest implements EntryPoint {

        @Override
        public void onModuleLoad() {
                DrawPane dp = new DrawPane();
                dp.setWidth(100);
                dp.setHeight(100);
                dp.setTop(100);
                dp.setLeft(100);
                dp.setBorder("1px solid black");
                dp.draw();
               
                DrawRect dr = new DrawRect();
                dr.setWidth(30);
                dr.setHeight(30);
                dr.setTop(10);
                dr.setLeft(10);
                dr.setFillColor("red");
                dr.setDrawPane(dp);
                dr.draw();
               
                Img i = new Img();
                i.setID("myimg");
                i.setWidth(100);
                i.setHeight(100);
                i.setTop(100);
                i.setLeft(300);
                i.setSrc(dp.getDataURL());
                i.draw();
        }
}

The page source shows this for the Img
Code:

<div class="normal" id="isc_2" style="left: 300px; top: 100px; width: 100px; height: 100px; overflow: visible; position: absolute; z-index: 200036;" onscroll="return myimg.$lh()" eventproxy="myimg">
    <div id="isc_1" style="width: 100%; vertical-align: top; display: inline-block; visibility: inherit; position: relative; z-index: 200036; cursor: default; box-sizing: border-box;" eventproxy="myimg">
        <img name="isc_1main" width="100" height="100" align="TEXTTOP" draggable="true" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGIAAABiCAYAAACrpQYOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAA8SURBVHhe7cExAQAAAMKg9U9tCU8gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC5qlnIAAacfqhgAAAAASUVORK5CYII=" border="0" suppress="TRUE">
    </div>
</div>

Thanks.

Sorting by an "undefined" property bug

$
0
0
Hello Isomorphic,

I think I found a bug when you group a ListGrid, because after the grouping is done a SortSpecifier with an "undefined" property is set on the resulting tree. And because SortSpecifiers are also propagated to the 'originalData' when invalidating the cache (please see DataBoundComponent.js#invalidateCache), such an 'undefined' sortBy property is also sent as a part of the fetch request.

Steps to reproduce:

1) Please go to your Showcase and choose "Live Grid" (http://www.smartclient.com/#fetchOperationFS)

2) Replace the code in the editor with this one:

Code:

isc.IButton.create({
  ID: "groupByBtn",
  autoDraw: false,
  width: 300,
  title: "1) Click here to group by category",
  click: function () { isc.say("After the grouping is done, the tree is gonna have a sort specifier set with an 'undefined' property.", function() { dsListGrid.groupBy("category"); }); }
});
isc.IButton.create({
  ID: "invalidateBtn",
  autoDraw: false,
  width: 300,
  title: "2) Once grouped click here to invalidate the cache",
  click: function () { isc.say("dsListGrid.data.getSort()[0].property: " + (dsListGrid.data.getSort()[0].property) + "<br/><br/>Please consult a network log to see &lt;sortBy xsi:type='xsd:List'&gt;&lt;elem&gt;undefined&lt;/elem&gt;&lt;/sortBy&gt; is sent", function() { dsListGrid.invalidateCache(); }); }
});

isc.ListGrid.create({
    autoDraw: false,
    ID:"dsListGrid",
    minFieldWidth:80,
    autoFetchData: true,
    dataSource: "supplyItem",
    groupByMaxRecords: Number.MAX_VALUE
});

isc.VLayout.create({
    ID: "layout",
    width: "100%",
    height: "100%",
    membersMargin: 10,
    members: [
        groupByBtn, invalidateBtn, dsListGrid
    ]
});

3) Click on the first button

4) Click on the second button

My suggestion (Version v10.0p_2014-12-10 (2014-12-10)):

Because Tree.js#getChildren calls sortByProperty()

Code:

...
getChildren : function (parentNode, displayNodeType, normalizer, sortDirection, criteria,
                        context, returnNulls, treatEmptyFoldersAsLeaves, dontUseNormalizer) {
   

    // If separateFolders is true, we need to have an openNormalizer so we can sort/separate
    // leaves and folders
    // This will not actually mark the tree as sorted by any property since we're not setting up
    // a sortProp.
   
    if (!dontUseNormalizer &&
        normalizer == null && this._openNormalizer == null && this.separateFolders)
    {
       
        if (this._sortSpecifiers != null) this.setSort(this._sortSpecifiers);
        else this.sortByProperty();
       
        normalizer = this._openNormalizer;
    }
...

and because sortByProperty() is defined as follows

Code:

sortByProperty : function (property, direction, normalizer, context) {
    if (!property && this.separateFolders == false) {
        // if we were called without a sort-property and this.sortProp is set, use it...
        if (this.sortProp) property = this.sortProp;
        else property = this.titleProperty;
    }
    if (!direction) direction = this.sortDirection;
    this.setSort([{
        property: property,
        direction: (isc.isA.String(direction) ? direction :
            (direction == true) ? "ascending" : "descending"),
        normalizer: normalizer,
        context: context
    }]);
}

I suggest making the setSort(...) call conditional:

Code:

sortByProperty : function (property, direction, normalizer, context) {
    if (!property && this.separateFolders == false) {
        // if we were called without a sort-property and this.sortProp is set, use it...
        if (this.sortProp) property = this.sortProp;
        else property = this.titleProperty;
    }
    if (!direction) direction = this.sortDirection;
    if(property) {
      this.setSort([{
          property: property,
          direction: (isc.isA.String(direction) ? direction :
              (direction == true) ? "ascending" : "descending"),
          normalizer: normalizer,
          context: context
      }]);
    }
}

Thank you and Best Regards

Dusan Kaloc

FormItem reset after a certain moment

$
0
0
Hi
When I edit a field (for example textItem) without saving and I let it for a certain moment the field reset automatically.
I want to know what we call (technically) this time of inactivation of an application?

I'm working with smartgwt3.0,GWT 2.1.0.
Operating system IE9

How to set focus to com.smartgwt.mobile.client.widgets.form.fields.TextItem

$
0
0
Hi Isomorphic

Under smartgwt-mobile-1.0 / chrome 39+

I was persecuted by a easy question recently,
I've tried but can not find out how to set focus to any form items(TextItem) manually;

I would appreciate some help here.

Best Regards,

Style individual CalendarEvents ?

$
0
0
How to style individual CalendarEvents for a data-bound calendar? Similar as the red event here:
http://www.smartclient.com/smartgwt/showcase/#databound_calendar_category

Since I have a data-bound calendar, I don't create the CalendarEvents explicitely. So how to access them to set their style, e.g. with calendar.setEventStyle() ?

I would like to do something like this:
Code:

calendar.fetchData(c, new DSCallback() {

                        @Override
                        public void execute(DSResponse dsResponse, Object data,
                                        DSRequest dsRequest) {
                                for (Record rec : dsResponse.getData()) {
                                        if (rec.getAttributeAsBoolean("condition")) {
                                                // how to do this?
                                                CalendarEvent event = calendar.getEvent(rec);
                                                calendar.setEventStyle(event, "myStyle");
                                        }
                                }
                        }
                });

Using smartgwt 4.1p power.

Calendar button

$
0
0
Where is the "Save event" button in the event dialog here? http://www.smartclient.com/smartgwt/showcase/#custom_editing_calendar_category

Or how to insert it again ?

German translation for am?

$
0
0
Why is "am" and "pm" translated differently in different parts of the calendar? Look at the attachments: in 1.png: am=vormittags, pm=nachmittags. But in 2.png: am=am, pm=pm.

Why not leave am and pm everywhere, which is the correct translation ?

Using 4.1p power.

Attached Images
File Type: png 1.png (4.4 KB)
File Type: png 2.png (11.8 KB)

[SC Bug] autoFitWidths is broken

$
0
0
Sorry, the functionality is ok. It was my mistake into the configuration. Thread can be deleted.

Calendar drag?

$
0
0
In the showcase e.g. http://www.smartclient.com/smartgwt/showcase/#simple_calendar_category you can drag an event by clicking *anywhere* on it and dragging it. In SmartGWT 4.1p power 17.01.15, you can only move the event if you put the mouse *on the event's title* and then dragging it. If you put the mouse in the body of the event, it is not possible to drag (the mouse icon does not change either). Is this a bug with the 4.1p version ?

Reorder indicator together with drop-move event handler

$
0
0
Hi,
What I need is to display some kind of custom indicator while drop-move event, but still have the build-in record reorder indicator active on ListGrid.
The following example shows that if only any drop-move event handler is added to the grid, then reorder indicator is gone.
When drop-move handler (doing nothing) is commented out, then dot-red reorder indicator is back again.

The question is: Is it possible to define custom drop-move event handler together with build-in reorder indicator?

Code:

package pl.com.tech4.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.DOM;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.events.DropMoveEvent;
import com.smartgwt.client.widgets.events.DropMoveHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;

public class MainEntryPoint implements EntryPoint {
 
    public void onModuleLoad() {

        DOM.getElementById("loadingPicture").removeFromParent();
        layout();
        SC.showConsole();
    }
 
    private void layout() {
     
        DataSource ds = new DataSource();
        DataSourceField fieldId = new DataSourceField();
        fieldId.setName("id");
        fieldId.setPrimaryKey(true);
        fieldId.setHidden(true);
        DataSourceTextField fieldCode = new DataSourceTextField();
        fieldCode.setName("code");
        ds.setFields(fieldId, fieldCode);
     
        ListGrid lg = new ListGrid();
        lg.setDataSource(ds);
        ListGridRecord[] records = new ListGridRecord[2];
        records[0] = new ListGridRecord();
        records[0].setAttribute("id", "1");
        records[0].setAttribute("code", "m/s");
        records[1] = new ListGridRecord();
        records[1].setAttribute("id", "2");
        records[1].setAttribute("code", "knots");
        lg.setData(records);
        lg.setCanReorderRecords(true);
     
        lg.addDropMoveHandler(new DropMoveHandler() {

            public void onDropMove(DropMoveEvent event) {
            }
        });

        lg.draw();
    }
}

Thanks,
MichalG

SmartClient Version: v10.0p_2014-12-27/LGPL Development Only (built 2014-12-27)
Firefox 24.8.0 (Gentoo linux)

Attached Images
File Type: png drop-move and reorder.png (2.6 KB)

Questions about scroll bar in ListGrid body

$
0
0
Hi,

We have a question about the scroll bar behavior in ListGrid body.

1. For horizonal scroll bar, if it is in the middle of the listgrid, after re-fetching the data, should it scroll to the left most position of the listgrid? If not, is there any property we can use to achieve this behavior?

2. For vertical scroll bar, if it is in the middle of the listgrid, when "wrapCells"is true and "fixedRecordHeights" is false, after re-fetching the data, it remains in the previous position. However, if these two properties are not set, after re-feteching the data, the scroll bar scrolls to the top of the listgrid. Why does the vertical scroll bar behave differently in these two cases? Is there any way we can do to make the scroll bar always scroll to the top after re-fetching?

This behavior can be reproduced on IE9 and FF 34 with SmartClient Version v8.3p_2014-10-18/PowerEdition.

Please try the following standalone using the "worldDS" datasource in feature explorer.

Steps to reproduce:

1. Click "Fetch All" button.
2. Scroll both horizontal and vertical scroll bar to the middle of the list grid.
3. Click "Invalidate Cache" button, both scroll bars stay in previous positions. (If comment out the "wrapCells" and "fixedRecordHeights" properties, the vertical scroll bar will scroll to the top.)


Code:

isc.ListGrid.create({   
ID: "countryList", 
width:300, height:224,
dataSource: worldDS,       
fields:[     
{name:"countryCode",width:"100"},     
{name:"countryName",width:"100"},     
{name:"capital", width:"100"},     
{name:"continent", width:"100"}], 
 wrapCells: true,   
fixedRecordHeights: false,
autoFetchData:false
 })


  isc.IButton.create({top:240, width:160, 
 title:"Fetch All", 
 click:"countryList.fetchData()"})
 isc.IButton.create({    left:170, top:240, width:160, 
  title:"Invalidate Cache",  click:function() {countryList.invalidateCache();}})

Thanks!

Calendar bug

$
0
0
http://www.smartclient.com/smartgwt/showcase/#databound_calendar_category

Open the day view. Edit the entry. Change again to the Week View --> No entries here ! All entries dissapear!

Calling refresh on another grid after an action on current grid

$
0
0
I currently have firstGrid that has some records, I have set a warning on removal message so a dialog box pops up when I click the delete button. How do I make it so secondGrid refresh when I confirm the delete on firstGrid?
Code:

firstGrid.setWarnOnRemoval(true);
firstGrid.setWarnOnRemovalMessage("Delete?");

Tree.indexOf() and Tree.findIndex() are not working for databounded TreeGrid

$
0
0
Hello,

It appears that neither indexOf() or findIndex() methods work when the Tree is loaded from a DataSource. find() works just fine. The issue was observed using Chrome 39.0.2171.99 and Isomorphic SmartClient/SmartGWT Framework (v10.0p_2014-12-09/Enterprise Deployment 2014-12-09) in both development and compiled modes.

Test case:
1. 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.DataSource;
import com.smartgwt.client.types.TreeModelType;
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.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.VStack;
import com.smartgwt.client.widgets.tree.Tree;
import com.smartgwt.client.widgets.tree.TreeGrid;
import com.smartgwt.client.widgets.tree.TreeGridField;
import com.smartgwt.client.widgets.tree.TreeNode;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class BuiltInDS implements EntryPoint {
    private ListGrid boundList;
   
    /**
    * This is the entry point method.
    */
    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();
            }
        });


        VStack vStack = new VStack();
        vStack.setLeft(175);
        vStack.setTop(75);
        vStack.setWidth("70%");
        vStack.setMembersMargin(20);
        final TreeGrid employeeTreeGrid = new TreeGrid(); 
        employeeTreeGrid.setWidth(500); 
        employeeTreeGrid.setHeight(400); 
        employeeTreeGrid.setFields(new TreeGridField("nodeTitle")); 
        employeeTreeGrid.setDataSource(DataSource.get("test_tree"));
        employeeTreeGrid.fetchData();
         
        vStack.addMember(employeeTreeGrid);
       
        HLayout hLayout = new HLayout(10);
        hLayout.setMembersMargin(10);
        hLayout.setHeight(22);

        IButton button = new IButton("Check");
        button.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                                for (TreeNode tnode : employeeTreeGrid.getData().getAllNodes()) {
                                        SC.logWarn("Path:" + employeeTreeGrid.getData().getPath(tnode));
                                }
                                TreeNode node = employeeTreeGrid.getData().find("/1/2");
                                if (node != null) {
                                        int index = employeeTreeGrid.getData().indexOf(node);
                                        int findIndex = employeeTreeGrid.getData().findIndex("id", node.getAttribute("id"));
                                        SC.say("indexOf returned " + index + " findIndex returned " + findIndex);
                                }
                        }
                });
        hLayout.addMember(button);
        vStack.addMember(hLayout);
       
        vStack.draw(); 
    }
}

2. test_tree.ds.xml:
Code:

<DataSource
    ID="test_tree"
        serverType="sql"
        tableName="test_tree"
>
    <fields>
        <field name="id"  type="integer"  primaryKey="true"  required="true"/>
        <field name="nodeTitle" type="text"/>
        <field name="parent_id"    type="integer" foreignKey=".id"/>
    </fields>
</DataSource>

3. test tree table:
Code:

CREATE CACHED TABLE PUBLIC.TEST_TREE(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL,nodeTitle VARCHAR_IGNORECASE(255),parent_id INTEGER DEFAULT NULL)
insert INTO TEST_TREE VALUES(default,'Root', null)
insert INTO TEST_TREE VALUES(default,'first level', 1)
insert INTO TEST_TREE VALUES(default,'second level', 2)
insert INTO TEST_TREE VALUES(default,'first level-2', 1)

Start the application and click "Check" button. find() method correctly returns a TreeNode that can't be later located by indexOf() nor findIndex(). Both calls return -1.

Calendar: "undefined"

$
0
0
If I don't write anything to the "description" area of an event in a data-bound calendar, I get "undefined" in the calendar (see screenshot.png).

Using smartgwt 4.1p power 17.01.15

Attached Images
File Type: png screenshot.png (2.9 KB)

Calendar: scrolling makes events dissapear?

$
0
0
See 1.png , 2.png , 3.png. One event disappears if I scroll the calendar one step. Then it appears again after scrolling another step.

I have observed similar behaviors with other events. What may be happening here?

Using Smartgwt 4.1p power 17.01

Attached Images
File Type: png 1.png (14.2 KB)
File Type: png 2.png (9.9 KB)
File Type: png 3.png (9.3 KB)

Questions about Hibernate DataSources and Wildfly transaction provider

$
0
0
SmartClient Version: v9.1p_2015-01-02/PowerEdition Development Only (built 2015-01-02)

Hi,
We have some questions about hibernate datasources:

1. We have datasource B with relation many-to-one to datasource A.
Is it true that, if we have 5 records from table A, hibernate will make 50 different sql calls to fetch related records from B table? If yes - is it possible to replace that 50 calls with one combined call without rewriting datasource?

2. The second problem is that sometimes, based on search criteria we need to directly specify name of partitioned table (which is slightly different that base table, eg. messages and messages_2015_02). What is preferred way to achieve this?

3. Is there a possibility to reuse existing persistence unit configuration(defined in persistence.xml file)? If yes, could you provide us with example configuration? And how should configuration look like so that datasource will use transaction provider from application server (wildfly)?

Best regards
Jacek

HLayout.getInnerHTML returns "nbsp;"

$
0
0
SmartClient Version: v10.0p_2015-01-20/Pro Deployment (built 2015-01-20)

Hi I trying to create some html to serve as the argument for EventHandler.setDragTracker(String html)

If I create a Label I can get it's html via label.getInnerHTML(), but if I put the Label inside a HLayout then hLayout.getInnerHTML() returns "nbsp;".
Am I misunderstanding the intended functionallity of getInnerHTML or shouldn't it return the html for the layout including all it's members?

TestCase:
Code:

Label label = new Label("THIS IS A LABEL!");

SC.logWarn("LabelHTML: " + label.getInnerHTML()); // <-- Prints the correct HTML

HLayout hLayout = new HLayout();
hLayout.addMember(label);

SC.logWarn("HLayout HTML: " + hLayout.getInnerHTML()); // <-- Prints &nbsp;

Flashlet not working in Chrome

$
0
0
Hello,

using SmartClient Version: v9.1p_2015-01-21/Pro Deployment (built 2015-01-21)

we have a page in which a flashlet is included.
Basically a 360 view of a bicycle with buttons to rotate and zoom the bike.

In google Chrome, the flash loads and rotates one time automatically,
but after that, the navigation buttons to rotate or zoom the bike do not work.

It works in FireFox.
It also works in Google Chrome with a plain html <object><embed ...> approach.

So it seems the flashlet is broken for Google Chrome.
Chrome Version 39.0.2171.99 m

Best regards,
Daniel
Viewing all 4756 articles
Browse latest View live