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
-~----------~----~----~----~------~----~------~--~---