Re: [OS-webwork] ActionContext clarification

2003-01-30 Thread Dick Zetterberg
Hi,

I just had a look at the code and tested it.
Unfortunately it does not work if you close the action tag as you thought
Rickard.
When the Action tag end is reached it calls the dispatcher finalizeContext
method which creates a new ActionContext object and sets it. The lookup
table from any previous context is then put into the new context.
But if you do not have a previous context (like in this model-1 example), it
is of course empty.

Wouldn't it be nice if in a web environment the stuff that is consistent
during the request, would remain in the ActionContext? Perhaps it could be
solved by adding another lookup table in the ActionContext for those
long-lived objects (request, response, servletcontext, session...). In the
finalizeContext method that map would just be transferred to the new
ActionContext created.
The long-lived lookup table would still be set whenever an action is
dispatched from ServletDispatcher or from an Action tag etc, so that no old
data would be lingering in the context.
Just a thought

Cheers,

Dick

[EMAIL PROTECTED]


- Original Message -
From: Rickard Öberg [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 29, 2003 2:41 PM
Subject: Re: [OS-webwork] ActionContext clarification


 Dick Zetterberg wrote:
  Isn't it possible to get a problem even if you do all your work in
actions,
  for example if you are doing some Model-1 coding? For example if you
have an
  action that you call many methods on, in a page like:
  ww:action name='MyAction' id=theAction/
 
  Later on in the page you decide to get some property from it:
  ww:property value=@theAction/someMethod/
 
  If that method getSomeMethod would try to access the session in the
  ActionContext it would not find one, isn't that so?
  So for that to work you would have to end the action tag at the bottom
of
  the page instead, right?

 It would work since the context is set on a per thread basis, i.e. the
 association that is done when the action tag is run is still in place.

 AFAIK.

 /Rickard





---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-30 Thread Konstantin Priblouda

--- Dick Zetterberg [EMAIL PROTECTED] wrote:
 Hi,
 
 I just had a look at the code and tested it.
 Unfortunately it does not work if you close the
 action tag as you thought
 Rickard.
 When the Action tag end is reached it calls the
 dispatcher finalizeContext
 method which creates a new ActionContext object and
 sets it. The lookup
 table from any previous context is then put into the
 new context.
 But if you do not have a previous context (like in
 this model-1 example), it
 is of course empty.
 
 Wouldn't it be nice if in a web environment the
 stuff that is consistent
 during the request, would remain in the
 ActionContext? Perhaps it could be
 solved by adding another lookup table in the
 ActionContext for those
 long-lived objects (request, response,
 servletcontext, session...). In the
 finalizeContext method that map would just be
 transferred to the new
 ActionContext created.
 The long-lived lookup table would still be set
 whenever an action is
 dispatched from ServletDispatcher or from an Action
 tag etc, so that no old
 data would be lingering in the context.
 Just a thought


I also played around. I put all code which does work
into actions ( and while doing this I discovered that
you can count on ActionContext only inside doExecute()
/ execute() ) - i got terrible race conditions while
trying to access action context out of getter methods
of my action. When I moved the code to doExcetutze()
those races dissappeared. 


As I can see from code, there are 2 kinds of session
maps in ActionContext - vanilla HashMap while not in
servlet environment, and SessionMap which is wrapper
around real session. 

From my point of view, it would be logical in servlet
entvironment to use this session map
( and of course synchronize on it, for cases where
there 2 requests paralel - like mine with frames )



Another question:
If I specify action in jsp page, when exactly it's
executed?

I got following code in jsp


---%--

decorator:usePage id=screen/
webwork:action name='windowManager' id=wm/
webwork:action name='renderScreen' id=render
webwork:param name='page' value=@screen/
webwork:param
name='URL'webwork:url//webwork:param
webwork:param name='windowManager'
value=@wm/windowManager/
!-- foo bar --
/webwork:action





webwork:if test=@render/refreshSidebar
SCRIPT language=JavaScript 
!-- 
parent.navbar.location.href = %=
request.getContextPath() + /layout/sidebar.jsp% ; 
//-- 
/SCRIPT
/webwork:if
webwork:if test=@render/refreshToolbar
SCRIPT language=JavaScript 
!--  
parent.parent.toolbar.location.href = %=
request.getContextPath() + /layout/toolbar.jsp% ;
//-- 
/SCRIPT
/webwork:if

-%- 



From console debug I can see:
---%

13:07:42,900 DEBUG [ServletValueStack] findValue()
for: query='windowManager' {[id=windowManager
type=0 values=]}
13:07:42,902 DEBUG [ActionSupport] Action executing..
13:07:42,902 DEBUG [WindowManagerAction] get session
before synchronizing:
{com.infodesire.webgui.beans.WindowManager=com.infodesire.webgui.beans.WindowManager@1939100}
13:07:42,902 DEBUG [WindowManagerAction] get session
while synchronizing:
{com.infodesire.webgui.beans.WindowManager=com.infodesire.webgui.beans.WindowManager@1939100}
13:07:42,902 DEBUG [ActionSupport] Action execution
done
13:07:42,902 DEBUG [ActionSupport] Action executed in
0 ms
13:07:42,903 DEBUG [ServletValueStack] findValue()
for: query='renderScreen' {[id=renderScreen
type=0 values=]}
13:07:42,904 DEBUG [ServletValueStack] findValue()
for: query='page' {[id=page type=0 values=]}
13:07:42,904 DEBUG [ServletValueStack] findValue()
for: query=@screen {[id=screen type=6
values=]}
13:07:42,904 DEBUG [RenderScreenAction] setting page:
com.opensymphony.module.sitemesh.parser.FastPage@14e3372
13:07:42,904 DEBUG [ServletValueStack] findValue()
for: query='URL' {[id=URL type=0 values=]}
13:07:42,904 DEBUG [RenderScreenAction] setting url:
/porttest/application1/index.jsp
13:07:42,904 DEBUG [ServletValueStack] findValue()
for: query='windowManager' {[id=windowManager
type=0 values=]}
13:07:42,905 DEBUG [ServletValueStack] findValue()
for: query=@wm/windowManager {[id=wm type=6
values=]} {[id=windowManager type=8 values=]}
13:07:42,906 DEBUG [WindowManagerAction] returning
window manager:
com.infodesire.webgui.beans.WindowManager@1939100
13:07:42,906 DEBUG [RenderScreenAction] set window
manager:
com.infodesire.webgui.beans.WindowManager@1939100
13:07:42,906 DEBUG [ActionSupport] Action executing..
13:07:42,906 DEBUG [WindowManager] returning active
window: null
13:07:42,906 DEBUG [ActionSupport] Action execution
done
13:07:42,907 DEBUG [ActionSupport] Action executed in
1 ms
13:07:42,907 DEBUG [ServletValueStack] findValue()
for: query=@render/refreshSidebar {[id=render
type=6 values=]} {[id=refreshSidebar type=8
values=]}
13:07:42,907 DEBUG [RenderScreenAction] returning
refreshSidebar: false

Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Konstantin Priblouda

--- Rickard_Öberg [EMAIL PROTECTED] wrote:
 Konstantin Priblouda wrote:
  Hi all, 
  I tried to get map of values stored in 
  HttpSession by calling  ActionContext.getSession()
  
  Docs state that it shall return map of values in
  actual HttpSession while in servlet environment,
 and
  just a map
  ( global one? ) if called elsewhere. 
  
  I used it from JPS , and different documents got
  different maps from action context.
 
 Using the ActionContext is only valid from within an
 action (i.e. after 
 a dispatcher has set it up properly). If you are
 accessing it from a 
 page that has not previously executed then you will
 get the wrong answer.
 
 Is this your case?

Yep. I have to live with frameset, and on couple the
first executions of various jsps it delivers different
objects. But then it stabilizes...
Kind of weird. 

I think I will provide 2 methods for my factory:
from jsp feed it with session and extract  object from
t here and fromj action just ask ActionContext 
for object with the same key.

Is there a better ( servlet agnostic? more webworky? )
way to obtain global object from web application?

regards,

=
Konstantin Priblouda ( ko5tik )Freelance Software developer
 http://www.pribluda.de   play java games - http://www.yook.de 
 render charts online - http://www.pribluda.de/povray/ 

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Rickard Öberg
Konstantin Priblouda wrote:

Yep. I have to live with frameset, and on couple the
first executions of various jsps it delivers different
objects. But then it stabilizes...
Kind of weird. 

I think I will provide 2 methods for my factory:
from jsp feed it with session and extract  object from
t here and fromj action just ask ActionContext 
for object with the same key.

Is there a better ( servlet agnostic? more webworky? )
way to obtain global object from web application?

Well, if you're using scriptlets then I guess you can use the request 
directly.

The WebWorky way is to have all code that does stuff in actions, and in 
that case you'd never have any problem.

/Rickard

--
Rickard Öberg
[EMAIL PROTECTED]
Senselogic

Got blog? I do. http://dreambean.com



---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Konstantin Priblouda

 Well, if you're using scriptlets then I guess you
 can use the request 
 directly.
 
 The WebWorky way is to have all code that does stuff
 in actions, and in 
 that case you'd never have any problem.

So you suggest that I convert my factory class into
action, and this action shall deposit my desired class
in [say] thread local upon execution?

Is there webwork example for such factory actions?

regards,

=
Konstantin Priblouda ( ko5tik )Freelance Software developer
 http://www.pribluda.de   play java games - http://www.yook.de 
 render charts online - http://www.pribluda.de/povray/ 

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Rickard Öberg
Konstantin Priblouda wrote:

So you suggest that I convert my factory class into
action, and this action shall deposit my desired class
in [say] thread local upon execution?

Is there webwork example for such factory actions?


What are you using the factory for? Sounds like the dispatcher to me.

/Rickard

--
Rickard Öberg
[EMAIL PROTECTED]
Senselogic

Got blog? I do. http://dreambean.com



---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Konstantin Priblouda

  Is there webwork example for such factory actions?
 
 What are you using the factory for? Sounds like the
 dispatcher to me.

I need a application-global object. 

Original version was: 
---%-
public static getFoo(HttpSession bar) {
 Foo foo = bar.getValue(FOO_KEY);

 if(foo == null) {
   foo = new Foo();
   bar.put(FOO_KEY,foo);
 }
  return foo;
}
---%-
Then i was in need to perform the same from action
 - so I modified this method to luse Map instead of
session
and added another static method which just feeds first
one with ActionContext.getSession()

Shall I use [say ] GenerixcDispatcher to initialize
ActionContext ?

regards,



=
Konstantin Priblouda ( ko5tik )Freelance Software developer
 http://www.pribluda.de   play java games - http://www.yook.de 
 render charts online - http://www.pribluda.de/povray/ 

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Rickard Öberg
Konstantin Priblouda wrote:

Is there webwork example for such factory actions?


What are you using the factory for? Sounds like the
dispatcher to me.


I need a application-global object. 

Original version was: 
---%-
public static getFoo(HttpSession bar) {
 Foo foo = bar.getValue(FOO_KEY);

 if(foo == null) {
   foo = new Foo();
   bar.put(FOO_KEY,foo);
 }
  return foo;
}
---%-

Hm.. this is not application-global. It is session-specific.


Then i was in need to perform the same from action
 - so I modified this method to luse Map instead of
session
and added another static method which just feeds first
one with ActionContext.getSession()

Shall I use [say ] GenerixcDispatcher to initialize
ActionContext ?


First of all: do you want it to be application-wide or session-wide?

Regardless, the initialization should probably be done using a 
ServiceContextListener.

/Rickard

--
Rickard Öberg
[EMAIL PROTECTED]
Senselogic

Got blog? I do. http://dreambean.com



---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Konstantin Priblouda

 Just an observation from your error description:
 Is the initial framset file a html file or a jsp
 file? If it is html and
 then if the frames are JSP files then I think you
 could get the behaviour
 you are describing with different sessions since no
 session is created when
 the frameset html file is requested and then several
 JSP pages (for each
 frame) is requested simultaneously. The solution is
 to make the frameset a
 JSP file as well.
 But maybe this is not the case, if so, please ignore
 this post.

Everything is JSP, but IMHO session shall be created 
on the first context invocation. 

Losing session track due plain html could be an issue
for url-mangled sessions, but not cookie-ones...

regards,

=
Konstantin Priblouda ( ko5tik )Freelance Software developer
 http://www.pribluda.de   play java games - http://www.yook.de 
 render charts online - http://www.pribluda.de/povray/ 

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Rickard Öberg
Konstantin Priblouda wrote:

Regardless, the initialization should probably be
done using a 
ServiceContextListener.

What is ServiceContextListener? Nothing in webwork
docs
about it, neither in servlet api


Sorry, I meant this one:
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContextListener.html

/Rickard

--
Rickard Öberg
[EMAIL PROTECTED]
Senselogic

Got blog? I do. http://dreambean.com



---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Konstantin Priblouda

--- Rickard_Öberg [EMAIL PROTECTED] wrote:
 Konstantin Priblouda wrote:
 Regardless, the initialization should probably be
 done using a 
 ServiceContextListener.
  
  What is ServiceContextListener? Nothing in webwork
  docs
  about it, neither in servlet api
 
 Sorry, I meant this one:

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContextListener.html

Well, not quite webworky :)

