Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to tell RAP to switch perspective from external servlet ?
How to tell RAP to switch perspective from external servlet ? [message #77621] Mon, 10 March 2008 09:29 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
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 #77995 is a reply to message #77848] Wed, 12 March 2008 07:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hello again,

see answers below.



Ciao

Frank

-----Urspr
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 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Eclipse UserFriend
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
>
>
>
Re: How to tell RAP to switch perspective from external servlet ? [message #78487 is a reply to message #78351] Mon, 17 March 2008 03:39 Go to previous message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Frank,

> IWorkbench workbench = PlatformUI.getWorkbench();
> IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();

Yes. This is what I'm looking for.

Thanks a lot for your help and patience so far.

Best Regards,


Setya
Previous Topic:Background image won't show up on ScrolledForm
Next Topic:How to create a custom widget?
Goto Forum:
  


Current Time: Sat Apr 20 00:43:30 GMT 2024

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

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

Back to the top