Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Integration Spring (session/request) scoped Beans into RAP
Integration Spring (session/request) scoped Beans into RAP [message #81565] Sat, 05 April 2008 13:16 Go to next message
Stefan Hansel is currently offline Stefan HanselFriend
Messages: 103
Registered: July 2009
Senior Member
<br><font size=2 face="sans-serif">I'm currently thinking of integrating
Spring with RAP. </font>
<br><font size=2 face="sans-serif">As long as just normal singleton or
prototype beans are uses, this works quite well.</font>
<br>
<br><font size=2 face="sans-serif">On additional useful feature of Spring
is the possibility to scope beans at the request or session level, which
makes life a lot easier.</font>
<br><font size=2 face="sans-serif">(</font><a href=" http://static.springframework.org/spring/docs/2.5.x/referenc e/beans.html#beans-factory-scopes-other-web-configuration"><font size=2 face="sans-serif"> http://static.springframework.org/spring/docs/2.5.x/referenc e/beans.html#beans-factory-scopes-other-web-configuration</font></a><font size=2 face="sans-serif">)</font>
<br>
<br><font size=2 face="sans-serif">Within RAP one could discuss how a 'request'
is mapped to the asynchronious AJAX world - I'd like to define it as every
RAP-Server-Roundtrip - so if I click on a RAP-Button (which has a listener
installed) and then somethings happens - that would be a request.</font>
<br>
<br><font size=2 face="sans-serif">In a normal web-application one would
install an additional Spring-ServletRequestListener (which in turn puts
the current request in a ThreadLocal). Springs Bean-Proxies (accessed within
the servlet-thread) are then aware &nbsp;of requests and sessions.</font>
<br>
<br><font size=2 face="sans-serif">With RAP things get a little bit complicated,
because the actual application code is not run in the servlet thread but
a special UIThread.</font>
<br><font size=2 face="sans-serif">Springs Bean-Proxies then can't find
their current ServletRequest in their ThreadLocal and throw exceptions.</font>
<br>
<br><font size=2 face="sans-serif">I was able to get it working (in a small
prototype) by calling Springs ServletRequestListener manually from the
UIThread. (See code at the end of posting):</font>
<br><font size=2 face="sans-serif">The way I done it assumes the following
lifecycle between ServletRequest and UIThread, which I'm not sure is always
correct &nbsp;?</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; -
createUI is always called from UIThread while the first ServletRequest
of a Session is running.</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; -
within display.readAndDispatch() the ServletRequest is not switching, but
the method is rather just dispatching all events the current request </font>
<br><font size=2 face="sans-serif">issued</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; -
when there is no event left readAndDispatch() returns false, one has to
call display.sleep() and the request is finished by sending back whatever
needs to be sent back to the browser</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; -
display.sleep() returns when there is the next request from the browser,
so there are new events in the event-queue.</font>
<br>
<br><font size=2 face="sans-serif">Are these assumptions right ?</font>
<br><font size=2 face="sans-serif">What is happening, when I have an extra
thread to calculate things and this thread puts an event into the queue.
I suppose display.sleep() wakes up, but what request does a call to RWT.getRequest()
return ?</font>
<br>
<br><font size=2 face="sans-serif">Could you think of a better approach
?</font>
<br><font size=2 face="sans-serif">I also thought about using RWTLiveCycle.addPhaseListener()
and listening to the start and end of PhaseId.PROCESS_ACTION, but was not
sure, whether this would be a better approach.</font>
<br>
<br>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>public</b></font><font size=2 face="Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>int</b></font><font size=2 face="Courier New">
<b>createUI</b>() {</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; RequestContextListener requestContextListener
= </font><font size=2 color=#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New">
<b>RequestContextListener</b>();</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; ServletRequestEvent servletRequestEvent =
<b>fireSpringRequestScopeStarted</b>(requestContextListener); </font>
<br>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#3f8080 face="Courier New"><b>//
createUI and access Spring-Business-Beans</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#3f8080 face="Courier New"><b>//
[...]</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; ServletContext context = RWT.<i>getRequest</i>().</font><font size=2 color=#008080 face="Courier New">getSession</font><font size=2 face="Courier New">().</font><font size=2 color=#008080 face="Courier New">getServletContext</font><font size=2 face="Courier New">();</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; WebApplicationContext ctx = WebApplicationContextUtils.<i>getWebApplicationContext</i >(context);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#3f8080 face="Courier New"><b>//
[...]</b></font>
<br>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>while</b></font><font size=2 face="Courier New">
(!shell.<b>isDisposed</b>()) {</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>if</b></font><font size=2 face="Courier New">
(!display.<b>readAndDispatch</b>()) {</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; <b>fireSpringRequestScopeEnded</b>(requestContextListener,
servletRequestEvent);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; display.<b>sleep</b>();</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; servletRequestEvent = <b>fireSpringRequestScopeStart</b>ed(requestContextListener); </font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>return</b></font><font size=2 face="Courier New">
0;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>private</b></font><font size=2 face="Courier New">
ServletRequestEvent <b>fireSpringRequestScopeStarted</b>(RequestContextListener
</font><font size=2 color=#820040 face="Courier New">requestContextListener</font><font size=2 face="Courier New">)
{</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; ServletRequestEvent servletRequestEvent =
</font><font size=2 color=#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New">
<b>ServletRequestEvent</b>(RWT.<i>getRequest</i>().</font ><font size=2 color=#008080 face="Courier New">getSession</font><font size=2 face="Courier New">().</font><font size=2 color=#008080 face="Courier New">getServletContext</font><font size=2 face="Courier New">(),
RWT.<i>getRequest</i>());</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New">requestContextListener</font><font size=2 face="Courier New">.<b>requestInitialized</b>(servletRequestEvent);</font >
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>return</b></font><font size=2 face="Courier New">
servletRequestEvent;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>private</b></font><font size=2 face="Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>void</b></font><font size=2 face="Courier New">
<b>fireSpringRequestScopeEnded</b>(RequestContextListener </font><font size=2 color=#820040 face="Courier New">requestContextListener</font><font size=2 face="Courier New">,
ServletRequestEvent </font><font size=2 color=#820040 face="Courier New">servletRequestEvent</font><font size=2 face="Courier New">)
{</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New">requestContextListener</font><font size=2 face="Courier New">.<b>requestDestroyed</b>(</font><font size=2 color=#820040 face="Courier New">servletRequestEvent</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br>
Re: Integrating Spring (session/request) scoped Beans into RAP [message #81582 is a reply to message #81565] Sat, 05 April 2008 14:47 Go to previous messageGo to next message
Stefan Hansel is currently offline Stefan HanselFriend
Messages: 103
Registered: July 2009
Senior Member
<br><font size=2 face="sans-serif">This is how a PhaseListener-solution
looks like (see below).</font>
<br><font size=2 face="sans-serif">This works equally well in my small
prototype and seems to be far more elegant.</font>
<br>
<br><font size=2 face="sans-serif">There's just one problem - where should
the PhaseListener be registered ?</font>
<br>
<br><font size=2 face="sans-serif">When using web.xml, two other important
PhaseListeners don't get registered and RAP is not working anymore. Our
web.xml thus has the following entry, but I think that this isn't safe
when new RAP versions come out.:</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#008080 face="Courier New">&lt;</font><font size=2 color=#3f8080 face="Courier New">context-param</font><font size=2 color=#008080 face="Courier New">&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#008080 face="Courier New">&lt;</font><font size=2 color=#3f8080 face="Courier New">param-name</font><font size=2 color=#008080 face="Courier New">&gt;</font><font size=2 face="Courier New">org.eclipse.rwt.phaseListeners</font><font size=2 color=#008080 face="Courier New">&lt;/</font><font size=2 color=#3f8080 face="Courier New">param-name</font><font size=2 color=#008080 face="Courier New">&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#008080 face="Courier New">&lt;</font><font size=2 color=#3f8080 face="Courier New">param-value</font><font size=2 color=#008080 face="Courier New">&gt;</font><font size=2 face="Courier New"> org.eclipse.rwt.internal.lifecycle.CurrentPhase$Listener,org .eclipse.rwt.internal.lifecycle.PreserveWidgetsPhaseListener ,de.tolina.web.SpringIntegratingPhaseListener </font><font size=2 color=#008080 face="Courier New">&lt;/</font><font size=2 color=#3f8080 face="Courier New">param-value</font><font size=2 color=#008080 face="Courier New">&gt;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#008080 face="Courier New">&lt;/</font><font size=2 color=#3f8080 face="Courier New">context-param</font><font size=2 color=#008080 face="Courier New">&gt;</font>
<br>
<br><font size=2 face="sans-serif">Any suggestions whereelse our PhaseListener
could be registered ? IEntryPoint.createUI is not working, because the
PhaseListener then would be registered more than once.</font>
<br>
<br><font size=2 face="sans-serif">Here's the PhaseListener: </font>
<br>
<br><font size=2 color=#820040 face="Courier New"><b>public</b></font><font size=2 face="Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>class</b></font><font size=2 face="Courier New">
SpringIntegratingPhaseListener </font><font size=2 color=#820040 face="Courier New"><b>implements</b></font><font size=2 face="Courier New">
PhaseListener {</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#3f8080 face="Courier New"><b>//
Springs RequestContextListener, where we will do fake calls for each PROCESS_ACTION
</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>private</b></font><font size=2 face="Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>final</b></font><font size=2 face="Courier New">
RequestContextListener </font><font size=2 color=#0021bf face="Courier New">requestContextListener</font><font size=2 face="Courier New">
= </font><font size=2 color=#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New">
<b>RequestContextListener</b>();</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>public</b></font><font size=2 face="Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>void</b></font><font size=2 face="Courier New">
<b>afterPhase</b>(PhaseEvent </font><font size=2 color=#820040 face="Courier New">event</font><font size=2 face="Courier New">)
{</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; ServletRequestEvent servletRequestEvent =
</font><font size=2 color=#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New">
<b>ServletRequestEvent</b>(RWT.<i>getRequest</i>().</font ><font size=2 color=#008080 face="Courier New">getSession</font><font size=2 face="Courier New">().</font><font size=2 color=#008080 face="Courier New">getServletContext</font><font size=2 face="Courier New">(),
RWT.<i>getRequest</i>());</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#0021bf face="Courier New">requestContextListener</font><font size=2 face="Courier New">.<b>requestDestroyed</b>(servletRequestEvent);</font >
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>public</b></font><font size=2 face="Courier New">
</font><font size=2 color=#820040 face="Courier New"><b>void</b></font><font size=2 face="Courier New">
<b>beforePhase</b>(PhaseEvent </font><font size=2 color=#820040 face="Courier New">event</font><font size=2 face="Courier New">)
{</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; ServletRequestEvent servletRequestEvent =
</font><font size=2 color=#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New">
<b>ServletRequestEvent</b>(RWT.<i>getRequest</i>().</font ><font size=2 color=#008080 face="Courier New">getSession</font><font size=2 face="Courier New">().</font><font size=2 color=#008080 face="Courier New">getServletContext</font><font size=2 face="Courier New">(),
RWT.<i>getRequest</i>());</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#0021bf face="Courier New">requestContextListener</font><font size=2 face="Courier New">.<b>requestInitialized</b>(servletRequestEvent);</font >
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>public</b></font><font size=2 face="Courier New">
PhaseId <b>getPhaseId</b>() {</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>return</b></font><font size=2 face="Courier New">
PhaseId.PROCESS_ACTION;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; }</font>
<br><font size=2 face="Courier New">}</font>
<br>
Re: Integration Spring (session/request) scoped Beans into RAP [message #81693 is a reply to message #81582] Mon, 07 April 2008 07:10 Go to previous message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

This is a multi-part message in MIME format.

------=_NextPart_000_0145_01C8988F.2AB85D50
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Hi,

your assumption about the readAndDispatch loop in your first mail are
correct. It's also correct how you've registered the phaselisteners for
RWT standalone - in case of manually configuring the phaselisteners like
you do the RWT listeners must be noted also. Don't know whether this is
the best solution, but that's how it works at the moment and in terms of
beeing API stable I don't expect this to be changed in the near future.


Ciao
Frank

_____

Von: stefan.hansel@tolina.de [mailto:stefan.hansel@tolina.de]
Bereitgestellt: Samstag, 5. April 2008 16:47
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Integration Spring (session/request) scoped Beans into RAP
Betreff: Re: Integrating Spring (session/request) scoped Beans into RAP



This is how a PhaseListener-solution looks like (see below).
This works equally well in my small prototype and seems to be far more
elegant.

There's just one problem - where should the PhaseListener be registered
?

When using web.xml, two other important PhaseListeners don't get
registered and RAP is not working anymore. Our web.xml thus has the
following entry, but I think that this isn't safe when new RAP versions
come out.:

<context-param>
<param-name>org.eclipse.rwt.phaseListeners</param-name>

<param-value>org.eclipse.rwt.internal.lifecycle.CurrentPhase$Listener,or
g.eclipse.rwt.internal.lifecycle.PreserveWidgetsPhaseListene r,de.tolina.
web.SpringIntegratingPhaseListener</param-value>
</context-param>

Any suggestions whereelse our PhaseListener could be registered ?
IEntryPoint.createUI is not working, because the PhaseListener then
would be registered more than once.

Here's the PhaseListener:

public class SpringIntegratingPhaseListener implements PhaseListener {
// Springs RequestContextListener, where we will do fake calls
for each PROCESS_ACTION
private final RequestContextListener requestContextListener =
new RequestContextListener();

public void afterPhase(PhaseEvent event) {
ServletRequestEvent servletRequestEvent = new
ServletRequestEvent(RWT.getRequest().getSession().getServlet Context(),
RWT.getRequest());

requestContextListener.requestDestroyed(servletRequestEvent) ;
}

public void beforePhase(PhaseEvent event) {
ServletRequestEvent servletRequestEvent = new
ServletRequestEvent(RWT.getRequest().getSession().getServlet Context(),
RWT.getRequest());

requestContextListener.requestInitialized(servletRequestEven t);
}

public PhaseId getPhaseId() {
return PhaseId.PROCESS_ACTION;
}
}


------=_NextPart_000_0145_01C8988F.2AB85D50
Content-Type: text/html;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Dus-ascii" =
http-equiv=3DContent-Type>
<META name=3DGENERATOR content=3D"MSHTML 6.00.6001.17184"></HEAD>
<BODY>
<DIV dir=3Dltr align=3Dleft><FONT color=3D#0000ff size=3D2 =
face=3DArial><SPAN=20
class=3D125580407-07042008>Hi,</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT color=3D#0000ff size=3D2 =
face=3DArial><SPAN=20
class=3D125580407-07042008></SPAN></FONT>&nbsp;</DIV >
<DIV dir=3Dltr align=3Dleft><FONT color=3D#0000ff size=3D2 =
face=3DArial><SPAN=20
class=3D125580407-07042008>your assumption about the readAndDispatch =
loop in your=20
first mail are correct. It's also correct how you've registered the=20
phaselisteners for RWT standalone - in case of manually configuring the=20
phaselisteners like you do the RWT listeners must be noted also. Don't =
know=20
whether this is the best solution, but that's how it works at the moment =
and in=20
terms of beeing API stable I don't expect this to be changed in the near =

future.</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT color=3D#0000ff size=3D2 =
face=3DArial><SPAN=20
class=3D125580407-07042008></SPAN></FONT>&nbsp;</DIV >
<DIV dir=3Dltr align=3Dleft><FONT color=3D#0000ff size=3D2 =
face=3DArial><SPAN=20
class=3D125580407-07042008></SPAN></FONT>&nbsp;</DIV >
<DIV dir=3Dltr align=3Dleft><FONT color=3D#0000ff size=3D2 =
face=3DArial><SPAN=20
class=3D125580407-07042008>Ciao</SPAN></FONT></DIV>
<DIV dir=3Dltr align=3Dleft><FONT color=3D#0000ff size=3D2 =
face=3DArial><SPAN=20
class=3D125580407-07042008>Frank</SPAN></FONT></DIV><BR >
<DIV dir=3Dltr lang=3Dde class=3DOutlookMessageHeader align=3Dleft>
<HR tabIndex=3D-1>
<FONT size=3D2 face=3DTahoma><B>Von:</B> stefan.hansel@tolina.de=20
[mailto:stefan.hansel@tolina.de] <BR><B>Bereitgestellt:</B> Samstag, 5. =
April=20
2008 16:47<BR><B>Bereitgestellt in:</B>=20
eclipse.technology.rap<BR><B>Unterhaltung:</B> Integration Spring=20
(session/request) scoped Beans into RAP<BR><B>Betreff:</B> Re: =
Integrating=20
Spring (session/request) scoped Beans into =
RAP<BR><BR></FONT></DIV><BR><FONT=20
size=3D2 face=3Dsans-serif>This is how a PhaseListener-solution looks =
like (see=20
below).</FONT> <BR><FONT size=3D2 face=3Dsans-serif>This works equally =
well in my=20
small prototype and seems to be far more elegant.</FONT> <BR><BR><FONT =
size=3D2=20
face=3Dsans-serif>There's just one problem - where should the =
PhaseListener be=20
registered ?</FONT> <BR><BR><FONT size=3D2 face=3Dsans-serif>When using =
web.xml, two=20
other important PhaseListeners don't get registered and RAP is not =
working=20
anymore. Our web.xml thus has the following entry, but I think that this =
isn't=20
safe when new RAP versions come out.:</FONT> <BR><BR><FONT size=3D2=20
face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </FONT><FONT =
color=3D#008080 size=3D2=20
face=3D"Courier New">&lt;</FONT><FONT color=3D#3f8080 size=3D2=20
face=3D"Courier New">context-param</FONT><FONT color=3D#008080 size=3D2=20
face=3D"Courier New">&gt;</FONT> <BR><FONT size=3D2 face=3D"Courier =
New">&nbsp; &nbsp;=20
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT><FONT color=3D#008080 =
size=3D2=20
face=3D"Courier New">&lt;</FONT><FONT color=3D#3f8080 size=3D2=20
face=3D"Courier New">param-name</FONT><FONT color=3D#008080 size=3D2=20
face=3D"Courier New">&gt;</FONT><FONT size=3D2=20
face=3D"Courier New">org.eclipse.rwt.phaseListeners</FONT><FONT =
color=3D#008080=20
size=3D2 face=3D"Courier New">&lt;/</FONT><FONT color=3D#3f8080 size=3D2 =

face=3D"Courier New">param-name</FONT><FONT color=3D#008080 size=3D2=20
face=3D"Courier New">&gt;</FONT> <BR><FONT size=3D2 face=3D"Courier =
New">&nbsp; &nbsp;=20
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT><FONT color=3D#008080 =
size=3D2=20
face=3D"Courier New">&lt;</FONT><FONT color=3D#3f8080 size=3D2=20
face=3D"Courier New">param-value</FONT><FONT color=3D#008080 size=3D2=20
face=3D"Courier New">&gt;</FONT><FONT size=3D2=20
face=3D"Courier =
New"> org.eclipse.rwt.internal.lifecycle.CurrentPhase$Listener,org .eclipse=
..rwt.internal.lifecycle.PreserveWidgetsPhaseListener,de.tol ina.web.Spring=
IntegratingPhaseListener</FONT><FONT=20
color=3D#008080 size=3D2 face=3D"Courier New">&lt;/</FONT><FONT =
color=3D#3f8080 size=3D2=20
face=3D"Courier New">param-value</FONT><FONT color=3D#008080 size=3D2=20
face=3D"Courier New">&gt;</FONT> <BR><FONT size=3D2 face=3D"Courier =
New">&nbsp; &nbsp;=20
&nbsp; &nbsp; </FONT><FONT color=3D#008080 size=3D2=20
face=3D"Courier New">&lt;/</FONT><FONT color=3D#3f8080 size=3D2=20
face=3D"Courier New">context-param</FONT><FONT color=3D#008080 size=3D2=20
face=3D"Courier New">&gt;</FONT> <BR><BR><FONT size=3D2 =
face=3Dsans-serif>Any=20
suggestions whereelse our PhaseListener could be registered ?=20
IEntryPoint.createUI is not working, because the PhaseListener then =
would be=20
registered more than once.</FONT> <BR><BR><FONT size=3D2 =
face=3Dsans-serif>Here's=20
the PhaseListener: </FONT><BR><BR><FONT color=3D#820040 size=3D2=20
face=3D"Courier New"><B>public</B></FONT><FONT size=3D2 face=3D"Courier =
New">=20
</FONT><FONT color=3D#820040 size=3D2 face=3D"Courier =
New"><B>class</B></FONT><FONT=20
size=3D2 face=3D"Courier New"> SpringIntegratingPhaseListener =
</FONT><FONT=20
color=3D#820040 size=3D2 face=3D"Courier =
New"><B>implements</B></FONT><FONT size=3D2=20
face=3D"Courier New"> PhaseListener {</FONT> <BR><FONT size=3D2=20
face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </FONT><FONT =
color=3D#3f8080 size=3D2=20
face=3D"Courier New"><B>// Springs RequestContextListener, where we will =
do fake=20
calls for each PROCESS_ACTION </B></FONT><BR><FONT size=3D2=20
face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </FONT><FONT =
color=3D#820040 size=3D2=20
face=3D"Courier New"><B>private</B></FONT><FONT size=3D2 face=3D"Courier =
New">=20
</FONT><FONT color=3D#820040 size=3D2 face=3D"Courier =
New"><B>final</B></FONT><FONT=20
size=3D2 face=3D"Courier New"> RequestContextListener </FONT><FONT =
color=3D#0021bf=20
size=3D2 face=3D"Courier New">requestContextListener</FONT><FONT =
size=3D2=20
face=3D"Courier New"> =3D </FONT><FONT color=3D#820040 size=3D2=20
face=3D"Courier New"><B>new</B></FONT><FONT size=3D2 face=3D"Courier =
New">=20
<B>RequestContextListener</B>();</FONT> <BR><BR><FONT size=3D2=20
face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </FONT><FONT =
color=3D#820040 size=3D2=20
face=3D"Courier New"><B>public</B></FONT><FONT size=3D2 face=3D"Courier =
New">=20
</FONT><FONT color=3D#820040 size=3D2 face=3D"Courier =
New"><B>void</B></FONT><FONT=20
size=3D2 face=3D"Courier New"> <B>afterPhase</B>(PhaseEvent </FONT><FONT =

color=3D#820040 size=3D2 face=3D"Courier New">event</FONT><FONT size=3D2 =

face=3D"Courier New">) {</FONT> <BR><FONT size=3D2 face=3D"Courier =
New">&nbsp; &nbsp;=20
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ServletRequestEvent=20
servletRequestEvent =3D </FONT><FONT color=3D#820040 size=3D2=20
face=3D"Courier New"><B>new</B></FONT><FONT size=3D2 face=3D"Courier =
New">=20
<B>ServletRequestEvent</B>(RWT.<I>getRequest</I>().</FONT ><FONT =
color=3D#008080=20
size=3D2 face=3D"Courier New">getSession</FONT><FONT size=3D2=20
face=3D"Courier New">().</FONT><FONT color=3D#008080 size=3D2=20
face=3D"Courier New">getServletContext</FONT><FONT size=3D2 =
face=3D"Courier New">(),=20
RWT.<I>getRequest</I>());</FONT> <BR><FONT size=3D2 face=3D"Courier =
New">&nbsp;=20
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT><FONT =
color=3D#0021bf=20
size=3D2 face=3D"Courier New">requestContextListener</FONT><FONT =
size=3D2=20
face=3D"Courier =
New">.<B>requestDestroyed</B>(servletRequestEvent);</FONT >=20
<BR><FONT size=3D2 face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; =
}</FONT>=20
<BR><BR><FONT size=3D2 face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; =
</FONT><FONT=20
color=3D#820040 size=3D2 face=3D"Courier New"><B>public</B></FONT><FONT =
size=3D2=20
face=3D"Courier New"> </FONT><FONT color=3D#820040 size=3D2=20
face=3D"Courier New"><B>void</B></FONT><FONT size=3D2 face=3D"Courier =
New">=20
<B>beforePhase</B>(PhaseEvent </FONT><FONT color=3D#820040 size=3D2=20
face=3D"Courier New">event</FONT><FONT size=3D2 face=3D"Courier New">) =
{</FONT>=20
<BR><FONT size=3D2 face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp;=20
&nbsp; &nbsp; ServletRequestEvent servletRequestEvent =3D </FONT><FONT=20
color=3D#820040 size=3D2 face=3D"Courier New"><B>new</B></FONT><FONT =
size=3D2=20
face=3D"Courier New">=20
<B>ServletRequestEvent</B>(RWT.<I>getRequest</I>().</FONT ><FONT =
color=3D#008080=20
size=3D2 face=3D"Courier New">getSession</FONT><FONT size=3D2=20
face=3D"Courier New">().</FONT><FONT color=3D#008080 size=3D2=20
face=3D"Courier New">getServletContext</FONT><FONT size=3D2 =
face=3D"Courier New">(),=20
RWT.<I>getRequest</I>());</FONT> <BR><FONT size=3D2 face=3D"Courier =
New">&nbsp;=20
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT><FONT =
color=3D#0021bf=20
size=3D2 face=3D"Courier New">requestContextListener</FONT><FONT =
size=3D2=20
face=3D"Courier =
New">.<B>requestInitialized</B>(servletRequestEvent);</FONT >=20
<BR><FONT size=3D2 face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; =
}</FONT>=20
<BR><BR><FONT size=3D2 face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; =
</FONT><FONT=20
color=3D#820040 size=3D2 face=3D"Courier New"><B>public</B></FONT><FONT =
size=3D2=20
face=3D"Courier New"> PhaseId <B>getPhaseId</B>() {</FONT> <BR><FONT =
size=3D2=20
face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;=20
</FONT><FONT color=3D#820040 size=3D2 face=3D"Courier =
New"><B>return</B></FONT><FONT=20
size=3D2 face=3D"Courier New"> PhaseId.PROCESS_ACTION;</FONT> <BR><FONT =
size=3D2=20
face=3D"Courier New">&nbsp; &nbsp; &nbsp; &nbsp; }</FONT> <BR><FONT =
size=3D2=20
face=3D"Courier New">}</FONT> <BR></BODY></HTML>

------=_NextPart_000_0145_01C8988F.2AB85D50--
Previous Topic:theme.properties file
Next Topic:how to populate WizardPage at view time?
Goto Forum:
  


Current Time: Fri Apr 19 04:34:09 GMT 2024

Powered by FUDForum. Page generated in 0.02784 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top