r1371 - in trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web: pages pages/security services tools
Author: glandais Date: 2008-03-17 17:45:56 +0000 (Mon, 17 Mar 2008) New Revision: 1371 Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/SimExplorerState.java trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/WebEntityVisitor.java Log: Redirect after login Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java 2008-03-17 17:45:04 UTC (rev 1370) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/Login.java 2008-03-17 17:45:56 UTC (rev 1371) @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.Arrays; +import org.apache.tapestry.ComponentResources; import org.apache.tapestry.annotations.ApplicationState; import org.apache.tapestry.annotations.Component; import org.apache.tapestry.annotations.InjectPage; @@ -27,7 +28,6 @@ import org.apache.tapestry.corelib.components.Form; import org.apache.tapestry.ioc.Messages; import org.apache.tapestry.ioc.annotations.Inject; -import org.apache.tapestry.services.RequestGlobals; import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; import fr.cemagref.simexplorer.is.security.entities.User; @@ -61,10 +61,6 @@ @ApplicationState private SimExplorerState applicationState; - /** The request globals. */ - @Inject - private RequestGlobals requestGlobals; - /** The messages. */ @Inject private Messages messages; @@ -73,13 +69,17 @@ @Component private Form formLogin; + /** The resources. */ + @Inject + private ComponentResources resources; + /** * On success. * * @return the object * * @throws SimExplorerException the sim explorer exception - * @throws IOException + * @throws IOException */ public Object onSuccessFromFormLogin() throws SimExplorerException, IOException { // on hache directement le password pour ne pas le transmettre en clair @@ -91,18 +91,17 @@ String token = RemoteSecurityService.getAuthentificationService().loginUser(user, pass); if (token != null && !token.equals("")) { - + User loggedUser = RemoteSecurityService.getAuthentificationService().getLoggedUser(token); applicationState.setToken(token); applicationState.setUser(loggedUser); - - String fromURL = applicationState.getRequestedURL(); - if (fromURL == null) { + + String fromPage = applicationState.getPageName(); + if (fromPage == null) { return elementList; } - //return fromURL.substring(1); - requestGlobals.getResponse().sendRedirect(fromURL); + return resources.createPageLink(applicationState.getPageName(), true, applicationState.getPageContext()); } formLogin.recordError(messages.get("simexplorer.ui.web.login.invalid")); return this; Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java 2008-03-17 17:45:04 UTC (rev 1370) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/pages/security/ProtectedPage.java 2008-03-17 17:45:56 UTC (rev 1371) @@ -22,7 +22,6 @@ import org.apache.tapestry.annotations.Persist; import org.apache.tapestry.ioc.Messages; import org.apache.tapestry.ioc.annotations.Inject; -import org.apache.tapestry.services.RequestGlobals; import org.codelutin.i18n.I18n; import fr.cemagref.simexplorer.is.exceptions.SimExplorerException; @@ -40,10 +39,6 @@ @ApplicationState private SimExplorerState applicationState; - /** The request globals. */ - @Inject - private RequestGlobals requestGlobals; - /** The user. */ @Persist private User user; @@ -75,11 +70,11 @@ * * @throws SimExplorerException the sim explorer exception */ - Object onActivate() throws SimExplorerException { + Object onActivate(Object... pageContext) throws SimExplorerException { getUserRights(); if (!userLogged) { - String fromURL = requestGlobals.getRequest().getPath(); - applicationState.setRequestedURL(fromURL); + applicationState.setPageName(resources.getPageName()); + applicationState.setPageContext(pageContext); return "Login"; } if (!hasAccessToPage()) Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/SimExplorerState.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/SimExplorerState.java 2008-03-17 17:45:04 UTC (rev 1370) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/services/SimExplorerState.java 2008-03-17 17:45:56 UTC (rev 1371) @@ -30,8 +30,11 @@ /** The user. */ private User user; - /** The requested url. */ - private String requestedURL; + /** The page name. */ + private String pageName; + + /** The page context. */ + private Object[] pageContext; /** * Instantiates a new sim explorer state. @@ -40,7 +43,8 @@ super(); token = null; user = null; - requestedURL = null; + pageName = null; + pageContext = null; } /** @@ -80,21 +84,40 @@ } /** - * Gets the requested url. + * Gets the page name. * - * @return the requested url + * @return the page name */ - public String getRequestedURL() { - return requestedURL; + public String getPageName() { + return pageName; } /** - * Sets the requested url. + * Sets the page name. * - * @param requestedURL the new requested url + * @param pageName the new page name */ - public void setRequestedURL(String requestedURL) { - this.requestedURL = requestedURL; + public void setPageName(String pageName) { + this.pageName = pageName; } + /** + * Gets the page context. + * + * @return the page context + */ + public Object[] getPageContext() { + return pageContext; + } + + /** + * Sets the page context. + * + * @param pageContext the new page context + */ + public void setPageContext(Object[] pageContext) { + this.pageContext = pageContext; + } + + } Modified: trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/WebEntityVisitor.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/WebEntityVisitor.java 2008-03-17 17:45:04 UTC (rev 1370) +++ trunk/simexplorer-is/simexplorer-is-web/src/java/fr/cemagref/simexplorer/is/ui/web/tools/WebEntityVisitor.java 2008-03-17 17:45:56 UTC (rev 1371) @@ -28,7 +28,6 @@ import fr.cemagref.simexplorer.is.entities.Composite; import fr.cemagref.simexplorer.is.entities.Entity; import fr.cemagref.simexplorer.is.entities.EntityHelper; -import fr.cemagref.simexplorer.is.entities.EntityTypeEnum; import fr.cemagref.simexplorer.is.entities.EntityVisitorTreeNode; import fr.cemagref.simexplorer.is.entities.SimExplorerPage; import fr.cemagref.simexplorer.is.entities.EntityHelper.Action;
participants (1)
-
glandais@users.labs.libre-entreprise.org