I have a couple of questions to be answered relating DAOs and GWT. I'm implementing a DAO class in the GWT project and I want to use it when a button is pressed, like this: (inside the .java GWT class)
lookUpButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
lookup();
}
});
... ... ...
private void lookup() {
PersonDao dao = new PersonDao();
Person m = dao.getPerson(3); //hard-coded the pk of the person
resultsFlexTable.setText(1, 0, m.toString());
I get two problems here, the first is practical, when I compile the project, I get an error and it just says "failed, try again" in my browser and I cannot run it.
The second question I have is this: Is it really a good practice to use a DAO in a GWT class given that it compiles directly into AJAX? Or should I send a request to a servlet that has said DAO and performs the data access itself?
Does GWT provide an easy to understand (for a beginner) and better way to access a MySQL database to get data?
(Context: I'm trying to build a basic search engine for a database and I need to access said data from a GWT widget. I'm learning Java web development, and I've learnt about .jsp, Servlets, and some more basic stuff like DAOs. For college, I have to build as a final project a web application which necessarily must be using the GWT Framework.) I've already tried the documentation but I cannot really get through this, I'm stuck.
This is not how gwt will work .... you can not simply write DAO layer call at UI side,
GWT is divided into 3 parts - to write the code
It should always be this way -
There are so many sample applications and examples available over sites.
There is one simple example here - https://github.com/davisford/gwt-demo/tree/master/src/main/java/com/example
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.