I would like to be servlet-agnostic...

What is correct way to obtain ActionContext
which was initialized with HttpSession data if there
is
HttpSession around?

regards,

=
Konstantin Priblouda ( ko5tik )Freelance Software developer
 http://www.pribluda.de   play java games - http://www.yook.de 
 render charts online - http://www.pribluda.de/povray/ 

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Rickard Öberg
Konstantin Priblouda wrote:

Well, not quite webworky :)


The idea is to not reinvent the wheel.


I would like to be servlet-agnostic...


Ok, then put the code that initializes the context in a class and call 
it from a ServiceContextListener.

What is correct way to obtain ActionContext
which was initialized with HttpSession data if there
is
HttpSession around?


I think ServletActionContext.getSession() works.

/Rickard

--
Rickard Öberg
[EMAIL PROTECTED]
Senselogic

Got blog? I do. http://dreambean.com



---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Konstantin Priblouda

  What is correct way to obtain ActionContext
  which was initialized with HttpSession data if
 there
  is
  HttpSession around?
 
 I think ServletActionContext.getSession() works.

This method does not exists in current CVS version
of webwork...

Another question: 
It seems to me that ActionContext is stored as
TreadLocal, is this map kept in synch with session
contents?

regards,

=
Konstantin Priblouda ( ko5tik )Freelance Software developer
 http://www.pribluda.de   play java games - http://www.yook.de 
 render charts online - http://www.pribluda.de/povray/ 

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Rickard Öberg
Konstantin Priblouda wrote:

What is correct way to obtain ActionContext
which was initialized with HttpSession data if


there


is
HttpSession around?


I think ServletActionContext.getSession() works.


This method does not exists in current CVS version
of webwork...


Sorry, that should be ActionContext.getSession()


Another question: 
It seems to me that ActionContext is stored as
TreadLocal, is this map kept in synch with session
contents?

The reference to the session is updated every time an action is 
executed. Execute an action - works. Don't execute an action - doesn't 
work, or unspecified.

Again, if you just run an action access to the context is not a problem. 
If you try to access the context in any other scenario, you're asking 
for trouble.

/Rickard

--
Rickard Öberg
[EMAIL PROTECTED]
Senselogic

Got blog? I do. http://dreambean.com



---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


RE: [OS-webwork] ActionContext clarification

2003-01-29 Thread Jason Carreira
Konstantin, 

I think the problem here is that you're not using the Model2 paradigm,
which Webwork is based upon. It sounds like you are hitting the JSPs
directly, whereas, in Webwork, we would hit foo.action, which (because
*.action is mapped to the Webwork ServletDispatcher) would be handled by
Webwork, and the ActionContext would be automatically set up for you and
ready to access from ActionContext.getSession().

Jason

 -Original Message-
 From: Konstantin Priblouda [mailto:[EMAIL PROTECTED]] 
 Sent: Wednesday, January 29, 2003 8:30 AM
 To: [EMAIL PROTECTED]
 Cc: webwork-devel
 Subject: Re: [OS-webwork] ActionContext clarification
 
 
 
   What is correct way to obtain ActionContext
   which was initialized with HttpSession data if
  there
   is
   HttpSession around?
  
  I think ServletActionContext.getSession() works.
 
 This method does not exists in current CVS version
 of webwork...
 
 Another question: 
 It seems to me that ActionContext is stored as
 TreadLocal, is this map kept in synch with session
 contents?
 
 regards,
 
 =
 Konstantin Priblouda ( ko5tik )Freelance Software developer
  http://www.pribluda.de   play java games - 
