• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is dwr?

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34656
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In attempt to answer what is DWR, I've quoted part of the book description from Amazon.

The Ajax craze is sweeping the world, and there is no shortage of libraries from which to choose to make it all easier to develop. One of those libraries has risen near the top in the Java space, and that library is DWR. DWR, or Direct Web Remoting, allows you to treat your Java classes running on the server as if they were local objects running in the browser, bringing the full power of your server-side business logic to the client without the usual problems that entails
 
akhilesh pandey
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes we can call java object from browser. But is really it execure on client machine? I think it can not, it need to go server sytem and execute there. How it is possible to run on client machine? Can you explain it?
Akhilesh
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't run on the client. No one said it did. DWR uses Ajax and servlet technology to allow a sort of RPC from the browser to Java classes on the server.
 
Frank Malinowski
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
It doesn't run on the client. No one said it did. DWR uses Ajax and servlet technology to allow a sort of RPC from the browser to Java classes on the server.


What types of variables does it have the ability to send to and receive from the server? Primitives? Arrays? Multi-dimensional data structures? I just want to get a feel for the depth and breadth of the classes and methods it will be able to interact with.

Thanks,
Frank
 
Ghulam Rasool Raja
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are able to send and recieve primitives, arrays, even you can recieve a list of objects / beans from the server. You can configure it in your dwr.xml using converter tag to convert a java bean into a javascript object. You have to write some getter methods in your jsp to access the data in the object returned.
 
Tina Ma
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a DWR API online to refer to?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34656
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sreerupa basu:
Is there a DWR API online to refer to?

The JavaDoc API
 
Frank Zammetti
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's perhaps not the most important point, but this statement: "You have to write some getter methods in your jsp to access the data in the object returned." isn't really accurate.

When DWR marshalls a Java object to Javascript, say an instance of this class:

public class Person {
private String firstName;
private String lastName;
public String getFirstName() { return firstName; }
public String getLastName() { return lastName; }
}

...what you get in Javascript is this:

{ firstName: "xxx", lastName: "yyy" }

...where xxx and yyy are the values of the fields obviously. So, to access them, you have only to do:

o.firstName

That assumes the variable o represents that object shown there. There's no methods present, and there's no need to write any methods to get the data, you simply access it directly like this.

I suspect that's what you meant ot say Ghulam, just wanted to clarify for anyone else reading this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic