You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alicia Sánchez-Mora <al...@gmail.com> on 2007/03/08 15:05:09 UTC

GUI implementation with tomcat

Hi, after one week fighting with the same I decided to ask

I am implementig a web service class and a client in java, using tomcat and
axis and I have to create a GUI. When I start the application a  window has
to appear and  every time the client calls a method in the service class a
new message on the window must be displyed. The problem is that every time I
call a method in the service class and I add a new message to the List of
messages  nothing appears on the window.

I have the class Window to initialize the GUI and I call (locally) an
instance  of this class from my service class. The problem, or at least
what I think the problem is, is that every time I make a call the service
container unloads my class and nothing (related to my window) is
initiallized. The idea is to run my window only one time, when tomcat
starts. To do that I should specify somehow on the web.xml file to do this:
write a jsp class, put it somewhere and call the initialization of the
window..

Any more concrete suguestion or solutions?

Thanks in advance,

Alicia

Re: GUI implementation with tomcat

Posted by Alicia Sánchez-Mora <al...@gmail.com>.
Hi kristian,

thank you for your explanation but still the topic is not clear for me. As
far I understand from your answer, I have to run the Frame fom my Client.
ok, I did it. Then, each time I call a service  I try to add a new message
on my window, both from the service class and form the client class, and I
still have th same problem: or nothing apperas or i have to create a new
Frame for each message (for each call)

Any clue?

thanks in advance

Alicia

On 3/8/07, Kristian Rink <kr...@zimmer428.net> wrote:
>
>
> Alicia;
>
> first off; thanks for your explanation and pointing things out a little
> more. :) I think I slightly understand the structure of your
> application but honestly I doubt it will work out this way:
>
>
> ["Alicia Sánchez-Mora" <al...@gmail.com> @ Thu, 8 Mar 2007
> 16:24:33 +0100]
>
> > public class ListItems  {
> >   List listOptions;
> >   private static ListItems instance;
> >   private Frame f;
>
> This is java.awt.Frame, isn't it?
>
> In my opinion (list people feel free to correct me if I'm all too wrong
> here), the issue with your application is that you try to instantiate
> and access the java.awt.Frame object from within code running on your
> server but you actually want it to appear and work on your client. This
> is not going to work out. To do so, you need to have the client code
> (containing the Frame stuff) run locally on the client - the fact that
> some window does actually appear is likely due to that server and
> client runs on the same machine in your setup.
>
> To achieve the desired effect, you should really try separating the web
> service and the window connecting to it into two different, separate
> applications (a webapp hosting the service, and a desktop application
> or an applet running the window/frame). Then, you need to implement
> logic in your client to remotely call the web service and possibly get
> some meaningful data from it.
>
> Don't know if this really is a helpful answer, feel free to ask if you
> need more assistance. :)
>
> Cheers,
> Kristian
>
> --
> Kristian Rink * http://zimmer428.net * http://flickr.com/photos/z428/
> jab: kawazu@jabber.ccc.de * icq: 48874445 * fon: ++49 176 2447 2771
> "One dreaming alone, it will be only a dream; many dreaming together
> is the beginning of a new reality." (Hundertwasser)
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: GUI implementation with tomcat

Posted by Kristian Rink <kr...@zimmer428.net>.
Alicia;

first off; thanks for your explanation and pointing things out a little
more. :) I think I slightly understand the structure of your
application but honestly I doubt it will work out this way:


["Alicia Sánchez-Mora" <al...@gmail.com> @ Thu, 8 Mar 2007
16:24:33 +0100]

> public class ListItems  {
>   List listOptions;
>   private static ListItems instance;
>   private Frame f;

This is java.awt.Frame, isn't it?

In my opinion (list people feel free to correct me if I'm all too wrong
here), the issue with your application is that you try to instantiate
and access the java.awt.Frame object from within code running on your
server but you actually want it to appear and work on your client. This
is not going to work out. To do so, you need to have the client code
(containing the Frame stuff) run locally on the client - the fact that
some window does actually appear is likely due to that server and
client runs on the same machine in your setup.

To achieve the desired effect, you should really try separating the web
service and the window connecting to it into two different, separate
applications (a webapp hosting the service, and a desktop application
or an applet running the window/frame). Then, you need to implement
logic in your client to remotely call the web service and possibly get
some meaningful data from it. 

Don't know if this really is a helpful answer, feel free to ask if you
need more assistance. :)

Cheers,
Kristian

-- 
Kristian Rink * http://zimmer428.net * http://flickr.com/photos/z428/
jab: kawazu@jabber.ccc.de * icq: 48874445 * fon: ++49 176 2447 2771
"One dreaming alone, it will be only a dream; many dreaming together
is the beginning of a new reality." (Hundertwasser)

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: GUI implementation with tomcat

Posted by Alicia Sánchez-Mora <al...@gmail.com>.
Hi Kristian,

here I send you some short pieces of my code to make the arquitecture of my
application clearer :)

This is the class to initilize the window

public class ListItems  {
  List listOptions;
  private static ListItems instance;
  private Frame f;