http://www.yook.de   render charts online -
http://www.pribluda.de/povray/ 

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork



Re: [OS-webwork] ActionContext clarification

2003-01-29 Thread Dick Zetterberg
- Original Message -
From: Jason Carreira [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, January 29, 2003 4:19 PM
Subject: RE: [OS-webwork] ActionContext clarification


 Konstantin,

 I think the problem here is that you're not using the Model2 paradigm,
 which Webwork is based upon. It sounds like you are hitting the JSPs
 directly, whereas, in Webwork, we would hit foo.action, which (because
 *.action is mapped to the Webwork ServletDispatcher) would be handled by
 Webwork, and the ActionContext would be automatically set up for you and
 ready to access from ActionContext.getSession().


As Rickard has said the problem is that there is no initialized context,
however I would not go as far saying that Webwork is only for Model-2. In
the WW documentation it is clearly described to be for both Model-1 and
Model-2 (that part written by Rickard originally I think). And in a Model-1
approach you use the ww:action and ww:bean tags.
And I think one should not forget this because there are times when Model-1
can be useful, and you can scare away people by saying that it is only
Model-2 (because they feel it gets more complicated than they want it).
In Konstantin's case one solution could be to use a ww:action in the page.

Best regards,

Dick

[EMAIL PROTECTED]





---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork