I am a new bee to Vaadin. Trying to develop a application. My scenario is like below. I have a page where i am displaying a table and a detail vie below that.The table displays only 4 feilds for a user object. I am able to display all the records from my source on the table with no issues.
The details section is a tab sheet with four tabs. When a use clicks on a record in the table. I need to get the details of that user from the source and display the details spread across these four tabs in the details section. This is what i am unable to achieve.
I went thru several posts and got to know that i need to use separate for each tab. But i was not successful in doing that.
Can any one guide me how to get the above scenarios achieved. If you can guide me to a sample code that would also help.
Forms can only be bind to Items not Containers. Use an SelectionListener to react on selection of rows in the table, get the corresponding Item and set that as ItemDatasource to the form.
Here is what i am doing. The below is my userdetails class which is a tabsheet.
public class UserDetailsTab extends TabSheet {
Panel generalInfoPanel = new Panel();
public UserDetailsTab() {
TabSheet.Tab userView_Gen_Info = addTab(getGeneralInfoTab());
}
public UserGeneralInfoTabForm getGeneralInfoTab() {
if(generalInfoTab == null)
return new UserGeneralInfoTabForm();
return generalInfoTab;
}
public void setDataSource(String userId) {
UserDetailContainer ds = UserDetailContainer.getUserDetailsByUserId(userId);
UserDetail userDetails = ds.getIdByIndex(0);
generalInfoTab.setItemDataSource(ds.getItem(userDetails));
}
}
And in my Table i added a valuechange Listener in which i am able to get the correct record that was selected form the table. Now based on this selected item i have to retrieve the details of this record which i am doing thru UserDetailContainer which is sucessful as well.
Only issue and getting here is when i am setting the item to the generalInfoTab (last line in the above code)
I get an error as below:
Jun 13, 2012 6:44:43 PM com.vaadin.Application terminalError
SEVERE: Terminal error:
com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.NullPointerException
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:162)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1166)
at com.vaadin.ui.AbstractField.fireValueChange(AbstractField.java:891)
at com.vaadin.ui.AbstractField.setValue(AbstractField.java:529)
at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:666)
at com.vaadin.ui.AbstractSelect.changeVariables(AbstractSelect.java:475)
at com.vaadin.ui.Table.changeVariables(Table.java:2023)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1297)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1217)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:733)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:483)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at com.imperativix.web.ui.UserDetailsTab.setDataSource(UserDetailsTab.java:81)
at com.imperativix.web.ui.UserTable$1.valueChange(UserTable.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:490)
Ok i corrected it now. Now i am not getting any error. But the form is not getting populated with the values from the Item i am setting to the form. Not sure what went wrong with my program.