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

Disabling a menu button when all of its menu items are disabled

$
0
0
Hello,

I am wondering if it is possible to let a menu button (IconMenuButton) disable itself when all its contained menu items (Menu with MenuItem) are (or actually more precise: become) disabled.

We could implement this ourselves but it would be great to have this out of the box, assuming you guys can code this 10x better than us ;-)

thanks for your thoughts

DateTimeItem doesn't validate the value as appose to DateItem

$
0
0
Hello,

I'm using SmartClient_v91p_2014-03-23_PowerEdition.

When I use this code and enter invalid data the validation error appear only in the DateItem and not in the DateTimeItem, why?

Code:

isc.VLayout.create({
        ID:"mainPageLayout",
        autoDraw:true, // This is the only place to set autoDraw true
        width:"100%",
        height:"100%",
        members:[

          isc.DynamicForm.create({

            ID:'form1',

            titleAlign:"left",

            validateOnExit:true,

            fields:[

              { /* Date */

                name:"date",

                title:"Date",

                editorType:"date",

                useTextField:true

              },

              { /* Date Time */

                name:"dateTime",

                title:"Date Time",

                editorType:"dateTime",

                useTextField:true

              }
            ]
          })

        ]

      });

listgrid hide inline editor

$
0
0
Hi,

I am using smartgwtpower 3.1.

I have an editable grid with a datasource where I want to manually process changed values without having them added to the datasource. Therefore I tried:

Code:

grid.addRowEditorExitHandler(new RowEditorExitHandler() {
        @Override
        public void onRowEditorExit(RowEditorExitEvent event) {
                event.cancel();
                // do some stuff
        }
});

But after that the inline editor is still showing up. Is there a way to hide it?

Looking forward to hear from you

Operation type 'fetch' not supported by this DataSource

$
0
0
I am using trail version of smartgwtee

I am getting below error for simple program for Direct Method Invocation (DMI) DataSource --

java.lang.Exception: Operation type 'fetch' not supported by this DataSource ----
Unable to get the data in the grid..

what method i have to use to get data?

Week, year, quarter and month picker

$
0
0
Hello,

I'm using SmartClient_v91p_2014-03-23_PowerEdition and I was wondering if there's a build in form item for week, year, quarter and month picker? if not, can you please direct me to how to create them by my self.

Thank you.

Tree Grid Refresh

$
0
0
I am using gwt-dev-2.4.0

I have a treegrid and it is working well. I can drag and drop nodes into it. When I do I call refreshRow with a row number.

I need to expand that row in the UI so that other processing can have access to sub folders (treeNodes).

in the class that is the Tree Grid I have setLoadDataOnDemand(true).. changing this to false would mean that I have the full tree of TreeNodes available to me, but.. breaks my displaying of them.. they overlap and things become a mess..

should I override the refreshRow method to.. refresh the children and display them..

as you can see I am not a UI person and GWT is.. new to me..

any ideas..
thanks for any help.. sorry for the newbie question..
..

Full screen with RichTextItem

$
0
0
Hello,

I'm using SmartClient_v91p_2014-03-23_PowerEdition and I was wondering if there is a way to create a button in the RichTextEditor that will open the editor in full screen mode (just like tinyMCE have in http://www.tinymce.com/index.php - View - Fullscreen).

Thank you

Passing back a Map with a key fo type Date in RPC?

$
0
0
I am making a RPC call and included in the response is a HashMap that has Date objects as keys. All the data is being stripped out and in the smartgwt.log I see these messages:

<b>Ignoring unconvertible Map key of type: java.util.Date</b>

Is there any reason I am not allowed to set over a Map with the keys being a Date object?

DateUtil.parseInput("2015-10-06", "yyyy-MM-dd") returning null

$
0
0
I am calling the method DateUtil.parseInput(String dateString, String format) with parameters of ("2015-10-06", "yyyy-MM-dd") and I am getting a null back as the value.

I am am using the SmartGWT 4.1p dated April 1st, 2014

SpinnerItem and negative step

$
0
0
SmartGWT version
SmartGWT4.0

Browser(s) and version(s) involved
Mozilla 26.0
Chrome 33.0.1750.154

Problem encountered

