aspose file tools*
The moose likes GWT and the fly likes Not able to access value set by one GWT module in another module. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Not able to access value set by one GWT module in another module." Watch "Not able to access value set by one GWT module in another module." New topic
Author

Not able to access value set by one GWT module in another module.

aditi singh
Greenhorn

Joined: Jun 17, 2013
Posts: 14
There are 2 GWT module with respective entry points and host page : Module A and Module B.
There is one common module with no entry point : Module C.
Module A sets a string value in Module C, say moduleC.setName("xyz").
Module B wants to get the value. say moduleC.getName();
On doing above the value Module B is getting is always null not the value set by module A.

Common module is packaged as jar and inherited in other two modules. what am I doing wrong?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

Common module is packaged as jar and inherited in other two modules. what am I doing wrong?

So do A and B share the same jar for module C or do they have their own copy?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
aditi singh
Greenhorn

Joined: Jun 17, 2013
Posts: 14
They have own copy of module C.
Module A includes common.jar in its build.xml and inherts common in gwt.xml file.
Similar is the case for moduleB.
How can I make both these module access the update field in common?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

They have own copy of module C.

So when you say C.setValue from A, A's copy of C is getting the value to reset. You need to call C.setValue on B's copy of C
aditi singh
Greenhorn

Joined: Jun 17, 2013
Posts: 14
how do I do that?
do I need to inherit module B in A tom access to module B's copy for C?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

Easiest would be expose a servlet on B which can be accessed by A to make a POST call with the new value
aditi singh
Greenhorn

Joined: Jun 17, 2013
Posts: 14
is there any other way of accessing values for cross communication between GWT modules.
or should the value be set somewhere else that is accesble by all modules?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

Are your modules hosted on the same server? If yes, you can consider an approach where the module would persist the value in some shared location. But you lose this facility if you host them across different servers. Thats why I suggested the servlet approach.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

You might also find this useful http://stackoverflow.com/questions/17273572/how-to-communicate-two-module-in-gwt which recommends the JS approach with certain conditions
aditi singh
Greenhorn

Joined: Jun 17, 2013
Posts: 14
apart from that, is there any way that A and B share the same copy of common?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

You keep asking for alternatives. Maybe it's time you explained what is wrong with the suggestions you have received till now
aditi singh
Greenhorn

Joined: Jun 17, 2013
Posts: 14
alright, servlet option is not suitable for us as we are not using a java container on web server (it is in place to route the async call to c++ backend).
JSNI is suitable but looks like javascript window obj has limitation on size of the data to be accessed. (I might go wrong here)
Hence, I asked for an approach where 2 GWT modules can share the same copy of common. This question clicked me from your 1st question "So do A and B share the same jar for module C or do they have their own copy? "
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

No java container? What are you using then?
You still havent told us
Maneesh Godbole wrote:Are your modules hosted on the same server?
aditi singh
Greenhorn

Joined: Jun 17, 2013
Posts: 14
yes they are on same server
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10376
    
    8

If you cannot be bothered to fully share the information we might need to help solve your problem, I doubt anyone will be willing to spend much volunteer time over it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not able to access value set by one GWT module in another module.