Hello
I am trying to add a new item using formlayout form to JPAContainer in vaddin 7. I use this code snippet:
String paramDAO = "PersonDAO"; //this parameter can be acquired from url, http request, data file and etc
Class<?> TC = null; //DAO class
InitialContext ic;
ic = new InitialContext();
TO = ic.lookup("java:app/MyDAOProject/"+paramDao);
// PersonDAO class extends JPAContainer<PersonEntity>
container = (JPAContainer<?>) TO;
T = container.getEntityClass();
if(event.getButton() == newButton)
{
final EntityItem newRecord = container.createEntityItem(T.newInstance()); //eclipse shows syntax error here
final EditorWindow editor = new EditorWindow(newRecord, T,
visibleColumns, this.entytiPropFactory);
editor.setCaption("New record");
editor.addListener(new EditorSavedListener()
{
@Override
public void editorSaved(EditorSavedEvent event)
{
container.addEntity(newRecord.getEntity()); //eclipse shows syntax error here
new Notification("New record created.", null, Notification.Type.TRAY_NOTIFICATION, true)
.show(Page.getCurrent());
}
}
);
UI.getCurrent().addWindow(editor);
}
The main idea is that I want to create a unified vaadin table with editing form that fits for mostly entities (data base tables) in my project. So I pass dao object name as string parameter (don’t ask why) and then i lookup it through jndi service. The dao object is tied with entity and extends JPAcontainer class. This approach worked perfectly in Vaadin 6 version with JPAContainer 2.2.0 but after migrating to Vaadin 7 and JPAContainer 3.0.0 eclipse throws me a syntax error in these lines (errors are in comments respectively every line below):
final EntityItem newRecord = container.createEntityItem(T.newInstance());
//The method createEntityItem(capture#9-of ?) in the type JPAContainer<capture#9-of ?> is not applicable for the arguments (capture#10-of ?)
container.addEntity(newRecord.getEntity());
//The method addEntity(capture#12-of ?) in the type JPAContainer<capture#12-of ?>
Also I try to compile this code directly from command-line using mvn install and mvn package commands I got errors too:
[INFO]
[ERROR]
COMPILATION ERROR :
[INFO]
[ERROR]
/workspace/HISproject/src/main/java/com/hisdainava/views/ClassificatorAppView.java:[298,44]
error: method createEntityItem in class JPAContainer cannot be applied to given types;
[ERROR]
required: CAP#1
found: Object
reason: actual argument Object cannot be converted to CAP#1 by method invocation conversion
where T is a type-variable:
T extends Object declared in class JPAContainer
where CAP#1 is a fresh type-variable:
CAP#1 extends Object from capture of ?
/workspace/HISproject/src/main/java/com/hisdainava/views/ClassificatorAppView.java:[308,19]
error: method addEntity in class JPAContainer cannot be applied to given types;
[INFO]
2 errors
[INFO]
[INFO]
[INFO]
BUILD FAILURE
[INFO]
[INFO]
Total time: 6.432s
[INFO]
Finished at: Fri Jul 05 15:24:49 EEST 2013
[INFO]
Final Memory: 34M/259M
[INFO]
[ERROR]
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project ELIView: Compilation failure: Compilation failure:
[ERROR]
/workspace/HISproject/src/main/java/com/hisdainava/views/ClassificatorAppView.java:[298,44]
error: method createEntityItem in class JPAContainer cannot be applied to given types;
[ERROR]
required: CAP#1
[ERROR]
found: Object
[ERROR]
reason: actual argument Object cannot be converted to CAP#1 by method invocation conversion
[ERROR]
where T is a type-variable:
[ERROR]
T extends Object declared in class JPAContainer
[ERROR]
where CAP#1 is a fresh type-variable:
[ERROR]
CAP#1 extends Object from capture of ?
[ERROR]
/workspace/HISproject/src/main/java/com/hisdainava/views/ClassificatorAppView.java:[308,19]
error: method addEntity in class JPAContainer cannot be applied to given types;
[ERROR]
→ [Help 1]
[ERROR]
[ERROR]
To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR]
Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR]
For more information about the errors and possible solutions, please read the following articles:
[ERROR]
[Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Please help me to solve this problem. Is this a mistake in my project architecture or methods I am using or this is a bug of JPAContainer?