Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Migrating from 3.0 to 4.0

    Hello isomorphic,
    I have an issue with migrating my project from SmartGWT power 3.0 to SmartGWT 4.0d, at first I started to migrate to 3.1Power, the first issue I encoutred was all my ListGrid were empty, after a week of research I found out that in my DataSource, the name of my field were invalid for JavaScript, they contains a dot (ex : <field name="User.name"..) which transformed to un Javascript Identifier after permutations, I corrected the issue by replacing the "." by un underScore "_" and it worked so please think about correcting this issue or make sure users get erros or warning when they put an invalid name in their dataSources.
    anyway, now in 4.0 I'm experiencing the same issue but I will correct it since I know already where it's coming from, but a new issue show up only with the 4.0d relase, I have Menu generated dynamically from database from two table (Menu and MenuItem),I have a dataSource named MenuItem.ds.xml which contains all field I need, the difference between my functionnal project 3.0 and the current project 4.0 is the DSRequest generated by my UI component doesn't conaints a criteria and My MenuItems are not fetched, I'll post my code here for more explanation.

    my MenuItemDS.ds.xml
    Code:
    <DataSource
    	ID="MenuItemDS"
    	serverConstructor="com.rifak.customDataSource.SmartGwtDataSource"
    	beanName="iMenuItemRepository"
    	dropExtraFields="true"
    	dataFormat="iscServer">
    	<fields>
    		<field name="id"			type="sequence" hidden="true" primaryKey="true" />
    		
    		<field name="name"			type="text"		length="255" required="true"/>
    		<field name="description"	type="text"		length="255" />
    		<field name="icon"			type="text"		length="255" />
    		<field name="internalName"	type="text"		length="255" required="true"/>	
    		<field name="Menu"		type="text"		required="true"	displayField="name" foreignKey="MenuDS.id"	valueField="id"	valueXPath="Menu/id" />
    		<field name="Menu.name"	type="text"		length="255" canEdit="false" canSave="false" valueXPath="Menu/name" />
    		<field name="seqNo"			type="integer"/>
    
    		<field name="isActive"		type="boolean"/>
    	</fields>
    	
    	<operationBindings>
    		<operationBinding operationType="fetch" operationId="fetchMenuItemForUser">
    			<serverObject className="com.rifak.customDataSource.MenuItemSmartGwtDataSource" lookupStyle="new" />
    			<serverMethod>fetchMenuItemForUser</serverMethod>
    		</operationBinding>
    		<operationBinding operationType="fetch" operationId="customExport">
    			<serverObject className="com.rifak.customDataSource.SmartGwtDataSource" lookupStyle="new" />
    			<serverMethod>customExport</serverMethod>
    		</operationBinding>
    	</operationBindings>
    </DataSource>
    my MenuItemSmartGwtDataSource

    Code:
    package ch.ilem.weforum.base.service.customDataSource;
    
    import java.util.List;
    import java.util.Map;
    
    import javax.servlet.http.HttpServletRequest;
    
    import org.apache.catalina.core.ApplicationContext;
    import org.springframework.web.context.support.WebApplicationContextUtils;
    
    import com.rifak.model.MenuItem;
    import com.rifak.service.IMenuItemService;
    
    import com.isomorphic.datasource.DSRequest;
    import com.isomorphic.datasource.DSResponse;
    
    
    public class MenuItemSmartGwtDataSource extends SmartGwtDataSource {
    
    	
    	private IMenuItemService	MenuItemService;
    
    	/**
    	 * Fetch menu item for user.
    	 */
    	public DSResponse fetchMenuItemForUser(final DSRequest dsRequest, final HttpServletRequest servletRequest) throws Exception {
    
    		if ( getApplicationContext() == null ) {
    			setApplicationContext( WebApplicationContextUtils.getWebApplicationContext( dsRequest.getServletContext() ) );
    		}
    		appContext= getApplicationContext();
    		if ( MenuItemService == null ) {
    			MenuItemService = ( IMenuItemService ) getApplicationContext().getBean( "MenuItemService" );
    		}
    
    		@SuppressWarnings("unchecked")
    		final Map<String, Object> criteriaMap = dsRequest.getCriteria();
    	/**
    	 * Here the deference between  3.0 and 4.0, the criteriaMap in 3.0 contains value {"UserId:1,MenuId:3} 
             * but in 4.0d its empty so no MenuItem is fetched
    	 */
    		final Long UserId = new Long( criteriaMap.get( "UserId" ).toString() );
    		final Long MenuId = new Long( criteriaMap.get( "MenuId" ).toString() );
    
    		final List<MenuItem> menuItems = MenuItemService.fetchMenuItems( MenuId, UserId );
    
    		final DSResponse response = new DSResponse();
    		response.setSuccess();
    		response.setData( menuItems );
    
    		return response;
    	}
    }
    Browser : I'm using firefox 20 and Chrome 26 ,I'm using 6 permutations
    Framework : Spring , MVP4G , JPA , Hibernate , Bitronixand SmartGWT

    if you need more informations or code dont hesitate.
    PS : sorry if my english is terrible but it's not my first language, if there is a French Forum it'll be great
    Thank you

    #2
    There are already warnings when you use bad field names. Also, for completeness, these field names were never allowed in any previous version, but the failures they caused were more subtle and you may not have noticed them.

    We can't do much with this partial code. If you believe you've isolated this to a framework issue, please put together a ready-to-run, standalone test case and we can take a look.

    Also, remember to always post your *full* SmartGWT version (not just 4.0).

    Also, wrong forum (SmartClient instead of SmartGWT) - we'll move the thread.

    Comment

    Working...
    X