Announcement

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

    SGWT.mobile dynamicFetch

    Hi,

    Trying to use dynamicFetch operation using SGWT.mobile in the same way I use it in desktop version.

    I am setting the fetchOperation on a TableView using :

    Code:
    setFetchOperation("dynamicFetch");
    Calling the fetch as follows:

    Code:
    		Map<String,Object> requestParameters = new HashMap<String,Object>();
    		requestParameters.put("dynamicSelectClause",dynamicSelectClause);
    		requestParameters.put("dynamicGroupClause",dynamicGroupClause);
    		
    		DSRequest rq = new DSRequest();
    		rq.setParams(requestParameters);
    
            tableAccounting.fetchData(c1, new DSCallback(){
    			public void execute(DSResponse response,Object rawData,DSRequest request) {
    				String ids = null;
    				Record records[] = response.getData();
    				if (records!=null&&records.length==1){
    					ids = records[0].getAttribute("id_person_owners");
    				}
    				applySecurity(ids,null);
    			}
            },rq);
    with the ds portion to declare custom dynamic fetch as follows
    Code:
    		<operationBinding operationType="fetch" operationId="dynamicFetch">
    	        <serverObject lookupStyle="new" className="be.celerity.moon.server.dmi.DynamicSQLDMI" />
    		    <selectClause>
    		        $rawValue.dynamicSelectClause
    		    </selectClause>
    		    <tableClause>
    		        $defaultTableClause
    		    </tableClause>
    		    <whereClause>
    				$defaultWhereClause				
    		    </whereClause>
    		    <groupClause>  
    				$rawValue.dynamicGroupClause
            	</groupClause> 
    		</operationBinding>	
        </operationBindings>
    and the server code to do the fetch as follows:
    Code:
    package be.celerity.moon.server.dmi;
    
    import javax.servlet.http.HttpServletRequest;
    
    import com.isomorphic.datasource.DSRequest;
    import com.isomorphic.datasource.DSResponse;
    
    
    public class DynamicSQLDMI {
    	
        public DSResponse fetch(DSRequest dsRequest) {
        	
            DSResponse dsResponse = new DSResponse();
    
            HttpServletRequest request = dsRequest.getHttpServletRequest();
            
            String dynamicSelectClause = (String)request.getParameter("dynamicSelectClause");
            if (dynamicSelectClause!=null) dsRequest.addToTemplateContext("dynamicSelectClause",dynamicSelectClause);
    
            String dynamicTableClause = (String)request.getParameter("dynamicTableClause");
            if (dynamicTableClause!=null) dsRequest.addToTemplateContext("dynamicTableClause",dynamicTableClause);
            
            String dynamicWhereClause = (String)request.getParameter("dynamicWhereClause");
            if (dynamicWhereClause!=null) dsRequest.addToTemplateContext("dynamicWhereClause",dynamicWhereClause);
    
            String dynamicOrderClause = (String)request.getParameter("dynamicOrderClause");
            if (dynamicOrderClause!=null) dsRequest.addToTemplateContext("dynamicOrderClause",dynamicOrderClause);
            
            String dynamicGroupClause = (String)request.getParameter("dynamicGroupClause");
            if (dynamicGroupClause!=null) dsRequest.addToTemplateContext("dynamicGroupClause",dynamicGroupClause);
    
            try {
    			dsResponse = dsRequest.execute();
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    
            return dsResponse;
    
        }
    
    }

    The problem is that the server code (dmi) never gets called.

    Thanks for your help, Ben.
    Last edited by bda@celerity.be; 10 Apr 2014, 02:38.

    #2
    Hi Ben,

    did you deploy the war or copied you code and restarted the app server?
    Have look at the server log. It usually tells you when it didn't find a class or method it expected and defaulted to standard behaviour.
    You can also see which operation ID the DSRequest targets.
    Besides that you might like to include the methodName in your operation binding to be perfectly sure.

    It should make no difference whether you call the operation from desktop or mobile for the server side.

    Best regards,
    Blama

    Comment

    Working...
    X