Hi friends,
I am a newbie to GWT.I am in a condition to develop a GWT
application. So i started my GWT journey by reading a book material
from PACKT publishers named "Google Web Toolkit Java Ajax
programming". I set my GWT environment and tested.It works pretty
well.Then i tried my first example application named as HelloGWT . I
created an application named as HelloGWT by using the below command
[color=red]applicationCreator.cmd -out <directory location>\GWTBook
\HelloGWT com.packtpub.gwtbook.HelloGWT.client.HelloGWT[/color]
Its created successfully.
Then i tried example application given in chapter 2 - creating a
random quote ajax application.I downloaded codes from PACKT publishers
home site.and placed that codes in corresponding folders as they said
in book.But its not working well when i run HelloGWT -shell. It shows
error as
[color=red]failed to load module
com.packtpub.gwtbook.hellogwt.HelloGWT
Unable to load module entry point class
com.packtpub.gwtbook1.hellogwt.client.HelloGWT (see associated
exception for details)
Failure to load module 'com.packtpub.gwtbook1.hellogwt.HelloGWT'[/
color]
I given below the codes that i tried with exact folder
structure.Please tell me where am i doing wrong thing in this one..
[color=green]HelloGWT\src\com\packtpub\gwtbook1\hellogwt\client
\HelloGWT.java[/color]
package com.packtpub.gwtbook1.hellogwt.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class HelloGWT implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final Label quoteText = new Label();
quoteText.setStyleName("quoteLabel");
// create the service
final RandomQuoteServiceAsync quoteService =
(RandomQuoteServiceAsync) GWT.create(RandomQuoteService.class);
// Specify the URL at which our service implementation is running.
ServiceDefTarget endpoint = (ServiceDefTarget) quoteService;
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "quotes");
Timer timer = new Timer() {
public void run() {
// create an async callback to handle the result.
AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
// display the retrieved quote in the label
quoteText.setText((String) result);
}
public void onFailure(Throwable caught) {
// display the error text if we cant get quote
quoteText.setText("Failed to get a quote.");
}
};
// Make the call.
quoteService.getQuote(callback);
}
};
// Schedule the timer to run once every second
timer.scheduleRepeating(1000);
RootPanel.get("slot1").add(quoteText);
}
}
[color=green]HelloGWT\src\com\packtpub\gwtbook1\hellogwt\client
\RandomQuoteService.java[/color]
package com.packtpub.gwtbook1.hellogwt.client;
import com.google.gwt.user.client.rpc.RemoteService;
public interface RandomQuoteService extends RemoteService {
public String getQuote();
}
[color=green]HelloGWT\src\com\packtpub\gwtbook1\hellogwt\client
\RandomQuoteServiceAsync.java[/color]
package com.packtpub.gwtbook1.hellogwt.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface RandomQuoteServiceAsync {
public void getQuote(AsyncCallback callback);
}
[color=green]HelloGWT\src\com\packtpub\gwtbook1\hellogwt\server
\RandomQuoteServiceImpl.java[/color]
package com.packtpub.gwtbook1.hellogwt.server;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.packtpub.gwtbook1.hellogwt.client.RandomQuoteService;
public class RandomQuoteServiceImpl extends RemoteServiceServlet
implements
RandomQuoteService {
private Random randomizer = new Random();
private static final long serialVersionUID = -1502084255979334403L;
private static List quotes = new ArrayList();
static {
quotes.add("No great thing is created suddenly — Epictetus");
quotes.add("Well done is better than well said — Benjamin
Franklin");
quotes.add("No wind favors he who has no destined port —
Montaigne");
quotes.add("Sometimes even to live is an act of courage —
Seneca");
quotes.add("Know thyself — Socrates");
}
public String getQuote() {
return (String) quotes.get(randomizer.nextInt(4));
}
}
[color=green]HelloGWT\src\com\packtpub\gwtbook1\hellogwt\public
\HelloGWT.html[/color]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- The HTML 4.01 Transitional DOCTYPE declaration-->
<!-- above set at the top of the file will set -->
<!-- the browser's rendering engine into -->
<!-- "Quirks Mode". Replacing this declaration -->
<!-- with a "Standards Mode" doctype is supported, -->
<!-- but may lead to some differences in layout. -->
<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<!-- -->
<!-- Any title is fine -->
<!-- -->
<title>HelloGWT</title>
<!-- -->
<!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<!-- -->
<script type="text/javascript" language="javascript"
src="com.packtpub.gwtbook1.hellogwt.HelloGWT.nocache.js"></script>
</head>
<!-- -->
<!-- The body can have arbitrary html, or -->
<!-- you can leave the body empty if you want -->
<!-- to create a completely dynamic UI. -->
<!-- -->
<body>
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1'
style="position:absolute;width:0;height:0;border:0"></iframe>
</body>
</html>
[color=green]HelloGWT\src\com\packtpub\gwtbook1\hellogwt\public
\HelloGWT.css[/color]
/** Add css rules here for your application. */
/** Example rules used by the template application (remove for your
app) */
.pc-template-btn {
display: block;
font-size: 16pt
}
#pc-template-img {
margin-top: 20px;
}
[color=green]HelloGWT\src\com\packtpub\gwtbook1\hellogwt
\HelloGWT.gwt.xml[/color]
<module>
<!-- Inherit the core Web Toolkit stuff.
-->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change
-->
<!-- the theme of your GWT application by uncommenting
-->
<!-- any one of the following lines.
-->
<inherits name='com.google.gwt.user.theme.standard.Standard'/>
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/>
-->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>
-->
<!-- Other module inherits
-->
<!-- Specify the app entry point class.
-->
<entry-point
class='com.packtpub.gwtbook1.hellogwt.client.HelloGWT'/>
<servlet path="/"
class="com.packtpub.gwtbook1.hellowgwt.server.RandomQuoteServiceImpl" /
>
<!-- Specify the application specific style sheet.
-->
<stylesheet src='HelloGWT.css' />
</module>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---