-
Stuck with direct jngine
Hey guys,
I am having some trouble with directJNgine... I got the grid showing with extjs. I keep getting the error
"No method registered as 'getResults' in action 'PartDatabase'"
I have the java code below:
Code:
package com.softwarementors.extjs.djn.demo;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.softwarementors.extjs.djn.config.annotations.DirectMethod;
import com.softwarementors.extjs.djn.servlet.ssm.ActionScope;
import com.softwarementors.extjs.djn.servlet.ssm.Scope;
@ActionScope(scope=Scope.APPLICATION)
public class PartDatabase {
//List<Part> items = new ArrayList<Part>();
private static class Part {
@SuppressWarnings("unused")
public int id;
@SuppressWarnings("unused")
public String name;
@SuppressWarnings("unused")
public int size;
@SuppressWarnings("unused")
public String location;
@SuppressWarnings("unused")
public int cost;
private Part( int id, String name, int size, String location, int cost) {
this.id = id;
this.name = name;
this.size = size;
this.location = location;
this.cost = cost;
}
}
List<Part> parts = new ArrayList<Part>();
@DirectMethod
public List<Part> djn_getResults() {
Collections.addAll( parts,
new Part( 0001, "cs345", 56, "waterloo", 1518),
new Part( 0002, "cs346", 57, "india", 1251547),
new Part( 0003, "cs347", 561, "waterloo", 1517),
new Part( 0004, "cs346", 331, "moline", 1514),
new Part( 0001, "cs345", 56, "waterloo", 1518),
new Part( 0002, "cs346", 57, "india", 1251547),
new Part( 0003, "cs347", 561, "waterloo", 1517),
new Part( 0004, "cs346", 331, "moline", 1514),
new Part( 0001, "cs345", 56, "waterloo", 1518),
new Part( 0002, "cs346", 57, "india", 1251547),
new Part( 0003, "cs347", 561, "waterloo", 1517),
new Part( 0004, "cs346", 331, "moline", 1514),
new Part( 0001, "cs345", 56, "waterloo", 1518),
new Part( 0002, "cs346", 57, "india", 1251547),
new Part( 0003, "cs347", 561, "waterloo", 1517),
new Part( 0004, "cs346", 331, "moline", 1514)
);
return parts;
}
Yes, I did modify one of the examples
below is my js code:
Code:
Ext.onReady(function() { Ext.Direct.addProvider(Ext.app.REMOTING_API);
Ext.define('PartInfo', {
extend: 'Ext.data.Model',
fields: [{name:'id',type:'int'}, 'name', 'size', 'location', 'cost'],
proxy: {
type: 'direct',
api: {
//create: QueryDatabase.createRecord,
read: PartDatabase.getResults,
//update: QueryDatabase.updateRecords,
//destroy: QueryDatabase.destroyRecord
}
}
});
var store = Ext.create('Ext.data.Store', {
model: 'PartInfo',
autoLoad: true
});
var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false
});
// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
height: 450,
width: 700,
cls: 'grid',
title: 'Parts list',
store: store,
columns: [{
dataIndex: 'id',
width: 50,
text: 'ID'
}, {
dataIndex: 'name',
flex: 1,
text: 'Name',
allowBlank: false,
field: {
type: 'textfield',
allowBlank: false
}
}, {
dataIndex: 'size',
flex: 1.3,
text: 'Size',
allowBlank: false,
field: {
type: 'textfield',
allowBlank: false
}
},{
dataIndex: 'location',
flex: 1.3,
text: 'Location',
allowBlank: false,
field: {
type: 'textfield',
allowBlank: false
}
}, {
dataIndex: 'cost',
flex: 0.8,
text: 'Cost',
allowBlank: false,
field: {
type: 'textfield',
allowBlank: false,
vtype: 'alphaSpace'
}
}],
renderTo: Ext.getBody(),
/*plugins: [
rowEditing
],*/
/*dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
//creating, add items
items: [{
iconCls: 'add',
text: 'Add',
handler: function() {
rowEditing.cancelEdit();
// create a blank record from PersonalInfo
var record = Ext.create('PartInfo');
//insert at top
store.insert(0, record);
//edit at row 0
rowEditing.startEdit(0, 0);
}
}, {
iconCls: 'delete',
text: 'Delete',
handler: function() {
rowEditing.cancelEdit();
var sm = grid.getSelectionModel();
Ext.Msg.show({
title:'Delete Record?',
msg: 'You are deleting a record permanently, this cannot be undone. Proceed?',
buttons: Ext.Msg.YESNO,
icon: Ext.Msg.QUESTION,
fn: function(btn){
if(btn === 'yes') {
store.remove(sm.getSelection());
store.sync();
}
}
});
}
}]
}]
});
grid.on('edit', function(e) {
console.log(e);
e.context.record.save();
});*/
});
});
Finally for those concerned... this is a snippet of my web.xml file.
Code:
<init-param>
<param-name>demo.classes</param-name>
<param-value>
com.softwarementors.extjs.djn.demo.Poll,
com.softwarementors.extjs.djn.demo.TestAction,
com.softwarementors.extjs.djn.demo.Profile,
com.softwarementors.extjs.djn.demo.FormPostDemo,
com.softwarementors.extjs.djn.demo.DirectStoreDemo,
com.softwarementors.extjs.djn.demo.PartDatabase
</param-value>
</init-param>