This content has been marked as final.
Show 6 replies
-
1. Re: Force "company" selection after login
titou09 Feb 17, 2010 11:57 PM (in response to ssamayoagt)We had recently the same need.
I suppose here that you use seam security with an authenticator component/method
For this we use two things
- a navigation rule in page.xml that redirect the user until a condition is met (he selected a company in your case)
- in the Authenticator.authenticate() method, call
Render.instance().setViewId(\<your view id name to select the company here\>)
After the user has been authenticated, it will be redirect to the page you want, and with the navigation/rule statement in page.xml, it will stay on this page untill the condition set in pages.xml is false
Hope this helps
-
2. Re: Force "company" selection after login
ssamayoagt Feb 18, 2010 2:42 AM (in response to ssamayoagt)Thanks for your response.
I'm using the JpaIdentityStore, I'm not Authenticator.authenticate() but I guess is matter of some minor changes to use it with the JpaIdentityStore.
About navogation rule, I tried this:
<page view-id="*">
<navigation>
<rule if-outcome="home">
<redirect view-id="/home.xhtml" />
</rule>
<rule if="#{identity.isLoggedIn and empreaActual eq null}">
<redirect view-id="/selemp.xhtml" />
</rule>
</navigation>
</page>
But the app never goes to the view.
Some little more help please.
Regards. -
3. Re: Force "company" selection after login
titou09 Feb 18, 2010 3:12 AM (in response to ssamayoagt)Maybe extends JpaIdentityStore, override the authenticate method, call super.authenticate() in there and if the result is
true
then call Render.instance().setViewId(/selemp.xhtml
).Should work.
-
4. Re: Force "company" selection after login
ssamayoagt Feb 18, 2010 8:28 PM (in response to ssamayoagt)Thanks, I will try.
Regards. -
5. Re: Force "company" selection after login
swd847 Feb 18, 2010 10:39 PM (in response to ssamayoagt)<page view-id="*" action="#{''.toString()}"> <navigation from-action="#{''.toString()}" > <rule if="#{identity.isLoggedIn and empreaActual eq null}"> <redirect view-id="/selemp.xhtml" /> </rule> </navigation> </page>
Note the use of a dummy action, navigation rules are only evaluated after an action is run.
-
6. Re: Force "company" selection after login
ssamayoagt Feb 20, 2010 5:51 AM (in response to ssamayoagt)Thanks Stuart.
I will have on mind - I never figure out that way!
By the way, I solve my problem using events:
components.xml:
<event type="com.ls.noHayEmpresaActual">
<action execute="#{redirect.captureCurrentView}" />
<action execute="#{manager.redirect('/selemp.xhtml')}" />
</event>
<event type="com.ls.yaHayEmpresaActual">
<action execute="#{redirect.returnToCapturedView}" />
</event>
And each view which needs a selected company runs an component's action like (actual code):
Some.page.xml:
<action execute="#{eventosEmpresa.hayEmpresaActual}" />
And the "eventosEmpresa" component raises both events (partial EventosEmpresa class):
@In(required = false)
@Out(required = false)
protected Empresa empresaActual;
@In(required = false)
protected Events events;
@Logger
private Log log;
public void hayEmpresaActual() {
if (empresaActual == null && events != null) {
log.info("hayEmpresaActiva(): no hay empresa activa.");
events.raiseEvent(EventosEmpresa.NO_HAY_EMPRESA_ACTUAL);
}
}
public void setEmpresaActual(Empresa empresaActual) {
this.empresaActual = empresaActual;
}
public void seleccionarEmpresa() {
if (empresaActual != null && events != null) {
log.info("seleccionarEmpresa(): Ya hay empresa activa.");
events.raiseEvent(EventosEmpresa.YA_HAY_EMPRESA_ACTUAL);
}
}
"seleccionarEmpresa()" is called from company selection view's command link.
So far, works great even with pages which requires login.
I posted my solution because maybe someone nees the same functionality.
Seam rules!
Regards.