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

Hibernate 4.1 not working outside showcase

$
0
0
This hibernate 4.1 example is not reading the associated key.

There were two problems with the extant code.

1) The use of Datasource.get(String) did not work at all.

2) The valueXPath display field exactly as supplied in the city data source (below) does not display. This is the critical issue. The code as copied almost directly from the showcase should work. The showcase appears to mask a problem.


Code:



        /**
        view plainprint?
/*
 * Isomorphic SmartGWT web presentation layer
 * Copyright 2000 and beyond 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.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.data.DataSource; 
import com.smartgwt.client.types.ListGridEditEvent; 
import com.smartgwt.client.util.KeyCallback;
import com.smartgwt.client.util.Page;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas; 
import com.smartgwt.client.widgets.IButton; 
import com.smartgwt.client.widgets.events.ClickEvent; 
import com.smartgwt.client.widgets.events.ClickHandler; 
import com.smartgwt.client.widgets.grid.ListGrid; 
import com.smartgwt.client.widgets.grid.ListGridField; 
import com.smartgwt.client.widgets.layout.VLayout; 
 
import com.google.gwt.core.client.EntryPoint; 
import com.google.gwt.user.client.Window;
//import com.isomorphic.datasource.DataSource;
 
public class MyDemo3b implements EntryPoint { 
        DataSource hbdb;
    @Override 
    public void onModuleLoad() { 

                KeyIdentifier debugKey = new KeyIdentifier();
                debugKey.setCtrlKey(true);
                debugKey.setKeyName("D");

                Page.registerKey(debugKey, new KeyCallback() {
                        public void execute(String keyName) {
                                SC.showConsole();
                        }
                });
               
   
        final ListGrid listGrid = new ListGrid(); 
  //    Window.alert("helloa");
    //  DataSource as written using set statement does not work
        hbdb = new DataSource();
      hbdb.setID("cityManyToOneSimpleHB");
   
                     
        listGrid.setDataSource(hbdb); 
        listGrid.setWidth(700); 
      //  Window.alert("hellob");
        listGrid.setHeight(224); 
        listGrid.setShowFilterEditor(true); 
        listGrid.setAlternateRecordStyles(true); 
        listGrid.setAutoFetchData(true); 
        listGrid.setDataPageSize(50); 
        listGrid.setCanEdit(true); 
        listGrid.setEditEvent(ListGridEditEvent.CLICK); 
        listGrid.setCanRemoveRecords(true); 
        listGrid.setFields(new ListGridField("cityName", "City"), new ListGridField("country", "Country")); 
 
        IButton newButton = new IButton("Add New"); 
        newButton.addClickHandler(new ClickHandler() { 
            public void onClick(ClickEvent event) { 
                listGrid.startEditingNew(); 
            } 
        }); 
    //    Window.alert("helloc");
 
        VLayout layout = new VLayout(); 
        layout.setWidth100();
        layout.addMember(listGrid); 
        layout.addMember(newButton); 
 
        layout.draw(); 
    } 
 
}

Code:

<DataSource
    ID="cityManyToOneSimpleHB"
    serverType="hibernate"
    beanClassName="com.smartgwt.sample.mydemo3b.server.CityManyToOneSimple"
    schemaBean="com.smartgwt.sample.mydemo3b.server.CityManyToOneSimple"
>
    <fields>
        <field name="countryName"  type="text"    hidden="true"  valueXPath="country\countryName"/>
        <field name="country"      title="Country" canEdit="true"  displayField="countryName"
                foreignKey="countryManyToOneSimpleHB.countryId"
        />
    </fields>
</DataSource>


Be sure your post includes:

1. SmartClient Version: v9.1p_2014-04-09/Pro Deployment (built 2014-04-09)

2. all InternetExplorer 8-11, Chrome 29, Firefox 29


4. for any problem processing a server response, the actual response as shown in the RPC tab in the Developer Console
[
{
affectedRows:0,
data:[
{
countryName:"Lithuania",
country:1,
cityId:1,
cityName:"Vilnius"
},
{
countryName:"Latvia",
country:2,
cityId:2,
cityName:"Riga"
},
{
countryName:"Estonia",
country:3,
cityId:3,
cityName:"Tallinn"
},
{
countryName:"Lithuania",
country:1,
cityId:4,
cityName:"Kaunas"
},
{
countryName:"United States of America",
country:4,
cityId:5,
cityName:"New York"
},
{
countryName:"United States of America",
country:4,
cityId:6,
cityName:"Washington"
}
],
endRow:6,
invalidateCache:false,
isDSResponse:true,
operationType:"fetch",
queueStatus:0,
startRow:0,
status:0,
totalRows:6
}
]




Posts with incomplete information are much more likely to be ignored.

Attached Images
File Type: jpg screen5.jpg (60.8 KB)

Viewing all articles
Browse latest Browse all 4756

Trending Articles