  public static ListItems getInstance () {
      if(instance == null) {
         instance = new ListItems ();
      }
      return instance;
   }
public  void initWindow(int i) {

if (i== 0){
      f = new Frame();
      listOptions = new List();
      f.add(listOptions);
     listOptions.addItem("reqConn");
      f.pack();
      f.setVisible(true);}
if (i!=0){

     listOptions.addItem("reqConn2");
     f.add(listOptions);
}


  }


This is the web services class:

*public* *class* SDMInterfaceImpl  *extends* Thread *implements*SDMInterface{

public ListItems list = ListItems ();

*public* SDMInterfaceImpl() {   }

** *public* *void* init(){
*
*list.getInstance();
}

*public* String reqConn(String src, String dst){

  String result = "";
  list.initWindow(0);
                    *return* result;
}

*public* String reqConn2(String src, String dst){

  String result = "";
  list.initWindow(1);
                    *return* result;
}

The client will call the methods reqConn and reqConn2 and on the window
should appear these 2 messages:
reqConn
reqConn2

Is it clearer now? Do not look at the class, it is a simplification to show
you how my application tries to work

regards,

Alicia

On 3/8/07, Kristian Rink <kr...@zimmer428.net> wrote:
>
>
> Alicia;
>
>
> ["Alicia Sánchez-Mora" <al...@gmail.com> @ Thu, 8 Mar 2007
> 15:05:09 +0100]
>
> > I have the class Window to initialize the GUI and I call (locally) an
> > instance  of this class from my service class. The problem, or at
> > least what I think the problem is, is that every time I make a call
> > the service container unloads my class and nothing (related to my
> > window) is initiallized. The idea is to run my window only one time,
> > when tomcat starts. To do that I should specify somehow on the
> > web.xml file to do this: write a jsp class, put it somewhere and call
> > the initialization of the window..
>
>
>
> honestly, the architecture of your overall application by now seems
> somewhat obscure to me. What exactly do you intend to do? Is the
> "window" supposed to display the web service calls actually supposed to
> be a _desktop application_ window or rather an HTML page rendered by
> some JSP?
>
> If you want to build a GUI, probably you will have to build something
> like that:
>
> * Web Service and related classes deployed to a tomcat application
> context making use of axis and friends, and
>
> * GUI application, built as a standalone Java application making use of
> Swing(?) to render a GUI and using web service client classes to do
> remote calls.
>
> Can you be more verbose about your application architecture? :)
>
> Cheers,
> Kristian
>
>
> --
> Kristian Rink * http://zimmer428.net * http://flickr.com/photos/z428/
> jab: kawazu@jabber.ccc.de * icq: 48874445 * fon: ++49 176 2447 2771
> "One dreaming alone, it will be only a dream; many dreaming together
> is the beginning of a new reality." (Hundertwasser)
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: GUI implementation with tomcat

Posted by Kristian Rink <kr...@zimmer428.net>.
Alicia;


["Alicia Sánchez-Mora" <al...@gmail.com> @ Thu, 8 Mar 2007
15:05:09 +0100]

> I have the class Window to initialize the GUI and I call (locally) an
> instance  of this class from my service class. The problem, or at
> least what I think the problem is, is that every time I make a call
> the service container unloads my class and nothing (related to my
> window) is initiallized. The idea is to run my window only one time,
> when tomcat starts. To do that I should specify somehow on the
> web.xml file to do this: write a jsp class, put it somewhere and call
> the initialization of the window..



honestly, the architecture of your overall application by now seems
somewhat obscure to me. What exactly do you intend to do? Is the
"window" supposed to display the web service calls actually supposed to
be a _desktop application_ window or rather an HTML page rendered by
some JSP? 

If you want to build a GUI, probably you will have to build something
like that:

* Web Service and related classes deployed to a tomcat application
context making use of axis and friends, and

* GUI application, built as a standalone Java application making use of
Swing(?) to render a GUI and using web service client classes to do
remote calls.

Can you be more verbose about your application architecture? :)

Cheers,
Kristian


-- 
Kristian Rink * http://zimmer428.net * http://flickr.com/photos/z428/
jab: kawazu@jabber.ccc.de * icq: 48874445 * fon: ++49 176 2447 2771
"One dreaming alone, it will be only a dream; many dreaming together
is the beginning of a new reality." (Hundertwasser)

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: GUI implementation with tomcat

Posted by David Delbecq <de...@oma.be>.
En l'instant précis du 08/03/07 15:05, Alicia Sánchez-Mora s'exprimait
en ces termes:
>
>
> I have the class Window to initialize the GUI and I call (locally) an
> instance  of this class from my service class. The problem, or at least
> what I think the problem is, is that every time I make a call the service
> container unloads my class and nothing (related to my window) is
> initiallized. The idea is to run my window only one time, when tomcat
> starts. To do that I should specify somehow on the web.xml file to do
> this:
> write a jsp class, put it somewhere and call the initialization of the
> window..
Shouldn't the GUI be on the *client* side instead of the *server* side?
If you want to initialize something at webapp startup, you have 2 solutions
1) a servlet with load on startup
2) a context listener
>
> Any more concrete suguestion or solutions?
>
> Thanks in advance,
>
> Alicia
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org