cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic landing page

alejandrogarcia
Champ in-the-making
Champ in-the-making
Hi folks,

I'm trying to figure out how to implement a mechanism that decides dynamically what's the landing page for a user.

I know that the default landing page is relatively easy to customize, as you can see in the following links:

http://blogs.alfresco.com/wp/ddraper/2011/11/01/advanced-share-customization-part-1/

http://zscribble.wordpress.com/2012/02/13/how-to-change-user-landing-page-in-alfresco-share/

But it is not enough because I need go a little further; after the successful authentication of any user, I need to retrieve the site/s that a user belongs to and then redirect to the dashboard of any of the sites.

I guess there is any authentication service that redirects to TOMCAT/webapps/share/site-index.jsp, and from here to either the user dashboard or a site dashboard, depending on the parameters received. If I'm right with my assumption, I understand I just should customize such supposed authentication service in order to get the user's sites and then redirect to the appropriate site dashboard's URL.

Am I in the right way? If not, any idea on how to proceed?

Thanks.
13 REPLIES 13

ddraper
World-Class Innovator
World-Class Innovator
Hi,

This was something that I actually tried to look into for the Share Customizations Live session (DevCon-2012) but wasn't able to find an easy solution. The problem is that in order for Surf to determine whether or not a page needs to be authenticated it has to actually load the page first - this also applies to the landing page (so that when no page is specified the landing page is loaded first to determine the authentication required). The only way that I think you can really achieve this is to have a redirect from the landing page. The only other option you consider would be to create your own Page implementation (extending the default Surf PageImpl class) and override the dispatchPage() method - you should then be able to dynamically evaluate the subsequent page to load.

Hope this helps - if you take the latter approach then I'd be interested to see your solution!

Regards,
Dave

alejandrogarcia
Champ in-the-making
Champ in-the-making
Thaks very much for replying Dave.

Well it helps actually because at least your giving me some options and paths to follow. Now I have to investigate and experiment by myself until I find such solution that both it meets my requirement and it is clean and scalable.

Anyway, I still would like to ask you a couple of questions. When you say "landing page" in your last post, are you always meaning the TOMCAT/webapps/share/site-index.jsp page? And finally, which of the two possible options you have mentioned would you go for and why?

Regards.

PD: Whatever the solution I adopt, I will share with you and the developers community if I consider it is worth (I wouldn't like to share a dirty, weird and obscure solution  :wink: ).

alejandrogarcia
Champ in-the-making
Champ in-the-making
By the way, regarding to the second option you mantioned, I don't see any "dispatchPage()" method in the org.springframework.extensions.surf.types.PageImpl class (perhaps I'm looking at the wrong package?).

https://fisheye.springsource.org/browse/se-surf/branches/1.2.0-M2/spring-surf/spring-surf/src/main/j...

Thanks.

Regards.

ddraper
World-Class Innovator
World-Class Innovator
Apologies… I meant PageView, you'll also need to override the PageViewResolver as well so that your PageView implementation is instantiated (this will require updates to the Spring configuration). Although I guess you could probably do everything you need by extending the PageViewResolver.

Regards,
Dave

alejandrogarcia
Champ in-the-making
Champ in-the-making
No problems Dave, apologies accepted  :wink:

Well, I've been taking a look at the org.springframework.extensions.surf.mvc.PageView class (https://fisheye.springsource.org/browse/se-surf/branches/1.2.0-M2/spring-surf/spring-surf/src/main/j...) and I've seen some "login stuff", specifically in the renderView(RequestContext context) method. Is this one which would make sense to override?

At the same time my colleague and I have thought about another approach:

As far as I know, the site-index property is configurable in alfresco\site-data\configurations\slingshot.site.configuration.xml. Then, according to the value defined in the <root-page> tag and similarly to the accept-invite component:

1.   Create a custom page
2.   Create a custom template-instance
3.   Create a custom FreeMarker template, exclusively containing the region that loads the webscript
4.   Implement a custom webscript that loads the user sites and
5.   Perform the redirection similarly as the accept-invite component is doing.

For me it makes sense as a completely clean and non-intrusive solution. Please, let me know what do you think and whether you believe this approach would work or not.

Thanks very much.

Regards.

ddraper
World-Class Innovator
World-Class Innovator
That's a perfectly acceptable approach and something I suggested in my first response Smiley Wink

The only way that I think you can really achieve this is to have a redirect from the landing page

It really just depends if you're happy to have a redirect from your landing page each time - but it will work,

Regards,
Dave

alejandrogarcia
Champ in-the-making
Champ in-the-making
I'm sorry, maybe it is caused by my lack of knowledge on Surf and Share, but as far as I understood about your first answer, the first option you proposed would imply a modification/customization of the original site-index.jsp page, by redirecting to a custom Surf page. My plan is to invoke that custom page directly, without passing though the site-index.jsp page and performing the redirection in the webscript component. Do you know what I mean?

Now I'm confused  :?

By the way, regarding to one of my previous questions: What do you think is better, a PageView customization based approach or a solution such as I have just explained in my last post?

Thanks for your patience  Smiley Happy

Regards.

ddraper
World-Class Innovator
World-Class Innovator
Ah… I hadn't made that clear, probably because of my own investigation into doing this for DevCon. My initial assumption was that you were referring to how you could dynamically change the default landing page and I just thought you were referring to dynamically modifying the root-page in the site-configuration (which isn't possible) - but you could have create a new root-page that performs redirection. Doing it this way is almost certainly the simplest way to achieve your goal, but as I said it's sometimes not ideal to have a redirection (effectively you're loading two pages instead of one). Overriding the PageView and PageViewResolver is definitely more complex but would avoid the redirect (because it would occur on the server and not the client).

For simplicity I'd suggest the client-side redirect.

Regards,
Dave

alejandrogarcia
Champ in-the-making
Champ in-the-making
Well, actually what I have now in mind is not to dynamically modify the root-page in the site-configuration.xml. To sum up and to clarify for other developers, my intention is to perform the redirection within a custom Surf page rather than in the site-index.jsp; this is configured in the site-configuration.xml file. Furthermore, the mentioned custom page will contain a webscript which: 1. invokes the REST API in order to retrieve the sites of the user, 2. dynamically generates the site's URL and 3. it performs the redirection.

How to retrieve the sites of a user via RESTful API and how to treat the response? As far as I know, by following as example several out-of-the-box Share components, for example the dashlet My Sites or the user-sites component that belongs to the user profile page.

I have tried out a "dummy" version of this approach and works fine, so I will post the full solution when I have it 100% working. At the moment I hope this thread helps others  Smiley Very Happy

I will investigate further the approach of overriding the PageView and PageViewResolver, I'm aware it is more efficient but it will require more time because of its complexity, as you said.

Thanks.

Regards.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.