Can you confirm (server side) that the array of objects isn't null? If so this sounds like GWT might not be able to handle objects of type Forum.
GWT can only handle objects declared under the client side packages and wont be able to handle any database POJO object declared at server level. For some more background info: http://www.dotnetguru2.org/bmarchesson/index.php?p=786&more=1&c=1&tb=1&pb=1 You'll need to create some form of client side DTO object alternatively if you can move over to using Hibernate you can use a package called Hibernate4GWT I've also compiled a tutorial on this at: http://eggsylife.blogspot.com/2007/11/hibernate-spring-google-web-toolkit.html That is part two of the tutorial with my DTO objects. On Apr 8, 4:38 pm, Cryssyenddo <[email protected]> wrote: > I solved the problem...I made a typo error at my impl class. > I've made the corrections and it works now. > > I'm wondering, how should i call a service properly? In this piece of > code below, i'm trying to get an array Forum object which the data i > retrieved form my database and then i intend topopulate my panel with > the buttons with each representing a forum. > > I've double checked that my database wasn't empty. But I kept hitting > a null exception. So i'm wondering did i call the services the right > way. Here are the two methods i used; first for calling the RPC to get > all the forum records and the second method to populate the panel with > forum buttons: > > /** > * Method to retrieve list of forums from server > */ > protected void getForums() { > if(services == null){ > services = (DiscussionBoardServiceAsync)GWT.create > (DiscussionBoardService.class); > } > > ServiceDefTarget serviceURL = (ServiceDefTarget) services; > String address = GWT.getModuleBaseURL() > +"DiscussionBoardServices"; > serviceURL.setServiceEntryPoint(address); > > AsyncCallback<Forum[]> callback = new AsyncCallback<Forum[]>() > { > public void onFailure(Throwable caught) { > String details = caught.getMessage(); > Window.alert(details); > } > public void onSuccess(Forum[] result) { > buildMainPage(result); > } > }; > > services.getForums(user.getUserClass(), callback); > } > > /** > * Method to build and display main page display contents > * @param receivedForumList > */ > private void buildMainPage(Forum[] receivedForumList){ > // Initialise all components > discussionBoardTitle = new Label("v-Care Discussion Board > Title"); > main_Panel = new VerticalPanel(); > main_Selection = new HorizontalPanel(); > forumList = new Forum[receivedForumList.length]; > forumButtons = new Button[receivedForumList.length]; > > pageFlag = PAGE_MAIN; > > forumButtonListsner = new ForumButtonListener(); > > main_Panel.setCellHorizontalAlignment(discussionBoardTitle, > HasHorizontalAlignment.ALIGN_CENTER); > > for(int i =0; i<receivedForumList.length; i++){ > forumButtons[i] = new Button(receivedForumList[i].getForumName > ()); > forumButtons[i].addClickListener(forumButtonListsner); > forumButtons[i].setStyleName("forumButton"); > forumList[i] = receivedForumList[i]; > > main_Selection.add(forumButtons[i]); > } > > // If user is admin then insert admin options > if (userClass <= 2) { > // Create admin buttons > admin_AddForumButton = new Button("Add Forum"); > > // Add button listeners > admin_AddForumButton.addClickListener(this); > > // Add admin options > main_Panel.insert(main_AdminOptions, 1); > } > > RootPanel.get().clear(); > RootPanel.get().add(main_Panel); > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
