Customized look on first login - spring

I'm working on a java Spring webapp. There is requirement that each user will have possibility to customize the webapp look & feel. I'd like if the user will see the customized look, even on his first login. How would you do that?
My ideas are for the time being
multiple contexts(per customer), but it is not dynamic
send user a link with some attribute, then set the custom info to cookies
in Spring I can possibly create some path variable (#RequestMapping(value = "/{customerId}/login"))
just create universal login page, which will be not customizable
How would you achieve that?

If you want to offer customized looks to every user, you can use use Portlets. Spring also supports Portlet development.

You can give separate URLs to each user, could be using sub-domain or url parameters. Then fetch the request URL in your handling page to deliver specific look-n-feel.
You could also try to explore GrooveUI, which is a third party tool that allows you to define website theme based on access URL.

Related

Sitemesh different decorators for the same URL

I'm using urlrewriteFilter (org.tuckey.web.filters.urlrewrite.UrlRewriteFilter) to forward pages like www.mysite.com/myname to a Struts2 action. The action is mapped up in sitemesh, and it works properly.
But now I want to keep the same URL but apply another decorator to the page, based on whether the user is logged in or not.
I'm using AppFuse-stack Struts2.
Ok - since no-one else looks like having a go.
Sitemesh selects the decorators based on the incoming url string, so to have different decorators you need different urls depending on the login status of your client. AFAIK Sitemesh uses the entire Url string so this includes parameters so you might get away with appending ?loggedIn="true" or ?loggedIn="false" and map the decorators on this. However this doesn't help with POST requests.
Another way to do it would be to create two Struts packages - one for logged in users and one for anonymous users so your actions will have different paths and then map on the path part of the Url.
I don't know how practical this might be in your scenario, but a third option maybe to have one common decorator and control the layout via seperate stylesheets which you could control via a test in your jsp.
HTH
Regards

file download in spring mvc

in my home page I want to display user guide in two different format ( pdf and word) these documents were already created by technical writers and I want to show the download links to these documents in home page after the user successfully logged in. I can achieve this easily by putting these two documents in one folder up to the 'WEB-INF' but it will enable anyone can download these files(without logging in). Could you advise whats the best way to handle this in spring mvc 2.5
I guess you already have some security support, so you can check whether user is logged in inside a controller code.
Then you can put your files into /WEB-INF folder and create a special controller for serving these files to the logged users. This controller will check that user is logged in and then forward a request to the target file. In typical Spring MVC configurations you can forward a request by returning something like forward:/WEB-INF/myFile.pdf as a view name.
Alternatively, if you use some security library, such as Spring Security, you can use its features to secure access to your files. In that case you don't need to put them into /WEB-INF and implement a specifal controller for accessing them.

Joomla CMS and Spring Framework

I want to create a Web application by combining Joomla CMS with Spring Framework. What would be the best way to build/use a single sign-on for both?. All the pages on the website will be serviced by Joomla CMS, but those that require authentication/authorization will be done with Spring Framework. The later will retrieve widgets from Joomla CMS to ensure the same User Interface.
I would appreciate any suggestion or pointer to information about this topic
Thanks
Peter
You can overload Joomla User plug-in, save/edit/delete/login/etc. This will hep you understand user event that you will need to implement, http://docs.joomla.org/Reference:User_Events_for_Plugin_System. Also look at the following file plugins/user/example.php
In my opinion, mixing 2 different languages PHP and Java in 1 project is a little extreme. I would keep the projects separate and created my own Joomla/Spring Field API. Then would make API call in Joomla components/modules/plug-ins to integrate with Spring Framework.
Another thing, do not modify Joomla's native code to achieve what you want (I mean don't rewrite base classes that Joomla uses). Instead create your own library in the /libraries/ directory and extend the classes. If you decide to adopt API, you might want to have some API object in your model. Create your own base model /libraries/your_lib/application/component/ then when you are creating a model in the component change the import code to jimport('your_lib.application.component.model')
IOPLEX sell a Java library (Jespa) to provide single signon using Windows NTLM credentials, they also have a Joomla plugin. Could be appropriate if you're authenticating against ActiveDirectory and have Windows clients.
i think using web service will give the chance to not touch the basic code of joomla because joomla give you hand to make an xmlrpc , and you have to keep in mind the session controle the best think is to let joomla manage session and creating a user plugin to make a specifique action in the login and logout event. hope will help.

Best practice to manage the path breadcrumbs in Spring without Web flow

I am engaged in a project where I need to show path bread crumbs to the user like
Home (This is linked to home page) >> (page name)
and like
Home >> contacts
and in contacts like
Contacts >> create
Contacts >> edit
etc.
Is there a best practice how to do this in spring without he usage of spring web flow? I am not using spring web flow and simply using the spring MVC.
I'm not sure why you'd have to do this in Spring if you're not using Spring MVC.
Depending on the site's structure and the URL structure, you might want to parse the URL into something readable.
Another option is to have some sort of push/pop mechanism but since browsers have a back button which does not signal the server this is often a recipe for disaster.
I'm not sure there is any universal solution for breadcrumbs. Here are a few variants:
use the URL structure. With spring mvc this is actually a very good option, since it (since 2.5) replies a lot on nice, structured URLs
have each page (view) identify its own path in the breadcrumb (via a request parameter). It's not
place current steps in session. This would break if multiple tabs/windows are used, so you will have to use a windowId.. and essentially roll-out a "crippled" webflow.
This sort of breadcrumbs is sometimes called homeward path navigation.
If you can capture your site layout in XML then an XSL could be used to generate the breadcrumbs. The same XML site layout document could also be used to generate a side navigation menu.
See also: Separating breadcrumb (homeward path) navigation from content using XML/XSL.

How to maintain state in a web app - as HTTP is stateless

I am new in building web apps and just begun learning and setting up Grails. I am planning to build an app which has a flow of 4 to 5 pages. Since HTTP is a stateless protocol, how is the state between the pages maintained usually. I am curious what is the accepted standard here, should I create session scoped objects and use them between pages or keep passing around the values between pages (not sure if it is effective if I have a large number of items on a page). Or instead of using 4 to 5 pages should I just use one page with multiple divs and show/hide based on the user clicks?
I think using domain objects in Grails would help here but I dont have a DB backing the UI and only some webservices which will do the UI actions so I cant use domain objects.
A Grails specific solution would be good but also wanted to know how this is handled in web development in general.
Without using a DB, there are a few options you could use:
Use POST/GET variables to pass info from page to page.
Use the session to store information.
Use cookies to store information.
Using POST/GET is usually best if you just have one page "talking" to one other page (e.g. submission of a form). If you have a bunch of data that will be shared by several pages, the best way to do it would probably be to put them in the session. If you need those values to stick around after the user leaves your site and comes back later, then you might want to use cookies.
You may want to look into WebFlow (Spring WebFlow) in Grails. I find it helpful in wizard like or shopping cart like applications where you want to hold on to the data between a group of pages (ie: Page 1, Page 2... Page 4) and then at the end submit the data somewhere etc.

Resources