Row Data not visible
Hi,<br />
<br />
I wrote a ScriptableDataSetAdapter to provide direct EJB Access. The logging produced is evidence that the data is received and processed during fetch method, but unfortunately the data is not displayed.<br />
<br />
The EjbDataSetAdapter below provides a method setRowData which is called during fetch and does the actual data setting.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public class EjbDataSetAdapter<T> extends ScriptedDataSetEventAdapter {
// removed constructor, members, initialisation and methods not required during fetch
/** maps all names of getters for generic <T> to the appropriate method using reflection.
* E.g. if T has a getter 'public String getName()' methods would map 'name' to the Method instance T.getName() **/
private Map<String,java.reflect.Method> methods;
protected void setRowValue(IDataSetInstance dataSet, IUpdatableDataSetRow row, T content) throws ScriptException {
IColumnMetaData cData = dataSet.getColumnMetaData();
if (content==null)
return;
int columnCount = cData.getColumnCount();
for(int i=1;i<=columnCount;i++) {
String name=cData.getColumnName(i);
if(isMatchingSimpleType(content,cData)) { // returns true for datasets with only one column whose Datatype matches the content class' simple name
log.debug("Setting '{}' as simple value to row column '{}' (id={})",new Object[]{content,name,1});
row.setColumnValue(name, content);
} else if(methods.containsKey(name)) {
Method method = methods.get(name);
try {
Object value = method.invoke(content, new Object[]{});
log.debug("Setting '{}' returned by method '{}' to row column '{}' (id={})",new Object[]{value,method.getName(),name,i});
row.setColumnValue(name, value);
} catch (Exception e) { // catches exceptions possible during reflection usage
throw new ScriptException(e.getMessage());
}
} else {
log.debug("Content type {} did not contain method for getting column {}",elementClass,name);
}
}
}
</pre>
<br />
In the rtpdesign i added a scripted datasource providing a dataset with one column named 'productName' of type String and added an concrete implementation of the above eventhandler. This implementation invokes "setRowValue" using:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>T content = "JDNXH.NB"</pre> with 'T' being of type java.lang.String.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
[ejb.EjbDataSetAdapter] isSimpleType=true,isSingleCoulmRow=true,hasMatchingTypes=true,columnTypeName=String,contentClass=String
[ejb.EjbDataSetAdapter] Setting 'JDNXH.NB' as simple value to row column 'productName' (id=1)
</pre>