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

how to fill authentication data from unit test in dsRequest

$
0
0
Hi Isomorphic,

<gwtVersion>2.4.0</gwtVersion>
<smartgwtGroupId>com.isomorphic.smartgwt</smartgwtGroupId>
<smartgwtVersion>3.1-p20140602</smartgwtVersion>

I am trying to create and execute DSRequest in an unit test. So far it works for me to mock and run the dsRequest via DSResponse execute = addDsRequest.execute() which is calling the appropriate DMI in my spring context and so forth and so on.

The problem that I am facing now is that the "insertedBy" field is not filled with the username of the logged in user. I have a datasource wich is inherited by other datasources with these fields:

<DataSource ID="wdMetaCreateInfo" serverType="sql">
<fields>
<field name="creationDate" type="creatorTimestamp" nativeName="INSERT_TS" escapeHTML="true"/>
<field name="insertedBy" type="creator" length="128" nativeName="INSERTED_BY" escapeHTML="true"/>
</fields>
</DataSource>

To mock the httpRequest within the dsRequest I used MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest();

Where should I set additionally the username in the HttRequest as header or as UserPrincipal so I make it work?

Thanks for any help,
zapryano

Customizing list grid cell

$
0
0
Hi

In one of my project i need to display a list grid to user which fetches data from datasource . Unlike default listgrid view i need to display each record in listgrid in different format as given below.I have attached the image file for reference

...................................................................................................
.Date place time
.
.Headline
.
.content
.
.................................................................................................

...................................................................................................
.Date place time
.
.Headline
.
.content
.
.................................................................................................


All these fields displayed in single listgrid cell is fetched from single datasource.

How can I achieve this by using List grid?
Is their any other option to achieve this with out using List grid?

Thanks in advance.

Attached Images
File Type: png examplegrid.png (2.8 KB)

ListGrid - strange scrolling behavior

$
0
0
In our app we have ListGrid with 30 columns. Only one column is editable where users enter some numbers. If there are only few rows in grid everything is working fine, but if there are many rows than something strange happen.
Scenario :
- user double clicks and begins to edit in that specific column
- when user hits enter, cell saved handler fires and focus moves to next editable cell in new row
- when user is in last visible row and hits enter, than list grid scrolls so user can no longer see the first few columns, but grid scrolls to right and first visible column is now that editable column

I hope screenshots can say more about the problem.
I believe something similar is happening like in this post : http://forums.smartclient.com/showthread.php?t=12045&highlight=listgrid+editable+column

So my question is, is there a way to prevent this scrolling behavior or at least set it so grid is not scrolled to right?


I'm using :
1. SNAPSHOT_v10.1d_2014-12-14/LGPL Development Only / GWT 2.6.0
2. Chrome 39.0.2171.95 m


Regards,
Zoran

Attached Images
File Type: jpg before.jpg (86.6 KB)
File Type: jpg after.jpg (43.6 KB)

timeItem doesn't render as disabled if it defines textBoxStyle

$
0
0
Hi,

If a timeItem defines a textBoxStyle, this style is always directly applied without taking into consideration if the item is disabled.

Tested with this snippet in http://www.smartclient.com/#Welcome (version ISC_100_BRANCH_2014-12-09_1418144730_wayne_limegreen-dev-server):

Code:

isc.ClassFactory.defineClass('MyTime', isc.TimeItem);
 
 isc.MyTime.addProperties({
  textBoxStyle: 'textItem',
  useTextField: true
 });
 
 isc.DynamicForm.create({
  ID: 'exampleForm',
  width: 250,
  fields: [{
    title: 'time1',
    type: 'MyTime',
    required: true,
    defaultValue: '10:20'
  },{
    title: 'time2',
    type: 'MyTime',
    required: false,
    defaultValue: '10:20'
  },{
    title: 'time3',
    disabled: true,
    type: 'MyTime',
    defaultValue: '10:20'
  }]
 });

how to disable EditPane.contextMenu?

$
0
0
SmartClient Version: v10.0p_2014-12-13/EVAL Deployment (expires 2015.02.11_12.43.38) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

Hello, I want to disable the 'clear' EditPane.contextMenu, how could it be done?

KeyPressFilter with whitespace

$
0
0
Hello there,

I'm trying to inherit TextItem to create TimeIntervalItem that accepts input in format (eg. 1w 5d 1h 23m). I'm using keyPressFilter String as: "[0-9wdhm.]" this works fine for digits and (wdhm chars), but I can't tell the item to accept white spaces as well. I've tried "\s" and literal space " " both doesn't work.
Any suggestions?

