How to call a bean method on load ?
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icesoft.org  [Login] Login 
How to call a bean method on load ?  XML
Forum Index -> General Help
Author Message
Baleyba

Joined: 16/11/2006 00:00:00
Messages: 110
Offline


Hi,

In my application, I need to call a testValidSession() method in my iface page in order to redirect user on login page if user isn't identified.

This case is encontouring when user is accessing .iface directly without goning on login page.

How can I call this method ?


Thanks for your help.

regards
Bal.

JBoss 4.2.3 | Java 1.6.0_16 | IceFaces 1.8.2
fabmars

Joined: 24/08/2006 00:00:00
Messages: 73
Offline


You may be tempted to put your code in the handler's constructor. But, if the bean is managed in session or application scope, the code is executed only at the first rendering of the view. You need a way to make your test at every view rendering, even refreshes.

Personnally with JSF 1.1, I do this using a managed bean (myHanlder here) that contains a method such as :
public boolean getBefore();

In the JSP, just after the <ice:form> :
<ice:inputHidden rendered="#{myHandler.before}"/>

Yeah this tries to mimick the before(PhaseEvent) method that's now in JSF1.2, but à la Struts way :) As soon as IceFaces is 1.2 compliant, I'll do that the PhaseEvent way.

Well, more specifically my getBefore() method contains my test code and throws a dedicated exception in case the user is not logged in. At the web.xml level I defined the login page as the location for this type of exception. This may be not the most proper way to do that though. Eventually my getBefore method always returns false so that there is no track from the hidden field on the rendered page.

http://www.suntriprecords.com
Baleyba

Joined: 16/11/2006 00:00:00
Messages: 110
Offline


Hi Fabmars!

Thanks for your answer.
I will try this.

Do you come from France ? ;)

regards
Bal.

JBoss 4.2.3 | Java 1.6.0_16 | IceFaces 1.8.2
fabmars

Joined: 24/08/2006 00:00:00
Messages: 73
Offline


You say that because of the "à la Struts" phrase isn't it ?

Yeah I'm French living in Belgium.

http://www.suntriprecords.com
Baleyba

Joined: 16/11/2006 00:00:00
Messages: 110
Offline


Exactement ;)

Merci pour ton aide!

I'm french too ;)

++
Bal

JBoss 4.2.3 | Java 1.6.0_16 | IceFaces 1.8.2
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team