While using negative step on a SpinnerItem, you can't go down (by pressing up) when you reach Max and can't go up (by pressing down) when you reach Min which totally block the spinner (can't go up AND down once a limit is reached)

Example : your spinnerItem is set to have max at 5 and step at -1, if you are at 5 and you press down, the value will be 6 and so this doesn't work (legit) but if you press up, the value will be 4 yet this is denied (You can still edit manually).

Sample code

Code:

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.SpinnerItem;

public class Spinner implements EntryPoint {

        @Override
        public void onModuleLoad() {
                DynamicForm df = new DynamicForm();
                SpinnerItem si = new SpinnerItem("priority");
                si.setMin(1);
                si.setMax(5);
                si.setValue(5);
                si.setStep(-1);
                df.setItems(si);
                df.draw();
        }
}

Kindly yours

Retrieve Object from ListGridRecord's getAttributeAsObject

$
0
0
I am unable to retrieve the ListGridRecordArray in the following code. An exception is thrown.
What is the proper way to get the ListGridRecordArray ?

Code:

ListGridRecord lgr = new ListGridRecord();
Record[] records = new ListGridRecord[list.size()];

for(int i = 0; i < list.size(); i++)
{
  //populate records
}

lgr.setAttribute("someName", records );
Record[] records2 =
(ListGridRecord[])breakRecord.getAttributeAsObject( "someName" );

SmartClient Version: v8.3p_2013-04-15/Enterprise Deployment (built 2013-04-15)
Firefox 20.0.1

Showcase DateChooser

$
0
0
I noticed on the showcase example:
http://www.smartclient.com/smartgwt/showcase/#grid_daterange_filtering

When I select a time as part of the DateChooser, it gets updated in the entry box but not on the right (label) and when I click the DateChooser again it always goes back to the original time.

See attached image from the showcase.

Attached Images
File Type: png screenshot_163.png (35.3 KB)

Edits not refreshed problem with displayField clumns in grouped listgrid

$
0
0
SmartClient_v91p_2014-03-04_PowerEdition

I have a ListGrid which has groupByField set. Some fields in this ListGrid have a displayField property ( displayField is fetched via a includeFrom on a FK on another table).
The ListGrid is displayed in a Hlayout with a dynamic form. Both the dynamic form and the listgrid use the same datasource. When the dynamic form updates a record, the listgrid displayes the updated record. But the problem is, the fields in listgrid which have a displayField, DO NOT reflect the changes made by the dynamic form. Changes to other fields are reflected immediately in the listgrid. Please note this behaviour is manifest only when the listgrid is grouped. If I ungroup the listgrid and then make changes using the dynamic form, listgrid reflected the changes immediately in all the changed fields from dynamicform. Also please note that the cacheSyncOperation used by the update DOES return all the displayField values. The total rows in the listgrid are only 90. I am completely puzzeled by this. Any pointers as to why this could be happening?

How to log remote ip address

$
0
0
SmartClient_v91p_2014-03-04_PowerEdition

In the server side log I can see entries like :
=== 2014-04-03 17:00:06,176 [c-40] DEBUG IDACall - remote user: prasad

Is there any way I can configure logging such that clients IP address is also logged?

Hover listgrid error

$
0
0
We are showing a message in the hover of a field from the listgrid.
This works ok in Chrome and anothers browsers, but iExplorer shows an error in the console relative to the framework.
I attach for your information both screen captures (ok and fail) and the source code.
There is a bug?


Code:


                                                                    isc.ListGrid.create({
                                                                        ID:"grdAlbaranes",  // Si se usa
                                                                        autoDraw:false,
                                                                        autoFetchData:false,
                                                                        showRecordComponents: true,
                                                                        showRecordComponentsByCell: true,
                                                                        //canFreezeFields: true,
                                                                        showFilterEditor:true,
                                                                        autoFitFieldWidths:false,
                                                                        wrapCells: false,
                                                                        dataSource:"ref:attevccamionalbaranesDS",
                                                                        hoverWidth:150,
                                                                        cellHeight:16,
                                                                        fixedRecordHeights:true,
                                                                        canEdit:false,
                                                                        fields:[{
                                                                                name:"botones",
                                                                                width:60,
                                                                                title: " ",
                                                                                canFilter:false
                                                                                },{
                                                                                name:"ALBS_ID",
                                                                                width:80,
                                                                                showHover:true,
                                                                                hoverHTML: function (record, value, rowNum, colNum, grid){
                                                                                              if ((record.IND_DECISION == "S") && (record.IND_INCIDENCIA == "S")){
                                                                                                  return cargaCamionUIDS.getField("hover.expedicion.faltasIncidencias").title;
                                                                                              } else  if (record.IND_DECISION == "S") {
                                                                                                      return cargaCamionUIDS.getField("hover.expedicion.faltas").title;
                                                                                              } else if (record.IND_INCIDENCIA == "S") {
                                                                                                      return cargaCamionUIDS.getField("hover.expedicion.incidencias").title;
                                                                                              } else if (record.ESTADO == "P") {
                                                                                                      return cargaCamionUIDS.getField("hover.expedicion.pantalla").title;
                                                                                              }else {
                                                                                                      return cargaCamionUIDS.getField("hover.expedicion.correcta").title;
                                                                                              } 
                                                                                }
                                                                                },{
                                                                                name:"IND_PARCIALES",
                                                                                width:40
                                                                            },{
                                                                                name:"SERV_ID",
                                                                                width:35
                                                                            },{
                                                                                name:"CLEM_ID_RMTE",
                                                                                width:80
                                                                            },{
                                                                                name:"CLRG_ID_RMTE",
                                                                                width:80
                                                                            },{
                                                                                name:"CLEM_ID_CONS",
                                                                                width:80
                                                                            },{
                                                                                name:"CLRG_ID_CONS",
                                                                                width:80
                                                                            },{
                                                                                name:"DIRECCION_CONS",
                                                                                width:150
                                                                            },{
                                                                                name:"POBLACION_CONS",
                                                                                width:120
                                                                            },{
                                                                                name:"PLZS_ID_ORG",
                                                                                title:"Org",
                                                                                width:40
                                                                            },{
                                                                                name:"PLZS_ID_DES",
                                                                                title:"Des",
                                                                                width:40
                                                                            },{
                                                                                name:"TOT_BULTOS_CARGA",
                                                                                width:60
                                                                            },{
                                                                                name:"NUM_BULTOS_ESCANEADOS",
                                                                                width:60
                                                                            },{
                                                                                name:"NUM_BULTOS_ESC_ANTES",
                                                                                width:60
                                                                            },{
                                                                                name:"PESO_CARGADO",
                                                                                width:80
                                                                            },{
                                                                                name:"VOLUMEN",
                                                                                width:50
                                                                            },{
                                                                                name:"IND_INCIDENCIA",
                                                                                width:40
                                                                            },{
                                                                                name:"IND_GENERAR_FALTA_TOTAL",
                                                                                width:60
                                                                    }],
                                                                        getCellCSSText: function (record, rowNum, colNum) {
                                                                              if (record.IND_DECISION == "S") {
                                                                                  return "background-color:#ffccff;";
                                                                              } else  if (record.IND_FALTA == "S") {
                                                                                  return "background-color:#FFFF99;";
                                                                              } else if (record.IND_INCIDENCIA == "S") {
                                                                                        return "background-color:#D0A9F5;";
                                                                              } else if (record.ESTADO == "P") {
                                                                                        return "background-color:#99CCCC;";
                                                                              }else {
                                                                                        return "background-color:white;";
                                                                              } 
                                                                        }, 
                                                                        initialSort:[{
                                                                                                property:"IND_DECISION",
                                                                                                direction:"descending"
                                                                                              },{
                                                                                                  property:"CLEM_ID_RMTE",
                                                                                                  direction:"ascending"
                                                                                              },{
                                                                                                property:"IND_INCIDENCIA",
                                                                                                direction:"descending"
                                                                                              },{
                                                                                                  property:"ALBS_ID",
                                                                                                  direction:"ascending"
                                                                      }],
                                                                      /**
                                                                      *  SUBGRID Bultos de Albaranes
                                                                      */
                                                                      canExpandRecords: true,
                                                                      expansionMode: "related",
                                                                      detailDS:"ref:attevccamionbultosDS",
                                                                      expansionCanEdit : false,
                                                                      getExpansionComponent : function (record) {
                                                                                var componenteSubGridBultos = isc.ObjSubgridBultosCC.create({});
                                                                                componenteSubGridBultos.subgridBultosCC._FILTRO_PADRE = {ALBS_ID: record.ALBS_ID, CCAM_ID: record.CCAM_ID};
                                                                                componenteSubGridBultos.subgridBultosCC.filterData({ALBS_ID: record.ALBS_ID, CCAM_ID: record.CCAM_ID});
                                                                                if (record.IND_DECISION != 'S' || record.ESTADO !='A'){
                                                                                        componenteSubGridBultos.botonBuscarObjSubgridBultosCC.disable();
                                                                                        componenteSubGridBultos.botonFaltaParcialObjSubgridBultosCC.disable();
                                                                                }
                                                                            return componenteSubGridBultos;
                                                                      },
                                                                      createRecordComponent : function (record, colNum) { 
                                                                    var fieldName = this.getFieldName(colNum); 
                                                           
                                                                    if (fieldName == "botones") {
                                                                            if ((record["NUM_BULTOS_ESCANEADOS"] == 0) && (record["IND_DECISION"] == "S") && (record["BULTOS_FPARCIAL"] == 0)){ 
                                                                                var recordFalta = isc.HLayout.create({
                                                                                    height: 16,
                                                                                    width:40,
                                                                                    align: "center"
                                                                                });
                                                                                if (record["ESTADO"] == "A") { 

                                                                                        var aceptarFaltaTotal = isc.ImgButton.create({
                                                                                                    showDown: false,
                                                                                                    showRollOver: false,
                                                                                                    layoutAlign: "center",
                                                                                                    src: Page.getAppImgDir()+"/delete2.png",
                                                                                                    prompt: "Aceptar Falta total",
                                                                                                    height: 16,
                                                                                                    width: 16,
                                                                                                    grid: this,
                                                                                                    visible: true,
                                                                                                    click : function () {
                                                                                                        /*Tras preguntar por creacion incidencia falta total, se marca el registro
                                                                                                            para no volver a buscar y en caso necesario para la generación de incidencia.
                                                                                                            Requiere validar que no se han escaneado ninguno de sus bultos y que todos ellos
                                                                                                            tienen como acción el volver a buscar.
                                                                                                            Para la creacion de incidencia es necesario que el numero de bultos del proceso sea igual
                                                                                                            al numero de bultos de la expedicion, en caso contrario
                                                                                                            solo marcar como falta sin incidencia*/
                                                                                                           
                                                                                                            miGrid = this.parentElement.parentElement.parentElement;
                                                                                                                albsId = miGrid.getRecord(miGrid.getEventRow()).ALBS_ID;
                                                                                                                ccamId = miGrid.getRecord(miGrid.getEventRow()).CCAM_ID;
                                                                                                               
                                                                                                            isc.confirm(cargaCamionUIDS.getField("mensaje.confirm.generar.incTotal").title,
                                                                                                                              "marcarFaltaTotal(value)",
                                                                                                                              {toolbarButtons : [Dialog.YES, Dialog.NO, Dialog.CANCEL] }
                                                                                                            );
                                                                                                    }
                                                                                        });
                                                                                        recordFalta.addMember(aceptarFaltaTotal);

                                                                                } else if (record["ESTADO"] == "F") {

                                                                                        var quitarFaltaTotal = isc.ImgButton.create({
                                                                                                    showDown: false,
                                                                                                    showRollOver: false,
                                                                                                    layoutAlign: "center",
                                                                                                    src: Page.getAppImgDir()+"/delete_verde.png",
                                                                                                    prompt: "Quitar falta total",
                                                                                                    height: 16,
                                                                                                    width: 16,
                                                                                                    grid: this,
                                                                                                    visible: true,
                                                                                                    click : function () {

                                                                                                            miGrid = this.parentElement.parentElement.parentElement;
                                                                                                                albsId = miGrid.getRecord(miGrid.getEventRow()).ALBS_ID;
                                                                                                                ccamId = miGrid.getRecord(miGrid.getEventRow()).CCAM_ID;
                                                                                                           
                                                                                                            isc.confirm(cargaCamionUIDS.getField("mensaje.confirm.quitar.incTotal").title,
                                                                                                                              "quitarFaltaTotal(value)"
                                                                                                            ); 
                                                                                                    }
                                                                                        });
                                                                                        recordFalta.addMember(quitarFaltaTotal);
                                                                                }
                                                                                return recordFalta; 

                                                                    } else { 
                                                                        return null; 
                                                                            }       
                                                                    } else { 
                                                                        return null; 
                                                                    }       
                                                                                    }
                                                                    })



v9.1d_2014-02-22/PowerEdition Development SC and IExplrorer 10.0.9200 navigator, Eclipse Helios and Tomcat 7.0.28

Attached Images
File Type: jpg Captura1.JPG (123.8 KB)
File Type: jpg Captura2.JPG (122.4 KB)

faster loading/startup

$
0
0
Are there any suggestions/guidelines/best-practice blog/document for

a) identifying what's causing the *initial* startup of my smartgwt application to take a fairly long time (eg 30 seconds)?
b) fixing it.

(This problem does not appear if the user attempts to log in a second time -- presumably, the browser has cached a lot. Also, we're ussing tomcat for j2ee and Apache httpd for front-end http pages. )

Related to this, is there any document/blog you could point me to that would show how I can create some sort of "splash" screen while the SmartGWT application loads up so that I can distract and inform a user while the application loads? (Based on the documentation, I believe that "background loading using "image" tags are somehow meant to be used, but any examples/documentation would very much help.)

Other irrelevant, here's my standard additional background info:
======================
SmartGWT (not smartclient) Version: SmartClient Version: v8.3p_2012-11-26/PowerEdition Deployment (built 2012-11-26)
...
Browser: Chrome on Win 7
GWT SDK: 2.5.0rc2
Sun JDK 1.6.0_13
J2EE: Tomcat 6
OS: Centos 6.x
IDE: MyEclipse 10.6 with Google Plugin for Eclipse (3.1.0)

How to uncheck the checkbox column header on a ListGrid

$
0
0
3.1p

Hi,

I have a ListGrid with the SelectionAppearancce set to CHECKBOX.

Question:
After I have removed all rows from the grid how can I uncheck the check box in the header?

thanks...

Exception thrown when attempting to re-size ListGrid fields

$
0
0
SmartClient Version (ISC_Core.js' header)
Version v9.0p_2013-12-10 (2013-12-10)

Browser
Internet Explorer 10


Problem:
We've got a ListGrid inside a popup. The visible fields have their width set to "*". On Chrome and FireFox, the fields are getting re-sized accordingly, as we change the window's width. On IE 10, however, they do not get re-sized. We've tried simply setting each field width during run-time, after the grid was created, but we get the following exception:



(trying to set it from the console)


Observation
jQuery's browser object has the following attributes:
Code:

>> $j.browser
{
        msie : true,
        version : "7.0"
}

So I wonder if the browser version has something to do with the the problem. Maybe you guys could tell me more about it.

ListGrid Configs
Code:

{
ID: "chatInteractionsGrid",
height: "*",
headerHeight: 30,
groupByField: "interactionGroup",
groupStartOpen: "all",
showSortNumerals: false,
quickDrawAheadRatio: 4.0,
wrapCells: true, // allows cells to break a line when the data is too long.
fixedRecordHeights: true, // must be set to false so that cells with long data strings are not cut out.
canCollapseGroup: false, // true by default.
canResizeFields: false,
canAutoFitFields: false,
canReorderFields: false,
virtualScrolling: false,
showHeaderContextMenu: false,
alternateRecordStyles: true,
showAsynchGroupingPrompt: false,
emptyMessage: CONFIG.EMPTY_MESSAGE,
recordClick: function() {...},
recordDoubleClick: function() {...},
headerClick: function() {...},
rowOver: function() {...},
rowOut: function() {...},
selectionChanged: function() {...}
}

// Set programmatically
chatInteractionsGrid.groupByAsyncThreshold = this._chatGridGroupByAsyncT;
chatInteractionsGrid.setCellHeight(this._chatGridRowHeight);
chatInteractionsGrid.setFields(this._chatGridFields);
chatInteractionsGrid.setSort(this._chatGridSortSpecifiers);
chatInteractionsGrid.resizeField("name", "*");
chatInteractionsGrid.resizeField("type", "*");
chatInteractionsGrid.resizeField("waiting", "*");
chatInteractionsGrid.setWidth("100%");
chatInteractionsGrid.groupBy("interactionGroup");

HTML File
Code:

<!DOCTYPE html>
<html>
    <head>
        <title>{{#txt_chat_interactions#}}</title>
        <meta charset="UTF-8" />
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <link rel="stylesheet" type="text/css" href="{{$css_path}}/control.css">
        <link rel="stylesheet" type="text/css" href="{{$css_path}}/agui_common.css">

        <!-- The only scripts we'll be loading up in the html head are jQuery and browser tricorder-->
        <script type="text/javascript" src="../AGUI/js/browser_tricorder.js"></script>
        <script type="text/javascript" src="../GEN/js/jQuery/jquery-1.8.2.min.js"></script>
        <script type="text/javascript">var $j = jQuery.noConflict();</script>
    </head>

    <body class="popped-out-chat">
        <script type="text/javascript">
            // Add classes to the document body
            browserTricorder.addClasses();
        </script>

        <div id="sc_container">
            <span id="loading-profile-span">{{#txt_loading_chat_interactions#}}</span>
            <img class="loading-image" src="{{$image_path}}/loading.gif" width="32" height="32"/>
        </div>

        <div id="grid_container"></div>

        <!-- As a good practice, we load up scripts at the bottom of the document -->
        <script type="text/javascript" src="../GEN/js/parentpagebus.js"></script>
        <script type="text/javascript" src="../GEN/js/gen_PageCommunicator.js"></script>
        <script type="text/javascript" src="../AGUI/js/agent_rtapi_lib.js"></script>
        <script type="text/javascript" src="../GEN/js/countdownlatch/countdownlatch.js"></script>

        <!-- SmartClient -->
        <script>var isomorphicDir = "../GEN/js/isomorphic/";</script>
        <script type="text/javascript" src="../GEN/js/isomorphic/system/modules/ISC_Core.js"></script>
        <script type="text/javascript" src="../GEN/js/isomorphic/system/modules/ISC_Foundation.js"></script>
        <script type="text/javascript" src="../GEN/js/isomorphic/system/modules/ISC_Containers.js"></script>
        <script type="text/javascript" src="../GEN/js/isomorphic/system/modules/ISC_Grids.js"></script>
        <script type="text/javascript" src="../GEN/js/isomorphic/system/modules/ISC_Forms.js"></script>
        <script type="text/javascript" src="../GEN/js/isomorphic/system/modules/ISC_DataBinding.js"></script>
        <script type="text/javascript" src="../GEN/js/isomorphic/skins/Enterprise/load_skin.js"></script>

        <!-- Loading main js file -->
        <script type="text/javascript" src="../AGUI/js/chat_grid_popout.js"></script>
    </body>
</html>


Attached Images
File Type: png ie_version.PNG (2.7 KB)
File Type: png exception.PNG (3.9 KB)
File Type: png exception_manual_call.PNG (5.9 KB)

ISC_FileLoader for perfect caching on StartUp of login screen

$
0
0
Hello everyone,

in the Quick Start Guide, Chapter "Authentication and Authorization", Isomorphic suggests that one caches files while displaying the login-screen.

I tried to set this up and I think I succeeded now and wanted to share my approach.

Basic setup:
The login HTML looks like:
Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="stylesheet.css" />

<script type="text/javascript" language="javascript">var isomorphicDir = "lms/sc/";</script>
<script type="text/javascript" language="javascript" src="lms/sc/modules/ISC_FileLoader.js"></script>
<script type="text/javascript" language="javascript">FL.modulesDir = "modules/"; FL.defaultSkin = "Enterprise"; FL.cacheISC();</script>
</head>
<body>
<div id="box">
<form method="post" action="j_security_check">
        <label>Name:</label>
            <input type="text" name="j_username" />
        <label>Password:</label>
            <input type="password" name="password" />
            <input type="password" name="j_password" style="display: none;" />
            <input type="submit" value="Login" name="submit" class="submit" />
            <input type="reset" value="Cancel" class="submit" />
</form>
</div>
<SCRIPT>//'"]]>>isc_loginRequired
//
// Embed this whole script block VERBATIM into your login page to enable
// SmartClient RPC relogin.

while (!window.isc && document.domain.indexOf(".") != -1) {
    try {
       
        if (parent.isc == null) {
            document.domain = document.domain.replace(/.*?\./, '');
            continue;
        }
        break;
    } catch (e) {
        document.domain = document.domain.replace(/.*?\./, '');
    }
}

var isc = top.isc ? top.isc : window.opener ? window.opener.isc : null;
if (isc.Canvas) isc.RPCManager.delayCall("handleLoginRequired", [window]);
</SCRIPT>
</body>
</html>

When starting with an empty cache, the ISC_FileLoader will issue requests to e.g. http://myserver.com/myapp/sc/modules..._2014-03-30.js. Note the version in the query parameter. This is added automatically by the ISC_FileLoader.js from its own version.
When calling again with "URL bar"->Enter, for my config the *.js files won't be loaded again, as I configured a 1 year expiry in Apache httpd (see below).

2nd is the main jsp file:
Code:

<!DOCTYPE html>
<%!
/** Ant task extractsgwtversion sets the version of the lib here **/
String regex_replaced = "v9.1p_2014-03-30";
String version = "?isc_version=" + regex_replaced + ".js";
%>

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="gwt:property" content="locale=de">
    <% /** <!-- Any title is fine -->**/ %>
    <title>My title</title>
    <% /** <!-- IMPORTANT : You must set the variable isomorphicDir to [MODULE_NAME]/sc/ so that the SmartGWT resource are
          correctly resolved --> **/ %>       
       
        <script type="text/javascript">var isomorphicDir = "myApp/sc/";</script>

  <% /** <!-- Needed here as SuperDev Mode can't use "include" in gwt.xml -->**/ %>
        <script type="text/javascript" src="myApp/sc/modules/ISC_Core.js<% out.print(version); %>"></script>
       
        <script type="text/javascript" src="myApp/sc/modules/ISC_Foundation.js<% out.print(version); %>"></script>
        <script type="text/javascript" src="myApp/sc/modules/ISC_Containers.js<% out.print(version); %>"></script>
        <script type="text/javascript" src="myApp/sc/modules/ISC_Grids.js<% out.print(version); %>"></script>
        <script type="text/javascript" src="myApp/sc/modules/ISC_Forms.js<% out.print(version); %>"></script>
        <% /** Unused so far
        <script type="text/javascript" src="myApp/sc/modules/ISC_RichTextEditor.js"></script>
        <script type="text/javascript" src="myApp/sc/modules/ISC_Calendar.js"></script>
  **/ %>
        <script type="text/javascript" src="myApp/sc/modules/ISC_DataBinding.js<% out.print(version); %>"></script>
        <script type="text/javascript" src="myApp/sc/skins/Enterprise/load_skin.js<% out.print(version); %>"></script>
  <% /**
    <!--                                          -->
    <!-- This script loads your compiled module.  -->
    <!-- If you add any GWT meta tags, they must  -->
    <!-- be added before this line.                -->
    <!--                                          -->
  **/ %>
  <script type="text/javascript" src="myApp/myApp.nocache.js"></script>
  </head>
  <% /**
  <!--                                          -->
  <!-- The body can have arbitrary html, or      -->
  <!-- you can leave the body empty if you want  -->
  <!-- to create a completely dynamic UI.        -->
  <!--                                          -->
  **/ %>
  <body>
    <% /** <!--load the datasources--> **/ %>
    <script type="text/javascript" src="myApp/sc/DataSourceLoader?dataSource=.........................................long list..............."></script>
    <% /** <!-- OPTIONAL: include this if you want history support --> **/ %>
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
  </body>
</html>

Note that this uses JSP-comments that are not present in the final HTML in order to keep the result better looking.
In order to have the ISC_*.js-files served from the cache, the URL must look exact the same as in the login screen. While in the login screen the FileLoader takes care of the version-string, you have to do it on your own this time. As this is easily forgotten when done manually, I created an Ant-task for it:
Code:

...
        <path id="catalina-ant-classpath">
                <fileset dir="${tomcat-dir}/lib">
                        <include name="catalina-ant.jar" />
                        <include name="tomcat-coyote.jar" />
                        <include name="tomcat-util.jar" />
                </fileset>
                <fileset dir="${tomcat-dir}/bin">
                        <include name="tomcat-juli.jar" />
                </fileset>
                <fileset dir="${sgwtee.sdk}/../ant/">
                        <include name="xmltask.jar" />
                </fileset>
        </path>
...
...
        <!-- Used in Ant Task extractsgwtversion -->
        <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpathref="catalina-ant-classpath" />
...
...
        <target name="extractsgwtversion" description="Extract version from SmartGWT library">
                <xmltask>
                        <fileset file="${sgwtee.sdk}/maven/pom/smartclient-eval.xml" />
                        <copy path="//*[local-name()=&quot;version&quot;]/text()" property="sgwtee.buildversion" />
                        <!--
                        Weird XPath stuff because of the namespace in the POM-file. See:
                        http://www.oopsconsultancy.com/software/xmltask/#usage.print
                        http://stackoverflow.com/questions/21928260/xpath-query-local-name-fetch-tag-based-on-other-tags-value
                        http://www.xml.com/pub/a/2004/02/25/qanda.html
                        -->
                </xmltask>
                <fail message="You must provide a file to extract the SGWT version from.">
            <condition>
                <not>
                    <resourcecount count="1">
                        <fileset id="fs" dir="${sgwtee.sdk}/maven/pom" includes="smartclient-eval.xml"/>
                    </resourcecount>
                </not>
            </condition>
                        </fail>
                <fail unless="sgwtee.buildversion" message="You must supply a correct XPath expression in order to extract the version." />
                <echo>${sgwtee.sdk}/maven/pom/smartclient-eval.xml</echo>
                <echo>${sgwtee.buildversion}</echo>
                <replaceregexp file="war/myApp.jsp" match="String regex_replaced.*" replace="String regex_replaced = &quot;${sgwtee.buildversion}&quot;;" byline="true" />
        </target>

The task tries to take one of the SmartGWT-maven-pom files and extract the version from it. Hopefully it's the same version as in ISC_FileLoader.js. If there is a better way to extract the version number from the framework, any pointers are appreciated.
This way, after building and deploying a war, the browser should download the needed JS-files once on start-up and then never again.
My Apache httpd virtual host cache configuration looks like this:
Code:

<VirtualHost *:80>
    ServerAdmin webmaster@mydomain.com
#  DocumentRoot /var/www/centos.mydomain.com/public_html
    DocumentRoot /usr/share/apache-tomcat-7.0.52/myapp_centos
    RedirectMatch ^/$ /centos/MyApp.jsp
    RedirectMatch ^/centos$ /centos/MyApp.jsp
    RedirectMatch ^/centos/$ /centos/MyApp.jsp
    ServerName centos.mydomain.com
    TraceEnable Off
    ErrorLog  /var/www/centos.mydomain.com/logs/error_log
    CustomLog /var/www/centos.mydomain.com/logs/access_log combined

    <IfModule mod_jk.c>
        JkMount /centos/j_security_check worker1
        JkMount /centos/*.jsp worker1
        JkMount /centos/myapp/sc/IDACall worker1
        JkMount /centos/myapp/sc/DataSourceLoader worker1
        JkMount /centos/myapp/sc/HttpProxy worker1
        JkMount /centos/myapp/sc/ worker1
        JkMount /centos/ServletLogin worker1
        JkMount /centos/ServletLogout worker1
    </IfModule>

#  <Directory /var/www/centos.mydomain.com/public_html>
    <Directory /usr/share/apache-tomcat-7.0.52/myapp_centos>
        AllowOverride FileInfo AuthConfig Limit
        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
                #SetOutputFilter DEFLATE
                AddOutputFilterByType DEFLATE text/plain text/html application/json text/xml text/css text/javascript
               
        <Limit GET POST OPTIONS>
                Order allow,deny
                Allow from all
        </Limit>
                <Files *.cache.*>
                  ExpiresActive on
                  ExpiresDefault "now plus 1 year"
                </Files>
                <Files *.js>
                  ExpiresActive on
                  ExpiresDefault "now plus 1 year"
                </Files>
                <FilesMatch "\.(gif|jpe?g|png)$">
                  ExpiresActive on
                  ExpiresDefault "now plus 1 year"
                </FilesMatch>
                <Files *.css>
                  ExpiresActive on
                  ExpiresDefault "now plus 1 year"
                </Files>
                <Files *.nocache.*>
                  ExpiresActive on
                  ExpiresDefault "now"
                  Header merge Cache-Control "public, max-age=0, must-revalidate"
                </Files>
                <Files *.html>
                  ExpiresActive on
                  ExpiresDefault "now"
                  Header merge Cache-Control "public, max-age=0, must-revalidate"
                </Files>
                # Correct, but done in some other way by Tomcat
                <Files *.jsp>
                  ExpiresActive on
                  ExpiresDefault "now"
                  Header merge Cache-Control "public, max-age=0, must-revalidate"
                </Files>
        </Directory>
</VirtualHost>

This way, for me everything besides Compression of the DataSourceLoader servlet result is now working in the best (?) possible way.

Best regards, I hope this HowTo helps someone,
Blama

JPA2DataSource child relationship abstraction

$
0
0
Let me start by showing you the entity model:

1. VideoStream.java
Code:

@Entity
@Inheritance(strategy = InheritedType.Joined)
@DiscriminatorColumn(name = "discriminator")
public abstract class VideoStream {
  @Id
  private long id;

  @Column(insertable = false, updatable = false)
  private String discriminator;

  //more fields, etc
}

VideoStreamGenerated.java
Code:

@MappedSuperclass
public abstract class VideoStreamGenerated extends VideoStream {
 //some fields etc
}

VideoStreamLive.java
Code:

@Entity
@DiscriminatorValue(value = "Live")
public class VideoStreamLive extends VideoStreamGenerated {
  @OneToMany(mappedBy = "videoStream", cascade = { CascadeType.DETACH, CascadeType.REFRESH,  CascadeType.REMOVE }, fetch = FetchType.EAGER)
        private List<VideoStreamDestination> destinations = new ArrayList<>();

  //more fields
}

VideoStreamArchived.java
Code:

@Entity
@DiscriminatorValue(value = "Archived")
public class VideoStreamArchived extends VideoStreamGenerated {
  @OneToOne(mappedBy = "videoStream", cascade = { CascadeType.DETACH, CascadeType.REFRESH, CascadeType.REMOVE }, fetch = FetchType.EAGER)
        private VideoStreamDestination destination = new VideoStreamDestination();

  //more fields
}

VideoStreamDestination.java
Code:

@Entity
public class VideoStreamDestination {
  @ManyToOne
  @JoinColumn(updatable = false)
  private VideoStream videoStream;
}

VideoStream_JPA.ds.xml
Code:

<DataSource
        allowAdvancedCriteria="true"
        dropExtraFields="false"
        beanClassName="com.sncorp.gs2.jee.entities.VideoStream"
        ID="VideoStream_JPA"
        serverConstructor="com.sncorp.gs2.gsui.server.datasource.FetchOnlyJPA2DataSource"
        >
    <fields>
        <field name="id" primaryKey="true" type="sequence"/>
        <field name="discriminator" type="text"/>
        <field name="name" type="text"/>
        <field name="owner" type="text"/>
        <field name="description" required="false" type="text"/>
    </fields>
</DataSource>

VideoStreamGenerated_JPA.ds.xml
Code:

<DataSource
        allowAdvancedCriteria="true"
        dropExtraFields="false"
        beanClassName="com.sncorp.gs2.jee.entities.VideoStreamGenerated"
        ID="VideoStreamGenerated_JPA"
        inheritsFrom="VideoStream_JPA"
        >
    <fields>
        <!-- some fields -->
    </fields>
</DataSource>

VideoStreamLive_JPA.ds.xml
Code:

<DataSource
        allowAdvancedCriteria="true"
        dropExtraFields="true"
        beanClassName="com.sncorp.gs2.jee.entities.VideoStreamLive"
        ID="VideoStreamLive_JPA"
        serverConstructor="com.sncorp.gs2.gsui.server.datasource.FetchOnlyJPA2DataSource"
        inheritsFrom="VideoStreamGenerated_JPA"
        >
        <fields>
        <!-- some fields -->
        </fields>
</DataSource>

VideoStreamDestination_JPA.ds.xml
Code:

<DataSource
        allowAdvancedCriteria="true"
        dropExtraFields="false"
        beanClassName="com.sncorp.gs2.jee.entities.VideoStreamDestination"
        ID="VideoStreamDestination_JPA"
        serverConstructor="com.sncorp.gs2.gsui.server.datasource.FetchOnlyJPA2DataSource"
        >
    <fields>
        <!-- some fields -->
        <field name="videoStream" type="VideoStream_JPA"/>
    </fields>   
</DataSource>

Given this setup, I can fetch against VideoStream_JPA.ds.xml and the results will actually contain all of the values from the concrete VideoStream implementation. Which is highly desirable. However, when I fetch from VideoStreamDestination_JPA.ds.xml the child stream only contains the fields specifically declared in VideoStream_JPA.ds.xml and not the fields from the concrete VideoStream implementation.
Is there a mechanism where I can easily have it return the actual concrete classes fields in the child entity? In our use case, there are actually 3 concrete implementations of VideoStream.java, and I would like to be able to return all destinations that belong to a user in a single fetch, but I need the concrete VideoStream class to work with on the client.

Your help is greatly appreciated.
Viewing all 4756 articles
Browse latest View live


Latest Images