Regards,

-------------------
<b>UPDATE</b>
It worked! "[0-9wdhm\\s]" works however It didn't work earlier don't know why. Thanks anyway.

Dual Axis with Smart GWT 4.1p version

$
0
0
Hello,

I have successfully implemented a chart with Dual Axis (with Smart GWT 3.1p_2013-07-24 version).
After upgrading to Smart GWT 4.1p20141205 version, and without modifying anything to the chart's code, I have the following issue:
- second axis values nor curve are missing
- error message "Uncaught TypeError: Cannot read property '0' of undefined" "ISC_Core.js:283" occurs in the browser's console (Chrome and IE)

Data used for the chart are fully available.
Please find below the code for the creation of the chart.

Do you know what's wrong?
And a second question if you allow me: does the ZOOM functionality available for Dual Axis chart?

Thank you very much for your help!

moeChart = new FacetChart();
moeChart.setWidth100();
moeChart.setHeight100();
moeChart.setChartType(ChartType.COLUMN);
moeChart.setStacked(true);
moeChart.setValueTitle("Nb Aggregation");
moeChart.setTitle("MOE " + moeValue + " space statistics");
moeChart.setShowChartRect(true);

areaFacet = new Facet();
areaFacet.setValues(new FacetValue(moeValue, moeValue));
areaFacet.setId("moeid");

metricFacet = new Facet();
metricFacet.setValues(new FacetValue("NBAGG", "Nb Aggregation"), new FacetValue("DBSIZE", "DB Size (MB)"));
metricFacet.setInlinedValues(true);
metricFacet.setId("metric");

metricSettings = new MetricSettings();
metricSettings.setChartType(ChartType.LINE);
metricSettings.setMultiFacet(true);
metricSettings.setShowDataPoints(true);
metricSettings.setValueTitle("DB Size (MB)");

moeChart.setFacets(new Facet("DATE"), areaFacet, metricFacet);
moeChart.setExtraAxisMetrics("DBSIZE");
moeChart.setExtraAxisSettings(metricSettings);
moeChart.setData(moeChartData);

graphViewerLayout.addMember(moeChart);

Portal Dashboard sample: portlet sizing problem

$
0
0
SmartClient Version: v10.0p_2014-12-16/EVAL Development Only (expires 2015.02.14_07.41.00) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

Chrome on OSX

We're in the process of upgrading our licenses to 10 -Enterprise Edition, and the first Enterprise feature we need it's the 'Portal Dashboard', so I've got some questions/problems about it..

as you could see in this video illustrating the issue (#portalDashboard sample):
https://www.youtube.com/watch?v=FtmiE6PAWMU

1. the height of the portlets is not a percentage, so when I open a dashboard saved on a 'taller' page, I got a scrollbar on the portlet column.

2. If I create a new dashboard, add a portlet, save it, then edit the same dashboard, add another portlet, again a scrollbar appears.

Is it intended behavior? Are there available settings to change it?

developer console logs:
Code:

11:19:28.602:INFO:Log:initialized
11:19:29.392:INFO:Log:isc.Page is loaded
11:19:31.434:WARN:Log:New Class ID: 'IAutoFitButton' collides with ID of existing Class object '[Class IAutoFitButton]'.  Existing object will be replaced.
11:19:31.434:WARN:Log:New Class ID: 'HeaderMenuButton' collides with ID of existing Class object '[Class HeaderMenuButton]'.  Existing object will be replaced.
11:19:31.440:WARN:Log:Detected loading of more than one skin - 'Enterprise' was loaded when 'Enterprise' was already loaded.  See the QuickStart Guide for instructions on correctly changing the current skin
11:19:35.871:XRP2:WARN:Log:ClassFactory.addGlobalID: ID:'animals' for object '[DataSource ID:animals]' collides with ID of existing object '[DataSource ID:animals]'. The global reference to this object will be replaced
11:19:42.607:MUP2:WARN:PortalColumnBody:PortalColumn0_rowLayout:couldn't find member to remove: [PortalRow ID:PortalRow2]
11:19:42.624:MUP2:WARN:PortalColumnBody:PortalColumn0_rowLayout:couldn't find member to remove: [PortalRow ID:PortalRow0]
11:20:02.486:MUP0:WARN:PortalColumnBody:PortalColumn0_rowLayout:couldn't find member to remove: [PortalRow ID:PortalRow0]
11:20:08.294:TMR9:WARN:GridBody:ListGrid1_body:row heights not yet available; returning all zeroes


Smart GWT V4.0, IE11

$
0
0
Issue 1:
I am using a list grid element to implement functionality in my application.
I have several fields in list grid and some of them can be edited by the user. If user gives data to the editable fields and click outside of the list grid row then data will be saved.

I am implementing code like below:
ValuesManager vm = new ValuesManager();
DataSource ds= DataSource.get("Datasource");
vm.setDataSource(ds);
ListGrid smGrid = new ListGrid();
smGrid.setAutoSaveEdits(false);
smGrid.setFields(all list gried fields);
smGrid.addRowEditorExitHandler(new RowEditorExitHandler() {

@Override
public void onRowEditorExit(RowEditorExitEvent event) {
// TODO Auto-generated method stub
Map dataMap = event.getNewValues();
if(dataMap != null)
{
if(event.getRowNum() == 0 )
{
\\ code Snippet
}
else
{
\\ code Snippet
}
saveData();
}
}
});

private void saveData(){
if(smGrid.validateRow(0)&& smGrid.validateRow(1)){

vm.saveData(new DSCallback() {

@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
\\ code Snippet


}
});
}
}


<DataSource ID="Datasource" serverType="generic">

<fields>
// Field Code Snippet
</fields>
<serverObject className="<package>.DatasourceDS" />
</DataSource>

public class DatasourceDS {
public DSResponse update(DSRequest dsRequest)
{
// code Snippet
}
}
We are testing this in Debug mode. We are trying catch up the debug pointer in Update() method of DataSource implementation class. But we are unable to catch up pointer in Update() in DataSource Class and did not get any respond from callback.
We are using GWT 2.6.1(using gwt-servelet.jar,gwt-dev.jar), Smart GWT 4.0 (smartgwt.jar, smartgwtpro.jar),and Internet explorer 11.
Previously it was working fine in IE8, IE9 with GWT 2.3.0, smart gwt 3.0. The above codes are running fine in IE8. We are upgrading the above mentioned jars to run this application in IE11.

Note: if anyone need any information further, please reply.

Smart GWT V4.0, IE11

$
0
0
Issue:
We are using a list grid to show some data and have one field in the list grid which has Boolean true or false value. We have a Data-Source attached with this item to.
The functionality is that Boolean field have to show two different image depending on the true or false value of the field .


The code is given below :
ListGrid gridField = new ListGrid();
gridField.setBooleanTrueImage(/image/custom/user.png);
gridField.setBooleanFalseImage((/image/custom/blank.png);
DataSource dsource = DataSource.get(datasource name);
gridField.setDataSource(ds);


But this is not working in IE11. The image is not showing and by default it is display as read only check box field as JavaDoc said. It is working in IE8.
We are using GWT 2.6.1(using gwt-servelet.jar,gwt-dev.jar), Smart GWT 4.0 (smartgwt.jar, smartgwtpro.jar),and Internet explorer 11.
Previously it was working fine in IE8, IE9 with GWT 2.3.0, smart gwt 3.0. The above codes are running fine in IE8. We are upgrading the above mentioned jars to run this application in IE11.

Note: if anyone need any information further, please reply.

Smart GWT V4.0, IE11

$
0
0
Issue 3:
I am using a dynamic form which is added to a SectionStackSection. A ToolStripButton named “save Button” is added to that SectionStackSection. Whenever user click on that button saveData() method of DynamicForm class is being invoked.


Code module is given below:

SectionStackSection sectionAttributes = new SectionStackSection("Section Details");
DynamicForm form = new DynamicForm();
form.setDataSource(DataSource.get("<<crosssectionDS>>"));
ToolStripButton saveButton = new ToolStripButton();
saveButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
form.saveData(new DSCallback() {

// code snippet

});
sectionAttributes.addItem(form);
sectionAttributes.setControls(saveButton);

In the <<crosssectionDS>> DataSource Class we have implemented Update() method.
public class CrossSectionSummaryDS {
public DSResponse update(DSRequest dsRequest) throws Exception
{
// code snippet
}
}


Now the Issue is we did not get any response from Data-Source implementation class.
We are using GWT 2.6.1(using gwt-servelet.jar,gwt-dev.jar), Smart GWT 4.0 (smartgwt.jar, smartgwtpro.jar),and Internet explorer 11.
Previously it was working fine in IE8, IE9 with GWT 2.3.0, smart gwt 3.0. The above codes are running fine in IE8. We are upgrading the above mentioned jars to run this application in IE11.

Note: if anyone need any information further, please reply.

Smart GWT V4.0, IE11

$
0
0
Issue 4:
In our application we are displaying some color static data in List grid. After selecting any particular record and doing edit on that record, displaying all data in Editor Screen which is designed with DynamicForm and rendered all data using Data-Source in that form. That Colored Static Data is not rendered as expected. It is showing as text field with this "<span class='remarkGood'>Good</span>" but non editable when it is running in IE11. But the same thing, when it is running in IE8, it is coming as expected.


The Static Code snippet is below:
String REMARK_GOOD = "<span class='remarkGood'>Good</span>"


CSS File code is below:
.remarkGood {
color: green;
font-size:12px;
font-family:Arial,Verdana,sans-serif;
font-weight:bold;
}

Please suggest how do we display this kind of Static Data in DyanmicForm.

We are using GWT 2.6.1(using gwt-servelet.jar,gwt-dev.jar), Smart GWT 4.0 (smartgwt.jar, smartgwtpro.jar),and Internet explorer 11.
Previously it was working fine in IE8, IE9 with GWT 2.3.0, smart gwt 3.0. The above codes are running fine in IE8. We are upgrading the above mentioned jars to run this application in IE11.

Note: if anyone need any information further, please reply.

ComboBoxItem that addUnknownValues but do not allowEmptyValue

$
0
0
Hello,

I am using a ComboBoxItem as a template for a ListGridField editor and I'd like to accept new distinct values (addUnknownValues = true) but disallowing empty value (tried: allowEmptyValue = false) with the "revert to original value" semantics.

Unfortunately, by reading the docs and code (_updateValue), it seems that setting allowEmptyValue to false has no effect when addUnknownValues is true. (suppressSave is always false in this condition).

Would it make sense for you to support that?

Something like replacing the current logic:
Code:

var suppressSave = !forceSave && !this._valuePicked && this.addUnknownValues == false;
if (suppressSave && this.allowEmptyValue && (value == "")) {
  suppressSave = false;
}

By this (obviously I'm totaly unaware of possible collateral effects):
Code:

var suppressSave;
if (forceSave || this._valuePicked) {
  suppressSave = false;
} else {
  suppressSave = !this.addUnknownValues || (value == "" && !this.allowEmptyValue);
}

If not, could you suggest a different approach to achieve that behavior?

Multiple requests with dataFetchMode paged and ReturnOpenFolders in TreeGrid

$
0
0
Hi,
I try to use a treeGrid with a dataSource and the "dataFetchMode: paged" attribute.
It works like charm, but if I set the “dataPropterties” to open the nodes when they were loaded the treeGrid does not work correctly.

The code for the treeGrid is the following:
Code:

      isc.TreeGrid.create(
      {
        "ID":"absencesTreeGrid",
        "width":"100%",
        "height":"100%",
        "selectionType":"single",
        "canEdit":false,
        dataSource:isc.DataSource.create(
        {
          "fields":
          [
          {
            "name":"parentId",
            "hidden":true,
            "canEdit":false,
            "canSort":false,
            "rootValue":"0",
            "foreignKey":"id",
          }
          ],
          "dataFormat":"json",
          "dataURL":"ScTreeGridDataSource?viewNumber=13&id=absencesTreeGrid",
          "transformRequest":clwTransformRequest,
          "transformResponse":clwTransformResponse,
          "recordXPath":"\/resultData"
        }
        ),
        "autoFetchData":true,
        "dataPageSize":100,
        "dataFetchMode":"paged",
        "selectionProperty":"isSelected",
        "fields":
        [
        {
          "name":"statusListGridField",
          "title":"Status",
          "type":"text",
          "width":220,
          "canEdit":false,
          "canSort":false,
        },
        {
          "name":"absenceKindGridField",
          "title":"Absence type",
          "type":"text",
          "align":"left",
          "canEdit":false,
          "canSort":false,
        },
        ],
        "dataProperties":
        {
        "canReturnOpenFolders":true,
        "childrenProperty":"children",
        "openProperty":"isOpen"
        }
      }
      ),

The first thing I noticed is, that there are too many requests. The first, for the root, seems correct and looks like this:
Code:

end                100
id                absencesTreeGrid
operationType        fetch
parentId        0
start                0

The other requests are ignoring the “dataPageSize” I have set at the initalization of the treeGrid.
The request for the first child looks like this:
Code:

end                2
id                absencesTreeGrid
operationType        fetch
parentId        24
start                0

If there are more objects under the node a second request is triggerd to get the next page of the visible nodes
Code:

end                102
id                absencesTreeGrid
operationType        fetch
parentId        24
start                2

This additional request use the correct dataPageSize (100).

The request for the second child looks like this:
Code:

end                1
id                absencesTreeGrid
operationType        fetch
parentId        25
start                0

And so on.

Note I have three nodes under the root-node and it seems that the start to end number in the request is bound to the number of these nodes. Also the end number decreases from request to request. So the first requests starts with start: 0 end: 3, the second request with start: 0 end: 2 and the last request calls with: start: 0 end: 1. Because there are many more items, for each of the three nodes there an additional request for the rest of the nodes is started.

At this point I stepped into another problem. If I use the dataPropterties option to open the nodes
something is going wrong with the visual selection of the elements

To explain that problem I attached the given file:


The selection type is set to “single”, so only one line should be selected.
But if you see it is possible to select more than one object. This is only a “visual” bug, the update method of the tree grid fires correctly and returns the correct object. It looks like the previous selected row doesn’t get redrawed after selecting a new row. After hovering the previous selected row the visual selection is removed.

I think there is a correlation between the selection and the request problem.

So do you have any suggestion what I can do to solve these problems, or is that a bug?

I have tested this behavior in all current browsers (IE 11, Firefox 34, Chrome 39) with the latest nightly build (SmartClient_v100p_2014-12-17_Pro)

Best Regards

Server-side session timeout

$
0
0
I would like to be able to detect when the user has not interacted with the server for a period.
The normal session timeout will not work for me because the client has a timer that periodically checks something on the server.

I tried creating a custom datasource by extending SQLDataDource and adding serverConstructor into the .ds.xml files. This was OK except when there was also serverObject custom DMI class. I don't really want to add custom code to each DMI.
I did see some reference to EventPreview in the client side, but it was unclear how exactly to implement this.

SmartClient Version: v9.0p_2013-10-17/PowerEdition Deployment (built 2013-10-17)

smartgwt-power-4.0-p20131017.jar

ViewState width with different screen sizes

$
0
0
Hi,
I want to implement the usage of viewState in our application. Therefore i run into other bugs, but besides that i have the problem that most of our listgrids we are using are defined with a width of 100%. So if the user has a small display the ListGrid fills the whole width and if he has a large display it also fills the whole width.

The current implementation of viewState does always return some absolute-pixel-width per ListGridField. After doing the calculation with width-attributes in percentages for each field it's understandable and easier to get the pixel-width insted of the percentages.

But if we are using the current implementation it will break the users listgrid if he ever switches the display-size (or resizes the browser). Then the listgrid is resized to the pixel-sizes fields which were saved after resizing on a large screen. This responds to a result, where some fields are hidden on the right, because the viewstate indirectly indicated that the listgrid is also large. So if you switch from a small to large screen, the white-space at the right side is always visible (and not needed) and switching from a large screen to a small screen you maybe not seeing all fields because they are only visible by scrolling there.

One solution to this would be before saving the viewState replacing all pixel-width in the fields wih a percentage-width.
This could be done by this snippet:
Code:

var viewstate = listGrid.getViewState();
a = viewstate.replace(/width:(\d*)/g,function(s,aWidth){
  var theListGridWidth = listGrid.width;
  if(aWidth != ""){
    return "\""+Math.round((parseInt(aWidth)/theListGridWidth)*100)+"%\"";
  } else{
    return ""
  }
});
console.log(a);

If this "relativeViewState" is saved in the backend this could be delivered at the initilaization of the view. But it seems that the viewState is fixed to a absolute-pixel width per field, so the whole viewState is ignored.

To build a workaround for this, we could send the proportionalViewState to the client and do the reverse-calculation (percentage-width to absolute-width) and after this do setViewState.
This doesn't seems to be a good solution. Is there a solution to work with differend screen-resolution (display-sizes)?

I have tested this behavior in all current browsers (IE 11, Firefox 34, Chrome 39) with the latest nightly build (SmartClient_v100p_2014-12-17_Pro)

Best Regards

Hilites do not match gird data

$
0
0
Hilites do not match gird data

All I want to do is color the entire row, based on one field.
I reworked your Simulated Stock Quotes Example in the EE showcase to use hilites.

First a button to launch a window
Code:

IButton button = new IButton("launch window");       
button.addClickHandler(new ClickHandler()
{
        int count = 1;
  @Override
        public void onClick(ClickEvent clickEvent)
        {
                new GuiWidgetLab("window" + count++).show();
        }
});

Click the button -> launch window 0 -> The servlet turns on updates for the next 90 seconds -> the updates go into the datasource -> the data updates -> the hilites update.
wait for the updates to end.
Click the button -> launch window 1 -> The servlet turns on updates for the next 90 seconds -> the updates go into the datasource -> the data updates -> the hilites update in all windows ( in window 1 they are correct. Window 0 they are not.)
wait for the updates to end.
Click the button -> launch window 2 -> The servlet turns on updates for the next 90 seconds -> the updates go into the datasource -> the data updates -> the hilites update in all windows ( in window 2 they are correct. Window 0 and window 1, they are not. )

The end state of the hilites for windows 0 and 1, is normally wrong (green rows with negitive change values, or red rows with positive), and windoww 1 doesn't match window 0.

The latest window, the hilite state is correct.


Code:

/*
 * Isomorphic SmartGWT web presentation layer
 * Copyright (c) 2011 Isomorphic Software, Inc.
 *
 * OWNERSHIP NOTICE
 * Isomorphic Software owns and reserves all rights not expressly granted in this source code,
 * including all intellectual property rights to the structure, sequence, and format of this code
 * and to all designs, interfaces, algorithms, schema, protocols, and inventions expressed herein.
 *
 *  If you have any questions, please email <sourcecode@isomorphic.com>.
 *
 *  This entire comment must accompany any portion of Isomorphic Software source code that is
 *  copied or moved from this file.
 */


import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.Timer;
import com.smartgwt.client.data.*;
import com.smartgwt.client.rpc.Messaging;
import com.smartgwt.client.rpc.MessagingCallback;
import com.smartgwt.client.rpc.RPCManager;
import com.smartgwt.client.rpc.RPCRequest;
import com.smartgwt.client.types.DSOperationType;
import com.smartgwt.client.types.OperatorId;
import com.smartgwt.client.util.JSOHelper;
import com.smartgwt.client.widgets.Button;
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.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class GuiWidgetLab extends Window
{
    private ListGrid stockQuotesGrid;

    public GuiWidgetLab(String title)
    {
        super();
        setTitle(title);
        setWidth("50%");
        setHeight("50%");
        final long startParameter = System.currentTimeMillis();

        // Grid and button below it
        setMembersMargin(10);
        setPadding(10);

        stockQuotesGrid = new ListGrid();
        stockQuotesGrid.setWidth(600);
        stockQuotesGrid.setHeight(300);
        stockQuotesGrid.setShowAllRecords(true);
        stockQuotesGrid.setDataSource(StockQuotesDS.getInstance());
        stockQuotesGrid.setAutoFetchData(true);
        stockQuotesGrid.enableHiliting();
        stockQuotesGrid.setCanEditHilites(false);
        stockQuotesGrid.setIncludeHilitesInSummaryFields(true);


        List<ListGridField> fieldList = new ArrayList<>(StockQuotesDS.getInstance().getFields().length);
        fieldList.add(new ListGridField("id"));
        fieldList.add(new ListGridField("name"));
        fieldList.add(new ListGridField("symbol"));
        fieldList.add(new ListGridField("lastValue"));
        fieldList.add(new ListGridField("changeValue"));
        fieldList.add(new ListGridField("openValue"));
        fieldList.add(new ListGridField("dayHighValue"));
        fieldList.add(new ListGridField("dayLowValue"));
        ListGridField lastUpdatedField = new ListGridField("lastUpdated");
        lastUpdatedField.setHidden(true);
        fieldList.add(lastUpdatedField);

        ListGridField[] fields = fieldList.toArray(new ListGridField[fieldList.size()]);
        stockQuotesGrid.setFields(fields);
        stockQuotesGrid.setHilites(buildHilites(fields));
        addItem(stockQuotesGrid);

        final Button generateUpdatesButton = new Button("Generate more updates");
        generateUpdatesButton.setWidth(200);
        generateUpdatesButton.addClickHandler(new ClickHandler()
        {
            @Override
            public void onClick(ClickEvent event)
            {
                generateUpdates(startParameter, generateUpdatesButton);
            }
        });
        addItem(generateUpdatesButton);
        // receive messages from the stockQuotes channel and update data grid
        Messaging.subscribe("stockQuotes" + startParameter, new MessagingCallback() {
            @Override
            public void execute(Object data) {
                updateStockQuotes(data);
            }
        });

        generateUpdates(startParameter, generateUpdatesButton);
    }

    /**
    * We get id and changeValue only from server - combine it with the record
    * in the grid to get the rest of the fields
    *
    * @param data
    */
    @SuppressWarnings("unchecked")
    private void updateStockQuotes(Object data) {
        List<List<?>> stockData = (List<List<?>>) JSOHelper
                .convertToJava((JavaScriptObject) data);
        List<Record> newStockData = new ArrayList<Record>();
        // prepare data for grid manually using received data from servlet
        // we receive only 'id' and 'change percent' data here
        for (List<?> recordData : stockData) {
            float change = ((Number) recordData.get(1)).floatValue();
            if (change != 0) {
                final Integer id = (Integer) recordData.get(0);
                Record record = stockQuotesGrid.getDataAsRecordList().find("id", id);
                float lastValue = record.getAttributeAsFloat("lastValue");
                float newChangeValue = change * lastValue / 100;
                float newLastValue = newChangeValue + lastValue;
                record.setAttribute("changeValue", newChangeValue);
                record.setAttribute("lastValue", newLastValue);
                record.setAttribute("dayHighValue",
                        Math.max(record.getAttributeAsFloat("dayHighValue"), newLastValue));
                record.setAttribute("dayLowValue",
                        Math.min(record.getAttributeAsFloat("dayLowValue"), newLastValue));
                record.setAttribute("lastUpdated", new Date());
                newStockData.add(record);

                new Timer()
                {
                    @Override
                    public void run()
                    {
                        Record record = stockQuotesGrid.getDataAsRecordList().find("id", id);
                        if(record.getAttribute("lastUpdated") != null)
                        {
                            Date lastUpdated = record.getAttributeAsDate("lastUpdated");
                            long delta = System.currentTimeMillis() - lastUpdated.getTime();
                            if(delta >= blinkPeriod)
                            {
                                record.setAttribute("lastUpdated", (Date) null);
                            }
                            DSResponse dsResponse = new DSResponse();
                            Record[] toUpdate = new Record[] {record};
                            dsResponse.setData(toUpdate);

                            DSRequest dsRequest = new DSRequest();
                            dsRequest.setOperationType(DSOperationType.UPDATE);
                            // broadcast the change - the grid will notice this automatically (and so would other
                            // components showing the same record)
                            StockQuotesDS.getInstance().updateCaches(dsResponse, dsRequest);

                        }
                    }
                }.schedule(blinkPeriod);
            }
        }

        DSResponse dsResponse = new DSResponse();
        dsResponse.setData((Record[]) newStockData.toArray(new Record[newStockData.size()]));

        DSRequest dsRequest = new DSRequest();
        dsRequest.setOperationType(DSOperationType.UPDATE);
        // broadcast the change - the grid will notice this automatically (and so would other
        // components showing the same record)
        StockQuotesDS.getInstance().updateCaches(dsResponse, dsRequest);
    }
    private int blinkPeriod = 2000;

    private void generateUpdates(final long startParameter, final Button generateUpdatesButton) {
        generateUpdatesButton.disable();
        RPCRequest request = new RPCRequest();
        // we tells servlet which channel it should use for sending data
        request.setActionURL("examples/StockQuotes/generate?sp=" + startParameter);
        RPCManager.sendRequest(request);
        // block button repeat click for 90 seconds - time while servlet
        // will send data to us
        new Timer() {
            public void run() {
                generateUpdatesButton.enable();
            }
        }.schedule(90000);
    }


    public static Hilite[] buildHilites(ListGridField... fields)
    {
        String [] names = new String[fields.length];
        int i = 0;
        for(ListGridField field: fields)
        {
            names[i] = field.getName();
            i++;
        }
        return buildHilites(names);
    }

    public static Hilite[] buildHilites(String... fields)
    {
        List<Hilite> lites= buildHilitesList(fields);
        return lites.toArray(new Hilite[lites.size()]);
    }

    public static List<Hilite> buildHilitesList(String... fields)
    {
        List<Hilite> lites= new ArrayList<>();
        lites.add(buildHilite("#000000", "#FF0000", fields, new Criterion("changeValue", OperatorId.LESS_THAN, 0f) ));
        lites.add(buildHilite("#000000", "#00FF00", fields, new Criterion("changeValue", OperatorId.GREATER_THAN, 0f)));
        lites.add(buildHilite("#000000", "#FFFFFF", fields, new Criterion("changeValue", OperatorId.EQUALS, 0f)));
        lites.add(buildHiliteNull("#000000", "#FFFFFF", fields, "lastUpdated"));
        return lites;
    }

    public static Hilite buildHilite(String textColor, String bkgrndColor, String[] hiliteFields, Criterion ... criterions)
    {
        Hilite build = new Hilite();
        build.setTextColor(textColor);
        build.setBackgroundColor(bkgrndColor);
        build.setFieldNames(hiliteFields);
        if(criterions == null || criterions.length <= 0 )
        {
            return build;
        }
        AdvancedCriteria criteria = new AdvancedCriteria(OperatorId.OR, criterions);
        build.setCriteria(criteria);
        return build;
    }
    public static Hilite buildHiliteNull(String textColor, String bkgrndColor, String[] hiliteFields, String criteriaField)
    {
        Hilite build = new Hilite();
        build.setTextColor(textColor);
        build.setBackgroundColor(bkgrndColor);
        build.setFieldNames(hiliteFields);

        List<Criterion> criterionList = new ArrayList<>(1);
            criterionList.add(new Criterion(criteriaField, OperatorId.IS_NULL ));
        AdvancedCriteria criteria = new AdvancedCriteria(OperatorId.OR, criterionList.toArray(new Criterion[criterionList.size()]));
        build.setCriteria(criteria);
        return build;
    }


}



1. SmartClient Version: v9.1p_2014-12-12/PowerEdition Deployment (built 2014-12-12)

2. FF 33.1.1
Chrome 39.0.2171.95m

3. - 5. n/a

6. see above

[Bug] Scrolling horizontally in TreeGrid with scrollbars

$
0
0
There is a bug in scrolling TreeGrid that happens after scrolling to the end and sorting.

To replicate: run code below in any of your demo examples, scroll all the way to the right, pick "Sort Descending" from drop down menu for column 18, then try scrolling to the end again - it does not work, can not see values for the column 19 (last column). If this doesn't replicate the problem - pick "Clear Sort" and pick "Sort Descending" again.

Code:

        var root = {
                        children: [{
                                0: 'rootData',
                                children: []
                        }]
                },
                rootData = root.children[0],
                row,
                fields = [],
                folders = 5,
                leafs = 5,
                allCols = 20,
                displayCols = 20;

        for(var i=0; i<folders; i++){
                var children = (
                        rootData.children[i] = {
                                0: 'child' + i,
                                children: []
                        }
                        ).children;
                for(var j=0; j < leafs; j++) {
                        row = children[j] = {};
                        for (var k = 0; k < allCols; k++) {
                                row[k] = i+j;
                                if(k>0) root.children[0][k] = rootData.children[i][k] = i+j;
                        }
                }
        }

        for(var i=0; i<displayCols; i++){
                fields.push({name: ''+ i, align:"right"});
        }

        var treeGrid = isc.TreeGrid.create({
                width: 500,
                height: 300,
                autoDraw: true,
                autoFitFieldWidths: true,
                autoFitWidthApproach: "both",
                data: isc.Tree.create({
                        root: root
                }),
                fields: fields
        });

        treeGrid.data.openAll();

smartgwt IE11 UI issues

$
0
0
I am working on a J2EE project which is using smartgwt as frontend framework, the frontend pages include JSP pages and java classes which include smartgwt code. All the pages and smartgwt UI components work fine in IE8, but there is UI issues in IE11.

In IE11, there is only one type of issue, it is that the listgrid content exceeds the listgrid bottom borders, and scrollbars don't work. The issue doesn't occur all the time. It happened after some add, update or delete operations on the page (Ajax operations, so page doesn't submit and reload) then load the data in the grid.

I saved the HTML code of the page before and after the issue happened. The two generated HTML code have a lot of differences, but the there are two main differences which are directly related to the UI issue. one is the style attribute of listgrid div of the wrong page doesn't include
Code:

overflow:hidden;
, another is the DIV which controls the listgrid's height and width has the height of
Code:

height:4534px
on the wrong page whereas it has the height of
Code:

height:300px
on the right page.

I tried to upgrade the smartgwt version to 4.0 and gwt version to 2.5.1, but that doesn't solve the problem.

I am new with smartgwt, I don't know where I should look at to find the solution of the problem, I don't know it is caused by the Java smartgwt code of the page, or it is a smartgwt issue with IE11, or some other reason. Can anybody guide in which direction I should tried to find the solution of the problem?

Click event performed on ListGrid's group summary row

$
0
0
I'm wondering how to add a click event handler on the group summary row of a ListGrid.

addRecordClickHandler() does not seem to have effect on the group summary row.

Thanks!
Viewing all 4756 articles
Browse latest View live