How to tell RAP to switch perspective from external servlet ? [message #77621] |
Mon, 10 March 2008 09:29 |
|
Hi,
On startup our app is opening a default perspective containing a maximized
viewpart that serves as a login page.
This login page is implemented using browser widget backed by a plain
servlet. Now if the user is successfully logged in the servlet must tell
RAP to switch to the main perspective containing the core business
application.
But in the login servlet I'm kind of lost since I don't know how to
contact the RAP.
Is this scenario possible at all ?
Thanks in advance for any advice.
Regards,
Setya
|
|
|
Re: How to tell RAP to switch perspective from external servlet ? [message #77787 is a reply to message #77621] |
Tue, 11 March 2008 07:12 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
I assume that your servlet is also handled by the http service of OSGi.
If so, map it to the RAP HttpContext (see
http://www.eclipse.org/rap/noteworthy/news_11M3.php RAP HttpContext). On
startup of your RAP application ensure to make the Display instance
available in the HttpSession ->
RWT.getSessionStore().getHttpSession().setAttribute( "theDisplayKey",
display );. In the service method of your servlet you should now be able
to retrieve the display -> request.getSession().getAttribute(
"theDisplayKey" );. After that call Display#asyncExec() to notify your
RAP app about whatever you need.
Note that the UICallback-Mechanism must be activated at that point of
time to notify the client side immediately of the serverside changes.
Note also that I didn't try to do this yet by myself, so maybe there is
something I've forgotten in my description. In particular I did not
think thouroughly about if the dependency to RWT (which you will need
for the solution) will cause any problems in the bundle that contains
your login servlet.
Hope it helps!
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Setya [mailto:jsetya@gmail.com]
Bereitgestellt: Montag, 10. März 2008 10:29
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: How to tell RAP to switch perspective from external
servlet ?
Betreff: How to tell RAP to switch perspective from external servlet ?
Hi,
On startup our app is opening a default perspective containing a
maximized viewpart that serves as a login page.
This login page is implemented using browser widget backed by a plain
servlet. Now if the user is successfully logged in the servlet must tell
RAP to switch to the main perspective containing the core business
application.
But in the login servlet I'm kind of lost since I don't know how to
contact the RAP.
Is this scenario possible at all ?
Thanks in advance for any advice.
Regards,
Setya
|
|
|
Re: How to tell RAP to switch perspective from external servlet ? [message #77848 is a reply to message #77787] |
Tue, 11 March 2008 08:41 |
|
Hi Frank,
> I assume that your servlet is also handled by the http service of OSGi.
If what you by 'handled by the http service of OSGi' is registering the
servlet via org.eclipse.equinox.http.registry.servlets ext. point than
yes. (But I use my own httpcontextid).
> If so, map it to the RAP HttpContext (see
> http://www.eclipse.org/rap/noteworthy/news_11M3.php RAP HttpContext).
So I have to use org.eclipse.rap.httpcontext as httpcontextid instead ?
> On startup of your RAP application ensure to make the Display instance
> available in the HttpSession ->
> RWT.getSessionStore().getHttpSession().setAttribute( "theDisplayKey",
> display );.
Can I do this in IEntryPoint.createUI() method with display reference I
obtain from PlatformUI.createDisplay() ?
> In the service method of your servlet you should now be able
> to retrieve the display -> request.getSession().getAttribute(
> "theDisplayKey" );. After that call Display#asyncExec() to notify your
> RAP app about whatever you need.
In order to switch perspective I need to at least have reference to
IWorkbench and IWorkbenchPage, how can I obtain the reference from the
servlet ?
> Note that the UICallback-Mechanism must be activated at that point of
> time to notify the client side immediately of the serverside changes.
Can you elaborate more on how to activate the UICallback mechanism ?
Thanks and Regards,
Setya
|
|
|
|
Re: How to tell RAP to switch perspective from external servlet ? [message #78103 is a reply to message #77995] |
Wed, 12 March 2008 09:30 |
|
Hi Frank,
I'm sorry for being too slow on this.
> In order to switch perspective I need to at least have reference to
> IWorkbench and IWorkbenchPage, how can I obtain the reference from the
> servlet ?
> To ease this you can program the runnable inside your entry point
> implementation and pass the runnable also via the session.
So from your suggestion I should have the following code in my
IEntryPoint#createUI():
public int createUI()
{
Display display = PlatformUI.createDisplay();
HttpSession httpSession = RWT.getSessionStore().getHttpSession();
Runnable runnable = new Runnable()
{
public void run()
{
//How to obtain the reference to IWorkbenchWindow at this stage ?
IWorkbenchPage page = window.getActivePage();
IPerspectiveDescriptor perspective = page.getPerspective();
perspective = window.getWorkbench().getPerspectiveRegistry()
.findPerspectiveWithId("main.perspective.id");
page.setPerspective(perspective);
UICallBack.deactivate("my.entrypoint.classname");
}
};
httpSession.setAttribute("key.display",display);
httpSession.setAttribute("key.runnable",runnable);
UICallBack.activate("my.entrypoint.classname");
return PlatformUI.createAndRunWorkbench(display,new CoreWorkbench());
}
I still can't see how I can obtain reference to IWorkbenchWindow at this
stage.
Or maybe I should create and store the runnable in
WorkbenchWindowAdvisor#postWindowOpen ?
public void postWindowOpen()
{
Runnable runnable = new Runnable()
{
public void run()
{
//Obtaining the reference to IWorkbenchWindow
IWorkbenchWindow window = getWindowConfigurer().getWindow();
IWorkbenchPage page = window.getActivePage();
IPerspectiveDescriptor perspective = page.getPerspective();
perspective = window.getWorkbench().getPerspectiveRegistry()
.findPerspectiveWithId("main.perspective.id");
page.setPerspective(perspective);
UICallBack.deactivate("my.entrypoint.classname");
}
};
RWT.getSessionStore().getHttpSession().setAttribute("key.runnable ",runnable);
super.postWindowOpen();
}
And finally in my login servlet :
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
//Perform login authentication here
boolean success = validateLogin(request.getParameter("user"),
request.getParameter("password"));
if (!success)
{
getServletContext().getRequestDispatcher(IPluginXmlConstants .WEB_CONTEXT +
"/login.html").forward(request,response);
return;
}
Display display = (Display)request.getAttribute("key.display");
Runnable runnable = (Runnable)request.getAttribute("key.runnable");
display.asyncExec(runnable);
}
Or am I missing something here ?
Regards,
Setya
|
|
|
Re: How to tell RAP to switch perspective from external servlet ? [message #78118 is a reply to message #78103] |
Wed, 12 March 2008 09:40 |
|
Hi,
> Display display = (Display)request.getAttribute("key.display");
> Runnable runnable = (Runnable)request.getAttribute("key.runnable");
> display.asyncExec(runnable);
Ooops sorry, should be:
Display display =
(Display)request.getSession().getAttribute("key.display");
Runnable runnable =
(Runnable)request.getSession().getAttribute("key.runnable");
display.asyncExec(runnable);
Setya
|
|
|
RE: How to tell RAP to switch perspective from external servlet ? [message #78177 is a reply to message #78118] |
Thu, 13 March 2008 07:42 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
>I still can't see how I can obtain reference to IWorkbenchWindow at
this stage.
the code don't get executed at that point, you create the runnable. If I
got you right your login screen is inside a view of the workbench
(browser widget I suggest). So the workbench exists at that point in
time when you execute the runnable and that's all that matters.
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Setya [mailto:jsetya@gmail.com]
Bereitgestellt: Mittwoch, 12. März 2008 10:40
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: How to tell RAP to switch perspective from external
servlet ?
Betreff: Re: How to tell RAP to switch perspective from external servlet
?
Hi,
> Display display = (Display)request.getAttribute("key.display");
> Runnable runnable = (Runnable)request.getAttribute("key.runnable");
> display.asyncExec(runnable);
Ooops sorry, should be:
Display display =
(Display)request.getSession().getAttribute("key.display");
Runnable runnable =
(Runnable)request.getSession().getAttribute("key.runnable");
display.asyncExec(runnable);
Setya
|
|
|
Re: How to tell RAP to switch perspective from external servlet ? [message #78192 is a reply to message #78177] |
Thu, 13 March 2008 09:50 |
|
Frank,
> the code don't get executed at that point, you create the runnable. If I
> got you right your login screen is inside a view of the workbench
> (browser widget I suggest). So the workbench exists at that point in
> time when you execute the runnable and that's all that matters.
OK.
So I should create the runnable inside
WorkbenchWindowAdvisor#postWindowOpen ?
Regards,
Setya
|
|
|
RE: How to tell RAP to switch perspective from external servlet ? [message #78205 is a reply to message #78192] |
Thu, 13 March 2008 15:24 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
from my understanding of what you want to do, it makes no difference,
whether you create the runnable in WorkbenchWindowAdvisor#postWindowOpen
or directly in IEntryPoint#createUI(), since the code of the Runnable
gets executed in one of the subsequent requests from the servlet. At
that point of time the workbench is already up an running. So feel free
to create the runnable in WorkbenchWindowAdvisor#postWindowOpen(), if
this is for any reasons your prefered place.
Ciao
Frank
-----Ursprüngliche Nachricht-----
Von: Setya [mailto:jsetya@gmail.com]
Bereitgestellt: Donnerstag, 13. März 2008 10:50
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: How to tell RAP to switch perspective from external
servlet ?
Betreff: Re: How to tell RAP to switch perspective from external servlet
?
Frank,
> the code don't get executed at that point, you create the runnable. If
> I got you right your login screen is inside a view of the workbench
> (browser widget I suggest). So the workbench exists at that point in
> time when you execute the runnable and that's all that matters.
OK.
So I should create the runnable inside
WorkbenchWindowAdvisor#postWindowOpen ?
Regards,
Setya
|
|
|
Re: How to tell RAP to switch perspective from external servlet ? [message #78235 is a reply to message #78205] |
Fri, 14 March 2008 03:46 |
|
Frank,
> from my understanding of what you want to do, it makes no difference,
> whether you create the runnable in WorkbenchWindowAdvisor#postWindowOpen
> or directly in IEntryPoint#createUI(), since the code of the Runnable
> gets executed in one of the subsequent requests from the servlet. At
> that point of time the workbench is already up an running. So feel free
> to create the runnable in WorkbenchWindowAdvisor#postWindowOpen(), if
> this is for any reasons your prefered place.
If you take a look at the runnable code I created earlier, it's impossible
to create the runnable in IEntryPoint#createUI() since I don't know how to
obtain the reference to IWorkbenchWindow in this method, or am I missing
something here ?
Regards,
Setya
|
|
|
Re: How to tell RAP to switch perspective from external servlet ? [message #78351 is a reply to message #78235] |
Fri, 14 March 2008 14:16 |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
why don't you use the following?
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
Ciao
Frank
"Setya" <jsetya@gmail.com> schrieb im Newsbeitrag
news:504362e97f4f3264bd72f1ce3df1c666$1@www.eclipse.org...
> Frank,
>
>> from my understanding of what you want to do, it makes no difference,
>> whether you create the runnable in WorkbenchWindowAdvisor#postWindowOpen
>> or directly in IEntryPoint#createUI(), since the code of the Runnable
>> gets executed in one of the subsequent requests from the servlet. At
>> that point of time the workbench is already up an running. So feel free
>> to create the runnable in WorkbenchWindowAdvisor#postWindowOpen(), if
>> this is for any reasons your prefered place.
>
> If you take a look at the runnable code I created earlier, it's impossible
> to create the runnable in IEntryPoint#createUI() since I don't know how to
> obtain the reference to IWorkbenchWindow in this method, or am I missing
> something here ?
>
> Regards,
>
> Setya
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03518 seconds